]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/repeats.itely
Merge branch 'master' of /home/lilydev/git/lily/
[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 @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 In some cases, manual repeat marks can be created by simply
218 printing the relevant bar lines.  For more information, see
219 @ref{Bar lines}.
220
221 The property @code{repeatCommands} can be used to control the
222 layout of repeats.  Its value is a Scheme list of repeat commands.
223
224 @table @asis
225 @item @code{start-repeat}
226 Print a @code{|:} bar line:
227
228 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
229 c1
230 \set Score.repeatCommands = #'( start-repeat )
231 d4 e f g
232 c1
233 @end lilypond
234
235 In order to print a @code{|:} bar line at the beginning of a piece,
236 the @code{BreakAlignment} property must be overridden:
237
238 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
239 \once \override Score.BreakAlignment #'break-align-orders =
240 #(make-vector 3 '(
241 instrument-name
242 left-edge
243 ambitus
244 span-bar
245 breathing-sign
246 clef
247 key-signature
248 time-signature
249 staff-bar
250 custos
251 span-bar
252 ))
253 \bar "|:"
254 c1
255 d1
256 d4 e f g
257 @end lilypond
258
259 @item @code{end-repeat}
260 Print a @code{:|} bar line:
261
262 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
263 c1
264 d4 e f g
265 \set Score.repeatCommands = #'( end-repeat )
266 c1
267 @end lilypond
268
269 @item @code{(volta #f)}
270 Stop a running volta bracket.
271
272 @c FIXME: example?
273 @c TODO: Modify and insert <Test volta.ly>.
274
275 @item @code{(volta @var{number})}
276 Change the volta number.
277
278 FIXME: simple example?
279 @c Test volta text.ly works
280
281 @c @lilypond[verbatim,quote,relative=2]
282
283 @c @end lilypond
284
285 @end table
286
287 @c FIXME: Should this be a ``selected snippet''?
288 @c TODO: the example will be fixed.
289
290 By using Scheme, @var{text} can be included with the volta
291 bracket.  The text can be a number or numbers or markup text, see
292 @ref{Formatting text}.  The simplest way to use markup text is to
293 define the markup first, then include the the markup in a Scheme
294 list. When manually creating a volta bracket, the bracket must be
295 explicitly terminated or an error will be generated.
296
297 Manual control of the volte, including a @code{|:} bar line at the
298 beginning and explicit volta numbers:
299
300 @lilypond[verbatim,quote,relative=2]
301 @c FIXME: I can't believe this is right.  
302 @c TODO: I think it is. I plan
303 @c to delete this example, since it's
304 @c already been given at L238. rp
305 s1*1/10
306 \set Score.repeatCommands = #'( start-repeat )
307 c1*9/10
308 d4 e f g
309 \set Score.repeatCommands = #'( ( volta "1, 2, 5" ) )
310 f4 g a b
311 \set Score.repeatCommands = #'( ( volta #f ) ( volta "95" ) end-repeat )
312 g4 a g a
313 \set Score.repeatCommands = #'( ( volta #f ) )
314 c1
315 @end lilypond
316
317 Manual control of the volte, including markup text:
318
319 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
320 c1
321 \set Score.repeatCommands = #'( start-repeat )
322 d1
323 d4 e f g
324 % FIXME: broken
325 %\set Score.repeatCommands = #(list (list 'volta voltaChorus ) )
326 f4 g a b
327 \set Score.repeatCommands = #'( ( volta #f ) ( volta "4" ) end-repeat )
328 g4 a g a
329 \set Score.repeatCommands = #'( ( volta #f ) )
330 c1
331 @end lilypond 
332
333 @seealso
334
335 Notation Reference:
336 @ref{Bar lines},
337 @ref{Formatting text}.
338
339 Snippets:
340 @rlsr{Repeats}.
341
342 Internals Reference:
343 @rinternals{VoltaBracket},
344 @rinternals{RepeatedMusic},
345 @rinternals{VoltaRepeatedMusic}.
346
347
348 @node Written-out repeats
349 @subsubsection Written-out repeats
350
351 @cindex written-out repeats
352 @cindex repetitious music
353 @cindex repeats, written-out
354
355 By using the @code{unfold} command, repeats can be used to simplify
356 the writing out of repetitious music.  The syntax is
357
358 @example
359 \repeat unfold @var{repeatcount} @var{musicexpr}
360 @end example
361
362 where @var{musicexpr} is a music expression.  Unfold repeats can be
363 made with or without alternate endings.  If there are more repeats
364 than there are alternate endings, the first alternative ending is
365 applied to the earliest endings.  Unfold repeats without alternate
366 endings:
367
368 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
369 c1
370 \repeat unfold 2 { c4 d e f }
371 c1
372 @end lilypond
373
374 Unfold repeats with alternate endings:
375
376 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
377 c1
378 \repeat unfold 2 { g4 f e d }
379   \alternative {
380     { cis2 g' }
381     { cis,2 b }
382   }
383 c1
384 \repeat unfold 3 { d4 c b2 }
385   \alternative {
386     { c4 d e f }
387     { d4 c b a }
388   }
389 c1
390 @end lilypond
391
392 @seealso
393
394 Snippets: @rlsr{Repeats}.
395
396 Internals Reference: @rinternals{RepeatedMusic},
397 @rinternals{UnfoldedRepeatedMusic}.
398
399 @node Short repeats
400 @subsection Short repeats
401
402 This section discusses how to input short repeats.  Short repeats can
403 take two basic forms: repeats of a single note to two measures,
404 represented by slashes or percent signs; and tremolos.
405
406 @menu
407 * Percent repeats::             
408 * Tremolo repeats::             
409 @end menu
410
411 @node Percent repeats
412 @subsubsection Percent repeats
413
414 @cindex percent repeats
415 @cindex measure repeats
416
417 Repeated short patterns of notes are supported.  The music is printed
418 once, and the pattern is replaced with a special sign.  Patterns that
419 are shorter than one measure are replaced by slashes, and patterns of
420 one or two measures are replaced by percent-like signs.  The syntax is
421
422 @example
423 @code{\repeat percent @var{number} @var{musicexpr}}
424 @end example
425
426 where @var{musicexpr} is a music expression. 
427
428 @lilypond[quote,verbatim,ragged-right]
429 \relative c' {
430   \repeat percent 4 { c4 }
431   \repeat percent 2 { b'4 a g f }
432   \repeat percent 2 { c2 es | f4 fis g c | }
433 }
434 @end lilypond
435
436 Measure repeats of more than two repeats get a counter if you switch
437 on the @code{countPercentRepeats} property:
438
439 @lilypond[relative=2,fragment,quote,verbatim,ragged-right]
440 \relative c' {
441   \set countPercentRepeats = ##t
442   \repeat percent 4 { c1 }
443 }
444 @end lilypond
445
446
447 Isolated percents can also be printed.  This is done by entering a
448 multi-measure rest with a different print function:
449
450 @lilypond[fragment,verbatim,quote]
451 \override MultiMeasureRest #'stencil
452   = #ly:multi-measure-rest::percent
453 R1
454 @end lilypond
455
456
457 @knownissues
458
459 Only three kinds of percent repeats are supported: a single slash
460 representing a single beat (regardless of the duration of the repeated
461 notes); a single slash with dots representing one full measure; and
462 two slashes with dots crossing a bar line representing two full
463 measures.  Neither multiple slashes representing single beat repeats
464 consisting of sixteenth or shorter notes, nor two slashes with dots
465 representing single beat repeats consisting of notes of varying
466 durations, are supported.
467
468
469 @seealso
470
471 Music Glossary: @rglos{percent repeat}, @rglos{simile}.
472
473 Snippets: @rlsr{Repeats}.
474
475 Internals Reference: @rinternals{RepeatSlash},
476 @rinternals{PercentRepeat}, @rinternals{DoublePercentRepeat},
477 @rinternals{DoublePercentRepeatCounter},
478 @rinternals{PercentRepeatCounter}, @rinternals{PercentRepeatedMusic}.
479
480 @node Tremolo repeats
481 @subsubsection Tremolo repeats
482
483 Tremolos can take two forms: alternation between two chords or two
484 notes, and rapid repetition of a single
485 note or chord. Tremolos consisting of an alternation are indicated by
486 adding beams between the notes or chords being alternated, while
487 tremolos consisting of the rapid repetition of a single note are
488 indicated by adding beams or slashes to a single note.
489
490 @cindex tremolo beams
491
492 To place tremolo marks between notes, use @code{\repeat} with
493 tremolo style:
494
495 @lilypond[quote,verbatim,ragged-right]
496 \relative c' {
497   \repeat tremolo 8 { c16 d }
498   \repeat tremolo 4 { c16 d }
499   \repeat tremolo 2 { c16 d }
500 }
501 @end lilypond
502
503 The @code{\repeat tremolo} syntax expects exactly two notes within
504 the braces, and the number of repetitions must correspond to a
505 note value that can be expressed with plain or dotted notes.  Thus,
506 @code{\repeat tremolo 7} is valid and produces a double dotted
507 note, but @code{\repeat tremolo 9} is not.
508
509 The duration of the tremolo equals the duration of the
510 braced expression multiplied by the number of repeats:
511 @code{\repeat tremolo 8 @{ c16 d16 @}} gives a whole note tremolo,
512 notated as two whole notes joined by tremolo beams. 
513
514 There are two ways to put tremolo marks on a single note.  The
515 @code{\repeat tremolo} syntax is also used here, in which case
516 the note should not be surrounded by braces:
517
518 @lilypond[quote,verbatim,ragged-right]
519 \repeat tremolo 4 c'16
520 @end lilypond
521
522 @cindex tremolo marks
523 @funindex tremoloFlags
524
525 The same output can be obtained by adding
526 @q{@code{:}[@var{number}]} after the note.  The number indicates
527 the duration of the subdivision, and it must be at least 8.  A
528 @var{number} value of 8 gives one line across the note stem.  If
529 the length is omitted, the last value (stored in
530 @code{tremoloFlags}) is used
531
532 @lilypond[quote,ragged-right,verbatim,fragment]
533 c'2:8 c':32 | c': c': |
534 @end lilypond
535
536
537 @knownissues
538
539
540 Tremolos entered with @q{@code{:}[@var{number}]} do not carry over
541 into the MIDI output.
542
543
544 @seealso
545
546 Snippets: @rlsr{Repeats}.
547