Positionng rests in the middle of a two-voice line

In choir scores, you often have the score for two voices (e.g., soprano and alto) in one line:

      \new Staff  = "Frauen"<<
         \new Voice = "Sopran" { \voiceOne \global  \soprano }
         \new Voice = "Alt" { \voiceTwo \global  \alto }
      >>

When they both have a pause at the same time with the same length, lilypond will still print two rests in different positions. If you (like me) think this looks weird, here is how you can change it:

soprano = \relative c' { a2 \oneVoice r4 \voiceOne } a4 }
alto = \relative c' { a2 s4 } a4 }

In one voice, change to only one voice with \oneVoice for the rest and then back to the usual voice, here /voiceOne. If you do the same in the other voice, you will get warnings about clashing notes, so instead of using a rest, use an invisible rest (spacer) with s.

An alternative is the following command which causes all rests to appear in the middle of the line. It should be used inside the \layout block:

   \override Voice.Rest #'staff-position = #0

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