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