source file of the GNU LilyPond music typesetter
- (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
Jan Nieuwenhuizen <janneke@gnu.org>
+
+
*/
const int MUSICAL_DIRECTION_FACTOR = 400;
const int IDEAL_SLOPE_FACTOR = 10;
+const Real ROUND_TO_ZERO_SLOPE = 0.05;
const int ROUND_TO_ZERO_POINTS = 4;
extern bool debug_beam_quanting_flag;
Real yl = gh_scm2double (gh_car (s));
Real yr = gh_scm2double (gh_cdr (s));
- Real ss = Staff_symbol_referencer::staff_space (me);
- Real thickness = gh_scm2double (me->get_grob_property ("thickness")) / ss;
- Real slt = me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness")) / ss;
+ /*
+ Calculations are relative to a unit-scaled staff, i.e. the quants are
+ divided by the current staff_space.
+
+ */
+ Real ss = Staff_symbol_referencer::staff_space (me);
+ Real thickness = Beam::get_thickness (me) / ss ;
+ Real slt = Staff_symbol_referencer::line_thickness (me) / ss;
SCM sdy = me->get_grob_property ("least-squares-dy");
Real dy_mus = gh_number_p (sdy) ? gh_scm2double (sdy) : 0.0;
for (int i= 0; i < stems.size(); i++)
{
Grob*s = stems[i];
- stem_infos.push (Stem::get_stem_info (s));
+
+ Stem_info si (Stem::get_stem_info (s));
+ si.scale (1 / ss);
+ stem_infos.push (si);
dirs_found[stem_infos.top ().dir_] = true;
bool f = to_boolean (s->get_grob_property ("french-beaming"))
&& s != lvs && s != fvs;
base_lengths.push (calc_stem_y (me, s, common, xl, xr,
- Interval (0,0), f));
+ Interval (0,0), f) / ss);
stem_xposns.push (s->relative_coordinate (common[X_AXIS], X_AXIS));
}
Real rad = Staff_symbol_referencer::staff_radius (me);
int beam_count = get_beam_count (me);
- Real beam_translation = get_beam_translation (me);
+ Real beam_translation = get_beam_translation (me) / ss;
Real reasonable_score = (knee_b) ? 200000 : 100;
for (int i = qscores.size (); i--;)
if (debug_beam_quanting_flag
&& gh_pair_p (inspect_quants))
{
- Real il = gh_scm2double (gh_car (inspect_quants));
- Real ir = gh_scm2double (gh_cdr (inspect_quants));
+ Drul_array<Real> ins = ly_scm2interval (inspect_quants);
int i = 0;
Real mindist = 1e6;
for (; i < qscores.size(); i ++)
{
- Real d =fabs (qscores[i].yl-il) + fabs (qscores[i].yr - ir);
+ Real d =fabs (qscores[i].yl- ins[LEFT]) + fabs (qscores[i].yr - ins[RIGHT]);
if (d < mindist)
{
best_idx = i;
#endif
me->set_grob_property ("positions",
- gh_cons (gh_double2scm (qscores[best_idx].yl),
- gh_double2scm (qscores[best_idx].yr)));
+ ly_interval2scm (Drul_array<Real> (qscores[best_idx].yl,
+ qscores[best_idx].yr)));
#if DEBUG_QUANTING
if (debug_beam_quanting_flag)
{
bool xstaff)
{
Real dy = yr - yl;
-
Real dem = 0.0;
/*
DAMPING_DIRECTION_PENALTY is a very harsh measure, while for
complex beaming patterns, horizontal is often a good choice.
+
+ TODO: find a way to incorporate the complexity of the beam in this
+ penalty.
*/
- if (sign (dy)
+ if (fabs (dy/dx) > ROUND_TO_ZERO_SLOPE
&& sign (dy_damp) != sign (dy))
{
dem += DAMPING_DIRECTION_PENALTY;
almost zero slopes look like errors in horizontal beams.
*/
if (fabs (dy) > 1e-3
- && (dy / dx < 0.05))
+ && fabs (dy / dx) < ROUND_TO_ZERO_SLOPE)
dem += ROUND_TO_ZERO_POINTS;
return dem;
gap.add_point (gap1);
gap.add_point (gap2);
- if (gap.elem_b (radius))
+ if (gap.contains (radius))
dem += extra_demerit;
}
while ((flip (&d))!= LEFT);