]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/notation/repeats.itely
oversight in repeats.itely
[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.17.11"
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 @funindex \inStaffSegno
243
244 The @code{\inStaffSegno} command can be used to place the segno
245 symbol in cooperation with the @code{\repeat volta} command.
246 Alternative bar line symbols can be set in a Score context by
247 overriding the properties @code{segnoType},
248 @code{startRepeatSegnoType}, @code{endRepeatSegnoType} or
249 @code{doubleRepeatSegnoType} as required.
250
251 @lilypond[verbatim,quote,relative=1]
252 e1
253 \repeat volta 2 {
254   \inStaffSegno
255   f2 g a b
256 }
257 c1_"D.S." \bar "|."
258 @end lilypond
259
260 @cindex repeats, with ties
261 @cindex alternative endings, with ties
262 @cindex ties, in repeats
263 @cindex ties, alternative endings
264 @funindex \repeatTie
265
266 Ties may be added to a second ending:
267
268 @lilypond[verbatim,quote,relative=2]
269 c1
270 \repeat volta 2 { c4 d e f~ }
271 \alternative {
272   { f2 d }
273   { f2\repeatTie f, }
274 }
275 @end lilypond
276
277 @snippets
278 @lilypondfile[verbatim,quote,texidoc,doctitle]
279 {shortening-volta-brackets.ly}
280
281 @lilypondfile[verbatim,quote,texidoc,doctitle]
282 {adding-volta-brackets-to-additional-staves.ly}
283
284 @lilypondfile[verbatim,quote,texidoc,doctitle]
285 {setting-the-double-repeat-default-for-volte.ly}
286
287 @cindex repeats, bar numbers letters
288 @cindex repeats, alternative bar numbers
289
290 @lilypondfile[verbatim,quote,texidoc,doctitle]
291 {alternative-bar-numbering.ly}
292
293 @seealso
294 Music Glossary:
295 @rglos{repeat},
296 @rglos{volta}.
297
298 Notation Reference:
299 @ref{Bar lines},
300 @ref{Modifying context plug-ins},
301 @ref{Modifying ties and slurs},
302 @ref{Time administration}.
303
304 Snippets:
305 @rlsr{Repeats}.
306
307 Internals Reference:
308 @rinternals{VoltaBracket},
309 @rinternals{RepeatedMusic},
310 @rinternals{VoltaRepeatedMusic},
311 @rinternals{UnfoldedRepeatedMusic}.
312
313 @knownissues
314 @cindex repeat, ambiguous
315 @cindex nested repeat
316 @cindex repeat, nested
317 @cindex repeat timing information
318 @cindex repeat and measure number
319 @cindex timing information and repeats
320 @cindex measure number and repeats
321 @cindex repeats and slur
322 @cindex slur and repeats
323 @cindex glissandi and repeats
324 @cindex repeats and glissandi
325
326 Slurs that span from a @code{\repeat} block into an
327 @code{\alternative} block will only work for the first alternative
328 ending.  The visual appearance of a continuing slur in other
329 alternative blocks may be simulated with @code{\repeatTie} if the
330 slur extends into only one note in the alternative block, although
331 this method does not work in @code{TabStaff}.  Other methods which
332 may be tailored to indicate continuing slurs over several notes in
333 alternative blocks, and which also work in @code{TabStaff} contexts,
334 are shown in @ref{Modifying ties and slurs}.
335
336 Also, slurs cannot wrap around from the end of one
337 alternative back to the beginning of the repeat.
338
339 Glissandi that span from a @code{\repeat} block into an
340 @code{\alternative} block will only work for the first alternative
341 ending.  The visual appearance of a continuing glissando in other
342 alternative blocks may be indicated by coding a glissando starting
343 on a hidden grace note.  For an example, see
344 @qq{Extending glissandi across repeats} under Selected Snippets
345 in @ref{Glissando}.
346
347 If a repeat that begins with an incomplete measure has an
348 @code{\alternative} block that contains modifications to the
349 @code{measureLength} property, using @code{\unfoldRepeats} will
350 result in wrongly-placed bar lines and bar check warnings.
351
352 A nested repeat like
353
354 @example
355 \repeat @dots{}
356 \repeat @dots{}
357 \alternative
358 @end example
359
360 @noindent
361 is ambiguous, since it is not clear to which @code{\repeat} the
362 @code{\alternative} belongs.  This ambiguity is resolved by always
363 having the @code{\alternative} belong to the inner @code{\repeat}.
364 For clarity, it is advisable to use braces in such situations.
365
366
367 @node Manual repeat marks
368 @unnumberedsubsubsec Manual repeat marks
369
370 @cindex manual repeat mark
371 @cindex repeat, manual
372 @cindex start repeat
373 @cindex repeat, start
374 @cindex end repeat
375 @cindex repeat, end
376 @cindex repeat number, changing
377 @cindex repeat volta, changing
378 @cindex volta bracket
379 @cindex bracket, volta
380 @funindex repeatCommands
381 @funindex start-repeat
382
383 @warning{These methods are only used for displaying unusual repeat
384 constructs, and may produce unexpected behavior.  In most cases,
385 repeats should be created using the standard @code{@bs{}repeat} command
386 or by printing the relevant bar lines.  For more information, see
387 @ref{Bar lines}.}
388
389 The property @code{repeatCommands} can be used to control the
390 layout of repeats.  Its value is a Scheme list of repeat commands.
391
392 @table @code
393 @item start-repeat
394 Print a @code{.|:} bar line.
395
396 @lilypond[verbatim,quote,relative=2]
397 c1
398 \set Score.repeatCommands = #'(start-repeat)
399 d4 e f g
400 c1
401 @end lilypond
402
403 As per standard engraving practice, repeat signs are not printed
404 at the beginning of a piece.
405
406 @item end-repeat
407 Print a @code{:|.} bar line:
408
409 @lilypond[verbatim,quote,relative=2]
410 c1
411 d4 e f g
412 \set Score.repeatCommands = #'(end-repeat)
413 c1
414 @end lilypond
415
416 @item (volta @var{number}) ... (volta #f)
417 Create a new volta with the specified number.  The volta bracket must
418 be explicitly terminated, or it will not be printed.
419
420 @lilypond[verbatim,quote,relative=2]
421 f4 g a b
422 \set Score.repeatCommands = #'((volta "2"))
423 g4 a g a
424 \set Score.repeatCommands = #'((volta #f))
425 c1
426 @end lilypond
427
428 @end table
429
430 Multiple repeat commands may occur at the same point:
431
432 @lilypond[verbatim,quote,relative=2]
433 f4 g a b
434 \set Score.repeatCommands = #'((volta "2, 5") end-repeat)
435 g4 a g a
436 c1
437 \set Score.repeatCommands = #'((volta #f) (volta "95") end-repeat)
438 b1
439 \set Score.repeatCommands = #'((volta #f))
440 @end lilypond
441
442 @cindex volta bracket with text
443 @cindex text in volta bracket
444
445 Text can be included with the volta bracket.  The text can be a
446 number or numbers or markup text, see @ref{Formatting text}.  The
447 simplest way to use markup text is to define the markup first,
448 then include the markup in a Scheme list.
449
450 @lilypond[verbatim,quote]
451 voltaAdLib = \markup { 1. 2. 3... \text \italic { ad lib. } }
452 \relative c'' {
453   c1
454   \set Score.repeatCommands =
455     #(list(list 'volta voltaAdLib) 'start-repeat)
456   c4 b d e
457   \set Score.repeatCommands = #'((volta #f) (volta "4.") end-repeat)
458   f1
459   \set Score.repeatCommands = #'((volta #f))
460 }
461 @end lilypond
462
463
464 @snippets
465
466 @lilypondfile[verbatim,quote,texidoc,doctitle]
467 {printing-a-repeat-sign-at-the-beginning-of-a-piece.ly}
468
469 @seealso
470 Notation Reference:
471 @ref{Bar lines},
472 @ref{Formatting text}.
473
474 Snippets:
475 @rlsr{Repeats}.
476
477 Internals Reference:
478 @rinternals{VoltaBracket},
479 @rinternals{RepeatedMusic},
480 @rinternals{VoltaRepeatedMusic}.
481
482
483 @node Written-out repeats
484 @unnumberedsubsubsec Written-out repeats
485
486 @cindex written-out repeats
487 @cindex repeats, written-out
488 @cindex repeats, unfold
489 @cindex repeats, alternative
490 @cindex unfold repeat
491 @cindex unfold repeat, alternate endings
492 @cindex alternate repeats
493 @cindex alternate endings, repeats
494 @funindex unfold
495
496 By using the @code{unfold} command, repeats can be used to simplify the
497 writing out of repetitious music.  The syntax is
498
499 @example
500 \repeat unfold @var{repeatcount} @var{musicexpr}
501 @end example
502
503 @noindent
504 where @code{@var{musicexpr}} is a music expression and
505 @code{@var{repeatcount}} is the number of times
506 @code{@var{musicexpr}} is repeated.
507
508 @lilypond[verbatim,quote,relative=2]
509 \repeat unfold 2 { c4 d e f }
510 c1
511 @end lilypond
512
513 In some cases, especially in a @code{\relative} context, the
514 @code{\repeat unfold} function is not the same as writing out the
515 music expression multiple times. E.g,
516
517 @example
518 \repeat unfold 2 @{ a'4 b c @}
519 @end example
520
521 is not equivalent to
522
523 @example
524 a'4 b c | a'4 b c
525 @end example
526
527 Unfold repeats can be made with alternate endings.
528
529 @lilypond[verbatim,quote,relative=2]
530 \repeat unfold 2 { c4 d e f }
531 \alternative {
532   { c2 g' }
533   { c,2 b }
534 }
535 c1
536 @end lilypond
537
538 If there are more repeats than there are alternate endings, the first
539 alternative is applied multiple times until the remaining alternatives
540 make up the total number of repeats.
541
542 @lilypond[verbatim,quote,relative=2]
543 \repeat unfold 4 { c4 d e f }
544 \alternative {
545   { c2 g' }
546   { c,2 b }
547   { e2 d }
548  }
549 c1
550 @end lilypond
551
552 If there are more alternate endings than repeats then only the first
553 alternatives are applied.  The remaining alternatives will be ignored
554 and not printed.
555
556 @lilypond[verbatim,quote,relative=2]
557 \repeat unfold 2 { c4 d e f }
558 \alternative {
559   { c2 g' }
560   { c,2 b }
561   { e2 d }
562 }
563 c1
564 @end lilypond
565
566 It is also possible to nest multiple @code{unfold} functions (with or
567 without alternate endings).
568
569 @lilypond[verbatim,quote,relative=2]
570 \repeat unfold 2 {
571   \repeat unfold 2 { c4 d e f }
572   \alternative {
573     { c2 g' }
574     { c,2 b }
575   }
576 }
577 c1
578 @end lilypond
579
580 Chord constructs can be repeated by the chord repetition symbol
581 @code{q}.  See @ref{Chord repetition}.
582
583 @warning{If you include @code{@bs{}relative} inside a @code{@bs{}repeat}
584 without explicitly instantiating the @code{Voice} context, extra
585 (unwanted) staves will appear.  See @rprogram{An extra staff appears}.}
586
587 @seealso
588 Notation Reference:
589 @ref{Chord repetition}.
590
591 Snippets:
592 @rlsr{Repeats}.
593
594 Internals Reference:
595 @rinternals{RepeatedMusic},
596 @rinternals{UnfoldedRepeatedMusic}.
597
598
599 @node Short repeats
600 @subsection Short repeats
601
602 This section discusses how to input short repeats.  Short repeats can
603 take two forms: slashes or percent signs to represent repeats of a
604 single note, a single measure or two measures, and tremolos otherwise.
605
606 @menu
607 * Percent repeats::
608 * Tremolo repeats::
609 @end menu
610
611 @node Percent repeats
612 @unnumberedsubsubsec Percent repeats
613
614 @cindex percent repeats
615 @cindex measure repeats
616 @cindex repeat, percent
617 @cindex repeat, measure
618 @cindex repeat, short
619 @funindex \repeat percent
620 @funindex percent
621
622 Repeated short patterns are printed once, and the repeated pattern
623 is replaced with a special sign.
624
625 The syntax is
626
627 @example
628 \repeat percent @var{number} @var{musicexpr}
629 @end example
630
631 @noindent
632 where @code{@var{musicexpr}} is a music expression.
633
634 Patterns that are shorter than one measure are replaced by slashes.
635
636 @lilypond[verbatim,quote,relative=2]
637 \repeat percent 4 { c128 d e f }
638 \repeat percent 4 { c64 d e f }
639 \repeat percent 5 { c32 d e f }
640 \repeat percent 4 { c16 d e f }
641 \repeat percent 4 { c8 d }
642 \repeat percent 4 { c4 }
643 \repeat percent 2 { c2 }
644 @end lilypond
645
646 Patterns of one or two measures are replaced by percent-like symbols.
647
648 @lilypond[verbatim,quote,relative=2]
649 \repeat percent 2 { c4 d e f }
650 \repeat percent 2 { c2 d }
651 \repeat percent 2 { c1 }
652 @end lilypond
653
654 @lilypond[verbatim,quote,relative=2]
655 \repeat percent 3 { c4 d e f | c2 g' }
656 @end lilypond
657
658 Patterns that are shorter than one measure but contain mixed durations
659 use a double-percent symbol.
660
661 @lilypond[verbatim,quote,relative=2]
662 \repeat percent 4 { c8. <d f>16 }
663 \repeat percent 2 { \tuplet 3/2 { r8 c d } e4 }
664 @end lilypond
665
666 @snippets
667
668 @lilypondfile[verbatim,quote,texidoc,doctitle]
669 {percent-repeat-counter.ly}
670
671 @lilypondfile[verbatim,quote,texidoc,doctitle]
672 {percent-repeat-count-visibility.ly}
673
674 @lilypondfile[verbatim,quote,texidoc,doctitle]
675 {isolated-percent-repeats.ly}
676
677 @seealso
678 Music Glossary:
679 @rglos{percent repeat},
680 @rglos{simile}.
681
682 Snippets:
683 @rlsr{Repeats}.
684
685 Internals Reference:
686 @rinternals{RepeatSlash},
687 @rinternals{RepeatSlashEvent},
688 @rinternals{DoubleRepeatSlash},
689 @rinternals{PercentRepeat},
690 @rinternals{PercentRepeatCounter},
691 @rinternals{PercentRepeatedMusic},
692 @rinternals{Percent_repeat_engraver},
693 @rinternals{DoublePercentEvent},
694 @rinternals{DoublePercentRepeat},
695 @rinternals{DoublePercentRepeatCounter},
696 @rinternals{Double_percent_repeat_engraver},
697 @rinternals{Slash_repeat_engraver}.
698
699
700 @node Tremolo repeats
701 @unnumberedsubsubsec Tremolo repeats
702
703 @cindex tremolo beams
704 @cindex tremolo
705 @cindex repeat, tremolo
706 @funindex \repeat tremolo
707 @funindex tremolo
708
709 Tremolos can take two forms: alternation between two chords or two
710 notes, and rapid repetition of a single note or chord.  Tremolos
711 consisting of an alternation are indicated by adding beams between the
712 notes or chords being alternated, while tremolos consisting of the
713 rapid repetition of a single note are indicated by adding beams or
714 slashes to a single note.
715
716 To place tremolo marks between notes, use @code{\repeat} with
717 tremolo style:
718
719 @lilypond[quote,verbatim,relative=2]
720 \repeat tremolo 8 { c16 d }
721 \repeat tremolo 6 { c16 d }
722 \repeat tremolo 2 { c16 d }
723 @end lilypond
724
725 The @code{\repeat tremolo} syntax expects exactly two notes within
726 the braces, and the number of repetitions must correspond to a
727 note value that can be expressed with plain or dotted notes.  Thus,
728 @code{\repeat tremolo 7} is valid and produces a double dotted
729 note, but @code{\repeat tremolo 9} is not.
730
731 The duration of the tremolo equals the duration of the
732 braced expression multiplied by the number of repeats:
733 @code{\repeat tremolo 8 @{ c16 d16 @}} gives a whole note tremolo,
734 notated as two whole notes joined by tremolo beams.
735
736 There are two ways to put tremolo marks on a single note.  The
737 @code{\repeat tremolo} syntax is also used here, in which case
738 the note should not be surrounded by braces:
739
740 @lilypond[quote,verbatim,ragged-right]
741 \repeat tremolo 4 c'16
742 @end lilypond
743
744 @cindex tremolo marks
745 @funindex tremoloFlags
746 @funindex :
747
748 The same output can be obtained by adding @code{:@var{N}} after
749 the note, where @code{@var{N}} indicates the duration of the
750 subdivision (it must be at least 8).  If @code{@var{N}} is 8, one
751 beam is added to the note's stem.  If @code{@var{N}} is omitted,
752 the last value (stored in @code{tremoloFlags}) is used:
753
754 @lilypond[quote,verbatim,relative=2]
755 c2:8 c:32
756 c: c:
757 @end lilypond
758
759 @snippets
760
761 @lilypondfile[verbatim,quote,texidoc,doctitle]
762 {cross-staff-tremolos.ly}
763
764 @seealso
765 Snippets:
766 @rlsr{Repeats}.
767
768 @cindex tremolo, cross-staff
769 @cindex cross-staff tremolo