source file of the GNU LilyPond music typesetter
- (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
Jan Nieuwenhuizen <janneke@gnu.org>
*/
*/
if (knee_b)
region_size += 2;
-
+
+ /*
+ Asymetry ? should run to <= region_size ?
+ */
for (int i = -region_size ; i < region_size; i++)
for (int j = 0; j < num_quants; j++)
{
beam_count, ldir, rdir);
}
- ; /* silly gdb thinks best_idx is inside for loop. */
+ // ; /* silly gdb thinks best_idx is inside for loop. */
for (int i = qscores.size (); i--;)
if (qscores[i].demerits < reasonable_score)
{
qscores[i].yl, qscores[i].yr);
}
- ; /* silly gdb thinks best_idx is inside for loop. */
+ // ; /* silly gdb thinks best_idx is inside for loop. */
int best_idx = best_quant_score_idx (qscores);
me->set_grob_property ("positions",
gh_cons (gh_double2scm (qscores[best_idx].yl),
}
Real
-Beam::score_stem_lengths (Link_array<Grob>stems,
- Array<Stem_info> stem_infos,
- Array<Real> base_stem_ys,
- Array<Real> stem_xs,
+Beam::score_stem_lengths (Link_array<Grob> const &stems,
+ Array<Stem_info> const &stem_infos,
+ Array<Real> const &base_stem_ys,
+ Array<Real> const &stem_xs,
Real xl, Real xr,
bool knee,
Real yl, Real yr)
{
- Real limit_pen = STEM_LENGTH_LIMIT_PENALTY;
+ Real limit_penalty = STEM_LENGTH_LIMIT_PENALTY;
Drul_array<Real> score (0, 0);
Drul_array<int> count (0, 0);
Real dx = xr-xl;
Real beam_y = yr *(x - xl)/dx + yl * ( xr - x)/dx;
Real current_y = beam_y + base_stem_ys[i];
- Real length_pen = STEM_LENGTH_LIMIT_PENALTY;
+ Real length_pen = STEM_LENGTH_DEMERIT_FACTOR;
Stem_info info = stem_infos[i];
Direction d = info.dir_;
- score[d] += limit_pen * (0 >? (d * (info.shortest_y_ - current_y)));
+ score[d] += limit_penalty * (0 >? (d * (info.shortest_y_ - current_y)));
Real ideal_diff = d * (current_y - info.ideal_y_);
Real ideal_score = shrink_extra_weight (ideal_diff, 1.5);
-
+
/* We introduce a power, to make the scoring strictly
convex. Otherwise a symmetric knee beam (up/down/up/down)
does not have an optimum in the middle. */
count[d] ++;
}
-
- if(count[LEFT])
- score[LEFT] /= count[LEFT];
- if(count[RIGHT])
- score[RIGHT] /= count[RIGHT];
+
+ Direction d = DOWN;
+ do
+ {
+ if(count[d])
+ score[d] /= count[d];
+ }
+ while (flip (&d) != DOWN);
return score[LEFT]+score[RIGHT];
}
Real
Beam::score_forbidden_quants (Real yl, Real yr,
- Real rad,
+ Real radius,
Real slt,
Real thickness, Real beam_translation,
int beam_count,
Real dy = yr - yl;
Real dem = 0.0;
- if (fabs (yl) < rad && fabs ( my_modf (yl) - 0.5) < 1e-3)
- dem += INTER_QUANT_PENALTY;
- if (fabs (yr) < rad && fabs ( my_modf (yr) - 0.5) < 1e-3)
- dem += INTER_QUANT_PENALTY;
+ for (int i = 0; i < 2; i++)
+ {
+ Real y = i? yl : yr;
+ if (fabs (y) <= (radius + 0.5) && fabs ( my_modf (y) - 0.5) < 1e-3)
+ dem += INTER_QUANT_PENALTY;
+ }
// todo: use beam_count of outer stems.
if (beam_count >= 2)
{
-
Real straddle = 0.0;
Real sit = (thickness - slt) / 2;
Real inter = 0.5;
Real hang = 1.0 - (thickness - slt) / 2;
- if (fabs (yl - ldir * beam_translation) < rad
+ if (fabs (yl - ldir * beam_translation) < radius
&& fabs (my_modf (yl) - inter) < 1e-3)
dem += SECONDARY_BEAM_DEMERIT;
- if (fabs (yr - rdir * beam_translation) < rad
+ if (fabs (yr - rdir * beam_translation) < radius
&& fabs (my_modf (yr) - inter) < 1e-3)
dem += SECONDARY_BEAM_DEMERIT;
/*
Can't we simply compute the distance between the nearest
staffline and the secondary beam? That would get rid of the
- silly case analysis here (which is probably not when we have
- different beam-thicknesses.)
+ silly case analysis here (which is probably not valid when we
+ have different beam-thicknesses.)
--hwn
*/
// hmm, without Interval/Drul_array, you get ~ 4x same code...
- if (fabs (yl - ldir * beam_translation) < rad + inter)
+ if (fabs (yl - ldir * beam_translation) < radius + inter)
{
if (ldir == UP && dy <= eps
&& fabs (my_modf (yl) - sit) < eps)
dem += SECONDARY_BEAM_DEMERIT;
}
- if (fabs (yr - rdir * beam_translation) < rad + inter)
+ if (fabs (yr - rdir * beam_translation) < radius + inter)
{
if (rdir == UP && dy >= eps
&& fabs (my_modf (yr) - sit) < eps)
if (beam_count >= 3)
{
- if (fabs (yl - 2 * ldir * beam_translation) < rad + inter)
+ if (fabs (yl - 2 * ldir * beam_translation) < radius + inter)
{
if (ldir == UP && dy <= eps
&& fabs (my_modf (yl) - straddle) < eps)
if (ldir == DOWN && dy >= eps
&& fabs (my_modf (yl) - straddle) < eps)
dem += SECONDARY_BEAM_DEMERIT;
- }
+ }
- if (fabs (yr - 2 * rdir * beam_translation) < rad + inter)
+ if (fabs (yr - 2 * rdir * beam_translation) < radius + inter)
{
if (rdir == UP && dy >= eps
&& fabs (my_modf (yr) - straddle) < eps)