A template for typesetting choir scores in Lilypond

LilyPond is LaTeX for music. You write down the music in a text file, typeset it with LilyPond and the output is a pdf containing sheet music in a beautiful layout. They have very good tutorials at the web page, so head over there to learn more. I just wanted to put my template for choir scores here for future reference.

\version "2.16.0" 


\header {
   title = "Titel"
   composer = "Composer"
}

global = { 
   \key c \major 
   \time 4/4 
}


sopran = \relative c' {
   c4 d e f
   g1   
   \bar "|." 
} 

alt = \relative c' {
   c4 c c c
   c1
} 

tenor = \relative c {
   c4 d e f
   g1
}

bass = \relative c {
   c4 c c c
   c1
}


strophe = \lyricmode {
   Sing -- ing as a test!
} 


% == Part for pdf ==
\score {
<<
   \new ChoirStaff <<
      
      \new Staff  = "Frauen"<<
         \new Voice = "Sopran" { \voiceOne \global  \sopran }
         \new Voice = "Alt" { \voiceTwo \global  \alt }
         \new Lyrics \lyricsto "Sopran" \strophe 
      >>
      
      \new Staff = "Maenner"<<
         \clef bass
         \new Voice = "Tenor" {\voiceOne \global \tenor }
         \new Voice = "Bass" { \voiceTwo \global  \bass }
         \new Lyrics \lyricsto "Tenor" \strophe 
      >>

   >>
>>

\layout {
   indent = 0.0\cm
   \context {\Score 
   }
}

}


% == Part for midi ==
\score { \unfoldRepeats
<<
   \new ChoirStaff <<      
      \new Staff <<
         \new Voice = "Sopran" { \global  \sopran }
      >>
      \new Staff <<
         \new Voice = "Alt" { \global  \alt }
      >>
      \new Staff <<
         \new Voice = "Tenor" { \global  \tenor }
      >>
      \new Staff <<
         \new Voice = "Bass" { \global  \bass }
      >>
   >>
>>
\midi {
   \tempo 4=112
   \set Staff.midiInstrument = "voice oohs" 
}

}

The parts sopran, alt, tenor, bass contain the music for the respective voices. strophe contains the text.

The first score element is for creating the pdf – that’s what the layout part is for. We will have two parallel staves (lines) of music, one for the women voices with a treble clef, one for the men voices with a bass clef. The text will be typeset below each staff, distributed to the notes according to the voices of soprano and tenor.

The second score element is for creating the midi – hence the midi part. Here we separate the four voices into four staves, so that we can turn them on and off separately in a midi player. The unfoldRepeats command is necessary if your piece has voltas (repetitions). You need the command to get the midid to include the repetitions at the places you specify them. Otherwise it will just skip ahead to the next part which is usually not what you want.

That’s it, have fun!

Midi playback with Timidity

Timidity is a little commandline program to play midi files on Linux:

timidity Was-soll-das-bedeuten.midi

My midi is a choir score with three voices and the output of timidity looks like this:

Playing Was-soll-das-bedeuten.midi
MIDI file: Was-soll-das-bedeuten.midi
Format: 1  Tracks: 6  Divisions: 384
Sequence: control track
Text: creator: 
Text: GNU LilyPond 2.18.2           
Track name: :Soprano
Track name: :Alto
Track name: :Men

With the above standard command all voices are played together. To practice something it is sometimes nice to have only your own voice alone, you can do this by quieting/muting all voices except your own. The voices to be muted are listed after the option -Q separated by comma. The value 0 means all voices, the number of the other voices is given by their order in the output. So in the file I have, Soprano would be 1, Alto 2 and the men’s voices 3. Including the number mutes the voice, including it with a minus sign plays it. So let’s say I want to practice the alto voice, I’ll mute all but voice 2:

timidity -Q 0,-2 Was-soll-das-bedeuten.midi

It’s also simple to transpose stuff, this will play the song two semitones higher:

timidity -K 2 Was-soll-das-bedeuten.midi