From a98abdb905071e49f19db84b4f2755f69490f9d7 Mon Sep 17 00:00:00 2001 From: hanwen Date: Sun, 25 Jul 2004 14:06:46 +0000 Subject: [PATCH] * lily/new-lyric-combine-music-iterator.cc (find_voice): allow change of melody by setting associatedVoice. * lily/parser.yy (re_rhythmed_music): \lyricsto implies lyrics mode. --- ChangeLog | 5 +++ Documentation/topdocs/NEWS.texi | 3 ++ Documentation/user/notation.itely | 5 ++- input/test/lyrics-melisma-faster.ly | 31 +++++++++++++ input/test/lyrics-melisma-variants.ly | 57 ++++++++++++++++++++++++ lily/new-lyric-combine-music-iterator.cc | 54 ++++++++++++++-------- lily/parser.yy | 9 ++-- 7 files changed, 141 insertions(+), 23 deletions(-) create mode 100644 input/test/lyrics-melisma-faster.ly create mode 100644 input/test/lyrics-melisma-variants.ly diff --git a/ChangeLog b/ChangeLog index 097683aaa7..e7474d525d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2004-07-25 Han-Wen Nienhuys + * lily/new-lyric-combine-music-iterator.cc (find_voice): allow + change of melody by setting associatedVoice. + + * lily/parser.yy (re_rhythmed_music): \lyricsto implies lyrics mode. + * scripts/lilypond-book.py (Lilypond_file_snippet.ly): don't copy file contents, rather \include them, so default linewidth is set. (ly_options): make BOOKPAPER set of options. Move linewidth diff --git a/Documentation/topdocs/NEWS.texi b/Documentation/topdocs/NEWS.texi index af1a26a572..10b5f2ef70 100644 --- a/Documentation/topdocs/NEWS.texi +++ b/Documentation/topdocs/NEWS.texi @@ -7,6 +7,9 @@ @unnumbered New features in 2.3 since 2.2 @itemize @bullet +@item The melody for a @code{\lyricsto} text can be changed during a melody. + +@item The @code{\lyricsto} keyword now automatically sets @code{\lyrics}. @item The LilyPond binary now supports output options @code{--dvi} @code{--png} @code{--ps} @code{--pdf} and diff --git a/Documentation/user/notation.itely b/Documentation/user/notation.itely index 7b597da7a3..69146ccac4 100644 --- a/Documentation/user/notation.itely +++ b/Documentation/user/notation.itely @@ -3567,7 +3567,10 @@ Program reference: Music expressions: @internalsref{LyricCombineMusic}, Contexts: @internalsref{Lyrics}, @internalsref{Melisma_translator}. Examples: @inputfileref{input/template,satb.ly}, -@inputfileref{input/regression,lyric-combine-new.ly}. +@inputfileref{input/regression,lyric-combine-new.ly}, +@c TODO: make separate section for melismata +@inputfileref{input/test,lyrics-melisma-variants.ly}. +@inputfileref{input/test,lyrics-melisma-faster.ly}. @refbugs diff --git a/input/test/lyrics-melisma-faster.ly b/input/test/lyrics-melisma-faster.ly new file mode 100644 index 0000000000..20c6c08e50 --- /dev/null +++ b/input/test/lyrics-melisma-faster.ly @@ -0,0 +1,31 @@ +\header +{ + texidoc = "A faster lyrics line may be set to a melismatic melody by +setting @code{ignoreMelismata}. A tricky aspect is that ignoreMelismata +must be set a syllable too soon." + +} + + +\paper { + raggedright = ##t +} + +\version "2.3.8" + +<< + \relative \context Voice = "lahlah" { + \set Staff.autoBeaming = ##f + c4 + \slurDotted + f8.[( g16]) + } + \new Lyrics \lyricsto "lahlah" { + slo -- ow + } + \new Lyrics \lyricsto "lahlah" { + \set ignoreMelismata = ##t % applies to "fas" + go fas -- ter + \unset ignoreMelismata + } +>> diff --git a/input/test/lyrics-melisma-variants.ly b/input/test/lyrics-melisma-variants.ly new file mode 100644 index 0000000000..3c43ee41c2 --- /dev/null +++ b/input/test/lyrics-melisma-variants.ly @@ -0,0 +1,57 @@ +\header { + +texidoc = "You can switch the Voice context for a lyrics melody + during a lyrics line using @code{associatedVoice}. Here, the + syllables \"rannosau\" are set to triplets. + +A tricky aspect is that @code{associatedVoice} needs to be changed one +syllable too soon. + +" +} + +\paper { + raggedright = ##t +} + +\version "2.3.8" + +<< + \relative \context Voice = "lahlah" { + \set Staff.autoBeaming = ##f + c4 + << + \context Voice = alternative { + \voiceOne + \times 2/3 { + + % show associations clearly. + \override NoteColumn #'force-hshift = #-3 + f8 f g + } + } + { + \voiceTwo + f8.[ g16] + \oneVoice + } >> + a8( b) c + + } + \new Lyrics \lyricsto "lahlah" \lyrics { + Ju -- ras -- sic Park + } + \new Lyrics \lyricsto "lahlah" \lyrics { + + % Tricky: need to set associatedVoice + % one syllable too soon! + \set associatedVoice = alternative % applies to "ran" + Ty -- + ran -- + no -- + \set associatedVoice = lahlah % applies to "rus" + sau -- rus Rex + } >> + + + diff --git a/lily/new-lyric-combine-music-iterator.cc b/lily/new-lyric-combine-music-iterator.cc index ff658fc8fa..6b73ba7e68 100644 --- a/lily/new-lyric-combine-music-iterator.cc +++ b/lily/new-lyric-combine-music-iterator.cc @@ -1,11 +1,11 @@ /* -new-lyric-combine-iterator.cc -- implement New_lyric_combine_music_iterator + new-lyric-combine-iterator.cc -- implement New_lyric_combine_music_iterator -source file of the GNU LilyPond music typesetter + source file of the GNU LilyPond music typesetter -(c) 2004 Han-Wen Nienhuys + (c) 2004 Han-Wen Nienhuys - */ +*/ #include "context.hh" #include "lyric-combine-music.hh" @@ -38,6 +38,8 @@ private: bool made_association_; Context * lyrics_context_; Context * music_context_; + SCM lyricsto_voice_name_; + Music_iterator * lyric_iter_; }; @@ -142,6 +144,9 @@ New_lyric_combine_music_iterator::construct_children () Music *m = unsmob_music (get_music ()->get_property ("element")); lyric_iter_ = unsmob_iterator (get_iterator (m)); + lyricsto_voice_name_ = get_music ()->get_property ("associated-context"); + + find_voice (); if (lyric_iter_) @@ -158,22 +163,33 @@ New_lyric_combine_music_iterator::construct_children () void New_lyric_combine_music_iterator::find_voice () { - if (!music_context_) + SCM voice_name = lyricsto_voice_name_; + SCM running = lyrics_context_ ? lyrics_context_->get_property ("associatedVoice") : SCM_EOL; + + if (ly_c_string_p (running)) + voice_name = running; + + if (ly_c_string_p (voice_name) + && (!music_context_ || ly_scm2string (voice_name) != music_context_->id_string ())) { - SCM voice_name = get_music ()->get_property ("associated-context"); - - if (ly_c_string_p (voice_name)) - { - Context *t = get_outlet (); - while (t && t->get_parent_context ()) - t = t->get_parent_context (); - - String name = ly_scm2string (voice_name); - Context *voice = find_context_below (t, ly_symbol2scm ("Voice"), name); - if (voice) - music_context_ = voice; - - } + /* + (spaghettini). + + Need to set associatedVoiceContext again + */ + if (music_context_) + made_association_ = false; + + Context *t = get_outlet (); + while (t && t->get_parent_context ()) + t = t->get_parent_context (); + + String name = ly_scm2string (voice_name); + Context *voice = find_context_below (t, ly_symbol2scm ("Voice"), name); + + + if (voice) + music_context_ = voice; } if (lyrics_context_ && music_context_) diff --git a/lily/parser.yy b/lily/parser.yy index 49d14e1399..cfd64db525 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -1234,9 +1234,12 @@ re_rhythmed_music: $$ = all; scm_gc_unprotect_object ($1->self_scm ()); } - | LYRICSTO string Music { - Music *music = $3; - SCM name = $2; + | LYRICSTO { + THIS->lexer_->push_lyric_state (); + } simple_string Music { + THIS->lexer_->pop_state (); + Music *music = $4; + SCM name = $3; $$ = make_lyric_combine_music (name, music); scm_gc_unprotect_object (music->self_scm ()); } -- 2.39.5