1.6.3 Writing parts

This section explains how to insert tempo indications and instrument names into a score. Methods to quote other voices and format cue notes are also described.


Instrument names

Instrument names can be printed on the left side of staves in the Staff, PianoStaff, StaffGroup, GrandStaff and ChoirStaff contexts. The value of instrumentName is used for the first staff, and the value of shortInstrumentName is used for all succeeding staves.

\new Staff \with {
  instrumentName = #"Violin "
  shortInstrumentName = #"Vln. "
}
{ c4.. g'16 c4.. g'16 \break | c1 }

[image of music]

\markup can be used to create more complex instrument names:

\new Staff \with {
  instrumentName = \markup {
    \column { "Clarinetti"
      \line { "in B" \smaller \flat }
    }
  }
}
{ c4 c,16 d e f g2 }

[image of music]

When two or more staff contexts are grouped together, the instrument names and short instrument names are centered by default. To center multi-line instrument names, \center-column must be used:

<<
  \new Staff \with {
    instrumentName = #"Flute"
  }
  { f2 g4 f }
  \new Staff \with {
    instrumentName = \markup {
      \center-column { "Clarinet"
        \line { "in B" \smaller \flat }
      }
    }
  }
  { c4 b c2 }
>>

[image of music]

However, if the instrument names are longer, the instrument names in a staff group may not be centered unless the indent and short-indent settings are increased. For details about these settings, see \paper variables for shifts and indents.

\relative c'' {
  <<
    \new Staff \with {
      instrumentName = #"Alto Flute in G"
      shortInstrumentName = #"Flt."
    }
    {
      f2 g4 f \break
      g4 f g2
    }
    \new Staff \with {
      instrumentName = #"Clarinet"
      shortInstrumentName = #"Clar."
    }
    {
      c,4 b c2 \break
      c2 b4 c
    }
  >>
}

\layout {
  indent = 3.0\cm
  short-indent = 1.5\cm
}

[image of music]

To add instrument names to other contexts (such as ChordNames or FiguredBass), Instrument_name_engraver must be added to that context. For details, see Modifying context plug-ins.

The shortInstrumentName may be changed in the middle of a piece. However, only the first instance of instrumentName will be printed and subsequent changes will be ignored:

\new Staff \with {
  instrumentName = #"Flute"
  shortInstrumentName = #"Flt."
}
{
  c1 c c c \break
  c1 c c c \break
  \set Staff.instrumentName = #"Clarinet"
  \set Staff.shortInstrumentName = #"Clt."
  c1 c c c \break
  c1 c c c \break
}

[image of music]

If an instrument switch is needed, \addInstrumentDefinition may be used in combination with \instrumentSwitch to create a detailed list of the necessary changes for the switch. The \addInstrumentDefinition command has two arguments: an identifying string, and an association list of context properties and values to be used for the instrument. It must be placed in the toplevel scope. \instrumentSwitch is used in the music expression to declare the instrument switch:

\addInstrumentDefinition #"contrabassoon"
  #`((instrumentTransposition . ,(ly:make-pitch -1 0 0))
     (shortInstrumentName . "Cbsn.")
     (clefGlyph . "clefs.F")
     (middleCPosition . 6)
     (clefPosition . 2)
     (instrumentCueName . ,(make-bold-markup "cbsn."))
     (midiInstrument . "bassoon"))

\new Staff \with {
  instrumentName = #"Bassoon"
}
\relative c' {
  \clef tenor
  \compressFullBarRests
  c2 g'
  R1*16
  \instrumentSwitch "contrabassoon"
  c,,2 g \break
  c,1 ~ | c1
}

[image of music]

See also

Notation Reference: \paper variables for shifts and indents, Modifying context plug-ins.

Snippets: Staff notation.

Internals Reference: InstrumentName, PianoStaff, Staff.


Quoting other voices

It is very common for one voice to use the same notes as those from another voice. For example, first and second violins playing the same phrase during a particular passage of the music. This is done by letting one voice quote the other, without having to re-enter the music all over again for the second voice.

The \addQuote command, used in the top level scope, defines a stream of music from which fragments can be quoted.

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 for the duration of the quote.

fluteNotes = \relative c'' {
  a4 gis g gis | b4^"quoted" r8 ais\p a4( f)
}

oboeNotes = \relative c'' {
  c4 cis c b \quoteDuring #"flute" { s1 }
}

\addQuote "flute" { \fluteNotes }

\score {
  <<
    \new Staff \with { instrumentName = "Flute" } \fluteNotes
    \new Staff \with { instrumentName = "Oboe" } \oboeNotes
  >>
}

[image of music]

If the music expression used in \quoteDuring contains notes instead of spacer or multimeasure rests then the quote will appear as polyphony and may produce unexpected results.

fluteNotes = \relative c'' {
  a4 gis g gis | b4^"quoted" r8 ais\p a4( f)
}

oboeNotes = \relative c'' {
  c4 cis c b \quoteDuring #"flute" { e4 r8 ais b4 a }
}

\addQuote "flute" { \fluteNotes }

\score {
  <<
    \new Staff \with { instrumentName = "Flute" } \fluteNotes
    \new Staff \with { instrumentName = "Oboe" } \oboeNotes
  >>
}

[image of music]

The \quoteDuring command uses the \transposition settings of both quoted and quoting parts to produce notes for the quoting part that have the same sounding pitch as those in the quoted part.

clarinetNotes = \relative c'' {
  \transposition bes
  \key d \major
  b4 ais a ais | cis4^"quoted" r8 bis\p b4( f)
}

oboeNotes = \relative c'' {
  c4 cis c b \quoteDuring #"clarinet" { s1 }
}

\addQuote "clarinet" { \clarinetNotes }


\score {
  <<
    \new Staff \with { instrumentName = "Clarinet" } \clarinetNotes
    \new Staff \with { instrumentName = "Oboe" } \oboeNotes
  >>
}

[image of music]

By default quoted music will include all articulations, dynamics, markups, etc., in the quoted expression. It is possible to choose which of these objects from the quoted music are displayed by using the quotedEventTypes context property.

fluteNotes = \relative c'' {
  a2 g2 |
  b4\<^"quoted" r8 ais a4\f( c->)
 }

oboeNotes = \relative c'' {
  c2. b4 |
  \quoteDuring #"flute" { s1 }
}

\addQuote "flute" { \fluteNotes }

\score {
  <<
    \set Score.quotedEventTypes = #'(note-event articulation-event
                                     crescendo-event rest-event
                                     slur-event dynamic-event)
    \new Staff \with { instrumentName = "Flute" } \fluteNotes
    \new Staff \with { instrumentName = "Oboe" } \oboeNotes
  >>
 }

[image of music]

Quotes can also be tagged, see Using tags.

See also

Notation Reference: Instrument transpositions, Using tags.

Installed Files: ‘scm/define-event-classes.scm’.

Snippets: Staff notation.

Internals Reference: Music classes, QuoteMusic, Voice.

Known issues and warnings

Only the contents of the first Voice occurring in an \addQuote command will be considered for quotation, so if the music expression contains \new or \context Voice statements, their contents will not be quoted. Quoting grace notes is unsupported and may cause LilyPond to crash whereas quoting nested triplets may result in poor notation.


Formatting cue notes

The simplest way to format cue notes is to explicitly create a CueVoice context within the part.

R1
<<
  { e2\rest r4. e8 }
  \new CueVoice {
    \stemUp d'8^"flute" c d e fis2
  }
>>
d,4 r a r

[image of music]

The \cueClef command can also be used with an explict CueVoice context if a change of clef is required and will print an appropriately sized clef for the cue notes. The \cueClefUnset command can then be used to switch back to the original clef, again with an appropriately sized clef.

\clef "bass"
R1
<<
  { e2\rest r4. \cueClefUnset e,8 }
  \new CueVoice {
    \cueClef "treble" \stemUp d''8^"flute" c d e fis2
  }
>>
d,,4 r a r

[image of music]

The \cueClef and \cueClefUnset command can also be used without a CueVoice if required.

\clef "bass"
R1
\cueClef "treble"
d'8^"flute" c d e fis2
\cueClefUnset
d,,4 r a r

[image of music]

For more complex cue note placement, e.g including transposition, or inserting cue notes from multiple music sources the \cueDuring or \cueDuringWithClef commands can be used. These are more specialized form of \quoteDuring, see Quoting other voices in the previous section.

The syntax is:

\cueDuring #quotename #direction #music

and

\cueDuringWithClef #quotename #direction #clef #music

The music from the corresponding measures of the quote name is added as a CueVoice context and occurs simultaneously with the music, which then creates a polyphonic situation. The direction takes the argument UP or DOWN, and corresponds to the first and second voices respectively, determining how the cue notes are printed in relation to the other voice.

fluteNotes = \relative c'' {
  r2. c4 | d8 c d e fis2 | g2 d |
}

oboeNotes = \relative c'' {
  R1
  \new CueVoice { \set instrumentCueName = "flute" }
  \cueDuring #"flute" #UP { R1 }
  g2 c,
}

\addQuote "flute" { \fluteNotes }

\new Staff {
  \oboeNotes
}

[image of music]

It is possible to adjust which aspects of the music are quoted with \cueDuring by setting the quotedCueEventTypes property. Its default value is '(note-event rest-event tie-event beam-event tuplet-span-event), which means that only notes, rests, ties, beams and tuplets are quoted, but not articulations, dynamic marks, markup etc.

Note: When a Voice starts with cueDuring, as in the following example, the Voice context must be explicitly declared, or else the entire music expression would belong to the CueVoice context.

oboeNotes = \relative c'' {
  r2 r8 d16(\f f e g f a)
  g8 g16 g g2.
}
\addQuote "oboe" { \oboeNotes }

\new Voice \relative c'' {
  \set Score.quotedCueEventTypes = #'(note-event rest-event tie-event
                                      beam-event tuplet-span-event
                                      dynamic-event slur-event)
  \cueDuring #"oboe" #UP { R1 }
  g2 c,
}

[image of music]

The name of the instrument playing the cue can be printed by setting the instrumentCueName property in a temporary CueVoice context. The placement and style of the instrumentCueName is controlled by the InstrumentSwitch object, see Instrument names. If the cue notes require a change in clef, this can be done manually but the original clef should also be restored manually at the end of the cue notes.

fluteNotes = \relative c'' {
  r2. c4 d8 c d e fis2 g2 d2
}

bassoonNotes = \relative c {
  \clef bass
  R1
  \clef treble
  \new CueVoice { \set instrumentCueName = "flute" }
  \cueDuring #"flute" #UP { R1 }
  \clef bass
  g4. b8 d2
}

\addQuote "flute" { \fluteNotes }

\new Staff {
  \bassoonNotes
}

[image of music]

Alternatively, the \cueDuringWithClef function can be used instead. This command takes an extra argument to specify the change of clef that needs to be printed for the cue notes but will automatically print the original clef once the cue notes have finished.

fluteNotes = \relative c'' {
  r2. c4 d8 c d e fis2 g2 d2
}

bassoonNotes = \relative c {
  \clef bass
  R1
  \new CueVoice { \set instrumentCueName = "flute" }
  \cueDuringWithClef #"flute" #UP #"treble" { R1 }
  g4. b8 d2
}

\addQuote "flute" { \fluteNotes }

\new Staff {
  \bassoonNotes
}

[image of music]

Like \quoteDuring, \cueDuring takes instrument transpositions into account. Cue notes are produced at the pitches that would be written for the instrument receiving the cue to produce the sounding pitches of the source instrument.

To transpose cue notes differently, use \transposedCueDuring. This command takes an extra argument to specify (in absolute mode) the printed pitch that you want to represent the sound of a concert middle C. This is useful for taking cues from an instrument in a completely different register.

piccoloNotes = \relative c''' {
  \clef "treble^8"
  R1
  c8 c c e g2
  c4 g g2
}

bassClarinetNotes = \relative c' {
  \key d \major
  \transposition bes,
  d4 r a r
  \transposedCueDuring #"piccolo" #UP d { R1 }
  d4 r a r
}

\addQuote "piccolo" { \piccoloNotes }

<<
  \new Staff \piccoloNotes
  \new Staff \bassClarinetNotes
>>

[image of music]

The \killCues command removes cue notes from a music expression, so the same music expression can be used to produce the instrument part with cues and the score. The \killCues command removes only the notes and events that were quoted by \cueDuring. Other markup associated with cues, such as clef changes and a label identifying the source instrument, can be tagged for selective inclusion in the score; see Using tags.

fluteNotes = \relative c'' {
  r2. c4 d8 c d e fis2 g2 d2
}

bassoonNotes = \relative c {
  \clef bass
  R1
  \tag #'part {
    \clef treble
    \new CueVoice { \set instrumentCueName = "flute" }
  }
  \cueDuring #"flute" #UP { R1 }
  \tag #'part \clef bass
  g4. b8 d2
}

\addQuote "flute" { \fluteNotes }

\new Staff {
  \bassoonNotes
}

\new StaffGroup <<
  \new Staff {
    \fluteNotes
  }
  \new Staff {
    \removeWithTag #'part { \killCues { \bassoonNotes } }
  }
>>

[image of music]

Alternatively, Clef changes and instrument labels can be collected into an instrument definition for repeated use, using \addInstrumentDefinition described in Instrument names.

See also

Notation Reference: Quoting other voices, Instrument transpositions, Instrument names, Clef, Musical cues, Using tags.

Snippets: Staff notation.

Internals Reference: CueVoice, Voice.

Known issues and warnings

Collisions can occur with rests, when using \cueDuring, between Voice and CueVoice contexts. When using \cueDuringWithClef or \transposedCueDuring the extra argument required for each case must come after the quote and the direction.


Other languages: deutsch, español, français, italiano, 日本語.
About automatic language selection.

LilyPond — Notation Reference v2.18.2 (stable-branch).