Thanks for all your help. Find attached a third version of my patch for syllables under grace notes. Compared to the patch dated March 31, the following has been done:
* 2 regression tests added (a basic test and a lyric extender test), * different wording in the docs (according to the hints by Graham Percival), * few code formatting fix-ups and a simplification (thanks, Neil). Currently I am facing a problem which I could not yet find a solution to: In order to have syllables put under grace notes, I need to "\set includeGraceNotes = ##t" before the syllable *preceding* the "grace syllable" -- which might be counterintuitive and is a problem if the grace note is the very first of a piece of music. Example: \relative c'' { \time 2/4 % c2 \grace { cis8 } d2 \grace { dis8 } e2 } \addlyrics { \set ignoreMelismata = ##t \set includeGraceNotes = ##t % x foo bar fuu ba } Here, the "foo" does not get put under the "cis8" grace note, but under "d2". If one uncomments "c2" and "x", then the syllable assignment is as expected ("x" under "c2", "foo" under "cis8"). Does anybody have a solution or a pointer to another lilypond construct whose implementation I should have a look at? Cheers, Richard On Sat, 3 Apr 2010 23:04:06 +0100, Neil Puttock <n.putt...@gmail.com> wrote: > Here are a few more comments on your patch: > > +...@code{\lyricsto} keine Silben zugeordnet. Dieses Verhalten kann > > Two spaces following a full stop. done > + \grace { f'16 [a'16] } c''2 > > + \afterGrace c''2 { f'16 [a'16] } > > f'16[ done > /* read */ > "extendersOverRests ", > + "includeGraceNotes " > > comma follows "includeGraceNotes " done > +Grob *get_current_note_head (Context *voice, bool includeGraceNotes); > > bool include_grace_notes done > + if (((end_mom->main_part_ > now.main_part_) || > + (includeGraceNotes && (bool)now.grace_part_ > + && end_mom->main_part_ == now.main_part_ > + && end_mom->grace_part_ > now.grace_part_)) > > I think > > (includeGraceNotes && > end_mom->grace_part_ > now.grace_part_) > > would be OK here agree; done > + to_boolean (get_property ("includeGraceNotes"))); > > fix indent done > I think something similar to your docs example would be fine as a > test case. > > I'd add a separate test for extenders; perhaps something like the > following snippet: > > \version "2.13.18" > > \relative c' { > c2 \grace { c16([ d e f] } g2) > } > \addlyrics { > \set includeGraceNotes = ##t > _ Ah __ > } added exactly this example as regression test - thanks a lot!
From 3ccf4d1804b1268111836de731717461fa4b276b Mon Sep 17 00:00:00 2001 From: Richard Gay <richard....@t-online.de> Date: Sat, 10 Apr 2010 12:38:37 +0200 Subject: [PATCH] includeGraceNotes: lyrics syllables of grace notes --- Documentation/de/notation/vocal.itely | 28 ++++++++++++++++++++++ Documentation/notation/vocal.itely | 28 ++++++++++++++++++++++ input/regression/lyric-extender-includegraces.ly | 16 ++++++++++++ input/regression/lyrics-includegraces.ly | 26 ++++++++++++++++++++ lily/extender-engraver.cc | 5 ++- lily/include/context.hh | 2 +- lily/lyric-combine-music-iterator.cc | 6 ++-- lily/lyric-engraver.cc | 17 ++++++++---- scm/define-context-properties.scm | 2 + 9 files changed, 118 insertions(+), 12 deletions(-) create mode 100644 input/regression/lyric-extender-includegraces.ly create mode 100644 input/regression/lyrics-includegraces.ly diff --git a/Documentation/de/notation/vocal.itely b/Documentation/de/notation/vocal.itely index 9393cc6..0e77a4c 100644 --- a/Documentation/de/notation/vocal.itely +++ b/Documentation/de/notation/vocal.itely @@ -1194,6 +1194,34 @@ Es ist notwendig, explizit @code{\set} und @code{\unset} zu verwenden, um den Text einzugrenzen, für den Melismen ignoriert werden sollen. +...@subsubheading Silben zu Verzierungsnoten hinzufügen + +Normalerweise werden Verzierungsnoten (z.B. durch @code{\grace}) bei +...@code{\lyricsto} keine Silben zugeordnet. Dieses Verhalten kann +geändert werden, wie das folgende Beispiel zeigt. + +...@lilypond[verbatim,ragged-right,quote] +<< + \relative c' { + f4 \appoggiatura a32 b4 + \grace { f16[ a16] } b2 + \afterGrace b2 { f16[ a16] } + \appoggiatura a32 b4 + \acciaccatura a8 b4 + } + \addlyrics { + normal + \set includeGraceNotes = ##t + case, + gra -- ce case, + after -- grace case, + \set ignoreMelismata = ##t + app. case, + acc. case. + } +>> +...@end lilypond + @subsubheading Zu einer alternativen Melodie umschalten diff --git a/Documentation/notation/vocal.itely b/Documentation/notation/vocal.itely index 34f6cc4..42aa938 100644 --- a/Documentation/notation/vocal.itely +++ b/Documentation/notation/vocal.itely @@ -1152,6 +1152,34 @@ not work if prefixed with @code{\once}. It is necessary to use @code{\set} and @code{\unset} to bracket the lyrics where melismata are to be ignored. +...@subsubheading Adding syllables to grace notes + +By default, grace notes (e.g. via @code{\grace}) do not get assigned +syllables when using @code{\lyricsto}, but this behavior can be +changed: + +...@lilypond[verbatim,ragged-right,quote] +<< + \relative c' { + f4 \appoggiatura a32 b4 + \grace { f16[ a16] } b2 + \afterGrace b2 { f16[ a16] } + \appoggiatura a32 b4 + \acciaccatura a8 b4 + } + \addlyrics { + normal + \set includeGraceNotes = ##t + case, + gra -- ce case, + after -- grace case, + \set ignoreMelismata = ##t + app. case, + acc. case. + } +>> +...@end lilypond + @subsubheading Switching to an alternative melody More complex variations in text underlay are possible. It is possible diff --git a/input/regression/lyric-extender-includegraces.ly b/input/regression/lyric-extender-includegraces.ly new file mode 100644 index 0000000..ae0e696 --- /dev/null +++ b/input/regression/lyric-extender-includegraces.ly @@ -0,0 +1,16 @@ +\version "2.13.18" + +\header { + texidoc=" +Setting @code{includeGraceNotes} enables lyrics syllables to be +assigned to grace notes. +" +} + +\relative c' { + c2 \grace { c16([ d e f] } g2) +} +\addlyrics { + \set includeGraceNotes = ##t + _ Ah __ +} diff --git a/input/regression/lyrics-includegraces.ly b/input/regression/lyrics-includegraces.ly new file mode 100644 index 0000000..81029c7 --- /dev/null +++ b/input/regression/lyrics-includegraces.ly @@ -0,0 +1,26 @@ +\version "2.13.18" + +\header { + texidoc=" +Setting @code{includeGraceNotes} enables lyrics syllables to be +assigned to grace notes. +" +} + +\relative c' { + f4 \appoggiatura a32 b4 + \grace { f16[ a16] } b2 + \afterGrace b2 { f16[ a16] } + \appoggiatura a32 b4 + \acciaccatura a8 b4 +} +\addlyrics { + normal + \set includeGraceNotes = ##t + case, + gra -- ce case, + after -- grace case, + \set ignoreMelismata = ##t + app. case, + acc. case. +} diff --git a/lily/extender-engraver.cc b/lily/extender-engraver.cc index 097b479..9936170 100644 --- a/lily/extender-engraver.cc +++ b/lily/extender-engraver.cc @@ -100,7 +100,7 @@ Extender_engraver::stop_translation_timestep () if (extender_ || pending_extender_) { Context *voice = get_voice_to_lyrics (context ()); - Grob *h = voice ? get_current_note_head (voice) : 0; + Grob *h = voice ? get_current_note_head (voice, to_boolean (get_property ("includeGraceNotes"))) : 0; if (h) { @@ -197,7 +197,8 @@ ADD_TRANSLATOR (Extender_engraver, "LyricExtender ", /* read */ - "extendersOverRests ", + "extendersOverRests " + "includeGraceNotes ", /* write */ "" diff --git a/lily/include/context.hh b/lily/include/context.hh index 45e94ab..4aa6c55 100644 --- a/lily/include/context.hh +++ b/lily/include/context.hh @@ -146,7 +146,7 @@ Context *find_context_below (Context *where, bool melisma_busy (Context *); Context *get_voice_to_lyrics (Context *lyrics); -Grob *get_current_note_head (Context *voice); +Grob *get_current_note_head (Context *voice, bool include_grace_notes); Grob *get_current_rest (Context *voice); DECLARE_UNSMOB (Context, context); diff --git a/lily/lyric-combine-music-iterator.cc b/lily/lyric-combine-music-iterator.cc index 7b304cf..5be3477 100644 --- a/lily/lyric-combine-music-iterator.cc +++ b/lily/lyric-combine-music-iterator.cc @@ -293,7 +293,6 @@ Lyric_combine_music_iterator::process (Moment /* when */) set_music_context (0); } - if (music_context_ && (start_new_syllable () || (busy_moment_ >= pending_grace_moment_)) @@ -304,13 +303,14 @@ Lyric_combine_music_iterator::process (Moment /* when */) { pending_grace_moment_ = now; pending_grace_moment_.grace_part_ = Rational (0); - return; + if (!to_boolean (lyrics_context_->get_property ("includeGraceNotes"))) + return; } else { pending_grace_moment_.set_infinite (1); } - + Moment m = lyric_iter_->pending_moment (); lyrics_context_->set_property (ly_symbol2scm ("associatedVoiceContext"), music_context_->self_scm ()); diff --git a/lily/lyric-engraver.cc b/lily/lyric-engraver.cc index 999efaa..3ec47cc 100644 --- a/lily/lyric-engraver.cc +++ b/lily/lyric-engraver.cc @@ -127,7 +127,7 @@ get_voice_to_lyrics (Context *lyrics) } Grob * -get_current_note_head (Context *voice) +get_current_note_head (Context *voice, bool include_grace_notes) { Moment now = voice->now_mom (); for (SCM s = voice->get_property ("busyGrobs"); @@ -141,10 +141,13 @@ get_current_note_head (Context *voice) continue; } - if (end_mom->main_part_ > now.main_part_ - && dynamic_cast<Item *> (g) - && Note_head::has_interface (g)) - return g; + if (((end_mom->main_part_ > now.main_part_) || + (include_grace_notes && end_mom->grace_part_ > now.grace_part_)) + && dynamic_cast<Item *>(g) + && Note_head::has_interface(g)) + { + return g; + } } return 0; @@ -159,7 +162,8 @@ Lyric_engraver::stop_translation_timestep () if (voice) { - Grob *head = get_current_note_head (voice); + bool include_grace_notes = to_boolean (get_property ("includeGraceNotes")); + Grob *head = get_current_note_head (voice, include_grace_notes); if (head) { @@ -191,6 +195,7 @@ ADD_TRANSLATOR (Lyric_engraver, /* read */ "ignoreMelismata " + "includeGraceNotes " "lyricMelismaAlignment ", /* write */ diff --git a/scm/define-context-properties.scm b/scm/define-context-properties.scm index 16b2538..5f937f6 100644 --- a/scm/define-context-properties.scm +++ b/scm/define-context-properties.scm @@ -267,6 +267,8 @@ string selector for tablature notation.") printed as numbers, but only as extender lines.") (implicitTimeSignatureVisibility ,vector? "break visibility for the default time signature.") + (includeGraceNotes ,boolean? "Do not ignore grace notes for +...@rinternals{lyrics}.") (instrumentCueName ,markup? "The name to print if another instrument is to be taken.") (instrumentEqualizer ,procedure? "A function taking a string -- 1.6.4.4
_______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel