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