1 @c -*- coding: utf-8; mode: texinfo; -*-
6 Repetition is a central concept in music, and multiple notations exist
15 @subsection Writing repeats
18 @unnumberedsubsubsec Repeat types
22 The following types of repetition are supported
26 Repeated music is fully written (played) out. This is useful when
27 entering repetitious music. This is the only kind of repeat that
28 is included in MIDI output.
31 Repeats are not written out, but alternative endings (volte) are
32 printed, left to right with brackets. This is the standard notation
33 for repeats with alternatives. These are not played in MIDI output by
38 Make tremolo beams. These are not played in MIDI output by default.
41 Make beat or measure repeats. These look like percent signs. These
42 are not played in MIDI output by default. Percent repeats must be
43 declared within a @code{Voice} context.
48 @anchor{Repeat syntax}
49 @unnumberedsubsubsec Repeat syntax
56 LilyPond has one syntactic construct for specifying different types of
57 repeats. The syntax is
60 \repeat @var{variant} @var{repeatcount} @var{repeatbody}
63 If you have alternative endings, you may add
64 @funindex \alternative
75 where each @var{alternative} is a music expression. If you do not
76 give enough alternatives for all of the repeats, the first alternative
77 is assumed to be played more than once.
79 Standard repeats are used like this
81 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
83 \repeat volta 2 { c4 d e f }
84 \repeat volta 2 { f e d c }
87 With alternative endings
89 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
91 \repeat volta 2 {c4 d e f}
92 \alternative { {d2 d} {f f,} }
95 Repeats with upbeats may be created.
97 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
100 \repeat volta 4 { c2 d2 | e2 f2 | }
101 \alternative { { g4 g g e } { a a a a | b2. } }
108 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
111 \repeat volta 4 { e | c2 d2 | e2 f2 | }
112 \alternative { { \partial 4*3 g4 g g } { a a a a | b2. } }
120 Ties may be added to a second ending,
122 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
124 \repeat volta 2 {c4 d e f ~ }
125 \alternative { {f2 d} {f\repeatTie f,} }
128 It is possible to shorten volta brackets
129 by setting @code{voltaSpannerDuration}. In the next example, the
130 bracket only lasts one measure, which is a duration of 3/4.
132 @lilypond[verbatim,ragged-right,quote]
136 \set Score.voltaSpannerDuration = #(ly:make-moment 3 4)
137 \repeat volta 5 { d d d }
138 \alternative { { e e e f f f }
143 If you want to start a repeat at the beginning of a line and have a
144 double bar at the end of the previous line, use
146 @dots{} \bar "||:" \break
147 \repeat volta 2 @{ @dots{}
149 see @ref{Bar lines} for more information.
153 Program reference: @internalsref{VoltaBracket},
154 @internalsref{RepeatedMusic},
155 @internalsref{VoltaRepeatedMusic}, and
156 @internalsref{UnfoldedRepeatedMusic}.
160 Brackets for the repeat are normally only printed over the topmost
161 staff. This can be adjusted by moving @code{Volta_engraver} to the
162 Staff context where you want the brackets to appear;
163 see @ref{Modifying context plug-ins} and
165 @lsr{repeats,volta@/-multi@/-staff@/.ly}.
170 @cindex repeat, ambiguous
181 is ambiguous, since it is is not clear to which @code{\repeat} the
182 @code{\alternative} belongs. This ambiguity is resolved by always
183 having the @code{\alternative} belong to the inner @code{\repeat}.
184 For clarity, it is advisable to use braces in such situations.
186 Timing information is not remembered at the start of an alternative,
187 so after a repeat timing information must be reset by hand; for
188 example, by setting @code{Score.measurePosition} or entering
189 @code{\partial}. Similarly, slurs or ties are also not repeated.
192 @anchor{Manual repeat commands}
193 @unnumberedsubsubsec Manual repeat commands
195 @funindex repeatCommands
197 The property @code{repeatCommands} can be used to control the layout of
198 repeats. Its value is a Scheme list of repeat commands.
201 @item @code{start-repeat}
202 Print a @code{|:} bar line.
204 @item @code{end-repeat}
205 Print a @code{:|} bar line.
207 @item @code{(volta @var{text})}
208 Print a volta bracket saying @var{text}: The text can be specified as
209 a text string or as a markup text, see @ref{Text markup}. Do not
210 forget to change the font, as the default number font does not contain
211 alphabetic characters;
213 @item @code{(volta #f)}
214 Stop a running volta bracket.
217 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
219 \set Score.repeatCommands = #'((volta "93") end-repeat)
221 \set Score.repeatCommands = #'((volta #f))
228 Program reference: @internalsref{VoltaBracket},
229 @internalsref{RepeatedMusic},
230 @internalsref{VoltaRepeatedMusic}, and
231 @internalsref{UnfoldedRepeatedMusic}.
233 @anchor{Repeats and MIDI}
234 @unnumberedsubsubsec Repeats and MIDI
236 @cindex expanding repeats
237 @funindex \unfoldRepeats
239 With a little bit of tweaking, all types of repeats can be present
240 in the MIDI output. This is achieved by applying the
241 @code{\unfoldRepeats} music function. This function changes all
242 repeats to unfold repeats.
244 @lilypond[quote,verbatim,fragment,line-width=8.0\cm]
246 \repeat tremolo 8 {c'32 e' }
247 \repeat percent 2 { c''8 d'' }
248 \repeat volta 2 {c'4 d' e' f'}
257 When creating a score file using @code{\unfoldRepeats} for MIDI,
258 it is necessary to make two @code{\score} blocks: one for MIDI (with
259 unfolded repeats) and one for notation (with volta, tremolo, and
260 percent repeats). For example,
268 \unfoldRepeats @var{..music..}
275 @subsection Other repeats
277 @anchor{Tremolo repeats}
278 @unnumberedsubsubsec Tremolo repeats
280 @cindex tremolo beams
282 To place tremolo marks between notes, use @code{\repeat} with tremolo
284 @lilypond[quote,verbatim,ragged-right]
285 \new Voice \relative c' {
286 \repeat tremolo 8 { c16 d16 }
287 \repeat tremolo 4 { c16 d16 }
288 \repeat tremolo 2 { c16 d16 }
292 Tremolo marks can also be put on a single note. In this case, the
293 note should not be surrounded by braces.
294 @lilypond[quote,verbatim,ragged-right]
295 \repeat tremolo 4 c'16
298 Similar output is obtained using the tremolo subdivision, described in
299 @ref{Tremolo subdivisions}.
304 In this manual: @ref{Tremolo subdivisions}, @ref{Repeats}.
306 Program reference: @internalsref{Beam}, @internalsref{StemTremolo}.
309 @anchor{Tremolo subdivisions}
310 @unnumberedsubsubsec Tremolo subdivisions
312 @cindex tremolo marks
313 @funindex tremoloFlags
315 Tremolo marks can be printed on a single note by adding
316 @q{@code{:}[@var{number}]} after the note. The number indicates the
317 duration of the subdivision, and it must be at least 8. A
318 @var{length} value of 8 gives one line across the note stem. If the
319 length is omitted, the last value (stored in @code{tremoloFlags}) is
322 @lilypond[quote,ragged-right,verbatim,fragment]
323 c'2:8 c':32 | c': c': |
329 Tremolos entered in this way do not carry over into the MIDI output.
334 In this manual: @ref{Tremolo repeats}.
336 Elsewhere: @internalsref{StemTremolo}.
339 @anchor{Measure repeats}
340 @unnumberedsubsubsec Measure repeats
342 @cindex percent repeats
343 @cindex measure repeats
345 In the @code{percent} style, a note pattern can be repeated. It is
346 printed once, and then the pattern is replaced with a special sign.
347 Patterns of one and two measures are replaced by percent-like signs,
348 patterns that divide the measure length are replaced by slashes.
349 Percent repeats must be declared within a @code{Voice} context.
351 @lilypond[quote,verbatim,ragged-right]
352 \new Voice \relative c' {
353 \repeat percent 4 { c4 }
354 \repeat percent 2 { c2 es2 f4 fis4 g4 c4 }
358 Measure repeats of more than 2 measures get a counter, if you switch
359 on the @code{countPercentRepeats} property,
361 @lilypond[relative=2,fragment,quote,verbatim,ragged-right]
363 \set countPercentRepeats = ##t
364 \repeat percent 4 { c1 }
370 Isolated percents can also be printed. This is done by putting a
371 multi-measure rest with a different print function,
373 @lilypond[fragment,verbatim,quote]
374 \override MultiMeasureRest #'stencil
375 = #ly:multi-measure-rest::percent
384 Program reference: @internalsref{RepeatSlash},
385 @internalsref{PercentRepeat}, @internalsref{DoublePercentRepeat},
386 @internalsref{DoublePercentRepeatCounter},
387 @internalsref{PercentRepeatCounter},
388 @internalsref{PercentRepeatedMusic}.