-#include <math.h>
+#include <cmath>
#include "warn.hh"
-#include "grob.hh"
#include "staff-symbol-referencer.hh"
#include "beam.hh"
#include "stem.hh"
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)
*/
-int best_quant_score_idx (Array<Quant_score> const & qscores)
+int
+best_quant_score_idx (Array<Quant_score> const & qscores)
{
Real best = 1e6;
int best_idx = -1;
}
}
+ if (best_idx < 0)
+ {
+ programming_error ("Huh? No best beam quant score?");
+ best_idx = 0;
+ }
+
+
return best_idx;
}
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));
/*
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<Real> quantsl;
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<Real> ins = ly_scm2interval (inspect_quants);
ly_interval2scm (Drul_array<Real> (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);
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)
{