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