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