From b4499a5881bb1fcc2a4ec3270aafb23303effde8 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Tue, 13 Aug 2002 14:56:02 +0000 Subject: [PATCH] * 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. --- ChangeLog | 10 ++++++++++ cygwin/lilypond-doc.hint | 7 ++++--- lily/beam-quanting.cc | 29 +++++++++++++++------------- lily/beam.cc | 20 +++++++------------- lily/stem.cc | 41 +++++++++++++++++++--------------------- scm/grob-description.scm | 8 +++++++- 6 files changed, 63 insertions(+), 52 deletions(-) diff --git a/ChangeLog b/ChangeLog index ed31b8b21e..2edaa77875 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2002-08-13 Jan Nieuwenhuizen + * 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. diff --git a/cygwin/lilypond-doc.hint b/cygwin/lilypond-doc.hint index 3d84e60071..dbe40b211f 100644 --- a/cygwin/lilypond-doc.hint +++ b/cygwin/lilypond-doc.hint @@ -1,5 +1,6 @@ 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." diff --git a/lily/beam-quanting.cc b/lily/beam-quanting.cc index c589e5da37..e20393afd5 100644 --- a/lily/beam-quanting.cc +++ b/lily/beam-quanting.cc @@ -32,9 +32,9 @@ const int IDEAL_SLOPE_FACTOR = 10; 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); } @@ -257,10 +257,10 @@ Beam::score_stem_lengths (Link_arraystems, bool knee, Real yl, Real yr) { - Real pen = STEM_LENGTH_LIMIT_PENALTY; - + Real limit_pen = STEM_LENGTH_LIMIT_PENALTY; Drul_array score (0, 0); Drul_array count (0, 0); + for (int i=0; i < stems.size (); i++) { Grob* s = stems[i]; @@ -271,20 +271,23 @@ Beam::score_stem_lengths (Link_arraystems, 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] ++; } @@ -315,14 +318,14 @@ Beam::score_slopes_dy (Real yl, Real yr, 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; } diff --git a/lily/beam.cc b/lily/beam.cc index 3e9c31f66c..63700ab163 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -819,23 +819,17 @@ Beam::least_squares (SCM smob) 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 diff --git a/lily/stem.cc b/lily/stem.cc index 493a7d0b77..bbb7310fd4 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -276,14 +276,13 @@ Stem::get_default_dir (Grob*me) 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")); @@ -761,24 +760,6 @@ Stem::get_beam (Grob*me) 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)) @@ -797,6 +778,22 @@ Stem::get_stem_info (Grob *me) 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); diff --git a/scm/grob-description.scm b/scm/grob-description.scm index 4539a35e58..ad6a813adf 100644 --- a/scm/grob-description.scm +++ b/scm/grob-description.scm @@ -852,7 +852,13 @@ (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 -- 2.39.5