]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/repeats.itely
Merge branch 'master' into dev/texi2html
[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.51"
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,texidoc,doctitle]
154 {shortening-volta-brackets.ly}
155
156 @lilypondfile[verbatim,lilyquote,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 @c It could be done by overriding
163 @c the BreakAlignment property. Want a separate example?
164 If you want to start a repeat at the beginning of a line and have a
165 double bar at the end of the previous line, use @code{\bar}. For more
166 information, see @ref{Bar lines}.
167
168 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
169 c4 c c c
170 \bar "||:" \break 
171 \repeat volta 2 { c4 d e f }   
172 @end lilypond
173
174
175 @seealso
176
177 Music Glossary: @rglos{repeat}, @rglos{volta}.
178
179 Notation Reference: @ref{Bar lines}, @ref{Modifying context plug-ins}.
180
181 Snippets: @rlsr{Repeats}.
182
183 Internals Reference: @rinternals{VoltaBracket},
184 @rinternals{RepeatedMusic}, @rinternals{VoltaRepeatedMusic},
185 @rinternals{UnfoldedRepeatedMusic}.
186
187 @knownissues
188
189 @cindex repeat, ambiguous
190
191 A nested repeat like
192
193 @example
194 \repeat @dots{}
195 \repeat @dots{}
196 \alternative
197 @end example
198
199 @noindent
200 is ambiguous, since it is is not clear to which @code{\repeat} the
201 @code{\alternative} belongs.  This ambiguity is resolved by always
202 having the @code{\alternative} belong to the inner @code{\repeat}.
203 For clarity, it is advisable to use braces in such situations.
204
205 Timing information is not remembered at the start of an alternative,
206 so after a repeat timing information must be reset by hand; for
207 example, by setting @code{Score.measurePosition} or entering
208 @code{\partial}.  Similarly, slurs are also not repeated.
209
210
211
212 @node Manual repeat marks
213 @subsubsection Manual repeat marks
214
215 @funindex repeatCommands
216
217 @warning{These methods are only used for displaying unusual repeat
218 constructs.  In most cases, repeats should be created using the
219 standard @code{\\repeat} command or by printing the relevant bar
220 lines.  For more information, see @ref{Bar lines}.}
221
222 The property @code{repeatCommands} can be used to control the
223 layout of repeats.  Its value is a Scheme list of repeat commands.
224
225 @table @code
226 @item start-repeat
227 Print a @code{|:} bar line.
228
229 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
230 c1
231 \set Score.repeatCommands = #'( start-repeat )
232 d4 e f g
233 c1
234 @end lilypond
235
236 As per standard engraving practice, repeat signs are not printed
237 at the beginning of a piece.
238
239 @item end-repeat
240 Print a @code{:|} bar line:
241
242 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
243 c1
244 d4 e f g
245 \set Score.repeatCommands = #'( end-repeat )
246 c1
247 @end lilypond
248
249 @item (volta @var{number})
250 Create a new volta with the specified number:
251
252 @lilypond[verbatim,quote,relative=2]
253 f4 g a b
254 \set Score.repeatCommands = #'( ( volta "2" ) )
255 g4 a g a
256 c1
257 @end lilypond
258
259 @item (volta #f)
260 Stops a running volta bracket:
261
262 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
263 c1
264 \set Score.repeatCommands = #'( ( volta "2" ) )
265 f4 g a b
266 \set Score.repeatCommands = #'( ( volta #f ) )
267 a4 g f e
268 c1
269 @end lilypond
270
271 @end table
272
273 Multiple repeat commands may occur at the same point:
274
275 @lilypond[verbatim,quote,relative=2]
276 f4 g a b
277 \set Score.repeatCommands = #'( ( volta "2, 5" ) end-repeat )
278 g4 a g a
279 c1
280 \set Score.repeatCommands = #'( ( volta #f ) ( volta "95" ) end-repeat )
281 b1
282 @end lilypond
283
284 Text can be included with the volta bracket.  The text can be a
285 number or numbers or markup text, see @ref{Formatting text}.  The
286 simplest way to use markup text is to define the markup first,
287 then include the the markup in a Scheme list.
288
289 @lilypond[verbatim,quote]
290 voltaAdLib = \markup { 1. 2. 3... \text \italic { ad lib. } }
291 \relative c'' {
292   c1
293   \set Score.repeatCommands = #(list (list 'volta voltaAdLib) 'start-repeat)
294   c4 b d e
295   \set Score.repeatCommands = #'((volta #f) (volta "4.") end-repeat)
296   f1
297   \set Score.repeatCommands = #'((volta #f))
298 }
299 @end lilypond
300
301
302 @snippets
303
304 @c FIXME: send these to Neil or Valentin to be added as snippets,
305 @c delete them.
306 Manual control of the volte, including a @code{|:} bar line at the
307 beginning and explicit volta numbers:
308
309 @c FIXME: I can't believe this is right.  
310 @c TODO: I think it is. I plan
311 @c to delete this example, since it's
312 @c already been given at L238. rp
313 @lilypond[verbatim,quote,relative=2]
314 s1*1/10
315 \set Score.repeatCommands = #'( start-repeat )
316 c1*9/10
317 d4 e f g
318 \set Score.repeatCommands = #'( ( volta "1, 2, 5" ) )
319 f4 g a b
320 \set Score.repeatCommands = #'( ( volta #f ) ( volta "95" ) end-repeat )
321 g4 a g a
322 \set Score.repeatCommands = #'( ( volta #f ) )
323 c1
324 @end lilypond
325
326 In order to print a @code{|:} bar line at the beginning of a piece,
327 the @code{BreakAlignment} property must be overridden:
328
329 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
330 \once \override Score.BreakAlignment #'break-align-orders =
331 #(make-vector 3 '(
332 instrument-name
333 left-edge
334 ambitus
335 span-bar
336 breathing-sign
337 clef
338 key-signature
339 time-signature
340 staff-bar
341 custos
342 span-bar
343 ))
344 \bar "|:"
345 c1
346 d1
347 d4 e f g
348 @end lilypond
349
350
351 @seealso
352
353 Notation Reference:
354 @ref{Bar lines},
355 @ref{Formatting text}.
356
357 Snippets:
358 @rlsr{Repeats}.
359
360 Internals Reference:
361 @rinternals{VoltaBracket},
362 @rinternals{RepeatedMusic},
363 @rinternals{VoltaRepeatedMusic}.
364
365
366 @node Written-out repeats
367 @subsubsection Written-out repeats
368
369 @cindex written-out repeats
370 @cindex repetitious music
371 @cindex repeats, written-out
372
373 By using the @code{unfold} command, repeats can be used to simplify
374 the writing out of repetitious music.  The syntax is
375
376 @example
377 \repeat unfold @var{repeatcount} @var{musicexpr}
378 @end example
379
380 where @var{musicexpr} is a music expression.  Unfold repeats can be
381 made with or without alternate endings.  If there are more repeats
382 than there are alternate endings, the first alternative ending is
383 applied to the earliest endings.  Unfold repeats without alternate
384 endings:
385
386 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
387 c1
388 \repeat unfold 2 { c4 d e f }
389 c1
390 @end lilypond
391
392 Unfold repeats with alternate endings:
393
394 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
395 c1
396 \repeat unfold 2 { g4 f e d }
397   \alternative {
398     { cis2 g' }
399     { cis,2 b }
400   }
401 c1
402 \repeat unfold 3 { d4 c b2 }
403   \alternative {
404     { c4 d e f }
405     { d4 c b a }
406   }
407 c1
408 @end lilypond
409
410 @seealso
411
412 Snippets: @rlsr{Repeats}.
413
414 Internals Reference: @rinternals{RepeatedMusic},
415 @rinternals{UnfoldedRepeatedMusic}.
416
417 @node Short repeats
418 @subsection Short repeats
419
420 This section discusses how to input short repeats.  Short repeats can
421 take two basic forms: repeats of a single note to two measures,
422 represented by slashes or percent signs; and tremolos.
423
424 @menu
425 * Percent repeats::             
426 * Tremolo repeats::             
427 @end menu
428
429 @node Percent repeats
430 @subsubsection Percent repeats
431
432 @cindex percent repeats
433 @cindex measure repeats
434
435 Repeated short patterns of notes are supported.  The music is printed
436 once, and the pattern is replaced with a special sign.  Patterns that
437 are shorter than one measure are replaced by slashes, and patterns of
438 one or two measures are replaced by percent-like signs.  The syntax is
439
440 @example
441 @code{\repeat percent @var{number} @var{musicexpr}}
442 @end example
443
444 where @var{musicexpr} is a music expression. 
445
446 @lilypond[quote,verbatim,ragged-right]
447 \relative c' {
448   \repeat percent 4 { c4 }
449   \repeat percent 2 { b'4 a g f }
450   \repeat percent 2 { c2 es | f4 fis g c | }
451 }
452 @end lilypond
453
454 Measure repeats of more than two repeats get a counter if you switch
455 on the @code{countPercentRepeats} property:
456
457 @lilypond[relative=2,fragment,quote,verbatim,ragged-right]
458 \relative c' {
459   \set countPercentRepeats = ##t
460   \repeat percent 4 { c1 }
461 }
462 @end lilypond
463
464
465 Isolated percents can also be printed.  This is done by entering a
466 multi-measure rest with a different print function:
467
468 @lilypond[fragment,verbatim,quote]
469 \override MultiMeasureRest #'stencil
470   = #ly:multi-measure-rest::percent
471 R1
472 @end lilypond
473
474
475 @knownissues
476
477 Only three kinds of percent repeats are supported: a single slash
478 representing a single beat (regardless of the duration of the repeated
479 notes); a single slash with dots representing one full measure; and
480 two slashes with dots crossing a bar line representing two full
481 measures.  Neither multiple slashes representing single beat repeats
482 consisting of sixteenth or shorter notes, nor two slashes with dots
483 representing single beat repeats consisting of notes of varying
484 durations, are supported.
485
486
487 @seealso
488
489 Music Glossary: @rglos{percent repeat}, @rglos{simile}.
490
491 Snippets: @rlsr{Repeats}.
492
493 Internals Reference: @rinternals{RepeatSlash},
494 @rinternals{PercentRepeat}, @rinternals{DoublePercentRepeat},
495 @rinternals{DoublePercentRepeatCounter},
496 @rinternals{PercentRepeatCounter}, @rinternals{PercentRepeatedMusic}.
497
498 @node Tremolo repeats
499 @subsubsection Tremolo repeats
500
501 Tremolos can take two forms: alternation between two chords or two
502 notes, and rapid repetition of a single
503 note or chord. Tremolos consisting of an alternation are indicated by
504 adding beams between the notes or chords being alternated, while
505 tremolos consisting of the rapid repetition of a single note are
506 indicated by adding beams or slashes to a single note.
507
508 @cindex tremolo beams
509
510 To place tremolo marks between notes, use @code{\repeat} with
511 tremolo style:
512
513 @lilypond[quote,verbatim,ragged-right]
514 \relative c' {
515   \repeat tremolo 8 { c16 d }
516   \repeat tremolo 4 { c16 d }
517   \repeat tremolo 2 { c16 d }
518 }
519 @end lilypond
520
521 The @code{\repeat tremolo} syntax expects exactly two notes within
522 the braces, and the number of repetitions must correspond to a
523 note value that can be expressed with plain or dotted notes.  Thus,
524 @code{\repeat tremolo 7} is valid and produces a double dotted
525 note, but @code{\repeat tremolo 9} is not.
526
527 The duration of the tremolo equals the duration of the
528 braced expression multiplied by the number of repeats:
529 @code{\repeat tremolo 8 @{ c16 d16 @}} gives a whole note tremolo,
530 notated as two whole notes joined by tremolo beams. 
531
532 There are two ways to put tremolo marks on a single note.  The
533 @code{\repeat tremolo} syntax is also used here, in which case
534 the note should not be surrounded by braces:
535
536 @lilypond[quote,verbatim,ragged-right]
537 \repeat tremolo 4 c'16
538 @end lilypond
539
540 @cindex tremolo marks
541 @funindex tremoloFlags
542
543 The same output can be obtained by adding
544 @q{@code{:}[@var{number}]} after the note.  The number indicates
545 the duration of the subdivision, and it must be at least 8.  A
546 @var{number} value of 8 gives one line across the note stem.  If
547 the length is omitted, the last value (stored in
548 @code{tremoloFlags}) is used
549
550 @lilypond[quote,ragged-right,verbatim,fragment]
551 c'2:8 c':32 | c': c': |
552 @end lilypond
553
554
555 @knownissues
556
557
558 Tremolos entered with @q{@code{:}[@var{number}]} do not carry over
559 into the MIDI output.
560
561
562 @seealso
563
564 Snippets: @rlsr{Repeats}.
565