From 5fa6f3fc33ca85903f16ef38f1cba304e1af655a Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Thu, 14 Mar 2002 00:56:01 +0100 Subject: [PATCH] patch::: 1.5.39.jcn2 2002-03-14 Jan Nieuwenhuizen * scm/beam.scm (default-beam-y-quants): Bugfix: lower beam-sit by 1 staff-line-thickness. Sadly, this makes dy quanting problems (dy quants allowed should depend on actual left y) more visible. --- ChangeLog | 23 ++++ Documentation/index.texi | 4 +- Documentation/regression-test.tely | 2 + VERSION | 2 +- input/baerenreiter-sarabande.ly | 3 +- input/regression/beam-center-slope.ly | 12 ++ input/regression/beam-concave.ly | 32 +---- input/regression/beam-quanting.ly | 2 +- input/test/beam-hss.ly | 36 ++++++ lily/beam.cc | 173 ++++++++++---------------- scm/beam.scm | 14 ++- scm/grob-description.scm | 8 +- scm/grob-property-description.scm | 6 + scm/ps.scm | 2 + 14 files changed, 168 insertions(+), 151 deletions(-) create mode 100644 input/regression/beam-center-slope.ly create mode 100644 input/test/beam-hss.ly diff --git a/ChangeLog b/ChangeLog index 04f8ff8ed6..536e25bbda 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,28 @@ +2002-03-14 Jan Nieuwenhuizen + + * scm/beam.scm (default-beam-y-quants): Bugfix: lower beam-sit by + 1 staff-line-thickness. Sadly, this makes dy quanting problems + (dy quants allowed should depend on actual left y) more visible. + 2002-03-13 Jan Nieuwenhuizen + * lily/beam.cc (quantise_dy): Bugfix: sign (0) = 0. Hmm. + + * scm/grob-property-description.scm (concaveness-threshold): Add + typecheck and description. + + * scm/grob-description.scm (Beam): Remove obsolete properties, add + concaveness-threshold (previously concaveness). + + * lily/beam.cc (check_concave): Remove choices and debugging + stuff: use best concaveness calculation. + (quantise_dy): Remove choice. Try to never make a slope steeper + by quantising, but certainly never quantise a slope away. + (check_stem_length_f): Remove choice. In case of lengthening + alowed, always lengthen to ideal length. + + * Documentation/index.texi: Fix FAQ url. + * Documentation/topdocs/INSTALL.texi: Add information about fink, compile fix and 1.4 specific fix that doesn't hurt 1.5. diff --git a/Documentation/index.texi b/Documentation/index.texi index f6fc22e683..9c7e44ba40 100644 --- a/Documentation/index.texi +++ b/Documentation/index.texi @@ -193,7 +193,7 @@ by computer}. @unnumberedsec Mailing lists If you have questions, do write to the mailing lists. But don't forget -to read the @uref{Documentation/topdocs/out-www/FAQ.html,Very Frequently +to read the @uref{../topdocs/out-www/FAQ.html,Very Frequently Asked Questions} and @uref{http://appel.dyndns.org/wiki?LilyPondFaqs, Frequently Asked Questions} first. @@ -217,7 +217,7 @@ Searchable archives are available from @item @uref{http://mail.gnu.org/mailman/listinfo/lilypond-user,lilypond-user@@gnu.org} For discussing every-day use of LilyPond, in particular the -stable releases.. +stable releases. Searchable archives are available from @uref{http://www.mail-archive.com/lilypond-user@@gnu.org}. diff --git a/Documentation/regression-test.tely b/Documentation/regression-test.tely index a2e6e9ce38..18a0520914 100644 --- a/Documentation/regression-test.tely +++ b/Documentation/regression-test.tely @@ -130,6 +130,8 @@ Grace note do weird things with timing. Fragile. @lilypondfile[printfilename]{beam-position.ly} +@lilypondfile[printfilename]{beam-center-slope.ly} + @lilypondfile[printfilename]{auto-beam-bar.ly} diff --git a/VERSION b/VERSION index 406ad197b3..eb73436f76 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=5 PATCH_LEVEL=39 -MY_PATCH_LEVEL=jcn1 +MY_PATCH_LEVEL=jcn2 # 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 2c4e0835b8..7a41495daa 100644 --- a/input/baerenreiter-sarabande.ly +++ b/input/baerenreiter-sarabande.ly @@ -99,8 +99,9 @@ sarabandeA = \context Voice \notes \relative c { gis4. } > \stemUp d16(cis)d f, + [a,8 e'] \stemBoth - [a,8 e'] [d' cis] | + [d' cis] | d4 d,,2 | } diff --git a/input/regression/beam-center-slope.ly b/input/regression/beam-center-slope.ly new file mode 100644 index 0000000000..cec90fc4f2 --- /dev/null +++ b/input/regression/beam-center-slope.ly @@ -0,0 +1,12 @@ +\header{ + texidoc="Simple beams on middle line should be allowed to have a slope." +} +\score{ + \notes\relative c''{ + [b'8 a] [a b] + [a,,8 b] [b a] + } + \paper{ + linewidth = 0.0 + } +} \ No newline at end of file diff --git a/input/regression/beam-concave.ly b/input/regression/beam-concave.ly index 1cf0fa5420..cb3cd9b1b6 100644 --- a/input/regression/beam-concave.ly +++ b/input/regression/beam-concave.ly @@ -10,30 +10,14 @@ 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 + \property Voice.Beam \set #'concaveness-threshold = #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 + %% concaveness: 0.06 \clef bass \time 3/4 \key g\major @@ -42,9 +26,7 @@ beams this way." %% SCS-I Menuet II, m20 %% horizontal %% slope = 0 - %% concaveness: 1.12 - %% concaveness-no-slope: 0.38 - %% concaveness-no-slope^2: 0.09 + %% concaveness: 0.09 \key f\major fis,^"horiz." a c es d c @@ -53,17 +35,13 @@ beams this way." %% Sarabande: m24 %% sloped - %% concaveness: 0.75 - %% concaveness-no-slope: 0.00 - %% concaveness-no-slope^2: 0.00 + %% concaveness: 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 + %% concaveness:a: 0.12 [a'16^"horiz." b c b] % Hmm. Concaveness of both: 1.75 diff --git a/input/regression/beam-quanting.ly b/input/regression/beam-quanting.ly index 8339c34279..eb41c94188 100644 --- a/input/regression/beam-quanting.ly +++ b/input/regression/beam-quanting.ly @@ -20,7 +20,7 @@ Have some fun beam quanting \score { \notes\relative c'{ - \property Voice.Beam \override #'height-quants = #beam-height-quants + \property Voice.Beam \override #'height-quant-function = #beam-height-quants \property Voice.Beam \override #'vertical-position-quant-function = #beam-vertical-position-quants c8 c c c diff --git a/input/test/beam-hss.ly b/input/test/beam-hss.ly new file mode 100644 index 0000000000..eea591381a --- /dev/null +++ b/input/test/beam-hss.ly @@ -0,0 +1,36 @@ +\header { + +texidoc = "Beams in hang, straddle sit positions." + +} + +\version "1.5.23" + +#(define ps-testing #t) +\score { + \notes\relative c'{ + \property Voice.Beam \override #'height-quant-function + = #(lambda (x y) '(0 4)) + + \property Voice.Beam \override #'vertical-position-quant-function + = #(lambda (beam dy x staff-line) + (let* ((thick (ly-get-grob-property beam 'thickness)) + (hang (- 1 (/ (- thick staff-line) 2)))) + (append (list hang) (list (+ hang 1))))) + [d8 d] + + \property Voice.Beam \override #'vertical-position-quant-function + = #(lambda (beam dy x staff-line) '(0 1)) + [d8 d] + + \property Voice.Beam \override #'vertical-position-quant-function + = #(lambda (beam dy x staff-line) + (let* ((thick (ly-get-grob-property beam 'thickness)) + (sit (/ (- thick staff-line) 2))) + (append (list sit) (list (+ sit 1))))) + [d8 d] + } + \paper{ + linewidth = 0.0 + } +} diff --git a/lily/beam.cc b/lily/beam.cc index e0440d5ec5..0fc84e6a42 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -329,20 +329,35 @@ MAKE_SCHEME_CALLBACK (Beam, least_squares, 1); SCM Beam::least_squares (SCM smob) { - Grob *me = unsmob_grob (smob); + Grob *me = unsmob_grob (smob); - if (visible_stem_count (me) <= 1) - return SCM_UNSPECIFIED; + int count = visible_stem_count (me); + if (count <= 1) + return SCM_UNSPECIFIED; Real y = 0; Real dy = 0; + Direction dir = Directional_element_interface::get (me); /* Stem_info, and thus y,dy in this function are corrected for beam-dir */ Real first_ideal = Stem::calc_stem_info (first_visible_stem (me)).idealy_f_; if (first_ideal == Stem::calc_stem_info (last_visible_stem (me)).idealy_f_) { - y = first_ideal; - dy = 0; + Real left = Stem::chord_start_f (first_visible_stem (me)); + Real right = Stem::chord_start_f (last_visible_stem (me)); + + /* Make simple beam on middle line have small tilt */ + if (!first_ideal && left != right && count == 2) + { + int d = sign (right - left) * dir; + dy = gh_scm2double (me->get_grob_property ("thickness")) * d; + y = 0; + } + else + { + y = first_ideal; + dy = 0; + } } else { @@ -369,13 +384,11 @@ Beam::least_squares (SCM smob) } /* Store true, not dir-corrected values */ - Direction dir = Directional_element_interface::get (me); me->set_grob_property ("y", gh_double2scm (y * dir)); me->set_grob_property ("dy", gh_double2scm (dy * dir)); return SCM_UNSPECIFIED; } -#include MAKE_SCHEME_CALLBACK (Beam, check_concave, 1); SCM Beam::check_concave (SCM smob) @@ -396,80 +409,33 @@ Beam::check_concave (SCM smob) if (stems.size () < 3) return SCM_UNSPECIFIED; - /* TODO: find-out what makes beam concave (#1, #2, #3, #4 or - something else) */ - SCM s = me->get_grob_property ("concaveness-no-slope"); - + /* Concaveness try #2: Sum distances of inner noteheads that + fall outside the interval of the two outer noteheads */ Real concave = 0; - if (!to_boolean (s)) + 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++) { - /* Concaveness try #1: Sum distances of inner noteheads to line - between two outer noteheads. */ - - s = me->get_grob_property ("concave-if-bigger-than-two"); - - 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; - - /* try #4: (Han-Wen): neem maximum afstand lijn - tot - extreme notehead (in geval van akkoorden). Als die - afstand >= 2.0 ss was, dan moest hij recht (of blijkbaar: - vrijwel recht, zie m 17, 18). Dat was nl. wat stolba zei: - als afstand lijn-noot >= 2.0 dan recht. */ - - if (to_boolean (s) && c >= 2.0) - { - concave = 1000 * Directional_element_interface::get (me); - break; - } - - concave += c; - } - + 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; } - 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; - } - } - concave *= Directional_element_interface::get (me); Real concaveness = concave / (stems.size () - 2); - /* ugh: this is the a kludge to get input/regression/beam-concave.ly - to behave as baerenreiter. - - try #3 (add-on to #2): */ - s = me->get_grob_property ("concaveness-square"); - if (to_boolean (s)) - concaveness /= (stems.size () - 2); + to behave as baerenreiter. */ + concaveness /= (stems.size () - 2); - s = me->get_grob_property ("concaveness"); - Real r = gh_scm2double (s); + Real r = gh_scm2double (me->get_grob_property ("concaveness-threshold")); /* TODO: some sort of damping iso -> plain horizontal */ if (concaveness > r) @@ -484,19 +450,6 @@ Beam::check_concave (SCM smob) 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; } @@ -553,7 +506,7 @@ Beam::quantise_dy (SCM smob) return SCM_UNSPECIFIED; Array a; - SCM proc = me->get_grob_property ("height-quants"); + SCM proc = me->get_grob_property ("height-quant-function"); SCM quants = gh_call2 (proc, me->self_scm (), gh_double2scm (me->paper_l ()->get_var ("stafflinethickness") / 1.0)); @@ -571,15 +524,16 @@ Beam::quantise_dy (SCM smob) Real staff_space = Staff_symbol_referencer::staff_space (me); Interval iv = quantise_iv (a, abs (dy)/staff_space) * staff_space; + +#if 0 Real q = (abs (dy) - iv[SMALLER] <= iv[BIGGER] - abs (dy)) ? iv[SMALLER] : iv[BIGGER]; - - if (to_boolean (me->get_grob_property ("quantise-dy-never-steeper")) - && iv[SMALLER] != 0) - q = iv[SMALLER]; +#else + Real q = (!dy || iv[SMALLER] != 0) ? iv[SMALLER] : iv[BIGGER]; +#endif - Real quantised_dy = q * sign (dy); + Real quantised_dy = q * (dy != 0 ? sign (dy) : 1); Real adjusted_y = y + (dy - quantised_dy) * 0.5; /* Store true, not dir-corrected values */ me->set_grob_property ("y", gh_double2scm (adjusted_y * dir)); @@ -716,7 +670,7 @@ Beam::calc_stem_y_f (Grob*me,Item* s, Real y, Real dy) Optionally (testing): try to lengthen more, to reach more ideal stem lengths */ Real -Beam::check_stem_length_f (Grob*me,Real y, Real dy) +Beam::check_stem_length_f (Grob *me, Real y, Real dy) { Real shorten = 0; Real lengthen = 0; @@ -725,8 +679,11 @@ Beam::check_stem_length_f (Grob*me,Real y, Real dy) Link_array stems= Pointer_group_interface__extract_grobs (me, (Item*)0, "stems"); + bool knee = false; int ideal_lengthen_count = 0; Real ideal_lengthen = 0; + int ideal_shorten_count = 0; + Real ideal_shorten = 0; for (int i=0; i < stems.size (); i++) { @@ -734,38 +691,40 @@ Beam::check_stem_length_f (Grob*me,Real y, Real dy) if (Stem::invisible_b (s)) continue; + knee |= dir != Directional_element_interface::get (s); + Real stem_y = calc_stem_y_f (me, s, y, dy); - + stem_y *= dir; Stem_info info = Stem::calc_stem_info (s); - // if (0 > info.maxy_f_ - stem_y) shorten = shorten ? info.miny_f_ - stem_y; if (info.idealy_f_ - stem_y > 0) { - ideal_lengthen += (info.idealy_f_ - stem_y); + ideal_lengthen += info.idealy_f_ - stem_y; ideal_lengthen_count++; } - // too long is not so bad as too short - else if (0) //info.idealy_f_ - stem_y < 0) + else if (info.idealy_f_ - stem_y < 0) { - ideal_lengthen += info.idealy_f_ - stem_y; - ideal_lengthen_count++; + ideal_shorten += info.idealy_f_ - stem_y; + ideal_shorten_count++; } } - + if (lengthen && shorten) me->warning (_ ("weird beam vertical offset")); - if (to_boolean (me->get_grob_property ("ideal-lengthen")) - && ideal_lengthen_count) + if (ideal_lengthen_count) lengthen = (ideal_lengthen / ideal_lengthen_count) >? lengthen; - - /* when all stems are too short, normal stems win */ - return dir * ((shorten) ? shorten : lengthen); + if (knee && ideal_shorten_count) + shorten = (ideal_shorten / ideal_shorten_count)