From: Jan Nieuwenhuizen Date: Mon, 11 Mar 2002 18:49:41 +0000 (+0100) Subject: patch::: 1.5.38.jcn1 X-Git-Tag: release/1.5.39~3 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=ff2fd96ac708af3268b454bb607893392e1695e4;p=lilypond.git patch::: 1.5.38.jcn1 2002-03-11 Jan Nieuwenhuizen * scm/grob-description.scm (Beam): Add concaveness. Replace Beam::cancel_suspect_slope with Beam::check_concave. * lily/beam.cc (check_concave): Calculate concaveness of beam, and set slope to horizontal if concaveness > Beam.concaveness. This handles cases that kludgy cancel_suspect_slope was meant to catch very well. (cancel_suspect_slope): Remove. --- diff --git a/ChangeLog b/ChangeLog index f525bd9ee3..4177a1c44b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2002-03-11 Jan Nieuwenhuizen + + * scm/grob-description.scm (Beam): Add concaveness. Replace + Beam::cancel_suspect_slope with Beam::check_concave. + + * lily/beam.cc (check_concave): Calculate concaveness of beam, and + set slope to horizontal if concaveness > Beam.concaveness. This + handles cases that kludgy cancel_suspect_slope was meant to catch + very well. + (cancel_suspect_slope): Remove. + 2002-03-11 Han-Wen * lily/grob.cc (warning): Use cause tracking to give more diff --git a/Documentation/regression-test.tely b/Documentation/regression-test.tely index 36cacbfb90..a2e6e9ce38 100644 --- a/Documentation/regression-test.tely +++ b/Documentation/regression-test.tely @@ -124,6 +124,8 @@ Grace note do weird things with timing. Fragile. @lilypondfile[printfilename]{beaming.ly} +@lilypondfile[printfilename]{beam-concave.ly} + @lilypondfile[printfilename]{beam-extreme.ly} @lilypondfile[printfilename]{beam-position.ly} diff --git a/VERSION b/VERSION index b4dfcf2045..291a9fe0af 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=5 PATCH_LEVEL=38 -MY_PATCH_LEVEL= +MY_PATCH_LEVEL=jcn1 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/input/baerenreiter-sarabande.ly b/input/baerenreiter-sarabande.ly index 450f08d173..4c41c9cd96 100644 --- a/input/baerenreiter-sarabande.ly +++ b/input/baerenreiter-sarabande.ly @@ -17,11 +17,7 @@ the spacing is almost identical. With a line-break forced before measure 25, we get back the linebreaking of Baerenreiter. This file used to show spacing weaknesses. Now it shows weaknesses in -beam and slur handling. - -Note that the Barenreiter edition contains a mistake. The second line -begins with measure 6, not 5. " - +beam and slur handling." } @@ -35,13 +31,13 @@ sarabandeA = \context Voice \notes \relative c { { d4 a2 } > f4. [e8 d c] | [bes g'] [f e16(f] [g a bes)d,] | - cis4.-\trill b8 a g | + cis4.-\trill [b8 a g] | % check spacing without accs: % c4.-\trill [bes8 a g] | < { d'8. e16 f4.-\trill d16 e | - f4. d8 e f } + f4. [d8 e f] } \\ { a2 } > | %5 @@ -67,7 +63,7 @@ sarabandeA = \context Voice \notes \relative c { fis8.-\trill es16 d8 c | [bes g'] [a, fis'] [es' d] | %16 - < bes4.-\trill d, g, > a8 g f! | + < bes4.-\trill d, g, > [a8 g f!] | e bes a f' g a | d, as g es' f g | [cis, bes'] [a g16 f] [e!8 f16 d] | @@ -88,7 +84,7 @@ sarabandeA = \context Voice \notes \relative c { \\ { f,4 fis4. s8 | gis4. } > - d16(cis)d f, a,8 e' d' cis | + d16(cis)d f, [a,8 e'] [d' cis] | d4 d,,2 | } diff --git a/input/regression/beam-concave.ly b/input/regression/beam-concave.ly new file mode 100644 index 0000000000..1cf0fa5420 --- /dev/null +++ b/input/regression/beam-concave.ly @@ -0,0 +1,88 @@ +\header{ + texidoc = "Concave beams should be horizontal. However, what exactly +it is that makes a beam concave is still unclear. + +Beams 1 and 3 should be sloped, 2 and 4 should be horizontal. Two +sane attempts of calculating concaveness of a beam fail to distinguish +beams this way." + +} + +\score{ + \notes\relative c'{ + \property Voice.Beam \set #'debug-concave = ##t + +%%% \property Voice.Beam \set #'concaveness = #0.8 +%%% \property Voice.Beam \set #'concaveness-no-slope = ##f +%%% \property Voice.Beam \set #'concaveness-square = ##f + + + + \property Voice.Beam \set #'concaveness-no-slope = ##t + %%\property Voice.Beam \set #'concaveness = #0.25 + + %% this gives what baerenreiter does, but it's too kludgy + %% to make much sense + \property Voice.Beam \set #'concaveness-square = ##t + \property Voice.Beam \set #'concaveness = #0.08 + +%% This case seems easy: second beam should be horizontal. + + %% SCS-I Menuet I, m15 + %% sloped + %% slope = -0.5ss + %% concaveness: 0.50 + %% concaveness-no-slope: 0.25 + %% concaveness-no-slope^2: 0.06 + \clef bass + \time 3/4 + \key g\major + a8 g fis e b dis + + %% SCS-I Menuet II, m20 + %% horizontal + %% slope = 0 + %% concaveness: 1.12 + %% concaveness-no-slope: 0.38 + %% concaveness-no-slope^2: 0.09 + \key f\major + fis,^"horiz." a c es d c + +%%% Sarabande: the first beam, obviously more concave, is not horizontal, +%%% but is matched with the next beam in the piece: context. + + %% Sarabande: m24 + %% sloped + %% concaveness: 0.75 + %% concaveness-no-slope: 0.00 + %% concaveness-no-slope^2: 0.00 + \stemUp + [d,16 a' b cis] + + %% Sarabande: m25 + %% horizontal + %% concaveness: 0.50 + %% concaveness-no-slope: 0.25 + %% concaveness-no-slope^2: 0.12 + [a'16^"horiz." b c b] + +% Hmm. Concaveness of both: 1.75 +% %% SCS-VI Prelude, m81 +% %% slope = 0.0 +% \stemBoth +% \key d\major +% [e,8 cis a'] + +% %% SCS-VI Prelude, m82 +% %% slope = 0.1ss (possibly b.o. context?) +% [g, e' cis] + + } + \paper{ + linewidth = -1.0 + } +} + +%% Local variables: +%% LilyPond-indent-level:2 +%% End: diff --git a/lily/beam.cc b/lily/beam.cc index 79d869b552..11b2c312b6 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -388,38 +388,108 @@ Beam::least_squares (SCM smob) return SCM_UNSPECIFIED; } -MAKE_SCHEME_CALLBACK (Beam, cancel_suspect_slope, 1); +#include +MAKE_SCHEME_CALLBACK (Beam, check_concave, 1); SCM -Beam::cancel_suspect_slope (SCM smob) +Beam::check_concave (SCM smob) { Grob *me = unsmob_grob (smob); + + Link_array stems = + Pointer_group_interface__extract_grobs (me, (Item*) 0, "stems"); + + for (int i = 0; i < stems.size ();) + { + if (Stem::invisible_b (stems[i])) + stems.del (i); + else + i++; + } - if (visible_stem_count (me) <= 1) + if (stems.size () < 3) return SCM_UNSPECIFIED; + + SCM s = me->get_grob_property ("concaveness-no-slope"); + + Real concave = 0; + if (!to_boolean (s)) + { + /* Concaveness try #1: Sum distances of inner noteheads to line + between two outer noteheads. */ + + 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; + concave += c; + } + + } + else + { + /* Concaveness try #2: Sum distances of inner noteheads that + fall outside the interval of the two outer noteheads */ + + Interval iv = Interval (Stem::chord_start_f (stems[0]), + Stem::chord_start_f (stems.top ())); + + if (iv[MAX] < iv[MIN]) + // iv.swap (); + iv = Interval (iv[MAX], iv[MIN]); + + 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; + } + } - /* Stem_info, and thus y,dy in this function are corrected for beam-dir */ - Direction dir = Directional_element_interface::get (me); - Real y = gh_scm2double (me->get_grob_property ("y")) * dir; - Real dy = gh_scm2double (me->get_grob_property ("dy")) * dir; - - /* steep slope running against lengthened stem is suspect */ - Real first_ideal = Stem::calc_stem_info (first_visible_stem (me)).idealy_f_; - Real last_ideal = Stem::calc_stem_info (last_visible_stem (me)).idealy_f_; - Real lengthened = gh_scm2double (me->get_grob_property ("outer-stem-length-limit")); - Real steep = gh_scm2double (me->get_grob_property ("slope-limit")); + concave *= Directional_element_interface::get (me); + + Real concaveness = concave / (stems.size () - 2); - // ugh -> use commonx - Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - first_visible_stem (me)->relative_coordinate (0, X_AXIS); - Real dydx = dy && dx ? dy/dx : 0; + /* ugh: this is the a kludge to get input/regression/beam-concave.ly + to behave as baerenreiter. */ + s = me->get_grob_property ("concaveness-square"); + if (to_boolean (s)) + concaveness /= (stems.size () - 2); + + s = me->get_grob_property ("concaveness"); + Real r = gh_scm2double (s); - if (( (y - first_ideal > lengthened) && (dydx > steep)) - || ((y + dy - last_ideal > lengthened) && (dydx < -steep))) + if (concaveness > r) { + Direction dir = Directional_element_interface::get (me); + Real y = gh_scm2double (me->get_grob_property ("y")) * dir; + Real dy = gh_scm2double (me->get_grob_property ("dy")) * dir; + Real adjusted_y = y + dy / 2; /* Store true, not dir-corrected values */ me->set_grob_property ("y", gh_double2scm (adjusted_y * dir)); me->set_grob_property ("dy", gh_double2scm (0)); } + + s = me->get_grob_property ("debug-concave"); + if (to_boolean (s)) + { +#if 0 + Item *text = new Item (me->get_property ("TextScript")); + text->set_grob_property ("text", + ly_str02scm (to_str (concaveness).ch_C ())), + Side_position_interface::add_support (text, stem[0]); +#else + printf ("concaveness: %.2f\n", concaveness); +#endif + } + return SCM_UNSPECIFIED; } diff --git a/lily/include/beam.hh b/lily/include/beam.hh index eba0901fbe..35dfbeb8aa 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -33,7 +33,7 @@ public: y-dy callbacks */ DECLARE_SCHEME_CALLBACK (least_squares, (SCM)); - DECLARE_SCHEME_CALLBACK (cancel_suspect_slope, (SCM)); + DECLARE_SCHEME_CALLBACK (check_concave, (SCM)); DECLARE_SCHEME_CALLBACK (slope_damping, (SCM)); DECLARE_SCHEME_CALLBACK (quantise_dy, (SCM)); DECLARE_SCHEME_CALLBACK (user_override, (SCM)); diff --git a/mf/feta-generic.mf b/mf/feta-generic.mf index 72a00dbac0..b323e46d71 100644 --- a/mf/feta-generic.mf +++ b/mf/feta-generic.mf @@ -42,8 +42,8 @@ else: % input feta-bolletjes; % input feta-banier; % input feta-eindelijk; -% input feta-klef; -% input feta-toevallig; + input feta-klef; + input feta-toevallig; % input feta-schrift; % input feta-haak; % input feta-timesig; diff --git a/scm/grob-description.scm b/scm/grob-description.scm index 48e9722f5a..7a54bdca2c 100644 --- a/scm/grob-description.scm +++ b/scm/grob-description.scm @@ -98,8 +98,12 @@ ;; todo: clean this up a bit: the list is getting ;; rather long. (molecule-callback . ,Beam::brew_molecule) +;; (concaveness . 0.8) + (concaveness . 0.08) + (concaveness-no-slope . #t) + (concaveness-square . #t) (y-dy-callbacks . (,Beam::least_squares - ,Beam::cancel_suspect_slope + ,Beam::check_concave ,Beam::slope_damping ,Beam::quantise_dy ,Beam::user_override