From: Jan Nieuwenhuizen Date: Sun, 31 Mar 2002 22:50:11 +0000 (+0000) Subject: * input/regression/beam-concave.ly: Add to-be-considered-concave X-Git-Tag: release/1.5.50~14 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4ac6f1d131f4594a0efa872ab966786f31ff2eca;p=lilypond.git * input/regression/beam-concave.ly: Add to-be-considered-concave beam. * lily/beam.cc (check_concave): Add check for large gap between an inner notehead and the line through outer noteheads. * scm/grob-description.scm (Beam): Add concaveness-gap, default value 2.0 staff-space. * scm/grob-property-description.scm (concaveness-gap): Add description. --- diff --git a/ChangeLog b/ChangeLog index 2cf3f21717..bb2b4ee7c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2002-04-01 Jan Nieuwenhuizen + + * input/regression/beam-concave.ly: Add to-be-considered-concave + beam. + + * lily/beam.cc (check_concave): Add check for large gap between an + inner notehead and the line through outer noteheads. + + * scm/grob-description.scm (Beam): Add concaveness-gap, default + value 2.0 staff-space. + + * scm/grob-property-description.scm (concaveness-gap): Add + description. + +2002-03-31 Jan Nieuwenhuizen + + * input/mozart-hrn3-allegro.ly: Fix typo. + 2002-03-31 Juergen Reuter * scm/ps.scm, ps/music-drawing-routines.ps, lily/lookup.cc, diff --git a/input/mozart-hrn3-allegro.ly b/input/mozart-hrn3-allegro.ly index fcead2faa7..2d7c95dc28 100644 --- a/input/mozart-hrn3-allegro.ly +++ b/input/mozart-hrn3-allegro.ly @@ -55,7 +55,7 @@ allegro = d4. [e16 fis] [g () fis e d] [c() b a g] \endcresc < a1(-\trill -1 { s2 \grace{ [g16 a] } } > + { s2 \grace{ [g16 a] } } > \mark "C" )g4 r r2 R1*15 diff --git a/input/regression/beam-concave.ly b/input/regression/beam-concave.ly index cb3cd9b1b6..ac8b48e492 100644 --- a/input/regression/beam-concave.ly +++ b/input/regression/beam-concave.ly @@ -11,6 +11,7 @@ beams this way." \score{ \notes\relative c'{ \property Voice.Beam \set #'concaveness-threshold = #0.08 + \property Voice.Beam \set #'concaveness-bt2 = #2.0 %% This case seems easy: second beam should be horizontal. @@ -54,7 +55,10 @@ beams this way." % %% SCS-VI Prelude, m82 % %% slope = 0.1ss (possibly b.o. context?) % [g, e' cis] + +%%% `Han-Wen': this should be concave + [a,16^"horiz." a' a a] } \paper{ linewidth = -1.0 diff --git a/lily/beam.cc b/lily/beam.cc index 23bd41dbaa..16f427bbf3 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -775,37 +775,64 @@ Beam::check_concave (SCM smob) if (stems.size () < 3) return SCM_UNSPECIFIED; - /* Concaveness try #2: Sum distances of inner noteheads that - fall outside the interval of the two outer noteheads */ - Real concave = 0; - Interval iv (Stem::chord_start_f (stems[0]), - Stem::chord_start_f (stems.top ())); - - if (iv[MAX] < iv[MIN]) - iv.swap (); - - for (int i = 1; i < stems.size () - 1; i++) + Direction dir = Directional_element_interface::get (me); + /* Concaveness #1: If distance of an inner notehead to line between + two outer noteheads is bigger than CONCAVENESS-GAP (2.0ss), + beam is concave (Heinz Stolba). */ + bool concaveness1 = false; + Real r1 = gh_scm2double (me->get_grob_property ("concaveness-gap")); + if (r1 > 0) { - Real c = 0; - Real f = Stem::chord_start_f (stems[i]); - if ((c = f - iv[MAX]) > 0) - concave += c; - else if ((c = f - iv[MIN]) < 0) - concave += c; + Real dy = Stem::chord_start_f (stems.top ()) + - Stem::chord_start_f (stems[0]); + Real slope = dy / (stems.size () - 1); + + Real y0 = Stem::chord_start_f (stems[0]); + for (int i = 1; i < stems.size () - 1; i++) + { + Real c = (Stem::chord_start_f (stems[i]) - y0) - i * slope; + if (c > r1) + { + concaveness1 = true; + break; + } + } } - Direction dir = Directional_element_interface::get (me); - concave *= dir; + + /* Concaveness #2: Sum distances of inner noteheads that fall + outside the interval of the two outer noteheads */ + Real concaveness2 = 0; + Real r2 = gh_scm2double (me->get_grob_property ("concaveness-threshold")); + if (!concaveness1 && r2 > 0) + { + Real concave = 0; + Interval iv (Stem::chord_start_f (stems[0]), + Stem::chord_start_f (stems.top ())); - Real concaveness = concave / (stems.size () - 2); - /* ugh: this is the a kludge to get input/regression/beam-concave.ly - to behave as baerenreiter. */ - concaveness /= (stems.size () - 2); - - Real r = gh_scm2double (me->get_grob_property ("concaveness-threshold")); + if (iv[MAX] < iv[MIN]) + iv.swap (); + + for (int i = 1; i < stems.size () - 1; i++) + { + Real c = 0; + Real f = Stem::chord_start_f (stems[i]); + if ((c = f - iv[MAX]) > 0) + concave += c; + else if ((c = f - iv[MIN]) < 0) + concave += c; + } + + concave *= dir; + concaveness2 = concave / (stems.size () - 2); + /* ugh: this is the a kludge to get input/regression/beam-concave.ly + to behave as baerenreiter. */ + concaveness2 /= (stems.size () - 2); + } + /* TODO: some sort of damping iso -> plain horizontal */ - if (concaveness > r) + if (concaveness1 || concaveness2 > r2) { Interval pos = ly_scm2interval (me->get_grob_property ("positions")); Real r = pos.linear_combination (0); diff --git a/scm/grob-description.scm b/scm/grob-description.scm index f90647f388..ab647f4df5 100644 --- a/scm/grob-description.scm +++ b/scm/grob-description.scm @@ -101,6 +101,7 @@ ;; todo: clean this up a bit: the list is getting ;; rather long. (molecule-callback . ,Beam::brew_molecule) + (concaveness-gap . 2.0) (concaveness-threshold . 0.08) (positions . (#f . #f)) (position-callbacks . (,Beam::least_squares diff --git a/scm/grob-property-description.scm b/scm/grob-property-description.scm index 0f453ffb34..055699db66 100644 --- a/scm/grob-property-description.scm +++ b/scm/grob-property-description.scm @@ -90,6 +90,9 @@ column as start/begin point. Only columns that have grobs or act as bounds are s (grob-property-description 'center-element ly-grob? "grob which will be at the center of the group after aligning (when using Align_interface::center_on_element). .") +(grob-property-description 'concaveness-gap number? "A beam is +considered to be concave if the distance of an inner notehead to the +line between two outer noteheads is bigger than this gap.") (grob-property-description 'concaveness-threshold number? "A beam is considered to be concave is concaveness is bigger than this threshold. Concaveness is calculated as the sum of the vertical distances of