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