SECONDARY_BEAM_DEMERIT = get_detail (details, ly_symbol2scm ("secondary-beam-demerit"), 10.0);
STEM_LENGTH_DEMERIT_FACTOR = get_detail (details, ly_symbol2scm ("stem-length-demerit-factor"), 5);
REGION_SIZE = get_detail (details, ly_symbol2scm ("region-size"), 2);
BEAM_EPS = get_detail (details, ly_symbol2scm ("beam-eps"), 1e-3);
SECONDARY_BEAM_DEMERIT = get_detail (details, ly_symbol2scm ("secondary-beam-demerit"), 10.0);
STEM_LENGTH_DEMERIT_FACTOR = get_detail (details, ly_symbol2scm ("stem-length-demerit-factor"), 5);
REGION_SIZE = get_detail (details, ly_symbol2scm ("region-size"), 2);
BEAM_EPS = get_detail (details, ly_symbol2scm ("beam-eps"), 1e-3);
STEM_LENGTH_LIMIT_PENALTY = get_detail (details, ly_symbol2scm ("stem-length-limit-penalty"), 5000);
DAMPING_DIRECTION_PENALTY = get_detail (details, ly_symbol2scm ("damping-direction-penalty"), 800);
STEM_LENGTH_LIMIT_PENALTY = get_detail (details, ly_symbol2scm ("stem-length-limit-penalty"), 5000);
DAMPING_DIRECTION_PENALTY = get_detail (details, ly_symbol2scm ("damping-direction-penalty"), 800);
MUSICAL_DIRECTION_FACTOR = get_detail (details, ly_symbol2scm ("musical-direction-factor"), 400);
IDEAL_SLOPE_FACTOR = get_detail (details, ly_symbol2scm ("ideal-slope-factor"), 10);
ROUND_TO_ZERO_SLOPE = get_detail (details, ly_symbol2scm ("round-to-zero-slope"), 0.02);
MUSICAL_DIRECTION_FACTOR = get_detail (details, ly_symbol2scm ("musical-direction-factor"), 400);
IDEAL_SLOPE_FACTOR = get_detail (details, ly_symbol2scm ("ideal-slope-factor"), 10);
ROUND_TO_ZERO_SLOPE = get_detail (details, ly_symbol2scm ("round-to-zero-slope"), 0.02);
/*
Calculations are relative to a unit-scaled staff, i.e. the quants are
divided by the current staff_space.
/*
Calculations are relative to a unit-scaled staff, i.e. the quants are
divided by the current staff_space.
Real slt = Staff_symbol_referencer::line_thickness (me) / ss;
Real dy_mus = robust_scm2double (me->get_property ("least-squares-dy"), 0);
Real straddle = 0.0;
Real slt = Staff_symbol_referencer::line_thickness (me) / ss;
Real dy_mus = robust_scm2double (me->get_property ("least-squares-dy"), 0);
Real straddle = 0.0;
Real quants [] = {straddle, sit, inter, hang };
int num_quants = int (sizeof (quants) / sizeof (Real));
Real quants [] = {straddle, sit, inter, hang };
int num_quants = int (sizeof (quants) / sizeof (Real));
Do stem computations. These depend on YL and YR linearly, so we can
precompute for every stem 2 factors.
*/
Do stem computations. These depend on YL and YR linearly, so we can
precompute for every stem 2 factors.
*/
- std::vector<Stem_info> stem_infos;
- std::vector<Real> base_lengths;
- std::vector<Real> stem_xposns;
+ vector<Stem_info> stem_infos;
+ vector<Real> base_lengths;
+ vector<Real> stem_xposns;
Drul_array<bool> dirs_found (0, 0);
Grob *common[2];
for (int a = 2; a--;)
common[a] = common_refpoint_of_array (stems, me, Axis (a));
Drul_array<bool> dirs_found (0, 0);
Grob *common[2];
for (int a = 2; a--;)
common[a] = common_refpoint_of_array (stems, me, Axis (a));
Real xl = fvs ? fvs->relative_coordinate (common[X_AXIS], X_AXIS) : 0.0;
Real xr = fvs ? lvs->relative_coordinate (common[X_AXIS], X_AXIS) : 0.0;
/*
Real xl = fvs ? fvs->relative_coordinate (common[X_AXIS], X_AXIS) : 0.0;
Real xr = fvs ? lvs->relative_coordinate (common[X_AXIS], X_AXIS) : 0.0;
/*
- We store some info to quickly interpolate.
-
- Sometimes my head is screwed on backwards. The stemlength are
- AFFINE linear in YL and YR. If YL == YR == 0, then we might have
+ We store some info to quickly interpolate. The stemlength are
+ affine linear in YL and YR. If YL == YR == 0, then we might have
- base_lengths.push_back (calc_stem_y (me, s, common, xl, xr,
- Interval (0, 0), f) / ss);
- stem_xposns.push_back (s->relative_coordinate (common[X_AXIS], X_AXIS));
- }
+ if (Stem::is_normal_stem (s))
+ {
+ base_lengths.push_back (calc_stem_y (me, s, common, xl, xr, CENTER,
+ Interval (0, 0), f) / ss);
+ }
+ else
+ {
+ base_lengths.push_back (0);
+ }
Direction ldir = Direction (stem_infos[0].dir_);
Direction rdir = Direction (stem_infos.back ().dir_);
Direction ldir = Direction (stem_infos[0].dir_);
Direction rdir = Direction (stem_infos.back ().dir_);
if (qscores[i].demerits < reasonable_score)
{
Real d = score_forbidden_quants (qscores[i].yl, qscores[i].yr,
if (qscores[i].demerits < reasonable_score)
{
Real d = score_forbidden_quants (qscores[i].yl, qscores[i].yr,
- rad, slt, thickness, beam_translation,
+ rad, slt, beam_thickness, beam_translation,
edge_beam_counts, ldir, rdir, ¶meters);
qscores[i].demerits += d;
edge_beam_counts, ldir, rdir, ¶meters);
qscores[i].demerits += d;
qscores[i].yl, qscores[i].yr, ¶meters);
qscores[i].demerits += d;
qscores[i].yl, qscores[i].yr, ¶meters);
qscores[i].demerits += d;
qscores[i].score_card_ += to_string (" L %.2f", d);
#endif
}
int best_idx = best_quant_score_idx (qscores);
qscores[i].score_card_ += to_string (" L %.2f", d);
#endif
}
int best_idx = best_quant_score_idx (qscores);
{
qscores[best_idx].score_card_ += to_string ("i%d", best_idx);
// debug quanting
me->set_property ("quant-score",
{
qscores[best_idx].score_card_ += to_string ("i%d", best_idx);
// debug quanting
me->set_property ("quant-score",
-Beam::score_stem_lengths (Link_array<Grob> const &stems,
- std::vector<Stem_info> const &stem_infos,
- std::vector<Real> const &base_stem_ys,
- std::vector<Real> const &stem_xs,
+Beam::score_stem_lengths (vector<Grob*> const &stems,
+ vector<Stem_info> const &stem_infos,
+ vector<Real> const &base_stem_ys,
+ vector<Real> const &stem_xs,
- if (fabs (dy / dx) > parameters->ROUND_TO_ZERO_SLOPE
- && sign (dy_damp) != sign (dy))
- dem += parameters->DAMPING_DIRECTION_PENALTY;
-
+ if (sign (dy_damp) != sign (dy))
+ {
+ if (!dy)
+ {
+ if (fabs (dy_damp / dx) > parameters->ROUND_TO_ZERO_SLOPE)
+ dem += parameters->DAMPING_DIRECTION_PENALTY;
+ else
+ dem += parameters->HINT_DIRECTION_PENALTY;
+ }
+ else
+ dem += parameters->DAMPING_DIRECTION_PENALTY;
+ }
+
dem += parameters->MUSICAL_DIRECTION_FACTOR
* max (0.0, (fabs (dy) - fabs (dy_mus)));
dem += parameters->MUSICAL_DIRECTION_FACTOR
* max (0.0, (fabs (dy) - fabs (dy_mus)));
Drul_array<int> beam_counts,
Direction ldir, Direction rdir,
Drul_array<int> beam_counts,
Direction ldir, Direction rdir,
- Real gap1 = y[d] - stem_dir * ((j - 1) * beam_translation + thickness / 2 - slt / 2.2);
- Real gap2 = y[d] - stem_dir * (j * beam_translation - thickness / 2 + slt / 2.2);
+ Real gap1 = y[d] - stem_dir * ((j - 1) * beam_translation + beam_thickness / 2 - slt / 2.2);
+ Real gap2 = y[d] - stem_dir * (j * beam_translation - beam_thickness / 2 + slt / 2.2);