* lily/beam-concave.cc (calc_concaveness): use property callback.
2005-10-26 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * lily/beam.cc (calc_least_squares_dy): use property callback.
+
+ * lily/beam-concave.cc (calc_concaveness): use property callback.
+
* ly/paper-defaults.ly: move fixed dimensions from paper.scm
2005-10-25 Jan Nieuwenhuizen <janneke@gnu.org>
}
Real
-calc_concaveness (Array<int> const &positions, Direction beam_dir)
+calc_positions_concaveness (Array<int> const &positions, Direction beam_dir)
{
Real dy = positions.top () - positions[0];
Real slope = dy / Real (positions.size () - 1);
return concaveness;
}
-MAKE_SCHEME_CALLBACK (Beam, check_concave, 1);
+
+MAKE_SCHEME_CALLBACK (Beam, calc_concaveness, 1);
SCM
-Beam::check_concave (SCM smob)
+Beam::calc_concaveness (SCM smob)
{
Grob *me = unsmob_grob (smob);
= extract_grob_array (me, "stems");
if (is_knee (me))
- return SCM_UNSPECIFIED;
+ return scm_from_double (0.0);
Direction beam_dir = CENTER;
for (int i = stems.size (); i--;)
far_positions.push ((int) rint (posns[-beam_dir]));
}
+ Real concaveness = 0.0;
+
if (is_concave_single_notes (far_positions, beam_dir))
{
+ (void) me->get_property ("least-squares-dy"); // ugh. dependency handling.
+
Drul_array<Real> pos = ly_scm2interval (me->get_property ("positions"));
Real r = linear_combination (pos, 0.0);
}
else
{
- Real concaveness = (calc_concaveness (far_positions, beam_dir)
- + calc_concaveness (close_positions, beam_dir)) / 2;
-
- me->set_property ("concaveness", scm_from_double (concaveness));
+ concaveness = (calc_positions_concaveness (far_positions, beam_dir)
+ + calc_positions_concaveness (close_positions, beam_dir)) / 2;
}
- return SCM_UNSPECIFIED;
+ return scm_from_double (concaveness);
}
}
/*
- Compute a first approximation to the beam slope.
+ Compute a first approximation to the beam slope.
*/
-MAKE_SCHEME_CALLBACK (Beam, least_squares, 1);
+MAKE_SCHEME_CALLBACK (Beam, calc_least_squares_dy, 1);
SCM
-Beam::least_squares (SCM smob)
+Beam::calc_least_squares_dy (SCM smob)
{
Grob *me = unsmob_grob (smob);
if (count < 1)
{
me->set_property ("positions", ly_interval2scm (pos));
- return SCM_UNSPECIFIED;
+ return scm_from_double (0.0);
}
Array<Real> x_posns;
Real y = 0;
Real slope = 0;
Real dy = 0;
-
+ Real ldy = 0.0;
if (!ideal.delta ())
{
Interval chord (Stem::chord_start_y (first_visible_stem (me)),
slope esp. of the first part of a broken beam should predict
where the second part goes.
*/
- me->set_property ("least-squares-dy",
- scm_from_double (pos[RIGHT] - pos[LEFT]));
+ ldy = pos[RIGHT] - pos[LEFT];
}
else
{
dy = slope * dx;
set_minimum_dy (me, &dy);
- me->set_property ("least-squares-dy", scm_from_double (dy));
+
+ ldy = dy;
pos = Interval (y, (y + dy));
}
me->set_property ("positions", ly_interval2scm (pos));
- return SCM_UNSPECIFIED;
+ return scm_from_double (ldy);
}
/*
if (visible_stem_count (me) <= 1)
return SCM_UNSPECIFIED;
+ /* trigger callback. */
+ (void) me->get_property ("least-squares-dy");
+
SCM s = me->get_property ("damping");
Real damping = scm_to_double (s);
if (damping)
{
+ Real concaveness = robust_scm2double (me->get_property ("concaveness"), 0.0);
+
Drul_array<Real> pos = ly_scm2interval (me->get_property ("positions"));
scale_drul (&pos, Staff_symbol_referencer::staff_space (me));
Real slope = dy && dx ? dy / dx : 0;
- Real concaveness = robust_scm2double (me->get_property ("concaveness"), 0.0);
-
slope = 0.6 * tanh (slope) / (damping + concaveness);
Real damped_dy = slope * dx;
DECLARE_SCHEME_CALLBACK (print, (SCM));
DECLARE_SCHEME_CALLBACK (calc_direction, (SCM));
DECLARE_SCHEME_CALLBACK (calc_positions, (SCM));
+ DECLARE_SCHEME_CALLBACK (calc_least_squares_dy, (SCM));
+ DECLARE_SCHEME_CALLBACK (calc_concaveness, (SCM));
/* position callbacks */
- DECLARE_SCHEME_CALLBACK (least_squares, (SCM));
- DECLARE_SCHEME_CALLBACK (check_concave, (SCM));
DECLARE_SCHEME_CALLBACK (slope_damping, (SCM));
DECLARE_SCHEME_CALLBACK (shift_region_to_valid, (SCM));
DECLARE_SCHEME_CALLBACK (quanting, (SCM));
;; todo: clean this up a bit: the list is getting
;; rather long.
(gap . 0.8)
- (position-callbacks . (,Beam::least_squares
- ,Beam::check_concave
- ,Beam::slope_damping
+
+ (position-callbacks . (,Beam::slope_damping
,Beam::shift_region_to_valid
,Beam::quanting))
-
+ (least-squares-dy . ,Beam::calc_least_squares_dy)
+ (concaveness . ,Beam::calc_concaveness)
(positions . ,Beam::calc_positions)
(direction . ,Beam::calc_direction)
(stencil . ,Beam::print)