]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/notation/repeats.itely
57a5dfb8fea3cf0901be361cff50d39565e8ebdb
[lilypond.git] / Documentation / notation / 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.  For details, see the Contributors'
7     Guide, node Updating translation committishes..
8 @end ignore
9
10 @c \version "2.14.0"
11
12 @node Repeats
13 @section Repeats
14
15 @lilypondfile[quote]{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
19 repeats:
20
21
22 @table @code
23 @item volta
24 The repeated music is not written out but enclosed between repeat bar
25 lines.  If the repeat is at the beginning of a piece, a repeat bar
26 line is only printed at the end of the repeat.  Alternative endings
27 (volte) are printed left to right with brackets.  This is the standard
28 notation for repeats with alternatives.
29
30 @item unfold
31 The repeated music is fully written out, as many times as
32 specified by @code{@var{repeatcount}}.  This is useful when
33 entering repetitious music.
34
35 @item percent
36 These are beat or measure repeats.  They look like single slashes or
37 percent signs.
38
39 @item tremolo
40 This is used to write tremolo beams.
41
42 @end table
43
44
45 @menu
46 * Long repeats::
47 * Short repeats::
48 @end menu
49
50 @node Long repeats
51 @subsection Long repeats
52
53 This section discusses how to input long (usually multi-measure)
54 repeats.  The repeats can take two forms: repeats enclosed between
55 repeat signs; or written-out repeats, used to input repetitious music.
56 Repeat signs can also be controlled manually.
57
58 @menu
59 * Normal repeats::
60 * Manual repeat marks::
61 * Written-out repeats::
62 @end menu
63
64 @cindex volta
65 @cindex prima volta
66 @cindex seconda volta
67 @cindex volta, prima
68 @cindex volta, seconda
69 @cindex repeat, normal
70 @cindex normal repeat
71 @cindex repeat with alternate endings
72 @cindex alternate endings
73 @funindex \repeat
74 @funindex \alternative
75 @funindex \partial
76
77 @node Normal repeats
78 @unnumberedsubsubsec Normal repeats
79
80 The syntax for a normal repeat is
81
82 @example
83 \repeat volta @var{repeatcount} @var{musicexpr}
84 @end example
85
86 @noindent
87 where @code{@var{musicexpr}} is a music expression.
88
89 A single repeat without an alternate ending:
90
91 @lilypond[verbatim,quote,relative=2]
92 \repeat volta 2 { c4 d e f }
93 c2 d
94 \repeat volta 2 { d4 e f g }
95 @end lilypond
96
97 Alternative endings can be produced using @code{\alternative}.  Each
98 group of alternatives must be themselves, enclosed in a set of braces.
99
100 @example
101 \repeat volta @var{repeatcount} @var{musicexpr}
102 \alternative @{
103   @{ @var{musicexpr} @}
104 @}
105 @end example
106
107 @noindent
108 where @code{@var{musicexpr}} is a music expression.
109
110 If there are more repeats than there are alternate endings, the earliest
111 repeats are given the first alternative.
112
113 A single repeat with one alternate ending:
114
115 @lilypond[verbatim,quote,relative=2]
116 \repeat volta 2 { c4 d e f | }
117 \alternative {
118   { c2 e | }
119   { f2 g | }
120 }
121 c1
122 @end lilypond
123
124 A single repeat with more than one alternate ending:
125
126 @lilypond[verbatim,quote,relative=2]
127 \repeat volta 4 { c4 d e f | }
128 \alternative {
129   { c2 e | }
130   { f2 g | }
131 }
132 c1
133 @end lilypond
134
135 Multiple repeats with more than one alternate ending:
136
137 @lilypond[verbatim,quote,relative=2]
138 \repeat volta 3 { c4 d e f | }
139 \alternative {
140   { c2 e | }
141   { f2 g | }
142   { a2 g | }
143 }
144 c1
145 @end lilypond
146
147 @warning{If there are two or more alternatives, nothing should appear
148 between the closing brace of one and the opening brace of the next
149 in an @code{@bs{}alternative} block, otherwise you will not get the
150 expected number of endings.}
151
152 @warning{If you include @code{@bs{}relative} inside a
153 @code{@bs{}repeat} without explicitly instantiating the
154 @code{Voice} context, extra (unwanted) staves will appear.  See
155 @rprogram{An extra staff appears}.}
156
157 @cindex repeat with upbeat
158 @cindex upbeat in a repeat
159 @cindex anacrucis in a repeat
160 @cindex repeat with anacrucis
161 @cindex repeat with pickup
162 @cindex pickup in a repeat
163 @funindex \partial
164
165 If a repeat starts in the middle of a measure and has no alternate
166 endings, normally the end of the repeat will also fall in the
167 middle of a measure, so that the two ends add up to one complete
168 measure.  In such cases, the repeat signs do not constitute true
169 bar lines.  Do not use @code{\partial} commands or bar checks
170 where these repeat signs are printed:
171
172 @lilypond[verbatim,quote,relative=1]
173 % no \partial here
174 c4 e g  % no bar check here
175 % no \partial here
176 \repeat volta 4 {
177   e4 |
178   c2 e |
179   % no \partial here
180   g4 g g  % no bar check here
181 }
182 % no \partial here
183 g4 |
184 a2 a |
185 g1 |
186 @end lilypond
187
188 Similarly, if a repeat begins with the initial partial measure of
189 a score and has no alternate endings, the same conditions apply as
190 in the above example, except that in this case the @code{\partial}
191 command is required at the beginning of the score:
192
193 @lilypond[verbatim,quote,relative=1]
194 \partial 4  % required
195 \repeat volta 4 {
196   e4 |
197   c2 e |
198   % no \partial here
199   g4 g g  % no bar check here
200 }
201 % no \partial here
202 g4 |
203 a2 a |
204 g1 |
205 @end lilypond
206
207 When alternate endings are added to a repeat that begins with an
208 incomplete measure, it becomes necessary to set the
209 @code{Timing.measureLength} context property manually, in the
210 following specific places:
211
212 @itemize
213 @item
214 at the start of any incomplete measures in the @code{\alternative}
215 block, which normally occur at the end of each alternative, except
216 (in most cases) the last.
217
218 @item
219 at the start of each alternative, except the first.
220 @end itemize
221
222 @lilypond[verbatim,quote,relative=1]
223 \partial 4
224 \repeat volta 2 { e4 | c2 e | }
225 \alternative {
226   {
227     f2 d |
228     \set Timing.measureLength = #(ly:make-moment 3 4)
229     g4 g g  % optional bar check is allowed here
230   }
231   {
232     \set Timing.measureLength = #(ly:make-moment 4 4)
233     a2 a |
234   }
235 }
236 g1 |
237 @end lilypond
238
239 The @code{measureLength} property is described in @ref{Time
240 administration}.
241
242 @cindex repeats with ties
243 @cindex alternative endings with ties
244 @cindex ties in repeats
245 @cindex ties in alternative endings
246 @funindex \repeatTie
247
248 Ties may be added to a second ending:
249
250 @lilypond[verbatim,quote,relative=2]
251 c1
252 \repeat volta 2 { c4 d e f~ }
253 \alternative {
254   { f2 d }
255   { f2\repeatTie f, }
256 }
257 @end lilypond
258
259 @snippets
260
261 @lilypondfile[verbatim,quote,texidoc,doctitle]
262 {shortening-volta-brackets.ly}
263
264 @lilypondfile[verbatim,quote,texidoc,doctitle]
265 {adding-volta-brackets-to-additional-staves.ly}
266
267 @lilypondfile[verbatim,quote,texidoc,doctitle]
268 {setting-the-double-repeat-default-for-volte.ly}
269
270 @seealso
271 Music Glossary:
272 @rglos{repeat},
273 @rglos{volta}.
274
275 Notation Reference:
276 @ref{Bar lines},
277 @ref{Modifying context plug-ins},
278 @ref{Time administration}.
279
280 Snippets:
281 @rlsr{Repeats}.
282
283 Internals Reference:
284 @rinternals{VoltaBracket},
285 @rinternals{RepeatedMusic},
286 @rinternals{VoltaRepeatedMusic},
287 @rinternals{UnfoldedRepeatedMusic}.
288
289
290 @knownissues
291
292 @cindex repeat, ambiguous
293 @cindex nested repeat
294 @cindex repeat, nested
295 @cindex repeat timing information
296 @cindex repeat and measure number
297 @cindex timing information and repeats
298 @cindex measure number and repeats
299 @cindex repeat and slur
300 @cindex slur and repeat
301
302 Slurs that span from a @code{\repeat} block into an
303 @code{\alternative} block will only work for the first alternate
304 ending.  Also, slurs cannot wrap around from the end of one
305 alternative back to the beginning of the repeat.
306
307 If a repeat that begins with an incomplete measure has an
308 @code{\alternative} block that contains modifications to the
309 @code{measureLength} property, using @code{\unfoldRepeats} will
310 result in wrongly-placed bar lines and bar check warnings.
311
312 A nested repeat like
313
314 @example
315 \repeat @dots{}
316 \repeat @dots{}
317 \alternative
318 @end example
319
320 @noindent
321 is ambiguous, since it is not clear to which @code{\repeat} the
322 @code{\alternative} belongs.  This ambiguity is resolved by always
323 having the @code{\alternative} belong to the inner @code{\repeat}.
324 For clarity, it is advisable to use braces in such situations.
325
326
327 @node Manual repeat marks
328 @unnumberedsubsubsec Manual repeat marks
329
330 @cindex manual repeat mark
331 @cindex repeat, manual
332 @cindex start repeat
333 @cindex repeat, start
334 @cindex end repeat
335 @cindex repeat, end
336 @cindex repeat number, changing
337 @cindex repeat volta, changing
338 @cindex volta bracket
339 @cindex bracket, volta
340 @funindex repeatCommands
341 @funindex start-repeat
342
343 @warning{These methods are only used for displaying unusual repeat
344 constructs, and may produce unexpected behavior.  In most cases,
345 repeats should be created using the standard @code{@bs{}repeat} command
346 or by printing the relevant bar lines.  For more information, see
347 @ref{Bar lines}.}
348
349 The property @code{repeatCommands} can be used to control the
350 layout of repeats.  Its value is a Scheme list of repeat commands.
351
352 @table @code
353 @item start-repeat
354 Print a @code{|:} bar line.
355
356 @lilypond[verbatim,quote,relative=2]
357 c1
358 \set Score.repeatCommands = #'(start-repeat)
359 d4 e f g
360 c1
361 @end lilypond
362
363 As per standard engraving practice, repeat signs are not printed
364 at the beginning of a piece.
365
366 @item end-repeat
367 Print a @code{:|} bar line:
368
369 @lilypond[verbatim,quote,relative=2]
370 c1
371 d4 e f g
372 \set Score.repeatCommands = #'(end-repeat)
373 c1
374 @end lilypond
375
376 @item (volta @var{number}) ... (volta #f)
377 Create a new volta with the specified number.  The volta bracket must
378 be explicitly terminated, or it will not be printed.
379
380 @lilypond[verbatim,quote,relative=2]
381 f4 g a b
382 \set Score.repeatCommands = #'((volta "2"))
383 g4 a g a
384 \set Score.repeatCommands = #'((volta #f))
385 c1
386 @end lilypond
387
388 @end table
389
390 Multiple repeat commands may occur at the same point:
391
392 @lilypond[verbatim,quote,relative=2]
393 f4 g a b
394 \set Score.repeatCommands = #'((volta "2, 5") end-repeat)
395 g4 a g a
396 c1
397 \set Score.repeatCommands = #'((volta #f) (volta "95") end-repeat)
398 b1
399 \set Score.repeatCommands = #'((volta #f))
400 @end lilypond
401
402 @cindex volta bracket with text
403 @cindex text in volta bracket
404
405 Text can be included with the volta bracket.  The text can be a
406 number or numbers or markup text, see @ref{Formatting text}.  The
407 simplest way to use markup text is to define the markup first,
408 then include the markup in a Scheme list.
409
410 @lilypond[verbatim,quote]
411 voltaAdLib = \markup { 1. 2. 3... \text \italic { ad lib. } }
412 \relative c'' {
413   c1
414   \set Score.repeatCommands = #(list(list 'volta voltaAdLib) 'start-repeat)
415   c4 b d e
416   \set Score.repeatCommands = #'((volta #f) (volta "4.") end-repeat)
417   f1
418   \set Score.repeatCommands = #'((volta #f))
419 }
420 @end lilypond
421
422
423 @snippets
424
425 @lilypondfile[verbatim,quote,texidoc,doctitle]
426 {printing-a-repeat-sign-at-the-beginning-of-a-piece.ly}
427
428
429 @seealso
430 Notation Reference:
431 @ref{Bar lines},
432 @ref{Formatting text}.
433
434 Snippets:
435 @rlsr{Repeats}.
436
437 Internals Reference:
438 @rinternals{VoltaBracket},
439 @rinternals{RepeatedMusic},
440 @rinternals{VoltaRepeatedMusic}.
441
442
443 @node Written-out repeats
444 @unnumberedsubsubsec Written-out repeats
445
446 @cindex written-out repeats
447 @cindex repeats, written-out
448 @cindex repeats, unfold
449 @cindex repeats, alternative
450 @cindex unfold repeat
451 @cindex unfold repeat, alternate endings
452 @cindex alternate repeats
453 @cindex alternate endings, repeats
454 @funindex unfold
455
456 By using the @code{unfold} command, repeats can be used to simplify the
457 writing out of repetitious music.  The syntax is
458
459 @example
460 \repeat unfold @var{repeatcount} @var{musicexpr}
461 @end example
462
463 @noindent
464 where @code{@var{musicexpr}} is a music expression and
465 @code{@var{repeatcount}} is the number of times
466 @code{@var{musicexpr}} is repeated.
467
468 @lilypond[verbatim,quote,relative=2]
469 \repeat unfold 2 { c4 d e f }
470 c1
471 @end lilypond
472
473 In some cases, especially in a @code{\relative} context, the
474 @code{\repeat unfold} function is not the same as writing out the
475 music expression multiple times. E.g,
476
477 @example
478 \repeat unfold 2 @{ a'4 b c @}
479 @end example
480
481 is not equivalent to
482
483 @example
484 a'4 b c | a'4 b c
485 @end example
486
487 Unfold repeats can be made with alternate endings.
488
489 @lilypond[verbatim,quote,relative=2]
490 \repeat unfold 2 { c4 d e f }
491 \alternative {
492   { c2 g' }
493   { c,2 b }
494 }
495 c1
496 @end lilypond
497
498 If there are more repeats than there are alternate endings, the first
499 alternative is applied multiple times until the remaining alternatives
500 make up the total number of repeats.
501
502 @lilypond[verbatim,quote,relative=2]
503 \repeat unfold 4 { c4 d e f }
504 \alternative {
505   { c2 g' }
506   { c,2 b }
507   { e2 d }
508  }
509 c1
510 @end lilypond
511
512 If there are more alternate endings than repeats then only the first
513 alternatives are applied.  The remaining alternatives will be ignored
514 and not printed.
515
516 @lilypond[verbatim,quote,relative=2]
517 \repeat unfold 2 { c4 d e f }
518 \alternative {
519   { c2 g' }
520   { c,2 b }
521   { e2 d }
522 }
523 c1
524 @end lilypond
525
526 It is also possible to nest multiple @code{unfold} functions (with or
527 without alternate endings).
528
529 @lilypond[verbatim,quote,relative=2]
530 \repeat unfold 2 {
531   \repeat unfold 2 { c4 d e f }
532   \alternative {
533     { c2 g' }
534     { c,2 b }
535   }
536 }
537 c1
538 @end lilypond
539
540 Chord constructs can be repeated by the chord repetition symbol
541 @code{q}.  See @ref{Chord repetition}.
542
543 @warning{If you include @code{@bs{}relative} inside a @code{@bs{}repeat}
544 without explicitly instantiating the @code{Voice} context, extra
545 (unwanted) staves will appear.  See @rprogram{An extra staff appears}.}
546
547 @seealso
548 Notation Reference:
549 @ref{Chord repetition}.
550
551 Snippets:
552 @rlsr{Repeats}.
553
554 Internals Reference:
555 @rinternals{RepeatedMusic},
556 @rinternals{UnfoldedRepeatedMusic}.
557
558 @node Short repeats
559 @subsection Short repeats
560
561 This section discusses how to input short repeats.  Short repeats can
562 take two forms: slashes or percent signs to represent repeats of a
563 single note, a single measure or two measures, and tremolos otherwise.
564
565 @menu
566 * Percent repeats::
567 * Tremolo repeats::
568 @end menu
569
570 @node Percent repeats
571 @unnumberedsubsubsec Percent repeats
572
573 @cindex percent repeats
574 @cindex measure repeats
575 @cindex repeat, percent
576 @cindex repeat, measure
577 @cindex repeat, short
578 @funindex \repeat percent
579 @funindex percent
580
581 Repeated short patterns are printed once, and the repeated pattern
582 is replaced with a special sign.
583
584 The syntax is
585
586 @example
587 \repeat percent @var{number} @var{musicexpr}
588 @end example
589
590 @noindent
591 where @code{@var{musicexpr}} is a music expression.
592
593 Patterns that are shorter than one measure are replaced by slashes.
594
595 @lilypond[verbatim,quote,relative=2]
596 \repeat percent 4 { c128 d e f }
597 \repeat percent 4 { c64 d e f }
598 \repeat percent 5 { c32 d e f }
599 \repeat percent 4 { c16 d e f }
600 \repeat percent 4 { c8 d }
601 \repeat percent 4 { c4 }
602 \repeat percent 2 { c2 }
603 @end lilypond
604
605 Patterns of one or two measures are replaced by percent-like symbols.
606
607 @lilypond[verbatim,quote,relative=2]
608 \repeat percent 2 { c4 d e f }
609 \repeat percent 2 { c2 d }
610 \repeat percent 2 { c1 }
611 @end lilypond
612
613 @lilypond[verbatim,quote,relative=2]
614 \repeat percent 3 { c4 d e f | c2 g' }
615 @end lilypond
616
617 Patterns that are shorter than one measure but contain mixed durations
618 use a double-percent symbol.
619
620 @lilypond[verbatim,quote,relative=2]
621 \repeat percent 4 { c8. <d f>16 }
622 \repeat percent 2 { \times 2/3 { r8 c d } e4 }
623 @end lilypond
624
625 @snippets
626
627 @lilypondfile[verbatim,quote,texidoc,doctitle]
628 {percent-repeat-counter.ly}
629
630 @lilypondfile[verbatim,quote,texidoc,doctitle]
631 {percent-repeat-count-visibility.ly}
632
633 @lilypondfile[verbatim,quote,texidoc,doctitle]
634 {isolated-percent-repeats.ly}
635
636 @seealso
637 Music Glossary:
638 @rglos{percent repeat},
639 @rglos{simile}.
640
641 Snippets:
642 @rlsr{Repeats}.
643
644 Internals Reference:
645 @rinternals{RepeatSlash},
646 @rinternals{RepeatSlashEvent},
647 @rinternals{DoubleRepeatSlash},
648 @rinternals{PercentRepeat},
649 @rinternals{PercentRepeatCounter},
650 @rinternals{PercentRepeatedMusic},
651 @rinternals{Percent_repeat_engraver},
652 @rinternals{DoublePercentEvent},
653 @rinternals{DoublePercentRepeat},
654 @rinternals{DoublePercentRepeatCounter},
655 @rinternals{Double_percent_repeat_engraver},
656 @rinternals{Slash_repeat_engraver}.
657
658
659 @node Tremolo repeats
660 @unnumberedsubsubsec Tremolo repeats
661
662 @cindex tremolo beams
663 @cindex tremolo
664 @cindex repeat, tremolo
665 @funindex \repeat tremolo
666 @funindex tremolo
667
668 Tremolos can take two forms: alternation between two chords or two
669 notes, and rapid repetition of a single note or chord.  Tremolos
670 consisting of an alternation are indicated by adding beams between the
671 notes or chords being alternated, while tremolos consisting of the
672 rapid repetition of a single note are indicated by adding beams or
673 slashes to a single note.
674
675 To place tremolo marks between notes, use @code{\repeat} with
676 tremolo style:
677
678 @lilypond[quote,verbatim,relative=2]
679 \repeat tremolo 8 { c16 d }
680 \repeat tremolo 6 { c16 d }
681 \repeat tremolo 2 { c16 d }
682 @end lilypond
683
684 The @code{\repeat tremolo} syntax expects exactly two notes within
685 the braces, and the number of repetitions must correspond to a
686 note value that can be expressed with plain or dotted notes.  Thus,
687 @code{\repeat tremolo 7} is valid and produces a double dotted
688 note, but @code{\repeat tremolo 9} is not.
689
690 The duration of the tremolo equals the duration of the
691 braced expression multiplied by the number of repeats:
692 @code{\repeat tremolo 8 @{ c16 d16 @}} gives a whole note tremolo,
693 notated as two whole notes joined by tremolo beams.
694
695 There are two ways to put tremolo marks on a single note.  The
696 @code{\repeat tremolo} syntax is also used here, in which case
697 the note should not be surrounded by braces:
698
699 @lilypond[quote,verbatim,ragged-right]
700 \repeat tremolo 4 c'16
701 @end lilypond
702
703 @cindex tremolo marks
704 @funindex tremoloFlags
705 @funindex :
706
707 The same output can be obtained by adding @code{:@var{N}} after
708 the note, where @code{@var{N}} indicates the duration of the
709 subdivision (it must be at least 8).  If @code{@var{N}} is 8, one
710 beam is added to the note's stem.  If @code{@var{N}} is omitted,
711 the last value (stored in @code{tremoloFlags}) is used:
712
713 @lilypond[quote,verbatim,relative=2]
714 c2:8 c:32
715 c: c:
716 @end lilypond
717
718 @snippets
719
720 @lilypondfile[verbatim,quote,texidoc,doctitle]
721 {cross-staff-tremolos.ly}
722
723
724 @seealso
725 Snippets:
726 @rlsr{Repeats}.
727
728 @cindex tremolo, cross-staff
729 @cindex cross-staff tremolo
730