Search code examples
lilypond

Align secondary lyrics to hidden Voice


I think I'm close, but can't quite seem to get two stanzas going with one aligned to a hidden voice - so that rhythmic variations can be approximated by the lyrics.

melody = \relative c' {
  \clef treble
  \key c \major
  \time 4/4
  c4 d e f | g f e d |

  <<
 \new Voice = "shown" {
  \relative c' { 
  c4 d c d | e f g2
     }
    }  

  \new Voice = "hidden" {
   \hide { 
  c'8 c d d c c d d | e f g2
     }
    }
  >>
}

text =  \lyricmode {
   Here we have a | li -- tle si -- lly

  <<
    {
      \set stanza = #"1. "
      Si -- lly li -- tle | al -- pha -- bet

    \new Lyrics {
      \set associatedVoice = "hidden"
      \set stanza = #"2. " 
      Si -- ly li -- tle fu -- nny soun -- ding |
      Al -- pha -- bet song.
        }
    }
  >>
  }

\score {
  <<
    \new Voice = "one" { \melody }
    \new Lyrics \lyricsto "one" \text
  >>

  \layout { }
  \midi { }
}

The above shows both voices and neither of their "associated" (or not) lyrics.


Solution

  • You can use the NullVoice context as so:

    \version "2.19.15"
    \language "english"
    
    \score {
      \new Staff
      <<
        \new Voice = "displayedMusic" \relative c'' {
          b8 c d \times 2/3 {c16 d c}
          b8 a g a
          bf c bf \times 2/3 {a16 bf a}
          g8 f g a
          bf f' e a,
          d cs4.~
          cs1
        }
    
        \new NullVoice = "hiddenMusic"
        {
          c4 d e f %\break
          g a b8~ b c4 \break
          d e f g a
        }
        \new Lyrics \lyricsto "hiddenMusic" {
          Those words seem to be aligned to the hidden melody or are they?
        }
      >>
    }
    

    Which will result in :

    Sheet Music Snippet