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

#### Metronome marks

A basic metronome mark is simple to write:

>     \tempo 4 = 120
>     c2 d
>     e4. d8 c2

Tempo indications with text can be used instead:

>     \tempo "Allegretto"
>     c4 e d c
>     b4. a16 b c4 r4

Combining a metronome mark and text will automatically place the metronome mark within parentheses:

>     \tempo "Allegro" 4 = 160
>     g4 c d e
>     d4 b g2

In general, the text can be any markup object:

>     \tempo \markup { \italic Faster } 4 = 132
>     a8-. r8 b-. r gis-. r a-. r

A parenthesized metronome mark with no textual indication may be written by including an empty string in the input:

>     \tempo "" 8 = 96
>     d4 g e c

#### Selected Snippets

Printing metronome and rehearsal marks below the staff

By default, metronome and rehearsal marks are printed above the staff. To place them below the staff simply set the `direction` property of `MetronomeMark` or `RehearsalMark` appropriately.

>     \layout { ragged-right = ##f }

>     {
>       % Metronome marks below the staff
>       \override Score.MetronomeMark #'direction = #DOWN
>       \tempo 8. = 120
>       c''1

>       % Rehearsal marks below the staff
>       \override Score.RehearsalMark #'direction = #DOWN
>       \mark \default
>       c''1
>     }

Changing the tempo without a metronome mark

To change the tempo in MIDI output without printing anything, make the metronome mark invisible.

>     \score {
>       \new Staff \relative c' {
>         \tempo 4 = 160
>         c4 e g b
>         c4 b d c
>         \set Score.tempoHideNote = ##t
>         \tempo 4 = 96
>         d,4 fis a cis
>         d4 cis e d
>       }
>       \layout { }
>       \midi { }
>     }

Creating metronome marks in markup mode

New metronome marks can be created in markup mode, but they will not change the tempo in MIDI output.

>     \relative c' {
>       \tempo \markup {
>         \concat {
>           (
>           \smaller \general-align #Y #DOWN \note #"16." #1
>           " = "
>           \smaller \general-align #Y #DOWN \note #"8" #1
>           )
>         }
>       }
>       c1
>       c4 c' c,2
>     }

For more details, see Formatting text.

#### See also

Music Glossary: metronome, metronomic indication, tempo indication, metronome mark.

Notation Reference: Formatting text, MIDI output.

Snippets: Staff notation.

Internals Reference: MetronomeMark.

#### Instrument names

Instrument names can be printed on the left side of staves in the `Staff` and `PianoStaff` 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 Horizontal dimensions.

>     \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 `GrandStaff`, `ChoirStaff`, or `StaffGroup`), `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:

>     \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: Horizontal dimensions, Modifying context plug-ins.

Snippets: Staff notation.

Internals Reference: InstrumentName, PianoStaff, Staff.

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

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

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

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

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

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

#### Formatting cue notes

The previous section explains how to create quotations. The `\cueDuring` command is a more specialized form of `\quoteDuring`, being particularly useful for inserting cue notes into a part. The syntax is as follows:

>     \cueDuring #partname #voice music

This command copies the corresponding measures from partname into a `CueVoice` context. The `CueVoice` is created implicitly, and occurs simultaneously with music, which creates a polyphonic situation. The voice argument determines whether the cue notes should be notated as a first or second voice; `UP` corresponds to the first voice, and `DOWN` corresponds to the second.

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

>     \new Voice \relative c'' {
>       \cueDuring #"oboe" #UP { R1 }
>       g2 c,
>     }

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

The name of the cued instrument can be printed by setting the `instrumentCueName` property in the `CueVoice` context.

>     oboe = \relative c''' {
>       g4 r8 e16 f e4 d
>     }
>     \addQuote "oboe" { \oboe }

>     \new Staff \relative c'' <<
>       \new CueVoice \with {
>         instrumentCueName = "ob."
>       }
>       \new Voice {
>         \cueDuring #"oboe" #UP { R1 }
>         g4. b8 d2
>       }
>     >>

In addition to printing the name of the cued instrument, when cue notes end, the name of the original instrument should be printed, and any other changes introduced by the cued part should be undone. This can be accomplished by using `\addInstrumentDefinition` and `\instrumentSwitch`. For an example and explanation, see Instrument names.

The `\killCues` command removes cue notes from a music expression. This can be useful if cue notes need to be removed from a part but may be restored at a later time.

>     flute = \relative c''' {
>       r2 cis2 r2 dis2
>     }
>     \addQuote "flute" { \flute }

>     \new Voice \relative c'' {
>       \killCues {
>         \cueDuring #"flute" #UP { R1 }
>         g4. b8 d2
>       }
>     }

The `\transposedCueDuring` command is useful for adding instrumental cues from a completely different register. The syntax is similar to `\cueDuring`, but it requires one extra argument to specify the transposition of the cued instrument. For more information about transposition, see Instrument transpositions.

>     piccolo = \relative c''' {
>       \clef "treble^8"
>       R1
>       c8 c c e g2
>       a4 g g2
>     }
>     \addQuote "piccolo" { \piccolo }

>     cbassoon = \relative c, {
>       \clef "bass_8"
>       c4 r g r
>       \transposedCueDuring #"piccolo" #UP c,, { R1 }
>       c4 r g r
>     }

>     <<
>       \new Staff = "piccolo" \piccolo
>       \new Staff = "cbassoon" \cbassoon
>     >>

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

#### See also

Notation Reference: Instrument transpositions, Instrument names, 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.

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

#### Notation Reference