]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/repeats.itely
Add 'lilyquote' fragment option to lilypond-book
[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 @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}
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
265 @seealso
266
267 Snippets: @lsrdir{repeats}
268
269 Internals Reference: @internalsref{VoltaBracket},
270 @internalsref{RepeatedMusic}, @internalsref{VoltaRepeatedMusic},
271 and @internalsref{UnfoldedRepeatedMusic}.
272
273
274 @node Other repeats
275 @subsection Other repeats
276
277 @menu
278 * Tremolo repeats::             
279 * Measure repeats::             
280 @end menu
281
282 @node Tremolo repeats
283 @unnumberedsubsubsec Tremolo repeats
284
285 @cindex tremolo beams
286
287 To place tremolo marks between notes, use @code{\repeat} with
288 tremolo style:
289
290 @lilypond[quote,verbatim,ragged-right]
291 \new Voice \relative c' {
292   \repeat tremolo 8 { c16 d16 }
293   \repeat tremolo 4 { c16 d16 }
294   \repeat tremolo 2 { c16 d16 }
295 }
296 @end lilypond
297
298 The @code{\repeat tremolo} syntax expects exactly two notes within
299 the braces, and the number of repetitions must correspond to a
300 note value that can be expressed with plain or dotted notes.  Thus,
301 @code{\repeat tremolo 7} is valid and produces a double dotted
302 note, but @code{\repeat tremolo 9} is not.
303
304 The duration of the tremolo equals the duration of the
305 braced expression multiplied by the number of repeats:
306 @code{\repeat tremolo 8 @{ c16 d16 @}} gives a whole note tremolo,
307 notated as two whole notes joined by tremolo beams. 
308
309 There are two ways to put tremolo marks on a single note.  The
310 @code{\repeat tremolo} syntax can be used even here, in which case
311 the note should not be surrounded by braces:
312
313 @lilypond[quote,verbatim,ragged-right]
314 \repeat tremolo 4 c'16
315 @end lilypond
316
317 @cindex tremolo marks
318 @funindex tremoloFlags
319
320 The same output can be obtained by adding
321 @q{@code{:}[@var{number}]} after the note.  The number indicates
322 the duration of the subdivision, and it must be at least 8.  A
323 @var{number} value of 8 gives one line across the note stem.  If
324 the length is omitted, the last value (stored in
325 @code{tremoloFlags}) is used
326
327 @lilypond[quote,ragged-right,verbatim,fragment]
328 c'2:8 c':32 | c': c': |
329 @end lilypond
330
331
332 @refbugs
333
334
335 Tremolos entered with @q{@code{:}[@var{number}]} do not carry over
336 into the MIDI output.
337
338
339 @seealso
340
341 Notation Reference: @ref{Tremolo repeats}.
342
343 Internals Reference: @internalsref{Beam},
344 @internalsref{StemTremolo}.
345
346 Snippets: @lsrdir{repeats}
347
348 Elsewhere: @internalsref{StemTremolo}.
349
350
351 @node Measure repeats
352 @unnumberedsubsubsec Measure repeats
353
354 @cindex percent repeats
355 @cindex measure repeats
356
357 A note pattern can be repeated with the @code{\repeat percent
358 @var{number}} syntax.  The music is printed once, and the pattern
359 is replaced with a special sign.  Patterns of one and two measures
360 are replaced by percent-like signs, patterns that divide the
361 measure length are replaced by slashes.  Percent repeats must be
362 declared within a @code{Voice} context.
363
364 @lilypond[quote,verbatim,ragged-right]
365 \new Voice \relative c' {
366   \repeat percent 4 { c4 }
367   \repeat percent 2 { c2 es2 f4 fis4 g4 c4 }
368 }
369 @end lilypond
370
371 Measure repeats of more than two measures get a counter if you
372 switch on the @code{countPercentRepeats} property:
373
374 @lilypond[relative=2,fragment,quote,verbatim,ragged-right]
375 \new Voice {
376   \set countPercentRepeats = ##t
377   \repeat percent 4 { c1 }
378 }
379 @end lilypond
380
381
382 Isolated percents can also be printed.  This is done by entering a
383 multi-measure rest with a different print function:
384
385 @lilypond[fragment,verbatim,quote]
386 \override MultiMeasureRest #'stencil
387   = #ly:multi-measure-rest::percent
388 R1
389 @end lilypond
390
391
392
393
394 @seealso
395
396 Snippets: @lsrdir{repeats}
397
398 Internals Reference: @internalsref{RepeatSlash},
399 @internalsref{PercentRepeat}, @internalsref{DoublePercentRepeat},
400 @internalsref{DoublePercentRepeatCounter},
401 @internalsref{PercentRepeatCounter},
402 @internalsref{PercentRepeatedMusic}.
403
404
405
406