LilyPond Notation Reference: 1.6.3 Writing parts

### 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.

>     \set Staff.instrumentName = #"Violin "
>     \set Staff.shortInstrumentName = #"Vln "
>     c4.. g'16 c4.. g'16
>     \break
>     c1

Markup mode can be used to create more complicated instrument names:

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

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 {
>         \set Staff.instrumentName = #"Flute"
>         f2 g4 f
>       }
>       \new Staff {
>         \set Staff.instrumentName = \markup \center-column {
>           Clarinet
>           \line { "in B" \smaller \flat }
>         }
>         c4 b c2
>       }
>     >>

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.

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

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

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.

Instrument names may be changed in the middle of a piece. However, remember that `instrumentName` will not be displayed in the middle of the piece, as it only appears on the first staff:

>     \set Staff.instrumentName = #"First"
>     \set Staff.shortInstrumentName = #"one"
>     c1 c c c \break
>     c1 c c c \break
>     \set Staff.instrumentName = #"Second"
>     \set Staff.shortInstrumentName = #"two"
>     c1 c c c \break
>     c1 c c c \break

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
>     }

#### 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
>       >>
>     }

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
>       >>
>     }

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
>       >>
>     }

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
>       >>
>      }

Quotes can also be tagged, 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" >>
>     }

Quoting another voice

The `quotedEventTypes` property determines the music event types which should be quoted. The default value is `(note-event rest-event tie-event beam-event tuplet-span-event)`, which means that only the notes, rests, ties, beams and tuplets of the quoted voice will appear in the `\quoteDuring` expression. In the following example, a 16th rest is not quoted since `rest-event` is not in `quotedEventTypes`.

For a list of event types, consult the “Music classes” section of the Internals Reference.

>     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. }
>         }
>       >>
>     >>

#### See also

Notation Reference: Instrument transpositions, Using tags.

Snippets: Staff notation.

Internals Reference: Music classes, QuoteMusic, Voice.

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

#### 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`.

#### 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

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

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

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 `CueVoice` context and occurs simultaneously with the `music`, which creates a polyphonic situation. The `direction` takes the argument `UP` or `DOWN`, and corresponds to 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
>       s1*0^\markup { \tiny "flute" }
>       \cueDuring #"flute" #UP { R1 }
>       g2 c,
>     }

>     \addQuote "flute" { \fluteNotes }

>     \new Staff {
>       \oboeNotes
>     }

In the above example, the `Voice` context had to be explicitly declared, or else the entire music expression would belong to the `CueVoice` context.

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.

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

>     \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,
>     }

Markup can be used to show the name of the quoted instrument. Also, if the cue notes require a change in clef, the original clef should be restored 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
>       s1*0^\markup { \tiny "flute" }
>       \cueDuring #"flute" #UP { R1 }
>       \clef bass
>       g4. b8 d2
>     }

>     \addQuote "flute" { \fluteNotes }

>     \new Staff {
>       \bassoonNotes
>     }

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
>         s1*0^\markup { \tiny "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 } }
>       }
>     >>

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

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.

>     piccolo = \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" { \piccolo }

>     <<
>       \new Staff \piccolo
>       \new Staff \bassClarinetNotes
>     >>

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
>         s1*0^\markup { \tiny "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 } }
>       }
>     >>

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, 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.

Jiné jazyky: deutsch, español, français, 日本語.

#### LilyPond — Notation Reference