GNU LilyPond Notation Reference: 1.4.1 Long repeats

### 1.4.1 Long repeats

This section discusses how to input long (usually multi-measure) repeats. The repeats can take two forms: repeats enclosed between repeat signs; or written out repeats, used to input repetitious music. Repeat signs can also be controlled manually.

#### Normal repeats

The syntax for a normal repeat is

>     \repeat volta repeatcount musicexpr

where musicexpr is a music expression. Alternate endings can be produced using `\alternative`. In order to delimit the alternate endings, the group of alternatives must be enclosed in a set of braces. If there are more repeats than there are alternate endings, the earliest repeats are given the first alternative.

Normal repeats without alternate endings:

>     \repeat volta 2 { c4 d e f }
>     c2 d
>     \repeat volta 2 { d4 e f g }

Normal repeats with alternate endings:

>     \repeat volta 4 { c4 d e f }
>     \alternative {
>       { d2 e }
>       { f2 g }
>     }
>     c1

Repeats with upbeats can be entered in two ways:

>     \partial 4
>     e |
>     \repeat volta 4 { c2 d | e2 f | }
>     \alternative {
>       { g4 g g e }
>       { a4 a a a | b2. }
>     }

or

>     \partial 4
>     \repeat volta 4 { e4 | c2 d | e2 f | }
>     \alternative {
>       { \partial 4*3 g4 g g }
>       { a4 a a a | b2. }
>     }

Ties may be added to a second ending:

>     c1
>     \repeat volta 2 { c4 d e f ~ }
>     \alternative {
>       { f2 d }
>       { f2\repeatTie f, }
>     }

#### Selected Snippets

Shortening volta brackets

By default, the volta brackets will be drawn over all of the alternative music, but it is possible to shorten them by setting `voltaSpannerDuration`. In the next example, the bracket only lasts one measure, which is a duration of 3/4.

>     \relative c'' {
>       \time 3/4
>       c4 c c
>       \set Score.voltaSpannerDuration = #(ly:make-moment 3 4)
>       \repeat volta 5 { d4 d d }
>       \alternative {
>         {
>           e4 e e
>           f4 f f
>         }
>         { g4 g g }
>       }
>     }

Adding volta brackets to additional staves

The `Volta_engraver` by default resides in the `Score` context, and brackets for the repeat are thus normally only printed over the topmost staff. This can be adjusted by adding the `Volta_engraver` to the `Staff` context where the brackets should appear; see also the "Volta multi staff" snippet.

>     <<
>       \new Staff { \repeat volta 2 { c'1 } \alternative { c' } }
>       \new Staff { \repeat volta 2 { c'1 } \alternative { c' } }
>       \new Staff \with { \consists "Volta_engraver" } { c'2 g' e' a' }
>       \new Staff { \repeat volta 2 { c'1 } \alternative { c' } }
>     >>

#### See also

Music Glossary: repeat, volta.

Notation Reference: Bar lines, Modifying context plug-ins.

Snippets: Repeats.

Internals Reference: VoltaBracket, RepeatedMusic, VoltaRepeatedMusic, UnfoldedRepeatedMusic.

#### Known issues and warnings

A nested repeat like

>     \repeat …
>     \repeat …
>     \alternative

is ambiguous, since it is is not clear to which `\repeat` the `\alternative` belongs. This ambiguity is resolved by always having the `\alternative` belong to the inner `\repeat`. For clarity, it is advisable to use braces in such situations.

Timing information is not remembered at the start of an alternative, so after a repeat timing information must be reset by hand; for example, by setting `Score.measurePosition` or entering `\partial`. Similarly, slurs are also not repeated.

#### Manual repeat marks

Note: These methods are only used for displaying unusual repeat constructs, and may produce unexpected behavior. In most cases, repeats should be created using the standard `\repeat` command or by printing the relevant bar lines. For more information, see Bar lines.

The property `repeatCommands` can be used to control the layout of repeats. Its value is a Scheme list of repeat commands.

`start-repeat`

  Print a `|:` bar line.

  >     c1
  >     \set Score.repeatCommands = #'(start-repeat)
  >     d4 e f g
  >     c1

  As per standard engraving practice, repeat signs are not printed at the beginning of a piece.

`end-repeat`

  Print a `:|` bar line:

  >     c1
  >     d4 e f g
  >     \set Score.repeatCommands = #'(end-repeat)
  >     c1

`(volta number) ... (volta #f)`

  Create a new volta with the specified number. The volta bracket must be explicitly terminated, or it will not be printed.

  >     f4 g a b
  >     \set Score.repeatCommands = #'((volta "2"))
  >     g4 a g a
  >     \set Score.repeatCommands = #'((volta #f))
  >     c1

Multiple repeat commands may occur at the same point:

>     f4 g a b
>     \set Score.repeatCommands = #'((volta "2, 5") end-repeat)
>     g4 a g a
>     c1
>     \set Score.repeatCommands = #'((volta #f) (volta "95") end-repeat)
>     b1
>     \set Score.repeatCommands = #'((volta #f))

Text can be included with the volta bracket. The text can be a number or numbers or markup text, see Formatting text. The simplest way to use markup text is to define the markup first, then include the markup in a Scheme list.

>     voltaAdLib = \markup { 1. 2. 3... \text \italic { ad lib. } }
>     \relative c'' {
>       c1
>       \set Score.repeatCommands = #(list(list 'volta voltaAdLib) 'start-repeat)
>       c4 b d e
>       \set Score.repeatCommands = #'((volta #f) (volta "4.") end-repeat)
>       f1
>       \set Score.repeatCommands = #'((volta #f))
>     }

#### Selected Snippets

Printing a repeat sign at the beginning of a piece

A `|:` bar line can be printed at the beginning of a piece, by overriding the relevant property:

>     \relative c'' {
>       \once \override Score.BreakAlignment #'break-align-orders =
>             #(make-vector 3 '(instrument-name
>                               left-edge
>                               ambitus
>                               span-bar
>                               breathing-sign
>                               clef
>                               key-signature
>                               time-signature
>                               staff-bar
>                               custos
>                               span-bar))
>       \bar "|:"
>       c1
>       d1
>       d4 e f g
>     }

#### See also

Notation Reference: Bar lines, Formatting text.

Snippets: Repeats.

Internals Reference: VoltaBracket, RepeatedMusic, VoltaRepeatedMusic.

#### Written-out repeats

By using the `unfold` command, repeats can be used to simplify the writing out of repetitious music. The syntax is

>     \repeat unfold repeatcount musicexpr

where musicexpr is a music expression and repeatcount is the number of times musicexpr is repeated.

>     c1
>     \repeat unfold 2 { c4 d e f }
>     c1

Unfold repeats can be made with alternate endings. If there are more repeats than there are alternate endings, the first alternative ending is applied to the earliest endings.

>     c1
>     \repeat unfold 2 { g4 f e d }
>       \alternative {
>         { cis2 g' }
>         { cis,2 b }
>       }
>     c1

#### See also

Snippets: Repeats.

Internals Reference: RepeatedMusic, UnfoldedRepeatedMusic.

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

#### Notation Reference