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