]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/repeats.itely
Merge branch 'master' into lilypond/translation
[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 @c \version "2.11.38"
10
11 @node Repeats
12 @section Repeats
13
14 @lilypondfile[ragged-right,line-width=16\cm,staffsize=16,quote]
15 {repeats-headword.ly}
16
17 Repetition is a central concept in music, and multiple notations
18 exist for repetitions. LilyPond supports the following kinds of repeats:
19
20
21 @table @code
22 @item volta
23 The repeated music is not written out but enclosed between repeat bar
24 lines.  If the repeat is at the beginning of a piece, a repeat bar
25 line is only printed at the end. Alternative endings (volte) are
26 printed left to right with brackets.  This is the standard notation
27 for repeats with alternatives.
28
29 @item unfold
30 The repeated music is fully written out, as many times as
31 specified by @var{repeatcount}.  This is useful when
32 entering repetitious music. 
33
34 @item percent
35 These are beat or measure repeats.  They look like single slashes or
36 percent signs.
37
38 @item tremolo
39 This is used to write tremolo beams.
40
41 @end table
42
43
44 @menu
45 * Long repeats::                
46 * Short repeats::               
47 @end menu
48
49 @node Long repeats
50 @subsection Long repeats
51
52 This section discusses how to input long (usually multi-measure)
53 repeats.  The repeats can take two forms: repeats enclosed between
54 repeat signs; or written out repeats, used to input repetitious music.
55 Repeat signs can also be controlled manually.
56
57 @menu
58 * Normal repeats::              
59 * Manual repeat marks::         
60 * Written-out repeats::  
61 @end menu
62
63 @cindex volta
64 @cindex prima volta
65 @cindex seconda volta
66 @cindex volta, prima
67 @cindex volta, seconda
68 @funindex \repeat
69
70 @node Normal repeats
71 @subsubsection Normal repeats
72
73 The syntax for a normal repeat is
74
75 @example
76 \repeat volta @var{repeatcount} @var{musicexpr}
77 @end example
78
79 where @var{musicexpr} is a music expression.  Alternate endings can be
80 produced using @code{\alternative}.  If there are more repeats than
81 there are alternate endings, the earliest repeats are given the first
82 alternative.
83
84 Normal repeats without alternate endings:
85
86 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
87 \repeat volta 2 { c4 d e f }
88 c2 d
89 \repeat volta 2 { d4 e f g }
90 @end lilypond
91
92 Normal repeats with alternate endings:
93
94 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
95 \repeat volta 2 { g4 f e d }
96   \alternative {
97     { cis2 g' }
98     { cis,2 b }
99   }
100 \repeat volta 3 { c4 d e f }
101   \alternative {
102     { d2 e }
103     { f2 g }
104   }
105 c1
106 @end lilypond
107
108
109 Repeats with upbeats can be entered in two ways:
110
111 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
112 \new Staff {
113   \partial 4
114   e |
115   \repeat volta 4 { c2 d | e2 f | }
116   \alternative {
117     { g4 g g e }
118     { a4 a a a | b2. }
119   }
120 }
121 @end lilypond
122
123 @noindent
124 or
125
126 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
127 \new Staff {
128   \partial 4 
129   \repeat volta 4 { e4 | c2 d | e2 f | }
130   \alternative {
131     { \partial 4*3 g4 g g }
132     { a4 a a a | b2. }
133   }
134 }
135 @end lilypond
136
137
138 @funindex \repeatTie
139
140 Ties may be added to a second ending:
141
142 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
143 c1
144 \repeat volta 2 {c4 d e f ~ }
145 \alternative {
146   {f2 d}
147   {f2\repeatTie f,}
148 }
149 @end lilypond
150
151 @snippets
152
153 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
154 {shortening-volta-brackets.ly}
155
156 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
157 {adding-volta-brackets-to-additional-staves.ly}
158
159
160 @c Is there a way to have a final bar ("|.") at the end of the
161 @c previous line? Doesn't seem to be.
162 If you want to start a repeat at the beginning of a line and have a
163 double bar at the end of the previous line, use @code{\bar}. For more
164 information, see @ref{Bar lines}.
165
166 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
167 c4 c c c
168 \bar "||:" \break 
169 \repeat volta 2 { c4 d e f }   
170 @end lilypond
171
172
173 @seealso
174
175 Music Glossary: @rglos{repeat}, @rglos{volta}.
176
177 Notation Reference: @ref{Bar lines}, @ref{Modifying context plug-ins}.
178
179 Snippets: @rlsr{Repeats}.
180
181 Internals Reference: @rinternals{VoltaBracket},
182 @rinternals{RepeatedMusic}, @rinternals{VoltaRepeatedMusic},
183 @rinternals{UnfoldedRepeatedMusic}.
184
185 @knownissues
186
187 @cindex repeat, ambiguous
188
189 A nested repeat like
190
191 @example
192 \repeat @dots{}
193 \repeat @dots{}
194 \alternative
195 @end example
196
197 @noindent
198 is ambiguous, since it is is not clear to which @code{\repeat} the
199 @code{\alternative} belongs.  This ambiguity is resolved by always
200 having the @code{\alternative} belong to the inner @code{\repeat}.
201 For clarity, it is advisable to use braces in such situations.
202
203 Timing information is not remembered at the start of an alternative,
204 so after a repeat timing information must be reset by hand; for
205 example, by setting @code{Score.measurePosition} or entering
206 @code{\partial}.  Similarly, slurs are also not repeated.
207
208
209
210 @node Manual repeat marks
211 @subsubsection Manual repeat marks
212
213 @funindex repeatCommands
214
215 In some cases, manual repeat marks can be created by simply
216 printing the relevant bar lines.  For more information, see
217 @ref{Bar lines}.
218
219 The property @code{repeatCommands} can be used to control the
220 layout of repeats.  Its value is a Scheme list of repeat commands.
221
222 @table @asis
223 @item @code{start-repeat}
224 Print a @code{|:} bar line:
225
226 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
227 c1
228 \set Score.repeatCommands = #'( start-repeat )
229 d4 e f g
230 c1
231 @end lilypond
232
233 In order to print a @code{|:} bar line at the beginning, a skip must
234 be used:
235
236 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
237 % FIXME: I can't believe this is right.
238 s1*1/10
239 \set Score.repeatCommands = #'( start-repeat )
240 c1*1/10
241 d4 e f g
242 c1
243 @end lilypond
244
245 @item @code{end-repeat}
246 Print a @code{:|} bar line:
247
248 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
249 c1
250 d4 e f g
251 \set Score.repeatCommands = #'( end-repeat )
252 c1
253 @end lilypond
254
255 @item @code{(volta #f)}
256 Stop a running volta bracket.
257
258 FIXME: example?
259
260 @item @code{(volta @var{text})}
261 Print a volta bracket saying @var{text}.
262
263 FIXME: simple example?
264
265 @end table
266
267 The text can be a number or numbers or markup text, see
268 @ref{Formatting text}.  The simplest way to use markup text is to
269 define the markup first, then include the the markup in a Scheme
270 list. When manually creating a volta bracket, the bracket must be
271 explicitly terminated or an error will be generated.
272
273 Manual control of the volte, including a @code{|:} bar line at the
274 beginning and explicit volta numbers:
275
276 @lilypond[verbatim,quote,relative=2]
277 % FIXME: I can't believe this is right.
278 s1*1/10
279 \set Score.repeatCommands = #'( start-repeat )
280 c1*9/10
281 d4 e f g
282 \set Score.repeatCommands = #'( ( volta "1, 2, 5" ) )
283 f4 g a b
284 \set Score.repeatCommands = #'( ( volta #f ) ( volta "95" ) end-repeat )
285 g4 a g a
286 \set Score.repeatCommands = #'( ( volta #f ) )
287 c1
288 @end lilypond
289
290 Manual control of the volte, including markup text:
291
292 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
293 c1
294 \set Score.repeatCommands = #'( start-repeat )
295 d1
296 d4 e f g
297 % FIXME: broken
298 %\set Score.repeatCommands = #(list (list 'volta voltaChorus ) )
299 f4 g a b
300 \set Score.repeatCommands = #'( ( volta #f ) ( volta "4" ) end-repeat )
301 g4 a g a
302 \set Score.repeatCommands = #'( ( volta #f ) )
303 c1
304 @end lilypond 
305
306 @seealso
307
308 Notation Reference:
309 @ref{Bar lines},
310 @ref{Formatting text}.
311
312 Snippets:
313 @rlsr{Repeats}.
314
315 Internals Reference:
316 @rinternals{VoltaBracket},
317 @rinternals{RepeatedMusic},
318 @rinternals{VoltaRepeatedMusic}.
319
320
321 @node Written-out repeats
322 @subsubsection Written-out repeats
323
324 @cindex written-out repeats
325 @cindex repetitious music
326 @cindex repeats, written-out
327
328 By using the @code{unfold} command, repeats can be used to simplify
329 the writing out of repetitious music.  The syntax is
330
331 @example
332 \repeat unfold @var{repeatcount} @var{musicexpr}
333 @end example
334
335 where @var{musicexpr} is a music expression.  Unfold repeats can be
336 made with or without alternate endings.  If there are more repeats
337 than there are alternate endings, the first alternative ending is
338 applied to the earliest endings.  Unfold repeats without alternate
339 endings:
340
341 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
342 c1
343 \repeat unfold 2 { c4 d e f }
344 c1
345 @end lilypond
346
347 Unfold repeats with alternate endings:
348
349 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
350 c1
351 \repeat unfold 2 { g4 f e d }
352   \alternative {
353     { cis2 g' }
354     { cis,2 b }
355   }
356 c1
357 \repeat unfold 3 { d4 c b2 }
358   \alternative {
359     { c4 d e f }
360     { d4 c b a }
361   }
362 c1
363 @end lilypond
364
365 @seealso
366
367 Snippets: @rlsr{Repeats}.
368
369 Internals Reference: @rinternals{RepeatedMusic},
370 @rinternals{UnfoldedRepeatedMusic}.
371
372 @node Short repeats
373 @subsection Short repeats
374
375 This section discusses how to input short repeats.  Short repeats can
376 take two basic forms: repeats of a single note to two measures,
377 represented by slashes or percent signs; and tremolos.
378
379 @menu
380 * Percent repeats::             
381 * Tremolo repeats::             
382 @end menu
383
384 @node Percent repeats
385 @subsubsection Percent repeats
386
387 @cindex percent repeats
388 @cindex measure repeats
389
390 Repeated short patterns of notes are supported.  The music is printed
391 once, and the pattern is replaced with a special sign.  Patterns that
392 are shorter than one measure are replaced by slashes, and patterns of
393 one or two measures are replaced by percent-like signs.  The syntax is
394
395 @example
396 @code{\repeat percent @var{number} @var{musicexpr}}
397 @end example
398
399 where @var{musicexpr} is a music expression. 
400
401 @lilypond[quote,verbatim,ragged-right]
402 \relative c' {
403   \repeat percent 4 { c4 }
404   \repeat percent 2 { b'4 a g f }
405   \repeat percent 2 { c2 es | f4 fis g c | }
406 }
407 @end lilypond
408
409 Measure repeats of more than two repeats get a counter if you switch
410 on the @code{countPercentRepeats} property:
411
412 @lilypond[relative=2,fragment,quote,verbatim,ragged-right]
413 \relative c' {
414   \set countPercentRepeats = ##t
415   \repeat percent 4 { c1 }
416 }
417 @end lilypond
418
419
420 Isolated percents can also be printed.  This is done by entering a
421 multi-measure rest with a different print function:
422
423 @lilypond[fragment,verbatim,quote]
424 \override MultiMeasureRest #'stencil
425   = #ly:multi-measure-rest::percent
426 R1
427 @end lilypond
428
429
430 @knownissues
431
432 Only three kinds of percent repeats are supported: a single slash
433 representing a single beat (regardless of the duration of the repeated
434 notes); a single slash with dots representing one full measure; and
435 two slashes with dots crossing a bar line representing two full
436 measures.  Neither multiple slashes representing single beat repeats
437 consisting of sixteenth or shorter notes, nor two slashes with dots
438 representing single beat repeats consisting of notes of varying
439 durations, are supported.
440
441
442 @seealso
443
444 Music Glossary: @rglos{percent repeat}, @rglos{simile}.
445
446 Snippets: @rlsr{Repeats}.
447
448 Internals Reference: @rinternals{RepeatSlash},
449 @rinternals{PercentRepeat}, @rinternals{DoublePercentRepeat},
450 @rinternals{DoublePercentRepeatCounter},
451 @rinternals{PercentRepeatCounter}, @rinternals{PercentRepeatedMusic}.
452
453 @node Tremolo repeats
454 @subsubsection Tremolo repeats
455
456 Tremolos can take two forms: alternation between two chords or two
457 notes, and rapid repetition of a single
458 note or chord. Tremolos consisting of an alternation are indicated by
459 adding beams between the notes or chords being alternated, while
460 tremolos consisting of the rapid repetition of a single note are
461 indicated by adding beams or slashes to a single note.
462
463 @cindex tremolo beams
464
465 To place tremolo marks between notes, use @code{\repeat} with
466 tremolo style:
467
468 @lilypond[quote,verbatim,ragged-right]
469 \relative c' {
470   \repeat tremolo 8 { c16 d }
471   \repeat tremolo 4 { c16 d }
472   \repeat tremolo 2 { c16 d }
473 }
474 @end lilypond
475
476 The @code{\repeat tremolo} syntax expects exactly two notes within
477 the braces, and the number of repetitions must correspond to a
478 note value that can be expressed with plain or dotted notes.  Thus,
479 @code{\repeat tremolo 7} is valid and produces a double dotted
480 note, but @code{\repeat tremolo 9} is not.
481
482 The duration of the tremolo equals the duration of the
483 braced expression multiplied by the number of repeats:
484 @code{\repeat tremolo 8 @{ c16 d16 @}} gives a whole note tremolo,
485 notated as two whole notes joined by tremolo beams. 
486
487 There are two ways to put tremolo marks on a single note.  The
488 @code{\repeat tremolo} syntax is also used here, in which case
489 the note should not be surrounded by braces:
490
491 @lilypond[quote,verbatim,ragged-right]
492 \repeat tremolo 4 c'16
493 @end lilypond
494
495 @cindex tremolo marks
496 @funindex tremoloFlags
497
498 The same output can be obtained by adding
499 @q{@code{:}[@var{number}]} after the note.  The number indicates
500 the duration of the subdivision, and it must be at least 8.  A
501 @var{number} value of 8 gives one line across the note stem.  If
502 the length is omitted, the last value (stored in
503 @code{tremoloFlags}) is used
504
505 @lilypond[quote,ragged-right,verbatim,fragment]
506 c'2:8 c':32 | c': c': |
507 @end lilypond
508
509
510 @knownissues
511
512
513 Tremolos entered with @q{@code{:}[@var{number}]} do not carry over
514 into the MIDI output.
515
516
517 @seealso
518
519 Snippets: @rlsr{Repeats}.
520