Lilypond Tips

What output is generated

In the absence of both \layout { } and \midi { }, LP produces a score. If you add a \midi { } and you still want a score, you must add a \layout { } too.

Annotations on score and parts

When one writes a score various annotations, e.g. tempo changes, are attached only to the top staff. When one generates separate parts one want those annotations on every part. If one attaches the annotations to every part the parts are correct, but one gets warnings in the full score but the appearance is correct. Here is a workaround, thanks to fremoin on lilypond-user group. You can attach textual annotatioins using \textMark "some txt" at appropriate points.


\version "2.24.3"

structure = { \tempo 4=42 s1*2 \tempo 4=80 }
high = {e''1 1 1 1 f'1}
low = {a'1 1 1 1 b'1}

\score {
    \header { piece = "Score" }
    <<
       \new Devnull \structure
       \new StaffGroup <<
          \new Staff \high
          \new Staff \low
       >>
    >>
}

\score {
    \header { piece = "Part High" }
    <<
       \new Devnull \structure
       \new StaffGroup <<
          \new Staff \high
       >>
    >>
}

\score {
    \header { piece = "Part Low" }
    <<
       \new Devnull \structure
       \new StaffGroup <<
          \new Staff \low
       >>
    >>
} 

Zero-length rests, empty chords

Use <> to create a zero-length, invisible object in the score. This is useful for attaching dynamic marks, particularly when you have no convenient object to use, e.g.
    expr = { c4 d e f g }
    ....
    <>\f \expr <>\!
    <>\p \expr <>\!

See Lilypond Reference Manual sections 1.2.1, 1.3.1 and 1.5.1.

Lyrics

Use \skip optionally followed by a duration to insert rests in a lyric stream. See NR 2.2.1 Multiple notes to one syllable. Alternatively, "" or _ will insert an invisibe syllable or a melisma.

Songs with verse and refrain

If one has a song with verse and refrain, then getting all the bits aligned can be tricky. This is the structure I use for a song with an refrain and three verses, where the \melody already includes all the repeat instructions.:

The essential bit is the context naming.


\version "2.24.3"

melody = { \relative c'
           \repeat volta 3 { a b c d e f g a }
}
verseA = \lyricmode {  This is verse one }
verseB = \lyricmode {  This is verse two }
verseC = \lyricmode {  This is verse three }
chorusWords = \lyricmode {  This is the chorus }

\score {
   \new Staff {
     \melody
     \addlyrics {
       \repeat volta 3 {
         \new Lyrics = mainlyrics \chorusWords
         <<
           \context Lyrics = mainlyrics \verseA
           \new Lyrics \verseB
           \new Lyrics \verseC
         >>
       }
     }
   }
   \layout { }
} 

When the refrain folows the verse, use

  \new Staff {
     \melody
     \addlyrics {
       \repeat volta 3 {
         <<
           \new Lyrics = mainlyrics \verseA
           \new Lyrics \verseB
           \new Lyrics \verseC
         >>
         \context Lyrics = mainlyrics \chorusWords
       }
     } 

Breath marks in lyrics

To insert breathing marks in lyrics add Breathing_sign_engraver in the Lyrics context and use the \breathe command in lyrics.

\layout {
  \context {
    \Lyrics
    \consists "Breathing_sign_engraver"
    \override BreathingSign.Y-offset = #2  % looks better
  }
}

<<
  \new Voice = "melody" \relative {
    a'1 a4. a8 \breathe a2
  }
  \new Lyrics \lyricsto "melody" {
    These are the \breathe words
  }
>>

Showing just chords and lyrics, with no music staff

Jazz rhythm players sometimes want just chords and lyrics. This can be done by using a NullVoice in a Devnull.

notes = { c'8. d'16 e'4 f'8( g') a'4 }

\layout {
  \context {
    \Devnull
    \accepts NullVoice
  }
}

music = <<
  \new ChordNames \chordmode { c4 a:m f bes:maj7 }
  \tag #'notes \new Staff \notes
  \new Devnull \new NullVoice = "lyrics" \notes
  \new Lyrics \lyricsto "lyrics" { A B C D E }
>>

% Print everything:
{ \music }

% Print just chords and lyrics
\removeWithTag #'notes \music

Adding an instrument name to a ChordNames taff

\layout {
  \context {
    \ChordNames
    \consists "Instrument_name_engraver"
    instrumentName = ""
    shortInstrumentName = ""
  }
}
Then "instrumentName" etc can be set on a ChordNames staff.