From 22d7891f2b9ddbe39118ff24f26b3a6eb302178e Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Wed, 24 Apr 2002 13:51:58 +0000 Subject: [PATCH] * input/mozart-hrn3-defs.ly (startGraceContext): Customize grace init. * scm/grob-property-description.scm (beam-space): Junk. * lily/beam.cc (space_function): New method. (get_interbeam): Call space-function. * scm/grob-description.scm (Beam): Initialize space-function with Beam::space_function. * ly/grace-init.ly (startGraceMusic, stopGraceMusic): Set/revert Beam.space-function. Don't quantise grace beams. --- ChangeLog | 15 ++++++++++ input/mozart-hrn3-defs.ly | 48 ++++++++++++++++++++++++++++++- lily/beam.cc | 48 +++++++++++++++---------------- lily/include/beam.hh | 7 +++-- ly/grace-init.ly | 13 +++++++++ scm/grob-description.scm | 1 + scm/grob-property-description.scm | 5 ++-- 7 files changed, 105 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index c37daf9b07..f42cd102de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2002-04-24 Jan Nieuwenhuizen + + * input/mozart-hrn3-defs.ly (startGraceContext): Customize grace init. + + * scm/grob-property-description.scm (beam-space): Junk. + + * lily/beam.cc (space_function): New method. + (get_interbeam): Call space-function. + + * scm/grob-description.scm (Beam): Initialize space-function with + Beam::space_function. + + * ly/grace-init.ly (startGraceMusic, stopGraceMusic): Set/revert + Beam.space-function. Don't quantise grace beams. + 2002-04-23 Han-Wen Nienhuys * mf/feta-nummer-code.mf (code): tweaks for three, fixes for 6 diff --git a/input/mozart-hrn3-defs.ly b/input/mozart-hrn3-defs.ly index 96dfe0b9a1..288e602036 100644 --- a/input/mozart-hrn3-defs.ly +++ b/input/mozart-hrn3-defs.ly @@ -27,6 +27,52 @@ cresc = \notes { \property Voice.crescendoSpanner = #'dashed-line } +startGraceContextOrig = \startGraceContext + +startGraceContext = { + %% Huh? + %% \startGraceContextOrig + + + %%URG copy from original + \property Voice.Stem \override #'direction = #1 + \property Voice.Stem \override #'length = #6 + \property Voice.Stem \override #'lengths = + #(map (lambda (x) (* 0.8 x)) '(3.5 3.5 3.5 4.5 5.0)) + \property Voice.Stem \override #'beamed-lengths = + #(map (lambda (x) (* 0.8 x)) '(0.0 2.5 2.0 1.5)) + \property Voice.Stem \override #'beamed-minimum-lengths = + #(map (lambda (x) (* 0.8 x)) '(0.0 1.5 1.25 1.0)) + \property Voice.Stem \override #'no-stem-extend = ##t + \property Voice.Stem \override #'flag-style = #"grace" + \property Voice.Beam \override #'thickness = #0.384 + + %% Instead of calling Beam::space_function, we should invoke + %% the previously active beam function... + \property Voice.Beam \override #'space-function = + #(lambda (beam mult) (* 0.8 (Beam::space_function beam mult))) + + \property Voice.Beam \override #'position-callbacks = + #`(,Beam::least_squares + ,Beam::check_concave + ,Beam::slope_damping) + + % Can't use Staff.fontSize, since time sigs, keys sigs, etc. will + % be smaller as well. + + \property Voice.fontSize = #-2 + \property Staff.Accidentals \override #'font-relative-size = #-2 + \property Voice.Slur \override #'direction = #-1 + %% end copy + + + \property Voice.Beam \revert #'space-function + \property Voice.Beam \override #'space-function + = #(lambda (beam mult) (* 0.8 0.8)) + \property Voice.Beam \revert #'thickness + \property Voice.Beam \override #'thickness = #(* 0.384 (/ 0.6 0.48)) +} + \paper{ \stylesheet #my-sheet \translator { @@ -39,7 +85,7 @@ cresc = \notes { MultiMeasureRest \override #'number-threshold = #1 Beam \override #'thickness = #0.6 - Beam \override #'beam-space = #0.8 + Beam \override #'space-function = #(lambda (beam mult) 0.8) Slur \override #'beautiful = #0.3 } \translator { diff --git a/lily/beam.cc b/lily/beam.cc index 898c9e0ce3..8c360baede 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -67,33 +67,12 @@ Beam::add_stem (Grob *me, Grob *s) add_bound_item (dynamic_cast (me), dynamic_cast (s)); } - -/* - TODO: fix this for grace notes. - */ Real Beam::get_interbeam (Grob *me) { - int multiplicity = get_multiplicity (me); - Real ss = Staff_symbol_referencer::staff_space (me); - - SCM s = me->get_grob_property ("beam-space"); - if (gh_number_p (s)) - return gh_scm2double (s) * ss; - else if (s != SCM_EOL && gh_list_p (s)) - return gh_scm2double (scm_list_ref (s, - gh_int2scm (multiplicity - 1 - paper_l ()->get_var ("linethickness"); - Real thickness = gh_scm2double (me->get_grob_property ("thickness")) * ss; - - Real interbeam = multiplicity < 4 - ? (2*ss + slt - thickness) / 2.0 - : (3*ss + slt - thickness) / 3.0; - - return interbeam; + SCM func = me->get_grob_property ("space-function"); + SCM s = gh_call2 (func, me->self_scm (), gh_int2scm (get_multiplicity (me))); + return gh_scm2double (s); } int @@ -110,6 +89,25 @@ Beam::get_multiplicity (Grob *me) return m; } +MAKE_SCHEME_CALLBACK (Beam, space_function, 2); +SCM +Beam::space_function (SCM smob, SCM multiplicity) +{ + Grob *me = unsmob_grob (smob); + + Real staff_space = Staff_symbol_referencer::staff_space (me); + Real line = me->paper_l ()->get_var ("linethickness"); + Real thickness = gh_scm2double (me->get_grob_property ("thickness")) + * staff_space; + + Real interbeam = gh_scm2int (multiplicity) < 4 + ? (2*staff_space + line - thickness) / 2.0 + : (3*staff_space + line - thickness) / 3.0; + + return gh_double2scm (interbeam); +} + + /* After pre-processing all directions should be set. Several post-processing routines (stem, slur, script) need stem/beam direction. @@ -1379,5 +1377,5 @@ the ideal slope, how close the result is to the ideal stems, etc.). We take the best scoring combination. ", - "position-callbacks beam-space concaveness-gap concaveness-threshold dir-function quant-score auto-knee-gap gap chord-tremolo beamed-stem-shorten shorten least-squares-dy direction damping flag-width-function neutral-direction positions thickness"); + "position-callbacks concaveness-gap concaveness-threshold dir-function quant-score auto-knee-gap gap chord-tremolo beamed-stem-shorten shorten least-squares-dy direction damping flag-width-function neutral-direction positions space-function thickness"); diff --git a/lily/include/beam.hh b/lily/include/beam.hh index dcc7ba1790..e8ace6dcce 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -26,9 +26,10 @@ public: static void set_stemlens (Grob*); static int get_multiplicity (Grob*me); static Real get_interbeam (Grob*me); - DECLARE_SCHEME_CALLBACK (brew_molecule, (SCM )); - DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM )); - DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM )); + DECLARE_SCHEME_CALLBACK (space_function, (SCM, SCM)); + DECLARE_SCHEME_CALLBACK (brew_molecule, (SCM)); + DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM)); + DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM)); /* position callbacks */ DECLARE_SCHEME_CALLBACK (least_squares, (SCM)); diff --git a/ly/grace-init.ly b/ly/grace-init.ly index 858e4d0057..39079b3396 100644 --- a/ly/grace-init.ly +++ b/ly/grace-init.ly @@ -11,6 +11,16 @@ startGraceMusic = { \property Voice.Stem \override #'no-stem-extend = ##t \property Voice.Stem \override #'flag-style = #"grace" \property Voice.Beam \override #'thickness = #0.384 + + %% Instead of calling Beam::space_function, we should invoke + %% the previously active beam function... + \property Voice.Beam \override #'space-function = + #(lambda (beam mult) (* 0.8 (Beam::space_function beam mult))) + + \property Voice.Beam \override #'position-callbacks = + #`(,Beam::least_squares + ,Beam::check_concave + ,Beam::slope_damping) % Can't use Staff.fontSize, since time sigs, keys sigs, etc. will % be smaller as well. @@ -32,6 +42,9 @@ stopGraceMusic = { \property Voice.Stem \revert #'lengths \property Voice.Stem \revert #'length \property Voice.Stem \revert #'direction + \property Voice.Beam \revert #'space-function + + \property Voice.Beam \revert #'position-callbacks % Can't use Staff.fontSize, since time sigs, keys sigs, etc. will % be smaller as well. diff --git a/scm/grob-description.scm b/scm/grob-description.scm index 351859214f..5a93c2a8d4 100644 --- a/scm/grob-description.scm +++ b/scm/grob-description.scm @@ -136,6 +136,7 @@ (damping . 1) (auto-knee-gap . 7) (font-name . "cmr10") + (space-function . ,Beam::space_function) (meta . ((interfaces . (staff-symbol-referencer-interface beam-interface)))) )) diff --git a/scm/grob-property-description.scm b/scm/grob-property-description.scm index e226f9082e..b8955a9bfc 100644 --- a/scm/grob-property-description.scm +++ b/scm/grob-property-description.scm @@ -48,8 +48,6 @@ This procedure is called (using dependency resolution) after line breaking. Retu (grob-property-description 'shortest-duration-space number? "Start with this much space for the shortest duration. This is explessed in @code{spacing-increment} as unit. See also @ref{spacing-spanner-interface}.") -(grob-property-description 'spacing-increment number? "Add this much space for a doubled duration. Typically, the width of a note head. See also @ref{spacing-spanner-interface}.") - (grob-property-description 'arpeggio ly-grob? "pointer to arpeggio object.") (grob-property-description 'arpeggio-direction dir? "If set, put an arrow on the arpeggio squiggly line.") @@ -71,7 +69,6 @@ In the case of alignment grobs, this should contain only one number.") (grob-property-description 'bass list? " musical-pitch, optional.") (grob-property-description 'beam ly-grob? "pointer to the beam, if applicable.") (grob-property-description 'beam-thickness number? "thickness, measured in staffspace.") -(grob-property-description 'beam-space (or number? list?) "the vertical distance between two beams, indexed by multiplicity") (grob-property-description 'beam-width number? "width of the tremolo sign.") (grob-property-description 'beamed-lengths list? "list of stem lengths given beam multiplicity .") (grob-property-description 'beamed-minimum-lengths list? "list of minimum stem lengths given beam multiplicity.") @@ -300,6 +297,8 @@ TODO: revise typing.") (grob-property-description 'space-alist list? "Alist of break align spacing tuples: format = (SYMBOL . (TYPE . DISTANCE)), where TYPE can be minimum-space or extra-space.") +(grob-property-description 'space-function procedure? "return interbeam space given Beam grob and multiplicity.") +(grob-property-description 'spacing-increment number? "Add this much space for a doubled duration. Typically, the width of a note head. See also @ref{spacing-spanner-interface}.") (grob-property-description 'spacing-procedure procedure? "procedure taking grob as argument. This is called after -- 2.39.2