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