]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/basic-notation.itely
Split Expressive marks.
[lilypond.git] / Documentation / user / basic-notation.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond.tely
3 @ignore
4     Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
5
6     When revising a translation, copy the HEAD committish of the
7     version that you are working on.  See TRANSLATION for details.
8 @end ignore
9
10
11 @c A menu is needed before every deeper *section nesting of @node's; run
12 @c     M-x texinfo-all-menus-update
13 @c to automatically fill in these menus before saving changes
14
15 @node Basic notation
16 @chapter Basic notation
17
18 This chapter explains how to use basic notation features.
19
20 @menu
21 * Polyphony::                   
22 * Staff notation::              
23 * Connecting notes::            
24 * Expressive marks old::        
25 * Repeats::                     
26 @end menu
27
28
29
30 @node Polyphony
31 @section Polyphony
32
33 Polyphony in music refers to having more than one voice occurring in
34 a piece of music.  Polyphony in LilyPond refers to having more than
35 one voice on the same staff.
36
37 @menu
38 * Chords::                      
39 * Stems::                       
40 * Basic polyphony::             
41 * Explicitly instantiating voices::  
42 * Collision Resolution::        
43 @end menu
44
45
46 @anchor{Chords}
47 @unnumberedsubsubsec Chords
48
49 @cindex Chords
50
51 A chord is formed by a enclosing a set of pitches between @code{<}
52 and @code{>}.  A chord may be followed by a duration, and a set of
53 articulations, just like simple notes
54
55 @lilypond[verbatim,ragged-right,fragment,quote,relative=1]
56 <c e g>4 <c>8
57 @end lilypond
58
59 For more information about chords, see @ref{Chord names}.
60
61
62 @c  I don't like having this here, but I can't think of
63 @c  anywhere else to put it.  :(   -gp
64 @anchor{Stems}
65 @unnumberedsubsubsec Stems
66
67 Whenever a note is found, a @internalsref{Stem} object is created
68 automatically.  For whole notes and rests, they are also created but
69 made invisible.
70
71 @refcommands
72
73 @funindex \stemUp
74 @code{\stemUp},
75 @funindex \stemDown
76 @code{\stemDown},
77 @funindex \stemNeutral
78 @code{\stemNeutral}.
79
80
81 @commonprop
82
83 To change the direction of stems in the middle of the staff, use
84
85 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
86 a4 b c b
87 \override Stem #'neutral-direction = #up
88 a4 b c b
89 \override Stem #'neutral-direction = #down
90 a4 b c b
91 @end lilypond
92
93
94 @anchor{Basic polyphony}
95 @unnumberedsubsubsec Basic polyphony
96
97 @cindex polyphony
98
99 The easiest way to enter fragments with more than one voice on a staff
100 is to enter each voice as a sequence (with @code{@{...@}}), and combine
101 them simultaneously, separating the voices with @code{\\}
102
103 @funindex \\
104
105 @lilypond[quote,verbatim,fragment]
106 \new Staff \relative c' {
107   c16 d e f
108   <<
109     { g4 f e | d2 e2 } \\
110     { r8 e4 d c8 ~ | c b16 a b8 g ~ g2 } \\
111     { s2. | s4 b4 c2 }
112   >>
113 }
114 @end lilypond
115
116 The separator causes @internalsref{Voice} contexts@footnote{Polyphonic
117 voices are sometimes called @q{layers} in other notation packages}
118 @cindex layers
119 to be instantiated.  They bear the names @code{"1"}, @code{"2"}, etc.  In
120 each of these contexts, vertical direction of slurs, stems, etc., is set
121 appropriately.
122
123 These voices are all separate from the voice that contains the notes just
124 outside the @code{<< \\ >>} construct.  This should be noted when making
125 changes at the voice level.  This also means that slurs and ties cannot go
126 into or out of a @code{<< \\ >>} construct.  Conversely, parallel voices
127 from separate @code{<< \\ >>} constructs on the same staff are the
128 same voice.  Here is the same example, with different noteheads and
129 colors for each
130 voice.  Note that the change to the note-head style in the main voice does
131 not affect
132 the inside of the @code{<< \\ >>} constructs.  Also, the change to the
133 second
134 voice in the first @code{<< \\ >>} construct is effective in the second
135 @code{<< \\ >>}, and the voice is tied across the two constructs.
136
137 @cindex note heads, styles
138
139 @lilypond[quote,verbatim,fragment]
140 \new Staff \relative c' {
141   \override NoteHead #'style = #'cross
142   \override NoteHead #'color = #red
143   c16 d e f
144   <<
145     { g4 f e } \\
146     { \override NoteHead #'style = #'triangle
147       \override NoteHead #'color = #blue
148     r8 e4 d c8 ~ }
149   >> |
150   <<
151     { d2 e2 } \\
152     { c8 b16 a b8 g ~ g2 } \\
153     { \override NoteHead #'style = #'slash 
154       \override NoteHead #'color = #green
155       s4 b4 c2 }
156   >>
157 }
158 @end lilypond
159
160 Polyphony does not change the relationship of notes within a
161 @code{\relative @{ @}} block.  Each note is calculated relative
162 to the note immediately preceding it.
163
164 @example
165 \relative @{ noteA << noteB \\ noteC >> noteD @}
166 @end example
167
168 @code{noteC} is relative to @code{noteB}, not @code{noteA};
169 @code{noteD} is relative to @code{noteC}, not @code{noteB} or
170 @code{noteA}.
171
172
173 @anchor{Explicitly instantiating voices}
174 @unnumberedsubsubsec Explicitly instantiating voices
175
176 @internalsref{Voice} contexts can also be instantiated manually
177 inside a @code{<< >>} block to create polyphonic music, using
178 @code{\voiceOne}, up to @code{\voiceFour} to assign stem directions
179 and a horizontal shift for each part.
180
181 Specifically,
182 @example
183 << \upper \\ \lower >>
184 @end example
185
186 @noindent
187 is equivalent to
188
189 @example
190 <<
191   \new Voice = "1" @{ \voiceOne \upper @}
192   \new Voice = "2" @{ \voiceTwo \lower @}
193 >>
194 @end example
195
196 The @code{\voiceXXX} commands set the direction of stems, slurs, ties,
197 articulations, text annotations, augmentation dots of dotted
198 notes, and fingerings.  @code{\voiceOne} and @code{\voiceThree} make
199 these objects point upwards, while @code{\voiceTwo} and @code{\voiceFour}
200 make them point downwards.
201 The command @code{\oneVoice} will revert back to the normal setting.
202
203 An expression that appears directly inside a @code{<< >>} belongs to
204 the main voice.  This is useful when extra voices appear while the main
205 voice is playing.  Here is a more correct rendition of the example from
206 the previous section.  The crossed colored noteheads demonstrate that the main
207 melody is now in a single voice context.
208
209 @lilypond[quote,ragged-right,verbatim]
210 \new Staff \relative c' {
211   \override NoteHead #'style = #'cross
212   \override NoteHead #'color = #red
213   c16 d e f
214   \voiceOne
215   <<
216     { g4 f e | d2 e2 }
217     \new Voice="1" { \voiceTwo
218       r8 e4 d c8 ~ | c8 b16 a b8 g ~ g2
219       \oneVoice
220     }
221     \new Voice { \voiceThree
222       s2. | s4 b4 c2
223       \oneVoice
224     }
225   >>
226   \oneVoice
227 }
228 @end lilypond
229
230 The correct definition of the voices allows the melody to be slurred.
231 @lilypond[quote,ragged-right,verbatim]
232 \new Staff \relative c' {
233   c16^( d e f
234   \voiceOne
235   <<
236     { g4 f e | d2 e2) }
237     \context Voice="1" { \voiceTwo
238       r8 e4 d c8 ~ | c8 b16 a b8 g ~ g2
239       \oneVoice
240     }
241     \new Voice { \voiceThree
242       s2. s4 b4 c2
243       \oneVoice
244     }
245   >>
246   \oneVoice
247 }
248 @end lilypond
249
250 Avoiding the @code{\\} separator also allows nesting polyphony
251 constructs, which in some case might be a more natural way to typeset
252 the music.
253
254 @lilypond[quote,ragged-right,verbatim]
255 \new Staff \relative c' {
256   c16^( d e f
257   \voiceOne
258   <<
259     { g4 f e | d2 e2) }
260     \context Voice="1" { \voiceTwo
261       r8 e4 d c8 ~ |
262       <<
263         {c8 b16 a b8 g ~ g2}
264         \new Voice { \voiceThree
265           s4 b4 c2
266           \oneVoice
267         }
268       >>
269     \oneVoice
270     }
271   >>
272   \oneVoice
273 }
274 @end lilypond
275
276 In some instances of complex polyphonic music, you may need additional
277 voices to avoid collisions between notes.  Additional voices are added
278 by defining an identifier, as shown below:
279
280 @lilypond[quote,verbatim,ragged-right,relative=2]
281 voiceFive = #(context-spec-music (make-voice-props-set 4) 'Voice)
282
283 \relative c''' <<
284   { \voiceOne g4 ~  \stemDown g32[ f( es d c b a b64 )g] } \\
285   { \voiceThree  b4} \\
286   { \voiceFive d,} \\
287   { \voiceTwo g,}
288 >>
289 @end lilypond
290
291
292 @anchor{Collision Resolution}
293 @unnumberedsubsubsec Collision Resolution
294
295 Normally, note heads with a different number of dots are not merged, but
296 when the object property @code{merge-differently-dotted} is set in
297 the @internalsref{NoteCollision} object, they are merged:
298
299 @lilypond[quote,verbatim,fragment,ragged-right,relative=2]
300 \new Voice << {
301   g8 g8
302   \override Staff.NoteCollision
303     #'merge-differently-dotted = ##t
304   g8 g8
305 } \\ { g8.[ f16] g8.[ f16] } >>
306 @end lilypond
307
308 Similarly, you can merge half note heads with eighth notes, by setting
309 @code{merge-differently-headed}:
310
311 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
312 \new Voice << {
313   c8 c4.
314   \override Staff.NoteCollision
315     #'merge-differently-headed = ##t
316 c8 c4. } \\ { c2 c2 } >>
317 @end lilypond
318
319 @noindent
320 @code{merge-differently-headed} and @code{merge-differently-dotted}
321 only apply to opposing stem directions (ie. Voice 1 & 2).
322
323 LilyPond also vertically shifts rests that are opposite of a stem,
324 for example
325
326 @lilypond[quote,ragged-right,fragment,verbatim]
327 \new Voice << c''4 \\ r4 >>
328 @end lilypond
329
330 If three or more notes line up in the same column,
331 @code{merge-differently-headed} cannot
332 successfully complete the merge of the two notes that should be merged.
333 To allow the merge to work properly, apply a @code{\shift} to the note that
334 should not be merged.  In the first measure of following example,
335 @code{merge-differently-headed} does not work (the half-note head is
336 solid).  In the second measure, @code{\shiftOn} is applied to move the
337 top @code{g} out of the column, and @code{merge-differently-headed}
338 works properly.
339
340 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
341 \override Staff.NoteCollision #'merge-differently-headed = ##t
342 <<
343   { d=''2 g2 } \\
344   { \oneVoice d=''8 c8 r4 e,8 c'8 r4 } \\
345   { \voiceFour e,,2 e'2}
346 >>
347 <<
348   { d'=''2 \shiftOn g2 } \\ 
349   { \oneVoice d=''8 c8 r4 e,8 c'8 r4 } \\
350   { \voiceFour e,,2 e'2}
351 >>
352 @end lilypond
353
354
355 @refcommands
356
357 @funindex \oneVoice
358 @code{\oneVoice},
359 @funindex \voiceOne
360 @code{\voiceOne},
361 @funindex \voiceTwo
362 @code{\voiceTwo},
363 @funindex \voiceThree
364 @code{\voiceThree},
365 @funindex \voiceFour
366 @code{\voiceFour}.
367
368 @funindex \shiftOn
369 @code{\shiftOn},
370 @funindex \shiftOnn
371 @code{\shiftOnn},
372 @funindex \shiftOnnn
373 @code{\shiftOnnn},
374 @funindex \shiftOff
375 @code{\shiftOff}: these commands specify the
376 degree to which chords of the current voice should be shifted.
377 The outer voices (normally: voice one and
378 two) have @code{\shiftOff}, while the inner voices (three and four)
379 have @code{\shiftOn}.  @code{\shiftOnn} and @code{\shiftOnnn} define
380 further shift levels.
381
382 When LilyPond cannot cope, the @code{force-hshift}
383 property of the @internalsref{NoteColumn} object and pitched rests can
384 be used to override typesetting decisions.
385
386 @lilypond[quote,verbatim,ragged-right]
387 \relative <<
388 {
389   <d g>
390   <d g>
391 } \\ {
392   <b f'>
393   \once \override NoteColumn #'force-hshift = #1.7
394   <b f'>
395 } >>
396 @end lilypond
397
398
399 @seealso
400
401 Program reference: the objects responsible for resolving collisions are
402 @internalsref{NoteCollision} and @internalsref{RestCollision}.
403
404
405 @refbugs
406
407 When using @code{merge-differently-headed} with an upstem eighth or a
408 shorter note, and a downstem half note, the eighth note gets the wrong
409 offset.
410
411 There is no support for clusters where the same note occurs with
412 different accidentals in the same chord.  In this case, it is
413 recommended to use enharmonic transcription, or to use special cluster
414 notation (see @ref{Clusters}).
415
416
417
418 @node Staff notation
419 @section Staff notation
420
421 @cindex Staff notation
422
423 This section describes music notation that occurs on staff level,
424 such as key signatures, clefs and time signatures.
425
426 @menu
427 * Clef::                        
428 * Key signature::               
429 * Time signature::              
430 * Bar lines::                   
431 * Unmetered music::             
432 * System start delimiters::     
433 * Staff symbol::                
434 * Writing music in parallel::   
435 @end menu
436
437
438 @anchor{System start delimiters}
439 @unnumberedsubsubsec System start delimiters
440
441 @cindex start of system
442 @cindex Staff, multiple
443 @cindex bracket, vertical
444 @cindex brace, vertical
445 @cindex grand staff
446 @cindex staff group
447 @cindex staff, choir
448
449 Many scores consist of more than one staff.  These staves can be
450 joined in four different ways
451
452 @itemize @bullet
453 @item The group is started with a brace at the left, and bar lines are
454 connected.  This is done with the @internalsref{GrandStaff} context.
455
456 @lilypond[verbatim,ragged-right,quote]
457 \new GrandStaff
458 \relative <<
459   \new Staff { c1 c }
460   \new Staff { c c }
461 >>
462 @end lilypond
463
464 @item The group is started with a bracket, and bar lines are connected.
465 This is done with the
466 @internalsref{StaffGroup} context
467
468 @lilypond[verbatim,ragged-right,quote]
469 \new StaffGroup
470 \relative <<
471   \new Staff { c1 c }
472   \new Staff { c c }
473 >>
474 @end lilypond
475
476 @item The group is started with a bracket, but bar lines are not
477 connected.  This is done with the @internalsref{ChoirStaff} context.
478
479 @lilypond[verbatim,ragged-right,quote]
480 \new ChoirStaff
481 \relative <<
482   \new Staff { c1 c }
483   \new Staff { c c }
484 >>
485 @end lilypond
486
487 @item The group is started with a vertical line.  Bar lines are not
488 connected.  This is the default for the score.
489
490 @lilypond[verbatim,ragged-right,quote]
491 \relative <<
492   \new Staff { c1 c }
493   \new Staff { c c }
494 >>
495 @end lilypond
496 @end itemize
497
498
499 @seealso
500
501 The bar lines at the start of each system are
502 @internalsref{SystemStartBar}, @internalsref{SystemStartBrace}, and
503 @internalsref{SystemStartBracket}.  Only one of these types is created
504 in every context, and that type is determined by the property
505 @code{systemStartDelimiter}.
506
507
508 @commonprop
509
510 System start delimiters may be deeply nested,
511
512 @lilypond[quote,ragged-right,verbatim]
513 \new StaffGroup
514 \relative <<
515   \set StaffGroup.systemStartDelimiterHierarchy
516     = #'(SystemStartSquare (SystemStartBracket a (SystemStartSquare b)) d)
517   \new Staff { c1 }
518   \new Staff { c1 }
519   \new Staff { c1 }
520   \new Staff { c1 }
521   \new Staff { c1 }
522 >>
523 @end lilypond
524
525
526 @anchor{Staff symbol}
527 @unnumberedsubsubsec Staff symbol
528
529 @cindex adjusting staff symbol
530
531 Notes, dynamic signs, etc., are grouped
532 with a set of horizontal lines, called a staff (plural @q{staves}).  In
533 LilyPond, these lines are drawn using a separate layout object called
534 @code{staff symbol}.
535
536 The staff symbol may be tuned in the number, thickness and distance
537 of lines, using properties.  This is demonstrated in the example files
538 @lsr{staff,changing-the-number-of-lines-in-a-staff.ly} and
539 @lsr{staff,changing-the-staff-size.ly}.
540
541 In addition, staves may be started and stopped at will. This is done
542 with @code{\startStaff} and @code{\stopStaff}.
543
544 @lilypond[verbatim,relative=2,fragment]
545 b4 b
546 \override Staff.StaffSymbol #'line-count = 2
547 \stopStaff \startStaff
548 b b
549 \revert Staff.StaffSymbol #'line-count
550 \stopStaff \startStaff
551 b b
552 @end lilypond
553
554 In combination with Frenched staves, this may be used to typeset ossia
555 sections. An example is shown here
556
557 @cindex ossia
558
559 @lilypondfile{ossia.ly}
560
561 @cindex staff lines, setting number of
562 @cindex staff lines, setting thickness of
563 @cindex thickness of staff lines, setting
564 @cindex number of staff lines, setting
565
566 @seealso
567
568 Program reference: @internalsref{StaffSymbol}.
569
570 Examples: @lsrdir{staff}
571
572
573 @anchor{Writing music in parallel}
574 @unnumberedsubsubsec Writing music in parallel
575
576 @cindex Writing music in parallel
577 @cindex Interleaved music
578
579 Music for multiple parts can be interleaved
580
581 @lilypond[quote,fragment,verbatim]
582 \parallelMusic #'(voiceA voiceB) {
583   r8     g'16[ c''] e''[ g' c'' e''] r8     g'16[ c''] e''[ g' c'' e''] |
584   c'2                                c'2                                |
585   r8     a'16[ d''] f''[ a' d'' f''] r8     a'16[ d''] f''[ a' d'' f''] |
586   c'2                                c'2                                |
587 }
588 \new StaffGroup <<
589   \new Staff \new Voice \voiceA
590   \new Staff \new Voice \voiceB
591 >>
592 @end lilypond
593
594 This works quite well for piano music
595
596 @lilypond[quote,verbatim]
597 music = {
598   \key c \major
599   \time 4/4
600   \parallelMusic #'(voiceA voiceB voiceC voiceD) {
601     % Bar 1
602     r8  g'16[ c''] e''[ g' c'' e''] r8  g'16[ c''] e''[ g' c''
603 e''] |
604     c'2                                 c'2 |
605     r8  a16[ d'] f'[ a d' f']       r8  a16[ d'] f'[ a d' f'] |
606     c2                                  c2 |
607
608     % Bar 2
609     a'8 b'      c'' d''    e'' f''    g'' a'' |
610     d'4         d'         d'         d' |
611     c16 d e f   d e f g    e f g a    f g a b |
612     a,4         a,4        a,4        a,4 |
613
614     % Bar 3 ...
615   }
616 }
617
618 \score {
619   \new PianoStaff <<
620     \music
621     \new Staff <<
622       \voiceA \\
623       \voiceB
624     >>
625     \new Staff {
626       \clef bass
627       <<
628         \voiceC \\
629         \voiceD
630       >>
631     }
632   >>
633 }
634 @end lilypond
635
636
637 @node Connecting notes
638 @section Connecting notes
639
640 This section deals with notation that affects groups of notes.
641
642 @menu
643 * Ties::                        
644 * Slurs::                       
645 * Phrasing slurs::              
646 * Laissez vibrer ties::         
647 * Automatic beams::             
648 * Manual beams::                
649 * Grace notes::                 
650 @end menu
651
652
653
654 @node Expressive marks old
655 @section Expressive marks old
656
657 Expressive marks help musicians to bring more to the music than simple
658 notes and rhythms.
659
660 @menu
661 * Articulations::               
662 * Fingering instructions::      
663 * Dynamics::                    
664 * Breath marks::                
665 * Trills::                      
666 * Glissando::                   
667 * Arpeggio::                    
668 * Falls and doits::             
669 @end menu
670
671
672 @anchor{Fingering instructions}
673 @unnumberedsubsubsec Fingering instructions
674
675 @cindex fingering
676 @cindex finger change
677
678 Fingering instructions can be entered using
679 @example
680 @var{note}-@var{digit}
681 @end example
682 For finger changes, use markup texts
683
684 @lilypond[quote,verbatim,ragged-right,fragment,relative=1]
685 c4-1 c-2 c-3 c-4
686 c^\markup { \finger "2 - 3" }
687 @end lilypond
688
689 You can use the thumb-script to indicate that a note should be
690 played with the thumb (e.g., in cello music)
691 @lilypond[quote,verbatim,ragged-right,fragment,relative=2]
692 <a_\thumb a'-3>8 <b_\thumb b'-3>
693 @end lilypond
694
695 Fingerings for chords can also be added to individual notes
696 of the chord by adding them after the pitches
697 @lilypond[quote,verbatim,ragged-right,fragment,relative=2]
698 < c-1 e-2 g-3 b-5 >4
699 @end lilypond
700
701
702 @commonprop
703
704 You may exercise greater control over fingering chords by
705 setting @code{fingeringOrientations}
706
707 @lilypond[quote,verbatim,ragged-right,fragment,relative=1]
708 \set fingeringOrientations = #'(left down)
709 <c-1 es-2 g-4 bes-5 > 4
710 \set fingeringOrientations = #'(up right down)
711 <c-1 es-2 g-4 bes-5 > 4
712 @end lilypond
713
714 Using this feature, it is also possible to put fingering instructions
715 very close to note heads in monophonic music,
716
717 @lilypond[verbatim,ragged-right,quote,fragment]
718 \set fingeringOrientations = #'(right)
719 <es'-2>4
720 @end lilypond
721
722
723 @seealso
724
725 Program reference: @internalsref{Fingering}.
726
727 Examples: @lsr{expressive,fingering-chords.ly}
728
729
730
731 @node Repeats
732 @section Repeats
733
734 Repetition is a central concept in music, and multiple notations exist
735 for repetitions.
736
737 @menu
738 * Repeat types::                
739 * Repeat syntax::               
740 * Repeats and MIDI::            
741 * Manual repeat commands::      
742 * Tremolo repeats::             
743 * Tremolo subdivisions::        
744 * Measure repeats::             
745 @end menu
746
747
748 @anchor{Repeat types}
749 @unnumberedsubsubsec Repeat types
750
751 @cindex repeats
752
753 The following types of repetition are supported
754
755 @table @code
756 @item unfold
757 Repeated music is fully written (played) out.  This is useful when
758 entering repetitious music.  This is the only kind of repeat that
759 is included in MIDI output.
760
761 @item volta
762 Repeats are not written out, but alternative endings (volte) are
763 printed, left to right with brackets.  This is the standard notation
764 for repeats with alternatives.  These are not played in MIDI output by
765 default.
766
767
768 @item tremolo
769 Make tremolo beams.  These are not played in MIDI output by default.
770
771 @item percent
772 Make beat or measure repeats.  These look like percent signs.  These
773 are not played in MIDI output by default.  Percent repeats must be
774 declared within a @code{Voice} context.
775
776 @end table
777
778
779 @anchor{Repeat syntax}
780 @unnumberedsubsubsec Repeat syntax
781
782 @cindex volta
783 @cindex prima volta
784 @cindex seconda volta
785 @funindex \repeat
786
787 LilyPond has one syntactic construct for specifying different types of
788 repeats.  The syntax is
789
790 @example
791 \repeat @var{variant} @var{repeatcount} @var{repeatbody}
792 @end example
793
794 If you have alternative endings, you may add
795 @funindex \alternative
796 @example
797 \alternative @{
798   @var{alternative1}
799   @var{alternative2}
800   @var{alternative3}
801   @dots{}
802 @}
803 @end example
804
805 @noindent
806 where each @var{alternative} is a music expression.  If you do not
807 give enough alternatives for all of the repeats, the first alternative
808 is assumed to be played more than once.
809
810 Standard repeats are used like this
811
812 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
813 c1
814 \repeat volta 2 { c4 d e f }
815 \repeat volta 2 { f e d c }
816 @end lilypond
817
818 With alternative endings
819
820 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
821 c1
822 \repeat volta 2 {c4 d e f}
823 \alternative { {d2 d} {f f,} }
824 @end lilypond
825
826 Repeats with upbeats may be created.
827
828 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
829 \new Staff {
830   \partial 4 e |
831   \repeat volta 4 { c2 d2 | e2 f2 | }
832   \alternative { { g4 g g e } { a a a a | b2. } }
833 }
834 @end lilypond
835
836 @noindent
837 or
838
839 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
840 \new Staff {
841   \partial 4 
842   \repeat volta 4 { e | c2 d2 | e2 f2 | }
843   \alternative { { \partial 4*3 g4 g g } { a a a a | b2. } }
844 }
845 @end lilypond
846
847
848
849 @funindex \repeatTie
850
851 Ties may be added to a second ending,
852
853 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
854 c1
855 \repeat volta 2 {c4 d e f ~ }
856 \alternative { {f2 d} {f\repeatTie f,} }
857 @end lilypond
858
859 It is possible to shorten volta brackets
860 by setting @code{voltaSpannerDuration}.  In the next example, the
861 bracket only lasts one measure, which is a duration of 3/4.
862
863 @lilypond[verbatim,ragged-right,quote]
864 \relative c''{
865   \time 3/4
866   c c c
867   \set Score.voltaSpannerDuration = #(ly:make-moment 3 4)
868   \repeat volta 5 { d d d }
869   \alternative { { e e e f f f }
870   { g g g } }
871 }
872 @end lilypond
873
874 If you want to start a repeat at the beginning of a line and have a
875 double bar at the end of the previous line, use
876 @example
877 @dots{} \bar "||:" \break 
878 \repeat volta 2 @{ @dots{} 
879 @end example
880 see @ref{Bar lines} for more information.
881
882 @seealso
883
884 Program reference: @internalsref{VoltaBracket},
885 @internalsref{RepeatedMusic},
886 @internalsref{VoltaRepeatedMusic}, and
887 @internalsref{UnfoldedRepeatedMusic}.
888
889 Examples:
890
891 Brackets for the repeat are normally only printed over the topmost
892 staff.  This can be adjusted by moving @code{Volta_engraver} to the
893 Staff context where you want the brackets to appear;
894 see @ref{Modifying context plug-ins} and
895
896 @lsr{repeats,volta@/-multi@/-staff@/.ly}.
897
898
899 @refbugs
900
901 @cindex repeat, ambiguous
902
903 A nested repeat like
904
905 @example
906 \repeat @dots{}
907 \repeat @dots{}
908 \alternative
909 @end example
910
911 @noindent
912 is ambiguous, since it is is not clear to which @code{\repeat} the
913 @code{\alternative} belongs.  This ambiguity is resolved by always
914 having the @code{\alternative} belong to the inner @code{\repeat}.
915 For clarity, it is advisable to use braces in such situations.
916
917 Timing information is not remembered at the start of an alternative,
918 so after a repeat timing information must be reset by hand; for
919 example, by setting @code{Score.measurePosition} or entering
920 @code{\partial}.  Similarly, slurs or ties are also not repeated.
921
922
923 @anchor{Repeats and MIDI}
924 @unnumberedsubsubsec Repeats and MIDI
925
926 @cindex expanding repeats
927 @funindex \unfoldRepeats
928
929 With a little bit of tweaking, all types of repeats can be present
930 in the MIDI output.  This is achieved by applying the
931 @code{\unfoldRepeats} music function.  This function changes all
932 repeats to unfold repeats.
933
934 @lilypond[quote,verbatim,fragment,line-width=8.0\cm]
935 \unfoldRepeats {
936   \repeat tremolo 8 {c'32 e' }
937   \repeat percent 2 { c''8 d'' }
938   \repeat volta 2 {c'4 d' e' f'}
939   \alternative {
940     { g' a' a' g' }
941     {f' e' d' c' }
942   }
943 }
944 \bar "|."
945 @end lilypond
946
947 When creating a score file using @code{\unfoldRepeats} for MIDI,
948 it is necessary to make two @code{\score} blocks: one for MIDI (with
949 unfolded repeats) and one for notation (with volta, tremolo, and
950 percent repeats).  For example,
951
952 @example
953 \score @{
954   @var{..music..}
955   \layout @{ .. @}
956 @}
957 \score @{
958   \unfoldRepeats @var{..music..}
959   \midi @{ .. @}
960 @}
961 @end example
962
963
964 @anchor{Manual repeat commands}
965 @unnumberedsubsubsec Manual repeat commands
966
967 @funindex repeatCommands
968
969 The property @code{repeatCommands} can be used to control the layout of
970 repeats.  Its value is a Scheme list of repeat commands.
971
972 @table @asis
973 @item @code{start-repeat}
974 Print a @code{|:} bar line.
975
976 @item @code{end-repeat}
977 Print a @code{:|} bar line.
978
979 @item @code{(volta @var{text})}
980 Print a volta bracket saying @var{text}: The text can be specified as
981 a text string or as a markup text, see @ref{Text markup}.  Do not
982 forget to change the font, as the default number font does not contain
983 alphabetic characters;
984
985 @item @code{(volta #f)}
986 Stop a running volta bracket.
987 @end table
988
989 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
990 c4
991   \set Score.repeatCommands = #'((volta "93") end-repeat)
992 c4 c4
993   \set Score.repeatCommands = #'((volta #f))
994 c4 c4
995 @end lilypond
996
997
998 @seealso
999
1000 Program reference: @internalsref{VoltaBracket},
1001 @internalsref{RepeatedMusic},
1002 @internalsref{VoltaRepeatedMusic}, and
1003 @internalsref{UnfoldedRepeatedMusic}.
1004
1005
1006 @anchor{Tremolo repeats}
1007 @unnumberedsubsubsec Tremolo repeats
1008
1009 @cindex tremolo beams
1010
1011 To place tremolo marks between notes, use @code{\repeat} with tremolo
1012 style
1013 @lilypond[quote,verbatim,ragged-right]
1014 \new Voice \relative c' {
1015   \repeat tremolo 8 { c16 d16 }
1016   \repeat tremolo 4 { c16 d16 }
1017   \repeat tremolo 2 { c16 d16 }
1018 }
1019 @end lilypond
1020
1021 Tremolo marks can also be put on a single note.  In this case, the
1022 note should not be surrounded by braces.
1023 @lilypond[quote,verbatim,ragged-right]
1024 \repeat tremolo 4 c'16
1025 @end lilypond
1026
1027 Similar output is obtained using the tremolo subdivision, described in
1028 @ref{Tremolo subdivisions}.
1029
1030
1031 @seealso
1032
1033 In this manual: @ref{Tremolo subdivisions}, @ref{Repeats}.
1034
1035 Program reference: @internalsref{Beam}, @internalsref{StemTremolo}.
1036
1037
1038 @anchor{Tremolo subdivisions}
1039 @unnumberedsubsubsec Tremolo subdivisions
1040
1041 @cindex tremolo marks
1042 @funindex tremoloFlags
1043
1044 Tremolo marks can be printed on a single note by adding
1045 @q{@code{:}[@var{number}]} after the note.  The number indicates the
1046 duration of the subdivision, and it must be at least 8.  A
1047 @var{length} value of 8 gives one line across the note stem.  If the
1048 length is omitted, the last value (stored in @code{tremoloFlags}) is
1049 used
1050
1051 @lilypond[quote,ragged-right,verbatim,fragment]
1052 c'2:8 c':32 | c': c': |
1053 @end lilypond
1054
1055
1056 @refbugs
1057
1058 Tremolos entered in this way do not carry over into the MIDI output.
1059
1060
1061 @seealso
1062
1063 In this manual: @ref{Tremolo repeats}.
1064
1065 Elsewhere: @internalsref{StemTremolo}.
1066
1067
1068 @anchor{Measure repeats}
1069 @unnumberedsubsubsec Measure repeats
1070
1071 @cindex percent repeats
1072 @cindex measure repeats
1073
1074 In the @code{percent} style, a note pattern can be repeated.  It is
1075 printed once, and then the pattern is replaced with a special sign.
1076 Patterns of one and two measures are replaced by percent-like signs,
1077 patterns that divide the measure length are replaced by slashes.
1078 Percent repeats must be declared within a @code{Voice} context.
1079
1080 @lilypond[quote,verbatim,ragged-right]
1081 \new Voice \relative c' {
1082   \repeat percent 4 { c4 }
1083   \repeat percent 2 { c2 es2 f4 fis4 g4 c4 }
1084 }
1085 @end lilypond
1086
1087 Measure repeats of more than 2 measures get a counter, if you switch
1088 on the @code{countPercentRepeats} property,
1089
1090 @lilypond[relative=2,fragment,quote,verbatim,ragged-right]
1091 \new Voice {
1092 \set countPercentRepeats = ##t
1093   \repeat percent 4 { c1 }
1094 }
1095 @end lilypond
1096
1097
1098
1099 Isolated percents can also be printed. This is done by putting a
1100 multi-measure rest with a different print function,
1101
1102 @lilypond[fragment,verbatim,quote]
1103 \override MultiMeasureRest #'stencil
1104   = #ly:multi-measure-rest::percent
1105 R1
1106 @end lilypond
1107
1108
1109
1110
1111 @seealso
1112
1113 Program reference: @internalsref{RepeatSlash},
1114 @internalsref{PercentRepeat}, @internalsref{DoublePercentRepeat},
1115 @internalsref{DoublePercentRepeatCounter},
1116 @internalsref{PercentRepeatCounter},
1117 @internalsref{PercentRepeatedMusic}.
1118
1119
1120