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