Jump to content

Associating lyrics with voices in \ChoirStaff

From LilyPond wiki
Revision as of 22:40, 26 October 2025 by Jean Abou Samra (talk | contribs) (Import snippet from LSR)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

If you use ChoirStaff and set lyrics with explicit durations (instead of using \lyricsto), then you have to use \set associatedVoice to associate the lyrics with the correct voices.

\version "2.24.0"

%% http://lsr.di.unimi.it/LSR/Item?id=345

sopranonotes = \relative c' { e2     e4  }
sopranowords = \lyricmode   { do2    me4 }

altonotes    = \relative c' { e4  e  e   }
altowords    = \lyricmode   { do4 re me  }

tenornotes   = \relative c  { e4  e  e   }
tenorwords   = \lyricmode   { do4 re me  }

bassnotes    = \relative c  { e4  e  e   }
basswords    = \lyricmode   { do4 re me  }

\score
{
  \context ChoirStaff
  <<
    \context Staff = soprano
    <<
      \context Voice = sop   { \clef treble \key c \major \time 4/4 \sopranonotes }
      \new Lyrics \lyricmode { \set associatedVoice = #"sop" \sopranowords }
    >>
    \context Staff = alto
    <<
      \context Voice = alt   { \clef treble \key c \major \time 4/4 \altonotes }
      \new Lyrics \lyricmode { \set associatedVoice = #"alt" \altowords }
    >>
    \context Staff = tenor
    <<
      \context Voice = ten   { \clef "G_8"  \key c \major \time 4/4 \tenornotes }
      \new Lyrics \lyricmode { \set associatedVoice = #"ten" \tenorwords     }
    >>
    \context Staff = bass
    <<
      \context Voice = bas   { \clef bass   \key c \major \time 4/4 \bassnotes }
      \new Lyrics \lyricmode { \set associatedVoice = #"bas" \basswords }
    >>
  >>
}