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