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