From 8bca46bcb5abd57557cb7c2b5665a4926289dd6b Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Tue, 23 Mar 2004 00:21:44 +0000 Subject: [PATCH] * lily/accidental-engraver.cc (acknowledge_grob): add property harmonicAccidentals * lily/piano-pedal-engraver.cc (del_linespanner): new function. general cleanups. * input/les-nereides.ly (middleDynamics): resurrect Les nereides. Remove pedal hack. --- ChangeLog | 11 ++ config.make.in | 2 +- input/les-nereides.ly | 133 ++++++------------- lily/accidental-engraver.cc | 29 ++--- lily/piano-pedal-engraver.cc | 207 ++++++++++++++---------------- ly/engraver-init.ly | 2 + scm/define-context-properties.scm | 2 + 7 files changed, 164 insertions(+), 222 deletions(-) diff --git a/ChangeLog b/ChangeLog index c8a60b4176..334c61fc90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2004-03-23 Han-Wen Nienhuys + + * lily/accidental-engraver.cc (acknowledge_grob): add property + harmonicAccidentals + + * lily/piano-pedal-engraver.cc (del_linespanner): new function. + general cleanups. + + * input/les-nereides.ly (middleDynamics): resurrect Les + nereides. Remove pedal hack. + 2004-03-22 Han-Wen Nienhuys * input/regression/property-grace-polyphony.ly: new file. diff --git a/config.make.in b/config.make.in index 6e86d2e9fb..9a0f9027ff 100644 --- a/config.make.in +++ b/config.make.in @@ -37,7 +37,7 @@ stepmake = @stepmake@ docdir = $(datadir)/doc/ omfdir = $(datadir)/omf/ elispdir = $(datadir)/emacs/site-lisp -vimdir = /usr/share/vim +vimdir = $(datadir)/vim # forced instead of $(datadir)/vim # move out of config.make.in? diff --git a/input/les-nereides.ly b/input/les-nereides.ly index 1ae83509c0..93702ec3fa 100644 --- a/input/les-nereides.ly +++ b/input/les-nereides.ly @@ -44,11 +44,11 @@ treble = \new Voice \notes\relative c''{ \change Staff=bass \once\override TextScript #'extra-offset = #'(-3 . -4) %tweak - - cis,16^2(^\markup {\small \italic "m.d." } + + cis,16^2(^\markup {\small \italic "m.d." }\sustainUp 8 | %4 - 4) + 4)\sustainDown \change Staff=treble @@ -62,22 +62,17 @@ treble = \new Voice \notes\relative c''{ \tieUp cis''''4^\markup { \small \italic "m.g." }\arpeggio~ \grace { - \override Stem #'stroke-style = #"grace" - - cis8 - - %\stemBoth Hmm + cis8 + \slurBoth % Tweak - \override Stem #'direction = #0 + \override Stem #'direction = #0 - a16[-5( fis dis] - #(set-octavation 0) + a16[-5( fis dis] + #(set-octavation 0) - cis32[ a-1 fis-4 dis] cis[ a fis)-2] - % the small grace in lower staff comes after us - s32 - - \revert Stem #'stroke-style + cis32[ a-1 fis-4 dis] cis[ a fis)-2] + % the small grace in lower staff comes after us + s32 } @@ -140,7 +135,9 @@ bass = \new Voice \notes\relative c{ r8. e,16(\f_2 8[ ] | %2 - 4 + \override Staff.SustainPedalLineSpanner #'staff-padding = #5 + + 4\sustainDown \change Staff=treble \stemDown \override Slur #'attachment = #'(stem . stem) %tweak @@ -154,11 +151,11 @@ bass = \new Voice \notes\relative c{ \override Slur #'y-free = #0.1 %tweak \revert Slur #'attachment-offset %tweak \override Slur #'attachment-offset = #'((0 . 3) . (0 . 8)) %tweak - r8. cis,,16( 8 + r8. cis,,16(\sustainUp 8 | %3 \override Stem #'length = #5 %tweak - 4 + 4\sustainDown \change Staff=treble \revert Stem #'length %tweak @@ -189,7 +186,7 @@ bass = \new Voice \notes\relative c{ s32 s s s s s \clef bass - 32( + 32(\sustainUp\sustainDown \revert Stem #'stroke-style } @@ -200,22 +197,27 @@ bass = \new Voice \notes\relative c{ % \fingerDown \override Fingering #'direction = #-1 - + + + \override Staff.SustainPedalLineSpanner #'staff-padding = #3.5 + \set Staff.pedalSustainStyle = #'mixed %%a,8 e'[-5(]) - a,8 e'[-5(])-2-3 + + + a,8\sustainDown e'[-5(])-2-3 %%r b,-5 4 - r b,-5 4-3-5 + r b,-5\sustainUp\sustainDown 4-3-5 \slurBoth \once \override Fingering #'extra-offset = #'(0 . -1) %tweak - e,8[-5( + e,8[-5(\sustainUp | %6 \once \override Fingering #'extra-offset = #'(0 . -1) %tweak - a)-2] + a)-2]\sustainDown \slurUp - e'[()] r b, 4 + e'[()] r b,\sustainUp\sustainDown 4 \slurBoth - e,8[( + e,8[(\sustainUp | %7 a)] @@ -239,16 +241,14 @@ middleDynamics = \notes{ | %4 s2 \grace { - \override Stem #'stroke-style = #"grace" - - s8 - s16 s s - s32 s - \once\override Dynamics.Hairpin #'extra-offset = #'(0 . 2) %tweak - s\> s - s32 s s s\! + s8 + s16 s s + s32 s + \once\override Dynamics.Hairpin #'extra-offset = #'(0 . 2) %tweak + s\> s + s32 s s s\! - \revert Stem #'stroke-style } + } s32 s-"rall." s s s8 s4 | %5 @@ -262,60 +262,6 @@ middleDynamics = \notes{ s8\! } -lowerDynamics = \notes{ - s2 - | %2 - s2\sustainDown s8. s16\sustainUp s4 - | %3 - s2\sustainDown s8. s16\sustainUp s4 - | %4 - s4\sustainDown - \set Dynamics.pedalSustainStrings = #'("Ped." "*Ped." "*") - - % grace destroys pedal-line-spanner? - % let's do manual tweak: - \once\override Dynamics.SustainPedal #'extra-offset = #'(10 . 0) %tweak - s8\sustainUp - \once\override Dynamics.SustainPedal #'extra-offset = #'(16 . 0) %tweak - s8\sustainDown -%{ - s4 - \grace { - \override Stem #'stroke-style = #"grace" - - s8 - s16 s s - s32 s s s\sustainUp - s32 s s s\sustainDown - - \revert Stem #'stroke-style } - -%} - s2 - - | %5 - % ugh, I don't think that 'mixed should show last edge, but rather: - % - % Ped__________/\__________ * - % - % that's what gray wants, anyway. - - \set Dynamics.pedalSustainStyle = #'mixed - s8\sustainDown s s - s s\sustainUp\sustainDown s - s - \once \set Dynamics.pedalSustainStyle = #'text - s\sustainUp - - | %6 - \set Dynamics.pedalSustainStyle = #'mixed - s8\sustainDown s s - s s\sustainUp\sustainDown s - s - \once \set Dynamics.pedalSustainStyle = #'text - s\sustainUp - | %7 -} \score{ \context PianoStaff << @@ -331,13 +277,11 @@ lowerDynamics = \notes{ \bass \bassTwo >> - \new Dynamics << - \lowerDynamics - >> >> \paper { \context { \ScoreContext + pedalSustainStrings = #'("Ped." "*Ped." "*") \remove Bar_number_engraver } \context { @@ -346,9 +290,6 @@ lowerDynamics = \notes{ \consists "Output_property_engraver" minimumVerticalExtent = #'(-1 . 1) - pedalSustainStrings = #'("Ped." "*Ped." "*") - - \consists "Piano_pedal_engraver" \consists "Script_engraver" \consists "Dynamic_engraver" \consists "Text_engraver" diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc index 52b5c13e02..3db03bf591 100644 --- a/lily/accidental-engraver.cc +++ b/lily/accidental-engraver.cc @@ -438,22 +438,21 @@ Accidental_engraver::acknowledge_grob (Grob_info info) if (note && note->is_mus_type ("note-event") - && Rhythmic_head::has_interface (info.grob_) -#if 0 - /* - todo: make tunable. - */ - && !gh_equal_p (info.grob_->get_property ("style"), - ly_symbol2scm ("harmonic")) -#endif - ) + && Rhythmic_head::has_interface (info.grob_)) { - Accidental_entry entry ; - entry.head_ = info.grob_; - entry.origin_ = info.origin_trans_->daddy_context_; - entry.melodic_ = note; - accidentals_.push (entry); + if (to_boolean ("harmonicAccidentals") + || !gh_equal_p (info.grob_->get_property ("style"), + ly_symbol2scm ("harmonic"))) + { + + Accidental_entry entry ; + entry.head_ = info.grob_; + entry.origin_ = info.origin_trans_->daddy_context_; + entry.melodic_ = note; + + accidentals_.push (entry); + } } else if (Tie::has_interface (info.grob_)) { @@ -505,5 +504,5 @@ ENTER_DESCRIPTION (Accidental_engraver, "Accidental", "", "finger-interface rhythmic-head-interface tie-interface arpeggio-interface", - "localKeySignature extraNatural autoAccidentals autoCautionaries", + "localKeySignature harmonicAccidentals extraNatural autoAccidentals autoCautionaries", "localKeySignature"); diff --git a/lily/piano-pedal-engraver.cc b/lily/piano-pedal-engraver.cc index f04f31c413..2a04aae68d 100644 --- a/lily/piano-pedal-engraver.cc +++ b/lily/piano-pedal-engraver.cc @@ -1,12 +1,12 @@ /* - piano-pedal-engraver.cc -- implement Piano_pedal_engraver + piano-pedal-engraver.cc -- implement Piano_pedal_engraver - source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter - (c) 2000--2004 Jan Nieuwenhuizen + (c) 2000--2004 Jan Nieuwenhuizen - Chris Jackson - extended to support - bracketed pedals. + Chris Jackson - extended to support + bracketed pedals. */ #include "engraver.hh" @@ -26,7 +26,6 @@ /* Urgh. This engraver is too complex. rewrite. --hwn - */ struct Pedal_info @@ -43,14 +42,14 @@ struct Pedal_info distinct from current_bracket_ev_, since current_bracket_ev_ only necessary for brackets, not for text style. - */ + */ Music* start_ev_; /* Events that were found in this timestep. - */ + */ Drul_array event_drul_; Item* item_; Spanner* bracket_; // A single portion of a pedal bracket @@ -58,7 +57,7 @@ struct Pedal_info /* This grob contains all the pedals of the same type on the same staff - */ + */ Spanner* line_spanner_; Spanner* finished_line_spanner_; }; @@ -87,10 +86,11 @@ private: */ Link_array previous_; + void del_linespanner (Spanner*); void create_text_grobs (Pedal_info *p, bool); void create_bracket_grobs (Pedal_info *p, bool); - void typeset_all (); + void typeset_all (Pedal_info*p); }; @@ -102,8 +102,6 @@ Piano_pedal_engraver::Piano_pedal_engraver () void Piano_pedal_engraver::initialize () { - previous_.clear (); - char * names [] = { "Sostenuto", "Sustain", "UnaCorda", 0 }; info_list_ = new Pedal_info[sizeof (names)/ sizeof (const char*)]; @@ -134,9 +132,9 @@ Piano_pedal_engraver::~Piano_pedal_engraver () } /* - Urg: Code dup - I'm a script - */ + Urg: Code dup + I'm a script +*/ void Piano_pedal_engraver::acknowledge_grob (Grob_info info) { @@ -160,7 +158,7 @@ Piano_pedal_engraver::acknowledge_grob (Grob_info info) bool Piano_pedal_engraver::try_music (Music *m) { - if (m->is_mus_type ("pedal-event")) + if (m->is_mus_type ("pedal-event")) { for (Pedal_info*p = info_list_; p->name_; p ++) { @@ -190,37 +188,38 @@ Piano_pedal_engraver::process_music () p->line_spanner_ = make_spanner (name.to_str0 ()); Music * rq = (p->event_drul_[START] ? p->event_drul_[START] : p->event_drul_[STOP]); + + announce_grob (p->line_spanner_, rq->self_scm ()); } /* Choose the appropriate grobs to add to the line spanner - These can be text items or text-spanners + These can be text items or text-spanners */ /* ugh, code dup, should read grob to create from other property. - bracket: |_________/\____| - text: Ped. *Ped. * - mixed: Ped. _____/\____| - */ + bracket: |_________/\____| + text: Ped. *Ped. * + mixed: Ped. _____/\____| + */ String prop = String ("pedal") + p->name_ + "Style"; SCM style = get_property (prop.to_str0 ()); + bool mixed = style == ly_symbol2scm ("mixed"); - if (style == ly_symbol2scm ("text") || - mixed) - { - if (! p->item_) - create_text_grobs (p, mixed); - } - if (style == ly_symbol2scm ("bracket") || - mixed) - { - create_bracket_grobs (p, mixed); - } + bool bracket = (mixed + || style == ly_symbol2scm ("bracket")); + bool text = (style == ly_symbol2scm ("text") + || mixed); + + if (text && !p->item_) + create_text_grobs (p, mixed); + if (bracket) + create_bracket_grobs (p, mixed); } } } @@ -271,8 +270,6 @@ Piano_pedal_engraver::create_text_grobs (Pedal_info *p, bool mixed) else { s = ly_caddr (strings); - if (previous_.size ()) - previous_.pop (); } p->start_ev_ = 0; } @@ -290,7 +287,7 @@ Piano_pedal_engraver::create_text_grobs (Pedal_info *p, bool mixed) // add extra space below the previous already-occuring pedal Side_position_interface::add_support (p->line_spanner_, previous_.top ()); - previous_.push ( p->line_spanner_); + previous_.push (p->line_spanner_); } } @@ -315,6 +312,7 @@ Piano_pedal_engraver::create_text_grobs (Pedal_info *p, bool mixed) } } + void Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed) { @@ -327,12 +325,6 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed) if (p->event_drul_[STOP]) { - if (!p->event_drul_[START]) - { - if (previous_.size ()) - previous_.pop (); - } - assert (!p->finished_bracket_); Grob *cmc = unsmob_grob (get_property ("currentMusicalColumn")); @@ -343,13 +335,13 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed) /* Set properties so that the stencil-creating function will know whether the right edge should be flared ___/ - */ + */ if (!p->event_drul_[START]) { SCM flare = p->bracket_->get_property ("bracket-flare"); p->bracket_->set_property ("bracket-flare", scm_cons (gh_car (flare), - gh_double2scm (0))); + gh_double2scm (0))); } p->finished_bracket_ = p->bracket_; @@ -377,7 +369,7 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed) /* Set this property for 'mixed style' pedals, Ped._______/\ , - so the stencil function will shorten the ____ line by the length of the Ped. text. + so the stencil function will shorten the ____ line by the length of the Ped. text. */ if (mixed) @@ -409,7 +401,7 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed) what about the right span point? - */ + */ Axis_group_interface::add_element (p->line_spanner_, p->bracket_); announce_grob (p->bracket_, p->event_drul_[START]->self_scm ()); @@ -420,7 +412,7 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed) code dup. --hwn. // position new pedal spanner below the current one - */ + */ if (previous_.size ()) Side_position_interface::add_support (p->line_spanner_, previous_.top ()); @@ -439,7 +431,7 @@ Piano_pedal_engraver::finalize () { /* suicide? - */ + */ if (p->line_spanner_ && !p->line_spanner_->live ()) p->line_spanner_ = 0; @@ -462,18 +454,25 @@ Piano_pedal_engraver::finalize () p->bracket_ = 0; p->finished_line_spanner_ = p->line_spanner_; p->line_spanner_ = 0; - typeset_all (); + typeset_all (p); } if (p->line_spanner_) { p->finished_line_spanner_ = p->line_spanner_; - typeset_all (); + typeset_all (p); } } } - +void +Piano_pedal_engraver::del_linespanner (Spanner *g) +{ + int idx = previous_.find_index (g); + if (idx >= 0) + previous_.del (idx); +} + void Piano_pedal_engraver::stop_translation_timestep () { @@ -483,10 +482,12 @@ Piano_pedal_engraver::stop_translation_timestep () { p->finished_line_spanner_ = p->line_spanner_; p->line_spanner_ = 0; + del_linespanner (p->finished_line_spanner_); } + + typeset_all (p); } - typeset_all (); for (Pedal_info*p = info_list_; p->name_; p ++) { @@ -497,79 +498,65 @@ Piano_pedal_engraver::stop_translation_timestep () void -Piano_pedal_engraver::typeset_all () +Piano_pedal_engraver::typeset_all (Pedal_info * p) { - Item * sustain = 0; - for (Pedal_info*p = info_list_; p->name_; p ++) - { - /* - Handle suicide. - */ - if (p->finished_line_spanner_ - && !p->finished_line_spanner_->live ()) - p->finished_line_spanner_ = 0; - if (p->finished_bracket_ - && !p->finished_bracket_->live ()) - p->finished_bracket_ = 0; - + /* + Handle suicide. + */ + if (p->finished_line_spanner_ + && !p->finished_line_spanner_->live ()) + p->finished_line_spanner_ = 0; + if (p->finished_bracket_ + && !p->finished_bracket_->live ()) + p->finished_bracket_ = 0; - if (p->name_ == String ("Sustain")) - sustain = p->item_; - if (p->item_) - { - /* - Hmm. - */ - if (p->name_ != String ("Sustain") && sustain) - { - Side_position_interface::add_support (p->item_,sustain); - } - typeset_grob (p->item_); - p->item_ = 0; - } + if (p->item_) + { + typeset_grob (p->item_); + p->item_ = 0; + } - if (p->finished_bracket_) + if (p->finished_bracket_) + { + Grob * r = p->finished_bracket_->get_bound (RIGHT); + if (!r) { - Grob * r = p->finished_bracket_->get_bound (RIGHT); - if (!r) - { - p->finished_bracket_->set_bound (RIGHT, unsmob_grob (get_property ("currentMusicalColumn"))); - } + p->finished_bracket_->set_bound (RIGHT, unsmob_grob (get_property ("currentMusicalColumn"))); + } - typeset_grob (p->finished_bracket_); + typeset_grob (p->finished_bracket_); - p->finished_bracket_ =0; - } + p->finished_bracket_ =0; + } - if (p->finished_line_spanner_) + if (p->finished_line_spanner_) + { + Grob * l = p->finished_line_spanner_->get_bound (LEFT); + Grob * r = p->finished_line_spanner_->get_bound (RIGHT); + if (!r && l) + p->finished_line_spanner_->set_bound (RIGHT, l); + else if (!l && r) + p->finished_line_spanner_->set_bound (LEFT, r); + else if (!r && !l) { - Grob * l = p->finished_line_spanner_->get_bound (LEFT); - Grob * r = p->finished_line_spanner_->get_bound (RIGHT); - if (!r && l) - p->finished_line_spanner_->set_bound (RIGHT, l); - else if (!l && r) - p->finished_line_spanner_->set_bound (LEFT, r); - else if (!r && !l) - { - Grob * cc = unsmob_grob (get_property ("currentMusicalColumn")); - Item * ci = dynamic_cast (cc); - p->finished_line_spanner_->set_bound (RIGHT, ci); - p->finished_line_spanner_->set_bound (LEFT, ci); - } - typeset_grob (p->finished_line_spanner_); - p->finished_line_spanner_ = 0; + Grob * cc = unsmob_grob (get_property ("currentMusicalColumn")); + Item * ci = dynamic_cast (cc); + p->finished_line_spanner_->set_bound (RIGHT, ci); + p->finished_line_spanner_->set_bound (LEFT, ci); } + typeset_grob (p->finished_line_spanner_); + p->finished_line_spanner_ = 0; } } ENTER_DESCRIPTION (Piano_pedal_engraver, -/* descr */ "Engrave piano pedal symbols and brackets.", -/* creats*/ "SostenutoPedal SustainPedal UnaCordaPedal SostenutoPedalLineSpanner SustainPedalLineSpanner UnaCordaPedalLineSpanner", -/* accepts */ "pedal-event", -/* acks */ "note-column-interface", -/* reads */ "currentCommandColumn " + /* descr */ "Engrave piano pedal symbols and brackets.", + /* creats*/ "SostenutoPedal SustainPedal UnaCordaPedal SostenutoPedalLineSpanner SustainPedalLineSpanner UnaCordaPedalLineSpanner", + /* accepts */ "pedal-event", + /* acks */ "note-column-interface", + /* reads */ "currentCommandColumn " "pedalSostenutoStrings pedalSustainStrings " "pedalUnaCordaStrings pedalSostenutoStyle " "pedalSustainStyle pedalUnaCordaStyle", -/* write */ ""); + /* write */ ""); diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index 8283cfe962..9c37b26c5a 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -475,6 +475,8 @@ AncientRemoveEmptyStaffContext = \context { pedalSostenutoStrings = #'("Sost. Ped." "*Sost. Ped." "*") pedalSostenutoStyle = #'mixed + + harmonicAccidentals = ##t fingeringOrientations = #'(up down) tupletNumberFormatFunction = #denominator-tuplet-formatter markFormatter = #format-mark-letters diff --git a/scm/define-context-properties.scm b/scm/define-context-properties.scm index b9894df096..85e926711a 100644 --- a/scm/define-context-properties.scm +++ b/scm/define-context-properties.scm @@ -205,6 +205,8 @@ fingered.") changed. Only active for the first clef after the property is set, not for the full staff.") + (harmonicAccidentals ,boolean? "If set, harmonic notes in chords +get accidentals.") (highStringOne ,boolean? "Whether the 1st string is the string with highest pitch on the instrument. This used by the automatic string selector for tab notation.") -- 2.39.2