comparison.
* lily/stem.cc (calc_stem_info): Moved, documented, cleaned up and
fixed up-to-stem feature.
* scm/grob-description.scm (beamed-lengths): Subtract half a beam
thickness, to fix most ugly beams. See input/test/stem.ly and
baerenreiter-sarabande.ly.
2002-08-13 Jan Nieuwenhuizen <janneke@gnu.org>
+ * lily/beam.cc (least_squares): Fix asymmetry and scary float
+ comparison.
+
+ * lily/stem.cc (calc_stem_info): Moved, documented, cleaned up and
+ fixed up-to-stem feature.
+
+ * scm/grob-description.scm (beamed-lengths): Subtract half a beam
+ thickness, to fix most ugly beams. See input/test/stem.ly and
+ baerenreiter-sarabande.ly.
+
* input/test/stem.ly:
* input/mutopia/J.S.Bach/baerenreiter-sarabande.ly: Play with
beamed-lengths.
sdesc: "LilyPond documentation."
category: Doc
-ldesc: "LilyPond Documentation in HTML, PS and DVI formats.
-This package contains the HTML, PostScript and DVI documentation for the
-LilyPond music typesetting software."
+ldesc: "LilyPond Documentation in HTML, PS, PDF and DVI formats. This
+package contains the HTML, PostScript PDF and DVI documentation for
+the LilyPond music typesetting software. Info and man pages are in
+the lilypond package."
static Real
-shrink_extra_weight (Real x)
+shrink_extra_weight (Real x, Real fac)
{
- return fabs (x) * ((x < 0) ? 1.5 : 1.0);
+ return fabs (x) * ((x < 0) ? fac : 1.0);
}
bool knee,
Real yl, Real yr)
{
- Real pen = STEM_LENGTH_LIMIT_PENALTY;
-
+ Real limit_pen = STEM_LENGTH_LIMIT_PENALTY;
Drul_array<Real> score (0, 0);
Drul_array<int> count (0, 0);
+
for (int i=0; i < stems.size (); i++)
{
Grob* s = stems[i];
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;
Stem_info info = stem_infos[i];
Direction d = info.dir_;
- score[d] += pen * (0 >? (d * (info.shortest_y_ - current_y)));
-
- Real ideal_score = shrink_extra_weight (d * (current_y - info.ideal_y_));
+ score[d] += limit_pen * (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. */
if (knee)
ideal_score = pow (ideal_score, 1.1);
- score[d] += STEM_LENGTH_DEMERIT_FACTOR * ideal_score;
+
+ score[d] += length_pen * ideal_score;
count[d] ++;
}
Real slope_penalty = IDEAL_SLOPE_FACTOR;
- /*
- Xstaff beams tend to use extreme slopes to get short stems. We
- put in a penalty here.
- */
+ /* Xstaff beams tend to use extreme slopes to get short stems. We
+ put in a penalty here. */
if (xstaff)
slope_penalty *= 10;
- dem += shrink_extra_weight (fabs (dy_damp) - fabs (dy))* slope_penalty;
+ /* Huh, why would a too steep beam be better than a too flat one ? */
+ dem += shrink_extra_weight (fabs (dy_damp) - fabs (dy), 1.5)
+ * slope_penalty;
return dem;
}
Interval chord (Stem::chord_start_y (first_visible_stem (me)),
Stem::chord_start_y (last_visible_stem (me)));
+ /* Make simple beam on middle line have small tilt.
- /*
- TODO -- use scoring for this.
-
- complicated, because we take stem-info.ideal for determining
- beam slopes.
- */
- /* Make simple beam on middle line have small tilt */
- if (!ideal[LEFT] && chord.delta () && count == 2)
+ Ideally, this should be handled by a scoring rule, but that's
+ complicated because we take stem-info.ideal for determining
+ beam slopes. */
+ if ((abs (ideal[LEFT]) < 0.5 || abs (ideal[RIGHT]) < 0.5)
+ && chord.delta () && count == 2)
{
-
- /*
- FIXME. -> UP
- */
+ /* FIXME. -> UP */
Direction d = (Direction) (sign (chord.delta ()) * UP);
pos[d] = gh_scm2double (me->get_grob_property ("thickness")) / 2;
- // * dir;
pos[-d] = - pos[d];
}
else
Real
Stem::get_default_stem_end_position (Grob*me)
{
+ /* Tab notation feature: make stem end extend out of staff. */
SCM up_to_staff = me->get_grob_property ("up-to-staff");
- if (to_boolean(up_to_staff))
+ if (to_boolean (up_to_staff))
{
int line_count = Staff_symbol_referencer::line_count (me);
-
Direction dir = get_direction (me);
-
- return dir* (line_count + 3.5);
+ return dir * (line_count + 3.5);
}
bool grace_b = to_boolean (me->get_grob_property ("grace"));
Stem_info
Stem::get_stem_info (Grob *me)
{
- /* DOCME!!! So, what's this all about? */
- SCM up_to_staff = me->get_grob_property ("up-to-staff");
- if (gh_scm2bool(up_to_staff))
- {
- /* Up-to-staff : the stem end out of the staff. */
-
- /* FIXME: duplicate code. */
- int line_count = Staff_symbol_referencer::line_count (me);
- Stem_info si ;
- Direction dir = get_direction (me);
-
- si.ideal_y_ = dir* (line_count + 1.5);
- si.dir_ = dir;
- si.shortest_y_ = si.ideal_y_;
- return si;
- }
-
-
/* Return cached info if available */
SCM scm_info = me->get_grob_property ("stem-info");
if (!gh_pair_p (scm_info))
void
Stem::calc_stem_info (Grob *me)
{
+ /* Tab notation feature: make stem end extend out of staff. */
+ SCM up_to_staff = me->get_grob_property ("up-to-staff");
+ if (to_boolean (up_to_staff))
+ {
+ int line_count = Staff_symbol_referencer::line_count (me);
+ Direction dir = get_direction (me);
+ Real ideal_y = dir * (line_count + 1.5);
+ Real shortest_y = ideal_y;
+
+ me->set_grob_property ("stem-info",
+ scm_list_n (gh_double2scm (ideal_y),
+ gh_double2scm (shortest_y),
+ SCM_UNDEFINED));
+ return;
+ }
+
Direction my_dir = Directional_element_interface::get (me);
Real staff_space = Staff_symbol_referencer::staff_space (me);
Grob *beam = get_beam (me);
(neutral-direction . -1)
;; [Wanske]: standard length (but no shorter than minimum).
- (beamed-lengths . (3.5))
+ ;; (beamed-lengths . (3.5))
+
+ ;; FIXME. 3.5 yields too long beams (according to Ross and
+ ;; looking at Baerenreiter examples) for a number of common
+ ;; boundary cases. Subtracting half a beam thickness fixes
+ ;; this, but the bug may well be somewhere else.
+ (beamed-lengths . (3.26))
;; [Wanske] lists three sets of minimum lengths. One
;; set for the nomal case, and one set for beams with `der