From 545bd166f0f4e34ef0456f0e452fd5b6c3707206 Mon Sep 17 00:00:00 2001 From: hanwen Date: Thu, 28 Mar 2002 00:40:24 +0000 Subject: [PATCH] '' --- ChangeLog | 16 ++++ input/mozart-hrn3-allegro.ly | 12 +-- input/mozart-hrn3-romanze.ly | 4 +- input/mozart-hrn3-rondo.ly | 2 +- lily/include/multi-measure-rest.hh | 4 +- lily/multi-measure-rest.cc | 133 ++++++++++++++++------------- lily/spaceable-grob.cc | 4 +- lily/spacing-spanner.cc | 51 +++++++++-- lily/timing-engraver.cc | 17 +++- lily/timing-translator.cc | 2 - mf/feta-macros.mf | 2 +- scm/grob-description.scm | 2 +- scm/grob-property-description.scm | 2 + 13 files changed, 166 insertions(+), 85 deletions(-) diff --git a/ChangeLog b/ChangeLog index c003526e5f..235d20bd14 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2002-03-28 Han-Wen + + * lily/multi-measure-rest.cc (brew_molecule): variable width molecule. + + * scm/grob-property-description.scm (measure-length): + measure-length grob property. + + * lily/spacing-spanner.cc (standard_breakable_column_spacing): + better spacing for breakable columns when they're juxtaposed: use + measure length if applicable + + * lily/timing-engraver.cc (start_translation_timestep): store + measure length in breakable column at start of measure. + 2002-03-28 Jan Nieuwenhuizen * ROADMAP: Add description for ports dir, to check email upon @@ -5,6 +19,8 @@ 2002-03-27 Han-Wen + * VERSION: 1.5.48 released + * lily/multi-measure-rest.cc (symbol_molecule): split off from brew_molecule() (set_spacing_rods): Use symbol_molecule() to determine minimum diff --git a/input/mozart-hrn3-allegro.ly b/input/mozart-hrn3-allegro.ly index c81bb95b5b..7c4de9cc58 100644 --- a/input/mozart-hrn3-allegro.ly +++ b/input/mozart-hrn3-allegro.ly @@ -19,7 +19,7 @@ allegro = r2 r4 g'4^"Solo" | e'4. () c8 [f (d c )b ] [b()c] g4 r8 [g-. c-. e-.] - g2. ( [g16-.( f e ))f] + g2. [g16-.( f e )f] dis4 () e4-- r8 [c8-. c-. c-.] c4.( [d16 e] f4 ) e a,( d g,) c @@ -49,8 +49,8 @@ allegro = [cis ()d] r4 r2 g,1 ~ g2 ~ [g8 a16 b] [c()d e c] f4-. d-. b-. g-. - r1 - \emptyText + R1 + c,2\p e4 g c \cresc e g4. e8 | d4. [e16 fis] [g () fis e d] [c() b a g] \endcresc @@ -88,7 +88,7 @@ allegro = r2 r8 [g,-. g-. g-.] e'4.() c8 [f( d c )b] [b()c] g4 r8 [g c e] | - g2. ( [g16( f e ))f] + g2. [g16( f e )f] dis4()e r8 [c-. c-. c-.] c4.( [d16 e] f4 )e a, ( d g, )c @@ -112,7 +112,7 @@ allegro = [e()d] d4 r [d8 d] d4(~ [d16 e d )e] [g8() f e d] | c4 r r2 - r1 + R1 c1 ~ c | [c8-. c-.] r c-. [cis()d] r d-. | @@ -128,7 +128,7 @@ allegro = { s2. \grace { [c16 d] } } > ) c4 r r2 - r1 | + R1 | \mark "H" \times 2/3 { [ c8 ()b a ] } \times 2/3 { [ g a b] } \times 2/3 { [ c d e] } \times 2/3 { [ f()e d] } | \times 2/3 { [ c () b a ] } \times 2/3 { [ g a b] } \times 2/3 { [ c d e] } \times 2/3 { [ f()e d] }| diff --git a/input/mozart-hrn3-romanze.ly b/input/mozart-hrn3-romanze.ly index 020d1a9226..4a5fa8e85e 100644 --- a/input/mozart-hrn3-romanze.ly +++ b/input/mozart-hrn3-romanze.ly @@ -23,7 +23,7 @@ romanze = \notes \relative c' { R1*2 g'4.() f8 [e( d c) bes] [bes (a d ) c] c4 r - r1 + R1 % 25 [c16\mf ( d c )d] [e ( f e )f] [g()e c-. c-.] [f()d b-. b-.] [c16\p () d c )d] [e ( f e )f] [g()e c-. c-.] [f()d b-. b-.] @@ -68,7 +68,7 @@ romanze = \notes \relative c' { [c8( e g )bes] [a( c f ) d] c r e r f4 r4 % -. ? - r1 + R1 c8-. r e-. r f4 r4 % Finish with F if played separately diff --git a/input/mozart-hrn3-rondo.ly b/input/mozart-hrn3-rondo.ly index aab198ee6c..8f2c175473 100644 --- a/input/mozart-hrn3-rondo.ly +++ b/input/mozart-hrn3-rondo.ly @@ -37,7 +37,7 @@ rondo = \notes \relative c' \rondotheme R2.*13 | - r8 r-\fermata d [d e f] + r8 r^\fermata d [d e f] [g ()e c-.] [d()e d-.] c4 c8 [d e f] [g()e c-.] [d()e d-.] diff --git a/lily/include/multi-measure-rest.hh b/lily/include/multi-measure-rest.hh index 0d46900ec7..3ba796c515 100644 --- a/lily/include/multi-measure-rest.hh +++ b/lily/include/multi-measure-rest.hh @@ -25,8 +25,8 @@ public: DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM )); static Molecule big_rest (Grob*,Real); - static Molecule symbol_molecule (Grob*); - static Molecule church_rest (Font_metric*, int,Real, Real); + static Molecule symbol_molecule (Grob*,Real); + static Molecule church_rest (Grob*, Font_metric*, int,Real); }; #endif /* MULTI_MEASURE_REST_HH */ diff --git a/lily/multi-measure-rest.cc b/lily/multi-measure-rest.cc index 8353e19812..d3f9e81221 100644 --- a/lily/multi-measure-rest.cc +++ b/lily/multi-measure-rest.cc @@ -85,31 +85,30 @@ Multi_measure_rest::brew_molecule (SCM smob) Interval sp_iv; Direction d = LEFT; + + Grob *common = sp->get_bound (LEFT)->common_refpoint (sp->get_bound (RIGHT), X_AXIS); do { Item * col = sp->get_bound (d)->column_l (); - Interval coldim = col->extent (0, X_AXIS); + Interval coldim = col->extent (common, X_AXIS); sp_iv[d] = coldim[-d] ; } while ((flip (&d)) != LEFT); - Molecule mol; - Real x_off = 0.0; + + Real space = sp_iv.length(); Real rx = sp->get_bound (LEFT)->relative_coordinate (0, X_AXIS); /* we gotta stay clear of sp_iv, so move a bit to the right if needed. */ - x_off += (sp_iv[LEFT] - rx) >? 0; + Real x_off = (sp_iv[LEFT] - rx) >? 0; - /* - center between stuff. - */ - x_off += sp_iv.length ()/ 2; - mol.add_molecule (symbol_molecule (me)); + Molecule mol; + mol.add_molecule (symbol_molecule (me, space)); int measures = 0; SCM m (me->get_grob_property ("measure-count")); @@ -123,8 +122,12 @@ Multi_measure_rest::brew_molecule (SCM smob) Molecule s = Text_item::text2molecule (me, ly_str02scm (to_str (measures).ch_C ()), alist_chain); + + s.align_to (X_AXIS, CENTER); s.translate_axis (3.0, Y_AXIS); + + s.translate_axis (mol.extent (X_AXIS).center (), X_AXIS); mol.add_molecule (s); } mol.translate_axis (x_off, X_AXIS); @@ -133,19 +136,8 @@ Multi_measure_rest::brew_molecule (SCM smob) Molecule -Multi_measure_rest::symbol_molecule (Grob *me) +Multi_measure_rest::symbol_molecule (Grob *me, Real space) { - SCM alist_chain = Font_interface::font_alist_chain (me); - - SCM style_chain = - Font_interface::add_style (me, ly_symbol2scm ("mmrest-symbol"), - alist_chain); - - Real staff_space = Staff_symbol_referencer::staff_space (me); - Font_metric *musfont - = Font_interface::get_font (me,style_chain); - Molecule s; - int measures = 0; SCM m (me->get_grob_property ("measure-count")); if (gh_number_p (m)) @@ -156,30 +148,48 @@ Multi_measure_rest::symbol_molecule (Grob *me) SCM limit = me->get_grob_property ("expand-limit"); if (measures <= 0) - return s; + return Molecule(); + + if (measures > gh_scm2int (limit)) + { + Real padding = 0.15; + Molecule s = big_rest (me, (1.0 - 2*padding) * space); + s.translate_axis (padding * space, X_AXIS); + return s; + } + + SCM alist_chain = Font_interface::font_alist_chain (me); + + SCM style_chain = + Font_interface::add_style (me, ly_symbol2scm ("mmrest-symbol"), + alist_chain); + + Real staff_space = Staff_symbol_referencer::staff_space (me); + Font_metric *musfont + = Font_interface::get_font (me,style_chain); + if (measures == 1) { - s = musfont->find_by_name (Rest::glyph_name (me, 0, "")); + Molecule s = musfont->find_by_name (Rest::glyph_name (me, 0, "")); /* ugh. */ if (Staff_symbol_referencer::position_f (me) == 0.0) s.translate_axis (staff_space, Y_AXIS); + + s.translate_axis ((space - s.extent (X_AXIS).length ())/2, X_AXIS); + + return s ; } - else if (measures <= gh_scm2int (limit)) - { - Real pad = gh_scm2double (me->get_grob_property ("padding")) * staff_space; - s = church_rest (musfont, measures, staff_space, pad); - } - else + else { - Real w = gh_scm2double (me->get_grob_property ("width")); - s = big_rest (me, w); + return church_rest (me, musfont, measures, space); } - return s; } + + Molecule Multi_measure_rest::big_rest (Grob *me, Real width) { @@ -197,25 +207,26 @@ Multi_measure_rest::big_rest (Grob *me, Real width) m.add_at_edge (X_AXIS, RIGHT, yb, -ythick); m.add_at_edge (X_AXIS, LEFT, yb, -ythick); - m.align_to (X_AXIS, CENTER); + m.align_to (X_AXIS, LEFT); return m; } /* Kirchenpause (?) - */ Molecule -Multi_measure_rest::church_rest (Font_metric *musfont, int measures, - Real staff_space, Real padding) +Multi_measure_rest::church_rest (Grob*me, Font_metric *musfont, int measures, + Real space) { - Molecule s; - /* - Build a rest from smaller parts. Distances inbetween are - really variable, see Wanske pp. 125 */ - + SCM mols = SCM_EOL; + + /* + see Wanske pp. 125 + */ int l = measures; + int count = 0; + Real symbols_width = 0.0; while (l) { int k; @@ -235,22 +246,32 @@ Multi_measure_rest::church_rest (Font_metric *musfont, int measures, l --; } - Real pad = s.empty_b () ? 0.0 : padding; - Molecule r (musfont->find_by_name ("rests-" + to_str (k))); if (k == 0) - r.translate_axis (staff_space, Y_AXIS); - - s.add_at_edge (X_AXIS, RIGHT, r, pad); + { + Real staff_space = Staff_symbol_referencer::staff_space (me); + r.translate_axis (staff_space, Y_AXIS); + } + symbols_width += r.extent (X_AXIS).length (); + mols = gh_cons (r.smobbed_copy (), mols); + count ++; + } + + + Real outer_padding_factor = 1.5; // make outer padding this much bigger. + Real inner_padding = (space - symbols_width) / (2 * outer_padding_factor + (count-1)); + + Molecule mol; + for (SCM s = mols; gh_pair_p (s); s = gh_cdr(s)) + { + mol.add_at_edge (X_AXIS, LEFT, *unsmob_molecule (gh_car (s)), inner_padding); } + mol.align_to (X_AXIS, LEFT); + mol.translate_axis (outer_padding_factor * inner_padding, X_AXIS); - s.align_to (X_AXIS, CENTER); - return s; + return mol; } -/* - UGH. JUNKME elt prop "columns" isn't really needed. - */ void Multi_measure_rest::add_column (Grob*me,Item* c) { @@ -263,6 +284,8 @@ MAKE_SCHEME_CALLBACK (Multi_measure_rest, set_spacing_rods,1); SCM Multi_measure_rest::set_spacing_rods (SCM smob) { + return SCM_UNSPECIFIED; + Grob*me = unsmob_grob (smob); Spanner*sp = dynamic_cast (me); @@ -290,14 +313,8 @@ Multi_measure_rest::set_spacing_rods (SCM smob) Rod rod; rod.item_l_drul_[LEFT] = l; rod.item_l_drul_[RIGHT] = r; - - /* - should do something more advanced. - */ - Molecule m = symbol_molecule(me); - rod.distance_f_ = l->extent (l, X_AXIS)[BIGGER] - r->extent (r, X_AXIS)[SMALLER] - + m.extent (X_AXIS).length () + 2.5*staff_space; + + 4.0; // magic! rod.add_to_cols (); } diff --git a/lily/spaceable-grob.cc b/lily/spaceable-grob.cc index 30e1b0503e..e19252783e 100644 --- a/lily/spaceable-grob.cc +++ b/lily/spaceable-grob.cc @@ -81,8 +81,8 @@ Spaceable_grob::remove_interface (Grob*me) ADD_INTERFACE (Spaceable,"spaceable-grob-interface", - "An grob (generally a Paper_column) that takes part in the + "An grob (a Paper_column) that takes part in the spacing problem. ", - "penalty minimum-distances ideal-distances + "measure-length penalty minimum-distances ideal-distances left-neighbors right-neighbors"); diff --git a/lily/spacing-spanner.cc b/lily/spacing-spanner.cc index 2fff9c08e6..674681f44f 100644 --- a/lily/spacing-spanner.cc +++ b/lily/spacing-spanner.cc @@ -34,11 +34,15 @@ class Spacing_spanner { public: + static void standard_breakable_column_spacing (Grob * me, Item*l, Item*r, + Real * fixed, Real * space, Moment); + + static Real default_bar_spacing (Grob*,Grob*,Grob*,Moment); static Real note_spacing (Grob*,Grob*,Grob*,Moment, bool*); static Real get_duration_space (Grob*,Moment dur, Rational shortest, bool*); static Rational find_shortest (Link_array const &); - static void breakable_column_spacing (Item* l, Item *r); + static void breakable_column_spacing (Grob*, Item* l, Item *r, Moment); static void find_loose_columns () {} static void prune_loose_colunms (Grob*,Link_array *cols, Rational); static void find_loose_columns (Link_array cols); @@ -470,7 +474,7 @@ Spacing_spanner::do_measure (Rational shortest, Grob*me, Link_array *cols) if (!Paper_column::musical_b (l)) { - breakable_column_spacing (l, r); + breakable_column_spacing (me, l, r, shortest); /* @@ -483,12 +487,12 @@ Spacing_spanner::do_measure (Rational shortest, Grob*me, Link_array *cols) Item *rb = r->find_prebroken_piece (LEFT); if (lb) - breakable_column_spacing (lb,r); + breakable_column_spacing (me, lb,r, shortest); if (rb) - breakable_column_spacing (l, rb); + breakable_column_spacing (me, l, rb, shortest); if (lb && rb) - breakable_column_spacing (lb, rb); + breakable_column_spacing (me, lb, rb, shortest); continue ; } @@ -553,15 +557,47 @@ Spacing_spanner::musical_column_spacing (Grob *me, Item * lc, Item *rc, Real inc Spaceable_grob::add_spring (lc, rc, max_note_space, 1 / (max_note_space -max_fixed_note_space), expand_only); } +void +Spacing_spanner::standard_breakable_column_spacing (Grob * me, Item*l, Item*r, + Real * fixed, Real * space, + Moment shortest) +{ + *fixed = l->extent (l, X_AXIS)[RIGHT] - r->extent (r, X_AXIS)[LEFT]; + + if (l->breakable_b (l) && r->breakable_b(r)) + { + Moment *dt = unsmob_moment (l->get_grob_property ("measure-length")); + Moment mlen (1); + if (dt) + mlen = *dt; + + Real incr = gh_scm2double (me->get_grob_property ("spacing-increment")); + + *space = *fixed + incr * double (mlen.main_part_ / shortest.main_part_) * 0.8; + } + else + { + Moment dt = Paper_column::when_mom (r) - Paper_column::when_mom (l); + bool dummy; + + *space = *fixed + get_duration_space (me, dt, shortest.main_part_, &dummy); + } + + +} + /* Read hints from L and generate springs. */ void -Spacing_spanner::breakable_column_spacing (Item* l, Item *r) +Spacing_spanner::breakable_column_spacing (Grob*me, Item* l, Item *r,Moment shortest) { Real max_fixed = -infinity_f; Real max_space = -infinity_f; + + standard_breakable_column_spacing (me, l, r, &max_fixed, &max_space , + shortest); for (SCM s = l->get_grob_property ("spacing-wishes"); gh_pair_p (s); s = gh_cdr (s)) @@ -590,6 +626,9 @@ Spacing_spanner::breakable_column_spacing (Item* l, Item *r) } } + + + if (isinf (max_space)) { programming_error ("No pref spacing found"); diff --git a/lily/timing-engraver.cc b/lily/timing-engraver.cc index d3aa30bb96..9a381cede4 100644 --- a/lily/timing-engraver.cc +++ b/lily/timing-engraver.cc @@ -11,6 +11,7 @@ #include "multi-measure-rest.hh" #include "timing-translator.hh" #include "engraver.hh" +#include "grob.hh" /** Do time bookkeeping @@ -54,14 +55,21 @@ Timing_engraver::start_translation_timestep () which = (now.main_part_ || now.main_part_ == last_moment_.main_part_) ? SCM_EOL : ly_str02scm ("|"); + + Moment mp = measure_position (); + bool start_of_measure = (last_moment_.main_part_ != now.main_part_&& !mp.main_part_ ); + + if (start_of_measure) + { + Moment mlen = Moment(measure_length ()); + unsmob_grob (get_property ("currentCommandColumn"))->set_grob_property ("measure-length", mlen.smobbed_copy()); + } if (!gh_string_p (which) && !to_boolean (nonauto)) { SCM always = get_property ("barAlways"); - Moment mp = measure_position (); - if ( (last_moment_.main_part_ != now.main_part_ - && !mp.main_part_) - || (to_boolean (always))) + + if ( start_of_measure || (to_boolean (always))) { /* should this work, or be junked? See input/bugs/no-bars.ly */ which = get_property ("defaultBarType"); @@ -77,6 +85,7 @@ Timing_engraver::stop_translation_timestep () Timing_translator::stop_translation_timestep (); daddy_trans_l_->set_property ("whichBar", SCM_EOL); last_moment_ = now_mom (); + } diff --git a/lily/timing-translator.cc b/lily/timing-translator.cc index edd5505bc4..f92b598a41 100644 --- a/lily/timing-translator.cc +++ b/lily/timing-translator.cc @@ -15,7 +15,6 @@ #include "multi-measure-rest.hh" - void Timing_translator::stop_translation_timestep () { @@ -50,7 +49,6 @@ Timing_translator::stop_translation_timestep () } } - void Timing_translator::initialize () { diff --git a/mf/feta-macros.mf b/mf/feta-macros.mf index 61764beba1..3b17c95f2e 100644 --- a/mf/feta-macros.mf +++ b/mf/feta-macros.mf @@ -209,7 +209,7 @@ def flare_path(expr pos,alpha,beta,line,flare, direction) = penpos2(flare,180+beta+alpha); z2=z3; penpos3(flare,0+alpha); - z3l=z1r+(1/2+0.43)*flare*dir(alpha+beta); + z3l=z1r+(1/2+0.43)*flare*dir(alpha+beta) ; save taille; taille = 0.0; z4=z2r- line * dir(alpha); diff --git a/scm/grob-description.scm b/scm/grob-description.scm index d35e4ac032..72438a926d 100644 --- a/scm/grob-description.scm +++ b/scm/grob-description.scm @@ -652,7 +652,7 @@ (SpacingSpanner . ( (spacing-procedure . ,Spacing_spanner::set_springs) - (grace-space-factor . 0.8) + (grace-space-factor . 0.5) (shortest-duration-space . 2.0) (spacing-increment . 1.2) diff --git a/scm/grob-property-description.scm b/scm/grob-property-description.scm index a0015f3744..0f453ffb34 100644 --- a/scm/grob-property-description.scm +++ b/scm/grob-property-description.scm @@ -221,6 +221,8 @@ and will have no effect. (grob-property-description 'magnify number? "the magnification factor. FIXME: doesn't work for feta fonts.") (grob-property-description 'maximum-length number? "don't make Grob longer than this") (grob-property-description 'maximum-rest-count integer? "kill off rests so we don't more than this number left.") +(grob-property-description 'measure-length moment? "Length of a +measure. Used in some spacing situations.") (grob-property-description 'measure-count integer? "number of measures for a multimeasure rest.") (grob-property-description 'merge-differently-dotted boolean? " Merge noteheads in collisions, even if they have a different number of dots. This normal notation for some types of polyphonic music. The value of this setting is used by @ref{note-collision-interface} .") (grob-property-description 'minimum-distance number? "minimum distance between notes and rests.") -- 2.39.5