]> 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.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 percent signs.
36 Percent repeats must be declared within a @code{Voice} context.
37
38 @item tremolo
39 This is used to write tremolo beams.
40
41 @end table
42
43 @ignore
44 LilyPond has one syntactic construct for specifying different
45 types of repeats.  The syntax is
46
47 @example
48 \repeat @var{variant} @var{repeatcount} @var{musicexpr}
49 @end example
50
51 where @var{musicexpr} is a music expression.
52
53
54 Alternative endings are entered with 
55 @funindex \alternative
56 @example
57 \alternative @{
58   @var{alternative1}
59   @var{alternative2}
60   @var{alternative3}
61   @dots{}
62 @}
63 @end example
64
65 @noindent
66 after a @code{\repeat volta} or @code{unfold} block, where each
67 @var{alternative} is a music expression.  If you give fewer
68 alternatives than @var{repeatcount}, the first alternative is assumed
69 to be played more than once.
70 @end ignore
71
72
73 @menu
74 * Long repeats::                
75 * Short repeats::               
76 @end menu
77
78 @node Long repeats
79 @subsection Long repeats
80
81 This section discusses how to input long (usually multi-measure)
82 repeats.  The repeats can take two forms: repeats enclosed between
83 repeat signs; or written out repeats, used to input repetitious music.
84 Repeat signs can also be controlled manually.
85
86 @menu
87 * Normal repeats::              
88 * Manual repeat marks::         
89 * Written-out repeats (unfold)::  
90 @end menu
91
92 @cindex volta
93 @cindex prima volta
94 @cindex seconda volta
95 @cindex volta, prima
96 @cindex volta, seconda
97 @funindex \repeat
98
99 @node Normal repeats
100 @subsubsection Normal repeats
101
102 The syntax for a normal repeat is
103
104 @example
105 \repeat volta @var{repeatcount} @var{musicexpr}
106 @end example
107
108 where @var{musicexpr} is a music expression.  Alternate endings can
109 be produced using @code{\alternative}.
110
111 Normal repeats without alternate endings:
112
113 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
114 \repeat volta 2 { c4 d e f }
115 c2 d
116 \repeat volta 2 { d4 e f g }
117 @end lilypond
118
119 Normal repeats with alternate endings:
120
121 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
122 \repeat volta 2 { g4 f e d }
123   \alternative {
124     { cis2 g' }
125     { cis,2 b }
126   }
127 c1
128 @end lilypond
129
130
131 Repeats with upbeats:
132
133 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
134 \new Staff {
135   \partial 4
136   e |
137   \repeat volta 4 { c2 d | e2 f | }
138   \alternative {
139     { g4 g g e }
140     { a4 a a a | b2. }
141   }
142 }
143 @end lilypond
144
145 @noindent
146 or
147
148 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
149 \new Staff {
150   \partial 4 
151   \repeat volta 4 { e4 | c2 d | e2 f | }
152   \alternative {
153     { \partial 4*3 g4 g g }
154     { a4 a a a | b2. }
155   }
156 }
157 @end lilypond
158
159
160 @funindex \repeatTie
161
162 Ties may be added to a second ending:
163
164 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
165 c1
166 \repeat volta 2 {c4 d e f ~ }
167 \alternative {
168   {f2 d}
169   {f2\repeatTie f,}
170 }
171 @end lilypond
172
173 @snippets
174
175 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc]
176 {shortening-volta-brackets.ly}
177
178 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc]
179 {adding-volta-brackets-to-additional-staves.ly}
180
181
182 @c Is there a way to have a final bar ("|.") at the end of the
183 @c previous line? Doesn't seem to be.
184 If you want to start a repeat at the beginning of a line and have a
185 double bar at the end of the previous line, use @code{\bar}. For more
186 information, see @ref{Bar lines}.
187
188 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
189 c4 c c c
190 \bar "||:" \break 
191 \repeat volta 2 { c4 d e f }   
192 @end lilypond
193
194
195 @seealso
196
197 Music Glossary: @rglos{repeat}, @rglos{volta}.
198
199 Notation Reference: @ref{Bar lines}, @ref{Modifying context plug-ins}.
200
201 Snippets: @rlsr{Repeats}.
202
203 Internals Reference: @rinternals{VoltaBracket},
204 @rinternals{RepeatedMusic}, @rinternals{VoltaRepeatedMusic},
205 @rinternals{UnfoldedRepeatedMusic}.
206
207 @knownissues
208
209 @cindex repeat, ambiguous
210
211 A nested repeat like
212
213 @example
214 \repeat @dots{}
215 \repeat @dots{}
216 \alternative
217 @end example
218
219 @noindent
220 is ambiguous, since it is is not clear to which @code{\repeat} the
221 @code{\alternative} belongs.  This ambiguity is resolved by always
222 having the @code{\alternative} belong to the inner @code{\repeat}.
223 For clarity, it is advisable to use braces in such situations.
224
225 Timing information is not remembered at the start of an alternative,
226 so after a repeat timing information must be reset by hand; for
227 example, by setting @code{Score.measurePosition} or entering
228 @code{\partial}.  Similarly, slurs or ties are also not repeated.
229
230
231
232 @node Manual repeat marks
233 @subsubsection Manual repeat marks
234
235 @funindex repeatCommands
236
237 @c FIXME: Markup does not work in the "text" field
238 @c And how does one change the font?
239 @c On the whole, this section needs better documentation (why the
240 @c double parentheses around the volta expressions?)
241
242 The property @code{repeatCommands} can be used to control the
243 layout of repeats.  Its value is a Scheme list of repeat commands.
244
245 @table @asis
246 @item @code{start-repeat}
247 Print a @code{|:} bar line.
248
249 @item @code{end-repeat}
250 Print a @code{:|} bar line.
251
252 @item @code{(volta @var{text})}
253 Print a volta bracket saying @var{text}.  The text can be specified as
254 a text string or as a markup text, see @ref{Formatting text}.  Do not
255 forget to change the font, as the default number font does not contain
256 alphabetic characters;
257
258
259 @item @code{(volta #f)}
260 Stop a running volta bracket.
261 @end table
262
263 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
264 c4
265 \set Score.repeatCommands = #'((volta "93") end-repeat)
266 c4 b
267 \set Score.repeatCommands = #'((volta #f))
268 d4 e
269 @end lilypond
270
271 @c FIXME: improve visibility of bar lines link?
272
273 @seealso
274
275 Notation Reference: @ref{Bar lines}, @ref{Formatting text}.
276
277 Snippets: @rlsr{Repeats}.
278
279 Internals Reference: @rinternals{VoltaBracket},
280 @rinternals{RepeatedMusic}, @rinternals{VoltaRepeatedMusic}.
281
282
283 @node Written-out repeats (unfold)
284 @subsubsection Written-out repeats (unfold)
285
286 @cindex written-out repeats
287 @cindex repetitious music
288 @cindex repeats, written-out
289
290 By using the @code{unfold} command, repeats can be used to simplify
291 the writing out of repetitious music.  The syntax is
292
293 @example
294 \repeat unfold @var{repeatcount} @var{musicexpr}
295 @end example
296
297 where @var{musicexpr} is a music expression.  Unfold repeats can be
298 made with or without alternate endings.  Unfold repeats without
299 alternate endings:
300
301 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
302 c1
303 \repeat unfold 2 { c4 d e f }
304 c1
305 @end lilypond
306
307 Unfold repeats with alternate endings:
308
309 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
310 c1
311 \repeat unfold 2 { g4 f e d }
312   \alternative {
313     { cis2 g' }
314     { cis,2 b }
315   }
316 c1
317 @end lilypond
318
319 @seealso
320
321 Snippets: @rlsr{Repeats}.
322
323 Internals Reference: @rinternals{RepeatedMusic},
324 @rinternals{UnfoldedRepeatedMusic}.
325
326 @node Short repeats
327 @subsection Short repeats
328
329 This section discusses how to input short repeats, either single-note
330 to multi-measure using slash marks, or tremolos.
331
332 @menu
333 * Percent repeats::             
334 * Tremolo repeats::             
335 @end menu
336
337 @node Percent repeats
338 @subsubsection Percent repeats
339
340 @cindex percent repeats
341 @cindex measure repeats
342
343 Repeated short patterns of notes are also supported.  The music is
344 printed once, and the pattern is replaced with a special sign.
345 Patterns of one and two measures are replaced by percent-like signs,
346 patterns that are shorter than one measure are replaced by slashes.
347 Percent repeats must be declared within a @code{Voice} context.  The
348 syntax is
349
350 @example
351 @code{\repeat percent @var{number} @var{musicexpr}}
352 @end example
353
354 where @var{musicexpr} is a music expression. 
355
356 @lilypond[quote,verbatim,ragged-right]
357 \relative c' {
358   \repeat percent 4 { c4 }
359   \repeat percent 2 { b'4 a g f }
360   \repeat percent 2 { c2 es | f4 fis g c | }
361 }
362 @end lilypond
363
364 Measure repeats of more than two measures get a counter if you
365 switch on the @code{countPercentRepeats} property:
366
367 @lilypond[relative=2,fragment,quote,verbatim,ragged-right]
368 \relative c' {
369   \set countPercentRepeats = ##t
370   \repeat percent 4 { c1 }
371 }
372 @end lilypond
373
374
375 Isolated percents can also be printed.  This is done by entering a
376 multi-measure rest with a different print function:
377
378 @lilypond[fragment,verbatim,quote]
379 \override MultiMeasureRest #'stencil
380   = #ly:multi-measure-rest::percent
381 R1
382 @end lilypond
383
384
385 @seealso
386
387 Snippets: @rlsr{Repeats}.
388
389 Internals Reference: @rinternals{RepeatSlash},
390 @rinternals{PercentRepeat}, @rinternals{DoublePercentRepeat},
391 @rinternals{DoublePercentRepeatCounter},
392 @rinternals{PercentRepeatCounter},
393 @rinternals{PercentRepeatedMusic}.
394
395 @node Tremolo repeats
396 @subsubsection Tremolo repeats
397
398 @cindex tremolo beams
399
400 To place tremolo marks between notes, use @code{\repeat} with
401 tremolo style:
402
403 @lilypond[quote,verbatim,ragged-right]
404 \relative c' {
405   \repeat tremolo 8 { c16 d }
406   \repeat tremolo 4 { c16 d }
407   \repeat tremolo 2 { c16 d }
408 }
409 @end lilypond
410
411 The @code{\repeat tremolo} syntax expects exactly two notes within
412 the braces, and the number of repetitions must correspond to a
413 note value that can be expressed with plain or dotted notes.  Thus,
414 @code{\repeat tremolo 7} is valid and produces a double dotted
415 note, but @code{\repeat tremolo 9} is not.
416
417 The duration of the tremolo equals the duration of the
418 braced expression multiplied by the number of repeats:
419 @code{\repeat tremolo 8 @{ c16 d16 @}} gives a whole note tremolo,
420 notated as two whole notes joined by tremolo beams. 
421
422 There are two ways to put tremolo marks on a single note.  The
423 @code{\repeat tremolo} syntax is also used here, in which case
424 the note should not be surrounded by braces:
425
426 @lilypond[quote,verbatim,ragged-right]
427 \repeat tremolo 4 c'16
428 @end lilypond
429
430 @cindex tremolo marks
431 @funindex tremoloFlags
432
433 The same output can be obtained by adding
434 @q{@code{:}[@var{number}]} after the note.  The number indicates
435 the duration of the subdivision, and it must be at least 8.  A
436 @var{number} value of 8 gives one line across the note stem.  If
437 the length is omitted, the last value (stored in
438 @code{tremoloFlags}) is used
439
440 @lilypond[quote,ragged-right,verbatim,fragment]
441 c'2:8 c':32 | c': c': |
442 @end lilypond
443
444
445 @knownissues
446
447
448 Tremolos entered with @q{@code{:}[@var{number}]} do not carry over
449 into the MIDI output.
450
451
452 @seealso
453
454 Notation Reference: @ref{Tremolo repeats}.
455
456 Internals Reference: @rinternals{Beam}, @rinternals{StemTremolo}.
457
458 Snippets: @rlsr{Repeats}.
459
460 Elsewhere: @rinternals{StemTremolo}.
461
462