]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/repeats.itely
Improve headword formatting.
[lilypond.git] / Documentation / user / repeats.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @ignore
3     Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
4
5     When revising a translation, copy the HEAD committish of the
6     version that you are working on.  See TRANSLATION for details.
7 @end ignore
8
9 @node Repeats
10 @section Repeats
11
12 @lilypondfile[quote]{repeats-headword.ly}
13
14 Repetition is a central concept in music, and multiple notations
15 exist for repetitions.
16
17 @menu
18 * Writing repeats::             
19 * Other repeats::               
20 @end menu
21
22 @node Writing repeats
23 @subsection Writing repeats
24
25 This section discusses how to write repeats, including repeated
26 sections of music enclosed within repeat bars, alternate repeat
27 endings, tremolos, and beat or measure repeats.
28
29 @menu
30 * Repeat syntax::               
31 * Normal repeats::              
32 * Manual repeat commands::      
33 @end menu
34
35
36 @node Repeat syntax
37 @subsubsection Repeat syntax
38
39 @cindex repeats
40 @cindex repeat syntax
41 @cindex syntax, repeat
42
43 LilyPond has one syntactic construct for specifying different
44 types of repeats.  The syntax is
45
46 @example
47 \repeat @var{variant} @var{repeatcount} @var{repeatbody}
48 @end example
49
50 where @var{repeabody} is a music expression.
51
52 The following types of repetition are supported
53
54 @cindex repeat volta
55 @cindex volta
56
57 @table @code
58 @item volta
59 The repeated music is not written out but enclosed in repeat bar
60 lines.  If the repeat is at the beginning of a piece, a repeat bar
61 line is only printed at the end. Alternative endings (volte) are
62 printed, left to right with brackets.  This is the standard
63 notation for repeats with alternatives.
64
65 @cindex repetitious music
66
67 @item unfold
68 The repeated music is fully written out, as many times as
69 specified by @var{repeatcount}.  This is useful when
70 entering repetitious music. 
71
72 @cindex tremolo
73 @cindex tremolo beams
74 @cindex beams, tremolo
75
76 @item tremolo
77 Make tremolo beams.
78
79 @cindex beat repeat
80 @cindex measure repeat
81 @cindex percent sign, for repeat
82
83 @item percent
84 Make beat or measure repeats.  These look like percent signs.
85 Percent repeats must be declared within a @code{Voice} context.
86
87 @end table
88
89 Alternative endings are entered with 
90 @funindex \alternative
91 @example
92 \alternative @{
93   @var{alternative1}
94   @var{alternative2}
95   @var{alternative3}
96   @dots{}
97 @}
98 @end example
99
100 @noindent
101 after a @code{\repeat volta} or @code{unfold} block, where each
102 @var{alternative} is a music expression.  If you give
103 less alternatives than @var{repeatcount}, the first alternative
104 is assumed to be played more than once.
105
106
107 @node Normal repeats
108 @subsubsection Normal repeats
109
110 @cindex volta
111 @cindex prima volta
112 @cindex seconda volta
113 @cindex volta, prima
114 @cindex volta, seconda
115 @funindex \repeat
116
117 Normal repeats, with or without alternate repeats:
118
119 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
120 \repeat volta 2 { c4 d e f }
121 \repeat volta 2 { g f e d }
122   \alternative {
123     { cis2 g' }
124     { cis,2 b }
125   }
126 c1
127 @end lilypond
128 Repeats with upbeats:
129
130 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
131 \new Staff {
132   \partial 4 e |
133   \repeat volta 4 { c2 d2 | e2 f2 | }
134   \alternative { { g4 g g e } { a a a a | b2. } }
135 }
136 @end lilypond
137
138 @noindent
139 or
140
141 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
142 \new Staff {
143   \partial 4 
144   \repeat volta 4 { e | c2 d2 | e2 f2 | }
145   \alternative { { \partial 4*3 g4 g g } { a a a a | b2. } }
146 }
147 @end lilypond
148
149
150 @funindex \repeatTie
151
152 Ties may be added to a second ending:
153
154 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
155 c1
156 \repeat volta 2 {c4 d e f ~ }
157 \alternative { {f2 d} {f\repeatTie f,} }
158 @end lilypond
159
160 By default, the volta brackets will be drawn over all of the
161 alternative music, but it is possible to shorten them by
162 setting @code{voltaSpannerDuration}.  In the next example, the
163 bracket only lasts one measure, which is a duration of 3/4.
164
165 @lilypond[verbatim,ragged-right,quote]
166 \relative c''{
167   \time 3/4
168   c c c
169   \set Score.voltaSpannerDuration = #(ly:make-moment 3 4)
170   \repeat volta 5 { d d d }
171   \alternative { { e e e f f f }
172   { g g g } }
173 }
174 @end lilypond
175
176 The @code{Volta_engraver} by default resides in the Score context,
177 and brackets for the repeat are thus normally only printed over
178 the topmost staff.  This can be adjusted by adding
179 @code{Volta_engraver} to the Staff context where you want the
180 brackets to appear; see @ref{Modifying context plug-ins} and
181 @c @lsr{repeats,volta@/-multi@/-staff@/.ly}.
182
183 @lilypond[verbatim,ragged-right,quote]
184 \score { <<
185   \new Staff { \repeat volta 2 { c'1 } \alternative { c' } }
186   \new Staff { \repeat volta 2 { c'1 } \alternative { c' } }
187   \new Staff \with { \consists Volta_engraver } { c'2 g' e' a' }
188   \new Staff { \repeat volta 2 { c'1 } \alternative { c' } }
189  >> }
190 @end lilypond
191
192 @c Is there a way to have a final bar ("|.") at the end of the
193 @c previous line? Doesn't seem to be.
194 If you want to start a repeat at the beginning of a line and have
195 a double bar at the end of the previous line, use
196
197 @example
198 @dots{} \bar "||:" \break 
199 \repeat volta 2 @{ @dots{} 
200 @end example
201
202 see @ref{Bar lines} for more information.
203
204 @seealso
205
206 Snippets: @lsrdir{Repeats,Repeats}
207
208 Internals Reference: @internalsref{VoltaBracket},
209 @internalsref{RepeatedMusic},
210 @internalsref{VoltaRepeatedMusic}, and
211 @internalsref{UnfoldedRepeatedMusic}.
212
213 @c Examples:
214
215
216 @knownissues
217
218 @cindex repeat, ambiguous
219
220 A nested repeat like
221
222 @example
223 \repeat @dots{}
224 \repeat @dots{}
225 \alternative
226 @end example
227
228 @noindent
229 is ambiguous, since it is is not clear to which @code{\repeat} the
230 @code{\alternative} belongs.  This ambiguity is resolved by always
231 having the @code{\alternative} belong to the inner @code{\repeat}.
232 For clarity, it is advisable to use braces in such situations.
233
234 Timing information is not remembered at the start of an
235 alternative, so after a repeat timing information must be reset by
236 hand; for example, by setting @code{Score.measurePosition} or
237 entering @code{\partial}.  Similarly, slurs or ties are also not
238 repeated.
239
240
241
242 @node Manual repeat commands
243 @subsubsection Manual repeat commands
244
245 @funindex repeatCommands
246
247 @c FIXME: Markup does not work in the "text" field
248 @c And how does one change the font?
249 @c On the whole, this section needs better documentation (why the
250 @c double parentheses around the volta expressions?)
251
252 The property @code{repeatCommands} can be used to control the
253 layout of repeats.  Its value is a Scheme list of repeat commands.
254
255 @table @asis
256 @item @code{start-repeat}
257 Print a @code{|:} bar line.
258
259 @item @code{end-repeat}
260 Print a @code{:|} bar line.
261
262 @item @code{(volta @var{text})}
263 Print a volta bracket saying @var{text}.  The text can be
264 specified as a text string or as a markup text, see @ref{Text
265 markup}.  Do not forget to change the font, as the default number
266 font does not contain alphabetic characters;
267
268
269 @item @code{(volta #f)}
270 Stop a running volta bracket.
271 @end table
272
273 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
274 c4
275   \set Score.repeatCommands = #'((volta "93") end-repeat)
276 c4 c4
277   \set Score.repeatCommands = #'((volta #f))
278 c4 c4
279 @end lilypond
280
281 @c FIXME: improve visibility of bar lines link?
282
283 @seealso
284
285 Notation Reference: @ref{Bar lines}.
286
287 Snippets: @lsrdir{Repeats,Repeats}
288
289 Internals Reference: @internalsref{VoltaBracket},
290 @internalsref{RepeatedMusic}, @internalsref{VoltaRepeatedMusic},
291 and @internalsref{UnfoldedRepeatedMusic}.
292
293
294 @node Other repeats
295 @subsection Other repeats
296
297 @menu
298 * Tremolo repeats::             
299 * Measure repeats::             
300 @end menu
301
302 @node Tremolo repeats
303 @subsubsection Tremolo repeats
304
305 @cindex tremolo beams
306
307 To place tremolo marks between notes, use @code{\repeat} with
308 tremolo style:
309
310 @lilypond[quote,verbatim,ragged-right]
311 \new Voice \relative c' {
312   \repeat tremolo 8 { c16 d16 }
313   \repeat tremolo 4 { c16 d16 }
314   \repeat tremolo 2 { c16 d16 }
315 }
316 @end lilypond
317
318 The @code{\repeat tremolo} syntax expects exactly two notes within
319 the braces, and the number of repetitions must correspond to a
320 note value that can be expressed with plain or dotted notes.  Thus,
321 @code{\repeat tremolo 7} is valid and produces a double dotted
322 note, but @code{\repeat tremolo 9} is not.
323
324 The duration of the tremolo equals the duration of the
325 braced expression multiplied by the number of repeats:
326 @code{\repeat tremolo 8 @{ c16 d16 @}} gives a whole note tremolo,
327 notated as two whole notes joined by tremolo beams. 
328
329 There are two ways to put tremolo marks on a single note.  The
330 @code{\repeat tremolo} syntax can be used even here, in which case
331 the note should not be surrounded by braces:
332
333 @lilypond[quote,verbatim,ragged-right]
334 \repeat tremolo 4 c'16
335 @end lilypond
336
337 @cindex tremolo marks
338 @funindex tremoloFlags
339
340 The same output can be obtained by adding
341 @q{@code{:}[@var{number}]} after the note.  The number indicates
342 the duration of the subdivision, and it must be at least 8.  A
343 @var{number} value of 8 gives one line across the note stem.  If
344 the length is omitted, the last value (stored in
345 @code{tremoloFlags}) is used
346
347 @lilypond[quote,ragged-right,verbatim,fragment]
348 c'2:8 c':32 | c': c': |
349 @end lilypond
350
351
352 @knownissues
353
354
355 Tremolos entered with @q{@code{:}[@var{number}]} do not carry over
356 into the MIDI output.
357
358
359 @seealso
360
361 Notation Reference: @ref{Tremolo repeats}.
362
363 Internals Reference: @internalsref{Beam},
364 @internalsref{StemTremolo}.
365
366 Snippets: @lsrdir{Repeats,Repeats}
367
368 Elsewhere: @internalsref{StemTremolo}.
369
370
371 @node Measure repeats
372 @subsubsection Measure repeats
373
374 @cindex percent repeats
375 @cindex measure repeats
376
377 A note pattern can be repeated with the @code{\repeat percent
378 @var{number}} syntax.  The music is printed once, and the pattern
379 is replaced with a special sign.  Patterns of one and two measures
380 are replaced by percent-like signs, patterns that divide the
381 measure length are replaced by slashes.  Percent repeats must be
382 declared within a @code{Voice} context.
383
384 @lilypond[quote,verbatim,ragged-right]
385 \new Voice \relative c' {
386   \repeat percent 4 { c4 }
387   \repeat percent 2 { c2 es2 f4 fis4 g4 c4 }
388 }
389 @end lilypond
390
391 Measure repeats of more than two measures get a counter if you
392 switch on the @code{countPercentRepeats} property:
393
394 @lilypond[relative=2,fragment,quote,verbatim,ragged-right]
395 \new Voice {
396   \set countPercentRepeats = ##t
397   \repeat percent 4 { c1 }
398 }
399 @end lilypond
400
401
402 Isolated percents can also be printed.  This is done by entering a
403 multi-measure rest with a different print function:
404
405 @lilypond[fragment,verbatim,quote]
406 \override MultiMeasureRest #'stencil
407   = #ly:multi-measure-rest::percent
408 R1
409 @end lilypond
410
411
412
413
414 @seealso
415
416 Snippets: @lsrdir{Repeats,Repeats}
417
418 Internals Reference: @internalsref{RepeatSlash},
419 @internalsref{PercentRepeat}, @internalsref{DoublePercentRepeat},
420 @internalsref{DoublePercentRepeatCounter},
421 @internalsref{PercentRepeatCounter},
422 @internalsref{PercentRepeatedMusic}.
423
424
425
426