Next: , Previous: Instrument names, Up: Writing parts


Quoting other voices

It is very common for one voice to double some of the music from another voice. For example, the first and second violins may play the same notes during a passage of music. In LilyPond this is accomplished by letting one voice quote the other voice without having to re-enter it.

Before a part can be quoted, the \addQuote command must be used to initialize the quoted fragment. This command must be used in the toplevel scope. The first argument is an identifying string, and the second is a music expression:

flute = \relative c'' {
  a4 gis g gis
}
\addQuote "flute" { \flute }

The \quoteDuring command is used to indicate the point where the quotation begins. It is followed by two arguments: the name of the quoted voice, as defined with \addQuote, and a music expression that indicates the duration of the quote, usually spacer rests or multi-measure rests. The corresponding music from the quoted voice is inserted into the music expression:

     
     flute = \relative c'' {
       a4 gis g gis
     }
     \addQuote "flute" { \flute }
     
     \relative c' {
       c4 cis \quoteDuring #"flute" { s2 }
     }

[image of music]

If the music expression used for \quoteDuring contains anything but a spacer rest or multi-measure rest, a polyphonic situation is created, which is often not desirable:

     
     flute = \relative c'' {
       a4 gis g gis
     }
     \addQuote "flute" { \flute }
     
     \relative c' {
       c4 cis \quoteDuring #"flute" { c4 b }
     }

[image of music]

Quotations recognize instrument transposition settings for both the source and target instruments if the \transposition command is used. For details about \transposition, see Instrument transpositions.

     
     clarinet = \relative c'' {
       \transposition bes
       a4 gis g gis
     }
     \addQuote "clarinet" { \clarinet }
     
     \relative c' {
       c4 cis \quoteDuring #"clarinet" { s2 }
     }

[image of music]

It is possible to tag quotations with unique names in order to process them in different ways. For details about this procedure, see Using tags.

Selected Snippets

Quoting another voice with transposition

Quotations take into account the transposition of both source and target. In this example, all instruments play sounding middle C; the target is an instrument in F. The target part may be transposed using \transpose. In this case, all the pitches (including the quoted ones) are transposed.

     
     \addQuote clarinet {
       \transposition bes
       \repeat unfold 8 { d'16 d' d'8 }
     }
     
     \addQuote sax {
       \transposition es'
       \repeat unfold 16 { a8 }
     }
     
     quoteTest = {
       % french horn
       \transposition f
       g'4
       << \quoteDuring #"clarinet" { \skip 4 } s4^"clar." >>
       << \quoteDuring #"sax" { \skip 4 } s4^"sax." >>
       g'4
     }
     
     {
       \set Staff.instrumentName =
         \markup {
           \center-column { Horn \line { in F } }
         }
       \quoteTest
       \transpose c' d' << \quoteTest s4_"up a tone" >>
     }

[image of music]

Quoting another voice

The quotedEventTypes property determines the music event types that are quoted. The default value is (note-event rest-event), which means that only notes and rests of the quoted voice appear in the \quoteDuring expression. In the following example, a 16th rest is not quoted since rest-event is not in quotedEventTypes.

     
     quoteMe = \relative c' {
       fis4 r16 a8.-> b4\ff c
     }
     \addQuote quoteMe \quoteMe
     
     original = \relative c'' {
       c8 d s2
       \once \override NoteColumn #'ignore-collision = ##t
       es8 gis8
     }
     
     <<
       \new Staff {
         \set Staff.instrumentName = #"quoteMe"
         \quoteMe
       }
       \new Staff {
         \set Staff.instrumentName = #"orig"
         \original
       }
       \new Staff \relative c'' <<
         \set Staff.instrumentName = #"orig+quote"
         \set Staff.quotedEventTypes =
           #'(note-event articulation-event)
         \original
         \new Voice {
           s4
           \set fontSize = #-4
           \override Stem #'length-fraction = #(magstep -4)
           \quoteDuring #"quoteMe" { \skip 2. }
         }
       >>
     >>

[image of music]

See also

Notation Reference: Instrument transpositions, Using tags.

Snippets: Staff notation.

Internals Reference: QuoteMusic, Voice.

Known issues and warnings

Only the contents of the first Voice occurring in an \addQuote command will be considered for quotation, so music cannot contain \new and \context Voice statements that would switch to a different Voice.

Quoting grace notes is broken and can even cause LilyPond to crash.

Quoting nested triplets may result in poor notation.

In earlier versions of LilyPond (pre 2.11), addQuote was written entirely in lower-case letters: \addquote.

Other languages: français, español, deutsch.