X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fbeam-quanting.cc;h=2075eb76d31ecd5ac4c21e9cf2ddfe971fa7d9e7;hb=c659cb200486c2f908703696a1b2873e78c8160a;hp=467ef517c3259ddb945b0216f43f572ee7d61119;hpb=f2731e17f7fca531ef4c4d0a2d7299592015745a;p=lilypond.git diff --git a/lily/beam-quanting.cc b/lily/beam-quanting.cc index 467ef517c3..2075eb76d3 100644 --- a/lily/beam-quanting.cc +++ b/lily/beam-quanting.cc @@ -12,10 +12,9 @@ -#include +#include #include "warn.hh" -#include "grob.hh" #include "staff-symbol-referencer.hh" #include "beam.hh" #include "stem.hh" @@ -38,7 +37,6 @@ const int DAMPING_DIRECTION_PENALTY = 800; const int MUSICAL_DIRECTION_FACTOR = 400; const int IDEAL_SLOPE_FACTOR = 10; const Real ROUND_TO_ZERO_SLOPE = 0.02; -const int ROUND_TO_ZERO_POINTS = 4; static Real shrink_extra_weight (Real x, Real fac) @@ -71,7 +69,8 @@ struct Quant_score */ -int best_quant_score_idx (Array const & qscores) +int +best_quant_score_idx (Array const & qscores) { Real best = 1e6; int best_idx = -1; @@ -84,6 +83,13 @@ int best_quant_score_idx (Array const & qscores) } } + if (best_idx < 0) + { + programming_error ("Huh? No best beam quant score?"); + best_idx = 0; + } + + return best_idx; } @@ -94,8 +100,8 @@ Beam::quanting (SCM smob) Grob *me = unsmob_grob (smob); SCM s = me->get_property ("positions"); - Real yl = ly_scm2double (ly_car (s)); - Real yr = ly_scm2double (ly_cdr (s)); + Real yl = scm_to_double (scm_car (s)); + Real yr = scm_to_double (scm_cdr (s)); /* @@ -107,14 +113,14 @@ Beam::quanting (SCM smob) Real thickness = Beam::get_thickness (me) / ss ; Real slt = Staff_symbol_referencer::line_thickness (me) / ss; - SCM sdy = me->get_property ("least-squares-dy"); - Real dy_mus = ly_c_number_p (sdy) ? ly_scm2double (sdy) : 0.0; - + Real dy_mus = robust_scm2double (me->get_property ("least-squares-dy"), 0); Real straddle = 0.0; Real sit = (thickness - slt) / 2; Real inter = 0.5; Real hang = 1.0 - (thickness - slt) / 2; Real quants [] = {straddle, sit, inter, hang }; + + int num_quants = int (sizeof (quants)/sizeof (Real)); Array quantsl; @@ -276,11 +282,10 @@ Beam::quanting (SCM smob) int best_idx = best_quant_score_idx (qscores); - #if DEBUG_QUANTING SCM inspect_quants = me->get_property ("inspect-quants"); - if (to_boolean (me->get_paper ()->lookup_variable (ly_symbol2scm ("debug-beam-quanting"))) - && ly_c_pair_p (inspect_quants)) + if (to_boolean (me->get_layout ()->lookup_variable (ly_symbol2scm ("debug-beam-quanting"))) + && scm_is_pair (inspect_quants)) { Drul_array ins = ly_scm2interval (inspect_quants); @@ -305,7 +310,7 @@ Beam::quanting (SCM smob) ly_interval2scm (Drul_array (qscores[best_idx].yl, qscores[best_idx].yr))); #if DEBUG_QUANTING - if (to_boolean (me->get_paper ()->lookup_variable (ly_symbol2scm ("debug-beam-quanting")))) + if (to_boolean (me->get_layout ()->lookup_variable (ly_symbol2scm ("debug-beam-quanting")))) { qscores[best_idx].score_card_ += to_string ("i%d", best_idx); @@ -408,23 +413,10 @@ Beam::score_slopes_dy (Real yl, Real yr, dem += shrink_extra_weight (fabs (dy_damp) - fabs (dy), 1.5) * slope_penalty; -#if 0 - /* - almost zero slopes look like errors in horizontal beams. - */ - /* - This causes too much problems, because horizontal depends on - horizontal spacing details. These errors should be dealt with - through concaveness. --hwn. - */ - if (fabs (dy) > 1e-3 - && fabs (dy / dx) < ROUND_TO_ZERO_SLOPE) - dem += ROUND_TO_ZERO_POINTS; -#endif - return dem; } + static Real my_modf (Real x) {