]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/basic-notation.itely
Remainder of info from NEWS.
[lilypond.git] / Documentation / user / basic-notation.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond.tely
3
4 @c A menu is needed before every deeper *section nesting of @node's; run
5 @c     M-x texinfo-all-menus-update
6 @c to automatically fill in these menus before saving changes
7
8 @node Basic notation
9 @chapter Basic notation
10
11 This chapter explains how to use basic notation features.
12
13 @menu
14 * Pitches::                     
15 * Rhythms::                     
16 * Multiple notes at once::      
17 * Staff notation::              
18 * Connecting notes::            
19 * Expressive marks::            
20 * Repeats::                     
21 @end menu
22
23
24
25 @node Pitches
26 @section Pitches
27
28 This section discusses how to specify the pitch of notes.
29
30 @menu
31 * Normal pitches::              
32 * Accidentals::                 
33 * Cautionary accidentals::      
34 * Micro tones::                 
35 * Notes names in other languages::  
36 * Relative octaves::            
37 * Octave check::                
38 * Transpose::                   
39 * Rests::                       
40 * Skips::                       
41 @end menu
42
43
44 @node Normal pitches
45 @subsection Normal pitches
46
47 @cindex Pitch names
48 @cindex pitches
49
50 A pitch name is specified using lowercase letters @code{a} through @code{g}.
51 An ascending C-major scale is engraved with
52
53 @lilypond[quote,fragment,verbatim,ragged-right]
54 \clef bass
55 c d e f g a b c'
56 @end lilypond
57
58 The note name @code{c} is engraved one octave below middle C.
59
60 @lilypond[quote,fragment,verbatim,ragged-right]
61 \clef treble
62 c1
63 \clef bass
64 c1
65 @end lilypond
66
67 @funindex '
68 @funindex ,
69
70 The optional octave specification takes the form of a series of
71 single quote (`@code{'}') characters or a series of comma
72 (`@code{,}') characters.  Each @code{'} raises the pitch by one
73 octave; each @code{,} lowers the pitch by an octave.
74
75 @lilypond[quote,ragged-right,fragment,verbatim]
76 \clef treble
77 c' c'' e' g d'' d' d c
78 \clef bass
79 c, c,, e, g d,, d, d c
80 @end lilypond
81
82 An alternate method may be used to declare which octave to
83 engrave a pitch; this method does not require as many
84 octave specifications (@code{'} and @code{,}).  See
85 @ref{Relative octaves}.
86
87
88 @node Accidentals
89 @subsection Accidentals
90
91 @cindex note names, Dutch
92 @cindex note names, default
93
94 A sharp is formed by adding @code{-is} to the end of a pitch name and
95 a flat is formed by adding @code{-es}.  Double sharps and double flats
96 are obtained by adding @code{-isis} or @code{-eses} to a note name.
97
98 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
99 a2 ais a aes
100 a2 aisis a aeses
101 @end lilypond
102
103 @noindent
104 These are the Dutch note names.  In Dutch, @code{aes} is contracted to
105 @code{as}, but both forms are accepted.  Similarly, both
106 @code{es} and @code{ees} are accepted
107
108 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
109 a2 as e es
110 @end lilypond
111
112 A natural will cancel the effect of an accidental or key signature.
113 However, naturals are not encoded into the note name syntax with a
114 suffix; a natural pitch is shown as a simple note name
115
116 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
117 a4 aes a2
118 @end lilypond
119
120 The input @code{d e f} is interpreted as ``print a D-natural,
121 E-natural, and an F-natural,'' regardless of the key
122 signature.  For more information about the distinction between
123 musical content and the presentation of that content, see
124 @ref{More about pitches}.
125
126 @lilypond[fragment,quote,ragged-right,verbatim,relative]
127 \key d \major
128 d e f g
129 d e fis g
130 @end lilypond
131
132
133 @commonprop
134
135 In accordance with standard typesetting rules, a natural sign is printed
136 before a sharp or flat if a previous accidental needs to be
137 cancelled.  To change this behavior, use
138 @code{\set Staff.extraNatural = ##f}
139
140 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
141 ceses4 ces cis c
142 \set Staff.extraNatural = ##f
143 ceses4 ces cis c
144 @end lilypond
145
146
147 @seealso
148
149 Program reference: @internalsref{LedgerLineSpanner},
150 @internalsref{NoteHead}.
151
152
153 @node Cautionary accidentals
154 @subsection Cautionary accidentals
155
156 @cindex accidental, reminder
157 @cindex accidental, cautionary
158 @cindex accidental, parenthesized
159 @cindex reminder accidental
160 @funindex ?
161 @cindex cautionary accidental
162 @cindex parenthesized accidental
163 @funindex !
164
165 Normally accidentals are printed automatically, but you may also
166 print them manually.  A reminder accidental
167 can be forced by adding an exclamation mark @code{!}
168 after the pitch.  A cautionary accidental
169 (i.e., an accidental within parentheses) can be obtained by adding the
170 question mark `@code{?}' after the pitch.  These extra accidentals
171 can be used to produce natural signs, too.
172
173 @lilypond[quote,ragged-right,fragment,verbatim,relative=1]
174 cis cis cis! cis? c c? c! c
175 @end lilypond
176
177
178 @seealso
179
180 The automatic production of accidentals can be tuned in many
181 ways.  For more information, see @ref{Automatic accidentals}.
182
183
184 @node Micro tones
185 @subsection Micro tones
186
187 @cindex quarter tones
188 @cindex semi-flats, semi-sharps
189
190 Half-flats and half-sharps are formed by adding @code{-eh} and
191 @code{-ih}; the following is a series of Cs with increasing pitches
192
193 @lilypond[verbatim,ragged-right,quote,relative=2,fragment]
194 \set Staff.extraNatural = ##f
195 ceseh ceh cih cisih
196 @end lilypond
197
198 Micro tones are also exported to the MIDI file.
199
200
201 @refbugs
202
203 There are no generally accepted standards for denoting
204 three-quarter flats, so LilyPond's symbol does not conform to any
205 standard.
206
207
208 @node Notes names in other languages
209 @subsection Notes names in other languages
210
211 There are predefined sets of note names for various other languages.
212 To use them, include the language specific init file.  For
213 example, add @code{\include "english.ly"} to the top of the input
214 file.  The available language files
215 and the note names they define are
216
217 @c  what about micro-tunes, double-sharps, and double-flats?  add
218 @c  more columns to the table?
219 @c  Oh, and should this be made into a multitable?
220 @cindex note names, other languages
221 @example
222                         Note Names               sharp       flat
223 nederlands.ly  c   d   e   f   g   a   bes b   -is         -es
224 english.ly     c   d   e   f   g   a   bf  b   -s/-sharp   -f/-flat
225                                                -x (double)
226 deutsch.ly     c   d   e   f   g   a   b   h   -is         -es
227 norsk.ly       c   d   e   f   g   a   b   h   -iss/-is    -ess/-es
228 svenska.ly     c   d   e   f   g   a   b   h   -iss        -ess
229 italiano.ly    do  re  mi  fa  sol la  sib si  -d          -b
230 catalan.ly     do  re  mi  fa  sol la  sib si  -d/-s       -b
231 espanol.ly     do  re  mi  fa  sol la  sib si  -s          -b
232 @end example
233
234
235 @node Relative octaves
236 @subsection Relative octaves
237
238 @cindex Relative
239 @cindex Relative octave specification
240 @funindex \relative
241
242 Octaves are specified by adding @code{'} and @code{,} to pitch names.
243 When you copy existing music, it is easy to accidentally put a pitch
244 in the wrong octave and hard to find such an error.  The relative
245 octave mode prevents these errors by making the mistakes much
246 larger: a single error puts the rest of the piece off by one octave
247
248 @example
249 \relative @var{startpitch} @var{musicexpr}
250 @end example
251
252 @noindent
253 or
254
255 @example
256 \relative @var{musicexpr}
257 @end example
258
259 @noindent
260 @code{c'} is used as the default if no starting pitch is defined.
261
262 The octave of notes that appear in @var{musicexpr} are calculated as
263 follows: if no octave changing marks are used, the basic interval
264 between this and the last note is always taken to be a fourth or
265 less.  This distance is determined without regarding alterations; a
266 @code{fisis} following a @code{ceses} will be put above the
267 @code{ceses}.  In other words, a doubly-augmented fourth is considered
268 a smaller interval than a diminished fifth, even though the
269 doubly-augmented fourth spans seven semitones while the diminished
270 fifth only spans six semitones.
271
272 The octave changing marks @code{'} and @code{,} can be added to raise
273 or lower the pitch by an extra octave.  Upon entering relative mode,
274 an absolute starting pitch can be specified that will act as the
275 predecessor of the first note of @var{musicexpr}.  If no starting pitch
276 is specified, then middle C is used as a start.
277
278 Here is the relative mode shown in action
279 @lilypond[quote,fragment,ragged-right,verbatim]
280 \relative c'' {
281   b c d c b c bes a
282 }
283 @end lilypond
284
285 Octave changing marks are used for intervals greater than a fourth
286
287 @lilypond[quote,ragged-right,fragment,verbatim]
288 \relative c'' {
289   c g c f, c' a, e''
290 }
291 @end lilypond
292
293 If the preceding item is a chord, the first note of the chord is used
294 to determine the first note of the next chord
295
296 @lilypond[quote,ragged-right,fragment,verbatim]
297 \relative c' {
298   c <c e g>
299   <c' e g>
300   <c, e' g>
301 }
302 @end lilypond
303
304 The pitch after @code{\relative} contains a note name.
305
306 The relative conversion will not affect @code{\transpose},
307 @code{\chordmode} or @code{\relative} sections in its argument.  To use
308 relative within transposed music, an additional @code{\relative} must
309 be placed inside @code{\transpose}.
310
311
312 @node Octave check
313 @subsection Octave check
314
315 @cindex Octave check
316
317 Octave checks make octave errors easier to correct: a note may be
318 followed by @code{=}@var{quotes} which indicates what its absolute
319 octave should be.  In the following example,
320
321 @example
322 \relative c'' @{ c='' b=' d,='' @}
323 @end example
324
325 @noindent
326 the @code{d} will generate a warning, because a @code{d''} is expected
327 (because @code{b'} to @code{d''} is only a third), but a @code{d'} is
328 found.  In the output, the octave is corrected to be a @code{d''} and
329 the next note is calculated relative to @code{d''} instead of @code{d'}.
330
331 There is also an octave check that produces no visible output.  The syntax
332
333 @example
334 \octave @var{pitch}
335 @end example
336
337 This checks that @var{pitch} (without quotes) yields @var{pitch} (with
338 quotes) in @code{\relative} mode compared to the note given in the
339 @code{\relative} command.  If not, a warning is printed, and the
340 octave is corrected.  The @var{pitch} is not printed as a note.
341
342 In the example below, the first check passes without incident, since
343 the @code{e} (in @code{relative} mode) is within a fifth of
344 @code{a'}.  However,
345 the second check produces a warning, since the @code{e} is not within
346 a fifth of @code{b'}.  The warning message is printed, and the octave
347 is adjusted so that the following notes are in the correct octave
348 once again.
349
350 @example
351 \relative c' @{
352   e
353   \octave a'
354   \octave b'
355 @}
356 @end example
357
358
359 The octave of a note following an octave check is determined with
360 respect to the note preceding it.  In the next fragment, the last note
361 is an @code{a'}, above middle C.  That means that the @code{\octave}
362 check passes successfully, so the check could be deleted without changing
363 the output of the piece.
364
365 @lilypond[quote,ragged-right,verbatim,fragment]
366 \relative c' {
367   e
368   \octave b
369   a
370 }
371 @end lilypond
372
373
374 @node Transpose
375 @subsection Transpose
376
377 @cindex Transpose
378 @cindex Transposition of pitches
379 @funindex \transpose
380
381 A music expression can be transposed with @code{\transpose}.  The
382 syntax is
383 @example
384 \transpose @var{from} @var{to} @var{musicexpr}
385 @end example
386
387 This means that @var{musicexpr} is transposed by the interval between
388 the pitches @var{from} and @var{to}: any note with pitch @code{from}
389 is changed to @code{to}.
390
391 For example, consider a piece written in the key of D-major.  If
392 this piece is a little too low for its performer, it can be
393 transposed up to E-major with
394 @example
395 \transpose d e @dots{}
396 @end example
397
398 Consider a part written for violin (a C instrument).  If
399 this part is to be played on the A clarinet (for which an
400 A is notated as a C, and which sounds a minor third lower
401 than notated), the following
402 transposition will produce the appropriate part
403
404 @example
405 \transpose a c @dots{}
406 @end example
407
408 @code{\transpose} distinguishes between enharmonic pitches: both
409 @code{\transpose c cis} or @code{\transpose c des} will transpose up
410 half a tone.  The first version will print sharps and the second
411 version will print flats
412
413 @lilypond[quote,ragged-right,verbatim]
414 mus = { \key d \major cis d fis g }
415 \new Staff {
416   \clef "F" \mus
417   \clef "G"
418   \transpose c g' \mus
419   \transpose c f' \mus
420 }
421 @end lilypond
422
423 @code{\transpose} may also be used to input written notes for a
424 transposing instrument.  Pitches are normally entered into LilyPond
425 in C (or ``concert pitch''), but they may be entered in another
426 key.  For example, when entering music for a B-flat trumpet which
427 begins on concert D, one would write
428
429 @example
430 \transpose c bes @{ e4 @dots{} @}
431 @end example
432
433 To print this music in B-flat again (i.e., producing a trumpet part,
434 instead of a concert pitch conductor's score) you would wrap the
435 existing music with another @code{transpose}
436
437 @example
438 \transpose bes c @{ \transpose c bes @{ e4 @dots{} @} @}
439 @end example
440
441
442 @seealso
443
444 Program reference: @internalsref{TransposedMusic}.
445
446 Example: @inputfileref{input/@/test,smart@/-transpose@/.ly}.
447
448
449 @refbugs
450
451 If you want to use both @code{\transpose} and @code{\relative},
452 you must put @code{\transpose} outside of @code{\relative}, since
453 @code{\relative} will have no effect on music that appears inside a
454 @code{\transpose}.
455
456
457 @node Rests
458 @subsection Rests
459 @cindex Rests
460
461 @funindex \rest
462 @funindex r
463
464 Rests are entered like notes with the note name @code{r}
465
466 @lilypond[fragment,quote,ragged-right,verbatim]
467 r1 r2 r4 r8
468 @end lilypond
469
470 Whole bar rests, centered in middle of the bar,
471 must be done with multi-measure rests.  They can be used for a
472 single bar as well as many bars, and are discussed in
473 @ref{Multi measure rests}.
474
475 To explicitly specify a rest's vertical position, write a note
476 followed by @code{\rest}.  A rest will be placed in the position
477 where the note would appear,
478
479 @lilypond[fragment,quote,ragged-right,verbatim]
480 a'4\rest d'4\rest
481 @end lilypond
482
483 @noindent
484 This makes manual formatting of
485 polyphonic music much easier, since the automatic rest collision
486 formatter will leave these rests alone.
487
488 @seealso
489
490 Program reference: @internalsref{Rest}.
491
492
493 @node Skips
494 @subsection Skips
495
496 @cindex Skip
497 @cindex Invisible rest
498 @cindex Space note
499 @funindex \skip
500 @funindex s
501
502 An invisible rest (also called a `skip') can be entered like a note
503 with note name `@code{s}' or with @code{\skip @var{duration}}
504
505 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
506 a4 a4 s4 a4 \skip 1 a4
507 @end lilypond
508
509 The @code{s} syntax is only available in note mode and chord mode.  In
510 other situations, for example, when entering lyrics, you should use
511 the @code{\skip} command
512
513 @lilypond[quote,ragged-right,verbatim]
514 <<
515   \relative { a'2 a2 }
516   \new Lyrics \lyricmode { \skip 2 bla2 }
517 >>
518 @end lilypond
519
520 The skip command is merely an empty musical placeholder.  It does not
521 produce any output, not even transparent output.
522
523 The @code{s} skip command does create @internalsref{Staff} and
524 @internalsref{Voice} when necessary, similar to note and rest
525 commands.  For example, the following results in an empty staff.
526
527 @lilypond[quote,ragged-right,verbatim]
528 { s4 }
529 @end lilypond
530
531 The fragment @code{@{ \skip 4 @} } would produce an empty page.
532
533 @seealso
534
535 Program reference: @internalsref{SkipMusic}.
536
537
538
539 @node Rhythms
540 @section Rhythms
541
542 This section discusses rhythms, durations, and bars.
543
544 @menu
545 * Durations::                   
546 * Augmentation dots::           
547 * Tuplets::                     
548 * Scaling durations::           
549 * Bar check::                   
550 * Barnumber check::             
551 * Automatic note splitting::    
552 @end menu
553
554
555 @node Durations
556 @subsection Durations
557
558 @cindex duration
559 @funindex \longa
560 @funindex \breve
561 @funindex \maxima
562
563 In Note, Chord, and Lyrics mode, durations are designated by numbers and
564 dots: durations are entered as their reciprocal values.  For example, a
565 quarter note is entered using a @code{4} (since it is a 1/4 note), while
566 a half note is entered using a @code{2} (since it is a 1/2 note).  For
567 notes longer than a whole you must use the @code{\longa} and
568 @code{\breve} commands
569
570 @example
571 c'\breve
572 c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64
573 r\longa r\breve
574 r1 r2 r4 r8 r16 r32 r64 r64
575 @end example
576
577 @lilypond[quote]
578 \score {
579 \relative c'' {
580     a\breve*1/2 \autoBeamOff
581     a1 a2 a4 a8 a16 a32 a64 a64
582    \bar "empty"
583    \break
584     r\longa*1/4 r\breve *1/2
585     r1 r2 r4 r8 r16 r32 r64 r64
586   }
587   \layout {
588     ragged-right = ##t
589     indent=0\mm
590     \context {
591       \Score
592         \remove "Bar_number_engraver"
593     }
594     \context {
595       \Staff
596         \remove "Clef_engraver"
597         \override StaffSymbol #'transparent = ##t
598         \override TimeSignature #'transparent = ##t
599         \override BarLine #'transparent = ##t
600         \consists "Pitch_squash_engraver"
601     }
602   }
603 }
604 @end lilypond
605
606 If the duration is omitted then it is set to the previously entered
607 duration.  The default for the first note is a quarter note.
608
609 @lilypond[quote,ragged-right,verbatim,fragment]
610 { a a a2 a a4 a a1 a }
611 @end lilypond
612
613
614 @node Augmentation dots
615 @subsection Augmentation dots
616
617 @funindex .
618
619 To obtain dotted note lengths, simply add a dot (`@code{.}') to
620 the number.  Double-dotted notes are produced in a similar way.
621
622 @lilypond[quote,ragged-right,fragment,verbatim]
623 a'4 b' c''4. b'8 a'4. b'4.. c''8.
624 @end lilypond
625
626 @refcommands
627
628 Dots are normally moved up to avoid staff lines, except in polyphonic
629 situations.  The following commands may be used to force a particular
630 direction manually
631
632 @funindex \dotsUp
633 @code{\dotsUp},
634 @funindex \dotsDown
635 @code{\dotsDown},
636 @funindex \dotsNeutral
637 @code{\dotsNeutral}.
638
639 @seealso
640
641 Program reference: @internalsref{Dots}, and @internalsref{DotColumn}.
642
643
644 @node Tuplets
645 @subsection Tuplets
646
647 @cindex tuplets
648 @cindex triplets
649 @funindex \times
650
651 Tuplets are made out of a music expression by multiplying all durations
652 with a fraction
653
654 @example
655 \times @var{fraction} @var{musicexpr}
656 @end example
657
658 @noindent
659 The duration of @var{musicexpr} will be multiplied by the fraction.
660 The fraction's denominator will be printed over the notes, optionally
661 with a bracket.  The most common tuplet is the triplet in which 3
662 notes have the length of 2, so the notes are 2/3 of their written
663 length
664
665 @lilypond[quote,ragged-right,fragment,verbatim]
666 g'4 \times 2/3 {c'4 c' c'} d'4 d'4
667 @end lilypond
668
669 Tuplets may be nested, for example,
670
671 @lilypond[fragment,ragged-right,verbatim,relative=2]
672 \override TupletNumber #'text = #tuplet-number::calc-fraction-text
673 \times 4/6 {
674   a4 a
675   \times 3/5 { a a a a a }
676 }
677 @end lilypond
678
679 @refcommands
680
681 @funindex \tupletUp
682 @code{\tupletUp},
683 @funindex \tupletDown
684 @code{\tupletDown},
685 @funindex \tupletNeutral
686 @code{\tupletNeutral}.
687
688
689 @commonprop
690
691 @funindex tupletNumberFormatFunction
692 @cindex tuplet formatting
693
694 The property @code{tupletSpannerDuration} specifies how long each
695 bracket should last.  With this, you can make lots of tuplets while
696 typing @code{\times} only once, thus saving lots of typing.  In the next
697 example, there are two triplets shown, while @code{\times} was only
698 used once
699
700 @lilypond[quote,fragment,relative=2,ragged-right,verbatim]
701 \set tupletSpannerDuration = #(ly:make-moment 1 4)
702 \times 2/3 { c8 c c c c c }
703 @end lilypond
704
705 @noindent
706 For more information about @code{make-moment}, see
707 @ref{Time administration}.
708
709 The format of the number is determined by the property @code{text} in
710 @code{TupletNumber}.  The default prints only the denominator, but if
711 it is set to the function @code{tuplet-number::calc-fraction-text},
712 @var{num}:@var{den} will be printed instead.
713
714 To avoid printing tuplet numbers, use
715
716 @lilypond[quote,fragment,relative=2,ragged-right,verbatim]
717 \times 2/3 { c8 c c } \times 2/3 { c8 c c }
718 \override TupletNumber #'transparent = ##t
719 \times 2/3 { c8 c c } \times 2/3 { c8 c c }
720 @end lilypond
721
722 Tuplet brackets can be made to run to prefatory matter or
723 the next note
724
725 @lilypond[ragged-right]
726 \new RhythmicStaff {
727   \set tupletFullLength = ##t
728   \time 4/4
729   \times 4/5 {
730     c4 c1
731   }
732   \set tupletFullLengthNote = ##t
733   \time 2/4
734   \times 2/3 {
735     c4 c c 
736   }
737   \time 3/4
738   c4 
739 }
740 @end lilypond
741
742
743 @seealso
744
745 Program reference: @internalsref{TupletBracket},
746 @internalsref{TupletNumber}, and @internalsref{TimeScaledMusic}.
747
748 Examples: @inputfileref{input/@/regression,tuplet@/-nest@/.ly}.
749
750
751
752 @node Scaling durations
753 @subsection Scaling durations
754
755 You can alter the length of duration by a fraction @var{N/M}
756 appending `@code{*}@var{N/M}' (or `@code{*}@var{N}' if @var{M=1}).  This
757 will not affect the appearance of the notes or rests produced.
758
759 In the following example, the first three notes take up exactly two
760 beats, but no triplet bracket is printed.
761 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
762 \time 2/4
763 a4*2/3 gis4*2/3 a4*2/3
764 a4 a4 a4*2
765 b16*4 c4
766 @end lilypond
767
768
769 @seealso
770
771 This manual: @ref{Tuplets}
772
773
774 @node Bar check
775 @subsection Bar check
776
777 @cindex Bar check
778 @funindex barCheckSynchronize
779 @funindex |
780
781 Bar checks help detect errors in the durations.  A bar check is
782 entered using the bar symbol, `@code{|}'.  Whenever it is encountered
783 during interpretation, it should fall on a measure boundary.  If it
784 does not, a warning is printed.  In the next example, the second bar
785 check will signal an error
786 @example
787 \time 3/4 c2 e4 | g2 |
788 @end example
789
790 Bar checks can also be used in lyrics, for example
791
792 @example
793 \lyricmode @{
794   \time 2/4
795   Twin -- kle | Twin -- kle
796 @}
797 @end example
798
799 Failed bar checks are caused by entering incorrect
800 durations.  Incorrect durations often completely garble up the score,
801 especially if the score is polyphonic, so a good place to start correcting
802 input is by scanning for failed bar checks and incorrect durations.
803
804 @funindex |
805 @funindex pipeSymbol
806
807 It is also possible to redefine the meaning of @code{|}.  This is done
808 by assigning a music expression to @code{pipeSymbol},
809
810 @lilypond[quote,ragged-right,verbatim]
811 pipeSymbol = \bar "||"
812
813 { c'2 c' | c'2 c' }
814 @end lilypond
815
816
817 @node Barnumber check
818 @subsection Barnumber check
819
820 When copying large pieces of music, it can be helpful to check that
821 the LilyPond bar number corresponds to the original that you are
822 entering from.  This can be checked with @code{\barNumberCheck}, for
823 example,
824
825 @verbatim
826 \barNumberCheck #123
827 @end verbatim
828
829 @noindent
830 will print a warning if the @code{currentBarNumber} is not 123 when it
831 is processed.
832
833
834 @node Automatic note splitting
835 @subsection Automatic note splitting
836
837 Long notes can be converted automatically to tied notes.  This is done
838 by replacing the @internalsref{Note_heads_engraver} by the
839 @internalsref{Completion_heads_engraver}.
840 In the following examples, notes crossing the bar line are split and tied.
841
842 @lilypond[quote,fragment,verbatim,relative=1,line-width=12\cm]
843 \new Voice \with {
844   \remove "Note_heads_engraver"
845   \consists "Completion_heads_engraver"
846 } {
847   c2. c8 d4 e f g a b c8 c2 b4 a g16 f4 e d c8. c2
848 }
849 @end lilypond
850
851 This engraver splits all running notes at the bar line, and inserts
852 ties.  One of its uses is to debug complex scores: if the measures are
853 not entirely filled, then the ties exactly show how much each measure
854 is off.
855
856
857 @refbugs
858
859 Not all durations (especially those containing tuplets) can be
860 represented exactly with normal notes and dots, but the engraver will
861 not insert tuplets.
862
863 @code{Completion_heads_engraver} only affects notes; it does not split
864 rests.
865
866
867 @seealso
868
869 Examples: @inputfileref{input/@/regression,completion@/-heads@/.ly}.
870
871 @noindent
872
873 Program reference: @internalsref{Completion_heads_engraver}.
874
875
876 @node Multiple notes at once
877 @section Multiple notes at once
878
879 Polyphony in music refers to having more than one voice occurring in
880 a piece of music.  Polyphony in LilyPond refers to having more than
881 one voice on the same staff.
882
883 @menu
884 * Chords::                      
885 * Stems::                       
886 * Basic polyphony::             
887 * Explicitly instantiating voices::  
888 * Collision Resolution::        
889 @end menu
890
891
892 @node Chords
893 @subsection Chords
894
895 @cindex Chords
896
897 A chord is formed by a enclosing a set of pitches between @code{<}
898 and @code{>}.  A chord may be followed by a duration, and a set of
899 articulations, just like simple notes
900
901 @lilypond[verbatim,ragged-right,fragment,quote,relative=1]
902 <c e g>4 <c>8
903 @end lilypond
904
905 For more information about chords, see @ref{Chord names}.
906
907
908 @node Stems
909 @subsection Stems
910
911 Whenever a note is found, a @internalsref{Stem} object is created
912 automatically.  For whole notes and rests, they are also created but
913 made invisible.
914
915 @refcommands
916
917 @funindex \stemUp
918 @code{\stemUp},
919 @funindex \stemDown
920 @code{\stemDown},
921 @funindex \stemNeutral
922 @code{\stemNeutral}.
923
924
925 @commonprop
926
927 To change the direction of stems in the middle of the staff, use
928
929 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
930 a4 b c b
931 \override Stem #'neutral-direction = #up
932 a4 b c b
933 \override Stem #'neutral-direction = #down
934 a4 b c b
935 @end lilypond
936
937
938 @node Basic polyphony
939 @subsection Basic polyphony
940
941 @cindex polyphony
942
943 The easiest way to enter fragments with more than one voice on a staff
944 is to enter each voice as a sequence (with @code{@{...@}}), and combine
945 them simultaneously, separating the voices with @code{\\}
946
947 @funindex \\
948
949 @lilypond[quote,verbatim,fragment]
950 \new Staff \relative c' {
951   c16 d e f
952   <<
953     { g4 f e | d2 e2 } \\
954     { r8 e4 d c8 ~ | c b16 a b8 g ~ g2 } \\
955     { s2. | s4 b4 c2 }
956   >>
957 }
958 @end lilypond
959
960 The separator causes @internalsref{Voice} contexts@footnote{Polyphonic
961 voices are sometimes called ``layers'' in other notation packages}
962 @cindex layers
963 to be instantiated.  They bear the names @code{"1"}, @code{"2"}, etc.  In
964 each of these contexts, vertical direction of slurs, stems, etc., is set
965 appropriately.
966
967 These voices are all separate from the voice that contains the notes just
968 outside the @code{<< \\ >>} construct.  This should be noted when making
969 changes at the voice level.  This also means that slurs and ties cannot go
970 into or out of a @code{<< \\ >>} construct.  Conversely, parallel voices
971 from separate @code{<< \\ >>} constructs on the same staff are the the
972 same voice.  Here is the same example, with different noteheads for each
973 voice.  Note that the change to the note-head style in the main voice does
974 not affect
975 the inside of the @code{<< \\ >>} constructs.  Also, the change to the
976 second
977 voice in the first @code{<< \\ >>} construct is effective in the second
978 @code{<< \\ >>}, and the voice is tied across the two constructs.
979
980 @cindex note heads, styles
981
982 @lilypond[quote,verbatim,fragment]
983 \new Staff \relative c' {
984   \override NoteHead #'style = #'cross
985   c16 d e f
986   <<
987     { g4 f e } \\
988     { \override NoteHead #'style = #'triangle
989     r8 e4 d c8 ~ }
990   >> |
991   <<
992     { d2 e2 } \\
993     { c8 b16 a b8 g ~ g2 } \\
994     { \override NoteHead #'style = #'slash s4 b4 c2 }
995   >>
996 }
997 @end lilypond
998
999 Polyphony does not change the relationship of notes within a
1000 @code{\relative @{ @}} block.  Each note is calculated relative
1001 to the note immediately preceding it.
1002
1003 @example
1004 \relative @{ noteA << noteB \\ noteC >> noteD @}
1005 @end example
1006
1007 @code{noteC} is relative to @code{noteB}, not @code{noteA};
1008 @code{noteD} is relative to @code{noteC}, not @code{noteB} or
1009 @code{noteA}.
1010
1011 @node Explicitly instantiating voices
1012 @subsection Explicitly instantiating voices
1013
1014 @internalsref{Voice} contexts can also be instantiated manually
1015 inside a @code{<< >>} block to create polyphonic music, using
1016 @code{\voiceOne}, up to @code{\voiceFour} to assign stem directions
1017 and a horizontal shift for each part.
1018
1019 Specifically,
1020 @example
1021 << \upper \\ \lower >>
1022 @end example
1023
1024 @noindent
1025 is equivalent to
1026
1027 @example
1028 <<
1029   \new Voice = "1" @{ \voiceOne \upper @}
1030   \new Voice = "2" @{ \voiceTwo \lower @}
1031 >>
1032 @end example
1033
1034 The @code{\voiceXXX} commands set the direction of stems, slurs, ties,
1035 articulations, text annotations, augmentation dots of dotted
1036 notes, and fingerings.  @code{\voiceOne} and @code{\voiceThree} make
1037 these objects point upwards, while @code{\voiceTwo} and @code{\voiceFour}
1038 make them point downwards.
1039 The command @code{\oneVoice} will revert back to the normal setting.
1040
1041 An expression that appears directly inside a @code{<< >>} belongs to
1042 the main voice.  This is useful when extra voices appear while the main
1043 voice is playing.  Here is a more correct rendition of the example from
1044 the previous section.  The crossed noteheads demonstrate that the main
1045 melody is now in a single voice context.
1046
1047 @lilypond[quote,ragged-right,verbatim]
1048 \new Staff \relative c' {
1049   \override NoteHead #'style = #'cross
1050   c16 d e f
1051   \voiceOne
1052   <<
1053     { g4 f e | d2 e2 }
1054     \new Voice="1" { \voiceTwo
1055       r8 e4 d c8 ~ | c8 b16 a b8 g ~ g2
1056       \oneVoice
1057     }
1058     \new Voice { \voiceThree
1059       s2. | s4 b4 c2
1060       \oneVoice
1061     }
1062   >>
1063   \oneVoice
1064 }
1065 @end lilypond
1066
1067 The correct definition of the voices allows the melody to be slurred.
1068 @lilypond[quote,ragged-right,verbatim]
1069 \new Staff \relative c' {
1070   c16^( d e f
1071   \voiceOne
1072   <<
1073     { g4 f e | d2 e2) }
1074     \context Voice="1" { \voiceTwo
1075       r8 e4 d c8 ~ | c8 b16 a b8 g ~ g2
1076       \oneVoice
1077     }
1078     \new Voice { \voiceThree
1079       s2. s4 b4 c2
1080       \oneVoice
1081     }
1082   >>
1083   \oneVoice
1084 }
1085 @end lilypond
1086
1087 Avoiding the @code{\\} separator also allows nesting polyphony
1088 constructs, which in some case might be a more natural way to typeset
1089 the music.
1090
1091 @lilypond[quote,ragged-right,verbatim]
1092 \new Staff \relative c' {
1093   c16^( d e f
1094   \voiceOne
1095   <<
1096     { g4 f e | d2 e2) }
1097     \context Voice="1" { \voiceTwo
1098       r8 e4 d c8 ~ |
1099       <<
1100         {c8 b16 a b8 g ~ g2}
1101         \new Voice { \voiceThree
1102           s4 b4 c2
1103           \oneVoice
1104         }
1105       >>
1106     \oneVoice
1107     }
1108   >>
1109   \oneVoice
1110 }
1111 @end lilypond
1112
1113
1114 @node Collision Resolution
1115 @subsection Collision Resolution
1116
1117 Normally, note heads with a different number of dots are not merged, but
1118 when the object property @code{merge-differently-dotted} is set in
1119 the @internalsref{NoteCollision} object, they are merged
1120 @lilypond[quote,verbatim,fragment,ragged-right,relative=2]
1121 \new Voice << {
1122   g8 g8
1123   \override Staff.NoteCollision
1124     #'merge-differently-dotted = ##t
1125   g8 g8
1126 } \\ { g8.[ f16] g8.[ f16] } >>
1127 @end lilypond
1128
1129 Similarly, you can merge half note heads with eighth notes, by setting
1130 @code{merge-differently-headed}
1131 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
1132 \new Voice << {
1133   c8 c4.
1134   \override Staff.NoteCollision
1135     #'merge-differently-headed = ##t
1136 c8 c4. } \\ { c2 c2 } >>
1137 @end lilypond
1138
1139 LilyPond also vertically shifts rests that are opposite of a stem,
1140 for example
1141
1142 @lilypond[quote,ragged-right,fragment,verbatim]
1143 \new Voice << c''4 \\ r4 >>
1144 @end lilypond
1145
1146
1147 @refcommands
1148
1149 @funindex \oneVoice
1150 @code{\oneVoice},
1151 @funindex \voiceOne
1152 @code{\voiceOne},
1153 @funindex \voiceTwo
1154 @code{\voiceTwo},
1155 @funindex \voiceThree
1156 @code{\voiceThree},
1157 @funindex \voiceFour
1158 @code{\voiceFour}.
1159
1160 @funindex \shiftOn
1161 @code{\shiftOn},
1162 @funindex \shiftOnn
1163 @code{\shiftOnn},
1164 @funindex \shiftOnnn
1165 @code{\shiftOnnn},
1166 @funindex \shiftOff
1167 @code{\shiftOff}: these commands specify in what chords of the current
1168 voice should be shifted.  The outer voices (normally: voice one and
1169 two) have @code{\shiftOff}, while the inner voices (three and four)
1170 have @code{\shiftOn}.  @code{\shiftOnn} and @code{\shiftOnnn} define
1171 further shift levels.
1172
1173 When LilyPond cannot cope, the @code{force-hshift}
1174 property of the @internalsref{NoteColumn} object and pitched rests can
1175 be used to override typesetting decisions.
1176
1177 @lilypond[quote,verbatim,ragged-right]
1178 \relative <<
1179 {
1180   <d g>
1181   <d g>
1182 } \\ {
1183   <b f'>
1184   \once \override NoteColumn #'force-hshift = #1.7
1185   <b f'>
1186 } >>
1187 @end lilypond
1188
1189
1190 @seealso
1191
1192 Program reference: the objects responsible for resolving collisions are
1193 @internalsref{NoteCollision} and @internalsref{RestCollision}.
1194
1195 Examples:
1196 @inputfileref{input/@/regression,collision@/-dots@/.ly},
1197 @inputfileref{input/@/regression,collision@/-head-chords@/.ly},
1198 @inputfileref{input/@/regression,collision@/-heads@/.ly},
1199 @inputfileref{input/@/regression,collision@/-mesh@/.ly}, and
1200 @inputfileref{input/@/regression,collisions@/.ly}.
1201
1202
1203 @refbugs
1204
1205 When using @code{merge-differently-headed} with an upstem eighth or a
1206 shorter note, and a downstem half note, the eighth note gets the wrong
1207 offset.
1208
1209 There is no support for clusters where the same note occurs with
1210 different accidentals in the same chord.  In this case, it is
1211 recommended to use enharmonic transcription, or to use special cluster
1212 notation (see @ref{Clusters}).
1213
1214
1215
1216 @node Staff notation
1217 @section Staff notation
1218
1219 @cindex Staff notation
1220
1221 This section describes music notation that occurs on staff level,
1222 such as key signatures, clefs and time signatures.
1223
1224 @menu
1225 * Clef::                        
1226 * Key signature::               
1227 * Time signature::              
1228 * Partial measures::            
1229 * Bar lines::                   
1230 * Unmetered music::             
1231 * System start delimiters::     
1232 * Staff symbol::                
1233 * Writing music in parallel::   
1234 @end menu
1235
1236
1237 @node Clef
1238 @subsection Clef
1239
1240 @funindex \clef
1241
1242 The clef indicates which lines of the staff correspond to which
1243 pitches.  The clef is set with the @code{\clef} command
1244
1245 @lilypond[quote,ragged-right,fragment,verbatim]
1246 { c''2 \clef alto g'2 }
1247 @end lilypond
1248
1249 @cindex treble clef
1250 @cindex violin clef
1251 @cindex alto clef
1252 @cindex tenor clef
1253 @cindex bass clef
1254 @cindex french clef
1255 @cindex soprano clef
1256 @cindex mezzosoprano clef
1257 @cindex baritone clef
1258 @cindex varbaritone clef
1259 @cindex subbass clef
1260
1261 Supported clefs include
1262
1263 @multitable @columnfractions .33 .66
1264 @headitem Clef @tab Position
1265 @item @code{treble}, violin, G, G2 @tab
1266 G clef on 2nd line
1267 @item @code{alto, C} @tab
1268 C clef on 3rd line
1269 @item @code{tenor} @tab
1270 C clef on 4th line.
1271 @item @code{bass, F} @tab
1272 F clef on 4th line
1273 @item @code{french} @tab
1274 G clef on 1st line, so-called French violin clef
1275 @item @code{soprano} @tab
1276 C clef on 1st line
1277 @item @code{mezzosoprano} @tab
1278 C clef on 2nd line
1279 @item @code{baritone} @tab
1280 C clef on 5th line
1281 @item @code{varbaritone} @tab
1282 F clef on 3rd line
1283 @item @code{subbass} @tab
1284 F clef on 5th line
1285 @item @code{percussion} @tab
1286 percussion clef
1287 @item @code{tab} @tab
1288 tablature clef
1289 @end multitable
1290
1291 By adding @code{_8} or @code{^8} to the clef name, the clef is
1292 transposed one octave down or up, respectively, and @code{_15} and
1293 @code{^15} transposes by two octaves.  The argument @var{clefname}
1294 must be enclosed in quotes when it contains underscores or digits.  For
1295 example,
1296
1297 @cindex choral tenor clef
1298 @lilypond[quote,ragged-right,verbatim,fragment,relative=1]
1299 \clef "G_8" c4
1300 @end lilypond
1301
1302
1303 @commonprop
1304
1305 The command @code{\clef "treble_8"} is equivalent to setting
1306 @code{clefGlyph},
1307 @code{clefPosition} (which controls the Y position of the clef),
1308 @code{middleCPosition} and @code{clefOctavation}.  A clef is printed
1309 when any of these properties are changed.  The following example shows
1310 possibilities when setting properties manually.
1311
1312 @lilypond[quote,ragged-right,verbatim]
1313 {
1314   \set Staff.clefGlyph = #"clefs.F"
1315   \set Staff.clefPosition = #2
1316   c'4
1317   \set Staff.clefGlyph = #"clefs.G"
1318   c'4
1319   \set Staff.clefGlyph = #"clefs.C"
1320   c'4
1321   \set Staff.clefOctavation = #7
1322   c'4
1323   \set Staff.clefOctavation = #0
1324   \set Staff.clefPosition = #0
1325   c'4
1326   \clef "bass"
1327   c'4
1328   \set Staff.middleCPosition = #4
1329   c'4
1330 }
1331 @end lilypond
1332
1333
1334 @seealso
1335
1336 Manual: @ref{Grace notes}.
1337
1338 Program reference: @internalsref{Clef}.
1339
1340
1341 @node Key signature
1342 @subsection Key signature
1343
1344 @cindex Key signature
1345 @funindex \key
1346
1347 The key signature indicates the tonality in which a piece is played.  It
1348 is denoted by a set of alterations (flats or sharps) at the start of the
1349 staff.
1350
1351 Setting or changing the key signature is done with the @code{\key}
1352 command
1353
1354 @example
1355 @code{\key} @var{pitch} @var{type}
1356 @end example
1357
1358 @funindex \minor
1359 @funindex \major
1360 @funindex \minor
1361 @funindex \ionian
1362 @funindex \locrian
1363 @funindex \aeolian
1364 @funindex \mixolydian
1365 @funindex \lydian
1366 @funindex \phrygian
1367 @funindex \dorian
1368 @cindex church modes
1369
1370 Here, @var{type} should be @code{\major} or @code{\minor} to get
1371 @var{pitch}-major or @var{pitch}-minor, respectively.  You may also
1372 use the standard mode names (also called ``church modes''): @code{\ionian},
1373 @code{\locrian}, @code{\aeolian}, @code{\mixolydian}, @code{\lydian},
1374 @code{\phrygian}, and @code{\dorian}.
1375
1376 This command sets the context property
1377 @code{Staff.keySignature}.  Non-standard key signatures
1378 can be specified by setting this property directly.
1379
1380 Accidentals and key signatures often confuse new users, because
1381 unaltered notes get natural signs depending on the key signature.  For
1382 more information, see @ref{Accidentals} or @ref{More about pitches}.
1383
1384 @lilypond[quote,ragged-right,verbatim,relative=2,fragment]
1385 \key g \major
1386 f1
1387 fis
1388 @end lilypond
1389
1390
1391 @commonprop
1392
1393 A natural sign is printed to cancel any previous accidentals.  This
1394 can be suppressed by setting the @code{Staff.printKeyCancellation}
1395 property.
1396
1397 @lilypond[quote,fragment,ragged-right,fragment,verbatim,relative=2]
1398 \key d \major
1399 a b cis d
1400 \key g \minor
1401 a bes c d
1402 \set Staff.printKeyCancellation = ##f
1403 \key d \major
1404 a b cis d
1405 \key g \minor
1406 a bes c d
1407 @end lilypond
1408
1409
1410 @seealso
1411
1412 Program reference: @internalsref{KeyCancellation},
1413 @internalsref{KeySignature}.
1414
1415
1416 @node Time signature
1417 @subsection Time signature
1418
1419 @cindex Time signature
1420 @cindex meter
1421 @funindex \time
1422
1423 Time signature indicates the metrum of a piece: a regular pattern of
1424 strong and weak beats.  It is denoted by a fraction at the start of the
1425 staff.
1426
1427 The time signature is set with the @code{\time} command
1428
1429 @lilypond[quote,ragged-right,fragment,verbatim]
1430 \time 2/4 c'2 \time 3/4 c'2.
1431 @end lilypond
1432
1433 @commonprop
1434
1435 The symbol that is printed can be customized with the @code{style}
1436 property.  Setting it to @code{#'()} uses fraction style for 4/4 and
1437 2/2 time,
1438
1439 @lilypond[fragment,quote,ragged-right,verbatim]
1440 \time 4/4 c'1
1441 \time 2/2 c'1
1442 \override Staff.TimeSignature #'style = #'()
1443 \time 4/4 c'1
1444 \time 2/2 c'1
1445 @end lilypond
1446
1447 There are many more options for its layout.  See @ref{Ancient time
1448 signatures} for more examples.
1449
1450 @code{\time} sets the property @code{timeSignatureFraction},
1451 @code{beatLength} and @code{measureLength} in the @code{Timing}
1452 context, which is normally aliased to @internalsref{Score}.  The
1453 property @code{measureLength} determines where bar lines should be
1454 inserted, and how automatic beams should be generated.  Changing the
1455 value of @code{timeSignatureFraction} also causes the symbol to be
1456 printed.
1457
1458 More options are available through the Scheme function
1459 @code{set-time-signature}.  In combination with the
1460 @internalsref{Measure_grouping_engraver}, it will create
1461 @internalsref{MeasureGrouping} signs.  Such signs ease reading
1462 rhythmically complex modern music.  In the following example, the 9/8
1463 measure is subdivided in 2, 2, 2 and 3.  This is passed to
1464 @code{set-time-signature} as the third argument @code{(2 2 2 3)}
1465
1466 @lilypond[quote,ragged-right,verbatim]
1467 \score {
1468   \relative c'' {
1469     #(set-time-signature 9 8 '(2 2 2 3))
1470     g8[ g] d[ d] g[ g] a8[( bes g]) |
1471     #(set-time-signature 5 8 '(3 2))
1472     a4. g4
1473   }
1474   \layout {
1475     \context {
1476       \Staff
1477       \consists "Measure_grouping_engraver"
1478     }
1479   }
1480 }
1481 @end lilypond
1482
1483
1484 @seealso
1485
1486 Program reference: @internalsref{TimeSignature}, and
1487 @internalsref{Timing_translator}.
1488
1489 Examples: @inputfileref{input/@/test,compound@/-time@/.ly}.
1490
1491
1492 @refbugs
1493
1494 Automatic beaming does not use the measure grouping specified with
1495 @code{set-time-signature}.
1496
1497
1498 @node Partial measures
1499 @subsection Partial measures
1500
1501 @cindex anacrusis
1502 @cindex upbeat
1503 @cindex partial measure
1504 @cindex measure, partial
1505 @cindex shorten measures
1506 @funindex \partial
1507
1508 Partial measures, such as an anacrusis or upbeat, are entered using the
1509
1510 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
1511 \partial 16*5 c16 cis d dis e | a2. c,4 | b2
1512 @end lilypond
1513
1514 The syntax for this command is
1515
1516 @example
1517 \partial @var{duration}
1518 @end example
1519
1520 where @code{duration} is the rhythmic length to be added before
1521 the next bar.
1522
1523 This is internally translated into
1524
1525 @example
1526 \set Timing.measurePosition = -@var{length of duration}
1527 @end example
1528
1529 The property @code{measurePosition} contains a rational number
1530 indicating how much of the measure has passed at this point.  Note
1531 that this is a negative number; @code{\partial 4} is internally
1532 translated to mean ``there is a quarter note left in the bar''.
1533
1534
1535 @refbugs
1536
1537 This command does not take into account grace notes at the start of
1538 the music.  When a piece starts with graces notes in the pickup, then
1539 the @code{\partial} should follow the grace notes
1540
1541 @lilypond[verbatim,quote,ragged-right,relative,fragment]
1542 \grace f16
1543 \partial 4
1544 g4
1545 a2 g2
1546 @end lilypond
1547
1548
1549 @node Bar lines
1550 @subsection Bar lines
1551
1552 @cindex Bar lines
1553 @funindex \bar
1554 @cindex measure lines
1555 @cindex repeat bars
1556
1557 Bar lines delimit measures, but are also used to indicate
1558 repeats.  Normally they are inserted automatically.  Line
1559 breaks may only happen on bar lines.
1560
1561 Special types of bar lines can be forced with the @code{\bar} command
1562
1563 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1564 c4 \bar "|:" c4
1565 @end lilypond
1566
1567 The following bar types are available
1568
1569 @lilypondfile[ragged-right,quote]{bar-lines.ly}
1570
1571 In addition, you can specify @code{"||:"}, which is equivalent to 
1572 @code{"|:"} except at line breaks, where it gives a double bar line at
1573 the end of the line and a start repeat at the beginning of the next
1574 line. 
1575
1576 To allow a line break where there is no visible bar line, use
1577
1578 @example
1579 \bar ""
1580 @end example
1581
1582 @noindent
1583 This will insert an invisible bar line and allow line breaks at this
1584 point.  This also increases the bar number counter.
1585
1586 In scores with many staves, a @code{\bar} command in one staff is
1587 automatically applied to all staves.  The resulting bar lines are
1588 connected between different staves of a @code{StaffGroup},
1589 @code{PianoStaff}, or @code{ChoirStaff}.
1590
1591 @lilypond[quote,ragged-right,fragment,verbatim]
1592 <<
1593   \new StaffGroup <<
1594     \new Staff {
1595       e'4 d'
1596       \bar "||"
1597       f' e'
1598     }
1599     \new Staff { \clef bass c4 g e g }
1600   >>
1601   \new Staff { \clef bass c2 c2 }
1602 >>
1603 @end lilypond
1604
1605
1606 @commonprop
1607
1608 @funindex whichBar
1609 @funindex repeatCommands
1610 @funindex defaultBarType
1611
1612 The command @code{\bar }@var{bartype} is a short cut for doing
1613 @code{\set Timing.whichBar = }@var{bartype}.  Whenever @code{whichBar}
1614 is set to a string, a bar line of that type is created.
1615
1616 A bar line is created whenever the @code{whichBar} property is set.
1617 At the start of a measure it is set to the contents of
1618 @code{Timing.defaultBarType}.  The contents of @code{repeatCommands} are
1619 used
1620 to override default measure bars.
1621
1622 You are encouraged to use @code{\repeat} for repetitions.  See
1623 @ref{Repeats}.
1624
1625
1626 @seealso
1627
1628 In this manual: @ref{Repeats}, @ref{System start delimiters}.
1629
1630 Program reference: @internalsref{BarLine} (created at
1631 @internalsref{Staff} level), @internalsref{SpanBar} (across staves).
1632
1633 Examples: @inputfileref{input/@/test,bar@/-lines@/.ly},
1634
1635
1636 @node Unmetered music
1637 @subsection Unmetered music
1638
1639 @cindex cadenza
1640 @funindex \cadenzaOn
1641 @funindex \cadenzaOff
1642
1643 Bar lines and bar numbers are calculated automatically.  For unmetered
1644 music (cadenzas, for example), this is not desirable.  To turn off
1645 automatic bar lines and bar numbers, use the commands @code{\cadenzaOn}
1646 and @code{\cadenzaOff}.
1647
1648 @lilypond[verbatim,quote,ragged-right,relative=2,fragment]
1649 c4 d e d
1650 \cadenzaOn
1651 c4 c d8 d d f4 g4.
1652 \cadenzaOff
1653 \bar "|"
1654 d4 e d c
1655 @end lilypond
1656
1657
1658 @refbugs
1659
1660 LilyPond will only insert line breaks and page breaks at a
1661 barline.  Unless the unmetered music ends before the end of
1662 the staff line, you will need to insert
1663 invisible bar lines
1664
1665 @example
1666 \bar ""
1667 @end example
1668
1669 @noindent
1670 to indicate where breaks can occur.
1671
1672
1673 @node System start delimiters
1674 @subsection System start delimiters
1675
1676 @cindex start of system
1677 @cindex Staff, multiple
1678 @cindex bracket, vertical
1679 @cindex brace, vertical
1680 @cindex grand staff
1681 @cindex staff group
1682 @cindex staff, choir
1683
1684 Many scores consist of more than one staff.  These staves can be
1685 joined in four different ways
1686
1687 @itemize @bullet
1688 @item The group is started with a brace at the left, and bar lines are
1689 connected.  This is done with the @internalsref{GrandStaff} context.
1690
1691 @lilypond[verbatim,ragged-right,quote]
1692 \new GrandStaff
1693 \relative <<
1694   \new Staff { c1 c }
1695   \new Staff { c c }
1696 >>
1697 @end lilypond
1698
1699 @item The group is started with a bracket, and bar lines are connected.
1700 This is done with the
1701 @internalsref{StaffGroup} context
1702
1703 @lilypond[verbatim,ragged-right,quote]
1704 \new StaffGroup
1705 \relative <<
1706   \new Staff { c1 c }
1707   \new Staff { c c }
1708 >>
1709 @end lilypond
1710
1711 @item The group is started with a bracket, but bar lines are not
1712 connected.  This is done with the @internalsref{ChoirStaff} context.
1713
1714 @lilypond[verbatim,ragged-right,quote]
1715 \new ChoirStaff
1716 \relative <<
1717   \new Staff { c1 c }
1718   \new Staff { c c }
1719 >>
1720 @end lilypond
1721
1722 @item The group is started with a vertical line.  Bar lines are not
1723 connected.  This is the default for the score.
1724
1725 @lilypond[verbatim,ragged-right,quote]
1726 \relative <<
1727   \new Staff { c1 c }
1728   \new Staff { c c }
1729 >>
1730 @end lilypond
1731 @end itemize
1732
1733
1734 @seealso
1735
1736 The bar lines at the start of each system are
1737 @internalsref{SystemStartBar}, @internalsref{SystemStartBrace}, and
1738 @internalsref{SystemStartBracket}.  Only one of these types is created
1739 in every context, and that type is determined by the property
1740 @internalsref{systemStartDelimiter}.
1741
1742
1743 @node Staff symbol
1744 @subsection Staff symbol
1745
1746 @cindex adjusting staff symbol
1747
1748 Notes, dynamic signs, etc., are grouped
1749 with a set of horizontal lines, called a staff (plural `staves').  In
1750 LilyPond, these lines are drawn using a separate layout object called
1751 @code{staff symbol}.
1752
1753 The staff symbol may be tuned in the number, thickness and distance
1754 of lines, using properties.  This is demonstrated in the example files
1755 @inputfileref{input/@/test,staff@/-lines@/.ly},
1756 @inputfileref{input/@/test,staff@/-size@/.ly}.
1757
1758 In addition, staves may be started and stopped at will. This is done
1759 with @code{\startStaff} and @code{\stopStaff}.
1760
1761 @lilypond[verbatim,relative=2,fragment]
1762 b4 b
1763 \override Staff.StaffSymbol #'line-count = 2
1764 \stopStaff \startStaff
1765 b b
1766 \revert Staff.StaffSymbol #'line-count
1767 \stopStaff \startStaff
1768 b b
1769 @end lilypond
1770
1771 In combination with Frenched staves, this may be used to typeset ossia
1772 sections. An example is in @inputfileref{input/@/test@/,ossia.ly},
1773 shown here
1774
1775 @cindex ossia
1776
1777 @lilypondfile{ossia.ly}
1778
1779 @cindex staff lines, setting number of
1780 @cindex staff lines, setting thickness of
1781 @cindex thickness of staff lines, setting
1782 @cindex number of staff lines, setting
1783
1784 @seealso
1785
1786 Program reference: @internalsref{StaffSymbol}.
1787
1788 Examples: @inputfileref{input/@/test,staff@/-lines@/.ly},
1789 @inputfileref{input/@/test@/,ossia.ly},
1790 @inputfileref{input/@/test,staff@/-size@/.ly},
1791 @inputfileref{input/@/regression,staff@/-line@/-positions@/.ly}.
1792
1793
1794 @node Writing music in parallel
1795 @subsection Writing music in parallel
1796
1797 @cindex Writing music in parallel
1798 @cindex Interleaved music
1799
1800 Music for multiple parts can be interleaved
1801
1802 @lilypond[quote,fragment,verbatim]
1803 \parallelMusic #'(voiceA voiceB) {
1804   r8     g'16[ c''] e''[ g' c'' e''] r8     g'16[ c''] e''[ g' c'' e''] |
1805   c'2                                c'2                                |
1806   r8     a'16[ d''] f''[ a' d'' f''] r8     a'16[ d''] f''[ a' d'' f''] |
1807   c'2                                c'2                                |
1808 }
1809 \new StaffGroup <<
1810   \new Staff \new Voice \voiceA
1811   \new Staff \new Voice \voiceB
1812 >>
1813 @end lilypond
1814
1815
1816
1817 @node Connecting notes
1818 @section Connecting notes
1819
1820 This section deals with notation that affects groups of notes.
1821
1822 @menu
1823 * Ties::                        
1824 * Slurs::                       
1825 * Phrasing slurs::              
1826 * Laissez vibrer ties::         
1827 * Automatic beams::             
1828 * Manual beams::                
1829 * Grace notes::                 
1830 @end menu
1831
1832
1833 @node Ties
1834 @subsection Ties
1835
1836 @cindex tie
1837 @funindex ~
1838
1839 A tie connects two adjacent note heads of the same pitch.  The tie in
1840 effect extends the length of a note.  Ties should not be confused with
1841 slurs, which indicate articulation, or phrasing slurs, which indicate
1842 musical phrasing.  A tie is entered using the tilde symbol `@code{~}'
1843
1844 @lilypond[quote,ragged-right,fragment,verbatim]
1845 e' ~ e' <c' e' g'> ~ <c' e' g'>
1846 @end lilypond
1847
1848 When a tie is applied to a chord, all note heads whose pitches match
1849 are connected.  When no note heads match, no ties will be created.  Chords
1850 may be partially tied by placing the tie inside the chord,
1851
1852 @lilypond[quote,ragged-right,fragment,verbatim,relative=1]
1853 <c~ e g~ b> <c e g b>
1854 @end lilypond
1855
1856 A tie is just a way of extending a note duration, similar to the
1857 augmentation dot.  The following example shows two ways of notating
1858 exactly the same concept
1859
1860 @lilypond[quote,fragment,ragged-right]
1861 \time 3/4 c'2. c'2 ~ c'4
1862 @end lilypond
1863
1864 @noindent
1865 Ties are used either when the note crosses a bar line, or when dots
1866 cannot be used to denote the rhythm.  When using ties, larger note
1867 values should be aligned to subdivisions of the measure, such as
1868
1869 @lilypond[fragment,quote,ragged-right]
1870 \relative {
1871   r8 c8 ~ c2 r4 | r8^"not" c2 ~ c8 r4
1872 }
1873 @end lilypond
1874
1875 If you need to tie a lot of notes over bars, it may be easier to use
1876 automatic note splitting (see @ref{Automatic note splitting}).  This
1877 mechanism automatically splits long notes, and ties them across bar
1878 lines.
1879
1880 @funindex \repeatTie
1881
1882 When a second alternative of a repeat starts with a tied note, you
1883 have to repeat the tie. This can be achieved with @code{\repeatTie},
1884
1885 @lilypond[fragment,quote,ragged-right,relative=2]
1886 r <c e g>\repeatTie
1887 @end lilypond
1888
1889 @cindex repeating ties
1890 @cindex volta brackets and ties
1891
1892 @commonprop
1893
1894 Ties are sometimes used to write out arpeggios.  In this case, two tied
1895 notes need not be consecutive.  This can be achieved by setting the
1896 @code{tieWaitForNote} property to true. The same feature is also useful,
1897 for example, to tie a tremolo to a chord. For example,
1898
1899 @lilypond[fragment,verbatim,relative=1,ragged-right]
1900 \set tieWaitForNote = ##t
1901 \grace { c16[~ e~ g]~ } <c, e g>2
1902 \repeat "tremolo" 8 { c32~ c'~ } <c c,>1
1903 e8~ c~ a~ f~ <e' c a f>2
1904 @end lilypond
1905
1906
1907 @refcommands
1908
1909
1910 @funindex \tieUp
1911 @code{\tieUp},
1912 @funindex \tieDown
1913 @code{\tieDown},
1914 @funindex \tieNeutral
1915 @code{\tieNeutral},
1916 @funindex \tieDotted
1917 @code{\tieDotted},
1918 @funindex \tieDashed
1919 @code{\tieDashed},
1920 @funindex \tieSolid
1921 @code{\tieSolid}.
1922
1923
1924 @seealso
1925
1926 In this manual: @ref{Automatic note splitting}.
1927
1928 Program reference: @internalsref{Tie}.
1929
1930 Examples:
1931 @inputfileref{input/@/regression,tie-arpeggio.ly}
1932 @inputfileref{input/@/regression,tie-manual.ly}
1933
1934
1935
1936
1937 @refbugs
1938
1939 Switching staves when a tie is active will not produce a slanted tie.
1940
1941
1942 @node Slurs
1943 @subsection Slurs
1944
1945 @cindex Slurs
1946
1947 A slur indicates that notes are to be played bound or
1948 @emph{legato}.  They are entered using parentheses
1949
1950 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1951 f( g a) a8 b( a4 g2 f4)
1952 <c e>2( <b d>2)
1953 @end lilypond
1954
1955 The direction of a slur can be specified with
1956 @code{\slur@emph{DIR}}, where @code{@emph{DIR}} is
1957 either @code{Up}, @code{Down}, or @code{Neutral} (automatically
1958 selected).
1959
1960 However, there is a convenient shorthand for forcing slur
1961 directions.  By adding @code{_} or @code{^} before the opening
1962 parentheses, the direction is also set.  For example,
1963
1964 @lilypond[relative=2,ragged-right,quote,verbatim,fragment]
1965 c4_( c) c^( c)
1966 @end lilypond
1967
1968 Only one slur can be printed at once.  If you need to print a long
1969 slur over a few small slurs, please see @ref{Phrasing slurs}.
1970
1971
1972 @commonprop
1973
1974 Some composers write two slurs when they want legato chords.  This can
1975 be achieved in LilyPond by setting @code{doubleSlurs},
1976
1977 @lilypond[verbatim,ragged-right,relative,fragment,quote]
1978 \set doubleSlurs = ##t
1979 <c e>4 ( <d f> <c e> <d f> )
1980 @end lilypond
1981
1982
1983 @refcommands
1984
1985 @funindex \slurUp
1986 @code{\slurUp},
1987 @funindex \slurDown
1988 @code{\slurDown},
1989 @funindex \slurNeutral
1990 @code{\slurNeutral},
1991 @funindex \slurDashed
1992 @code{\slurDashed},
1993 @funindex \slurDotted
1994 @code{\slurDotted},
1995 @funindex \slurSolid
1996 @code{\slurSolid}.
1997
1998 @seealso
1999
2000 Program reference: @seeinternals{Slur}.
2001
2002
2003 @node Phrasing slurs
2004 @subsection Phrasing slurs
2005
2006 @cindex phrasing slurs
2007 @cindex phrasing marks
2008
2009 A phrasing slur (or phrasing mark) connects notes and is used to
2010 indicate a musical sentence.  It is written using @code{\(} and @code{\)}
2011 respectively
2012
2013 @lilypond[quote,ragged-right,fragment,verbatim,relative=1]
2014 \time 6/4 c'\( d( e) f( e) d\)
2015 @end lilypond
2016
2017 Typographically, the phrasing slur behaves almost exactly like a
2018 normal slur.  However, they are treated as different objects.  A
2019 @code{\slurUp} will have no effect on a phrasing slur; instead, use
2020 @code{\phrasingSlurUp}, @code{\phrasingSlurDown}, and
2021 @code{\phrasingSlurNeutral}.
2022
2023 You cannot have simultaneous phrasing slurs.
2024
2025
2026 @refcommands
2027
2028 @funindex \phrasingSlurUp
2029 @code{\phrasingSlurUp},
2030 @funindex \phrasingSlurDown
2031 @code{\phrasingSlurDown},
2032 @funindex \phrasingSlurNeutral
2033 @code{\phrasingSlurNeutral}.
2034
2035
2036 @seealso
2037
2038 Program reference: @internalsref{PhrasingSlur}.
2039
2040
2041 @node Laissez vibrer ties
2042 @subsection Laissez vibrer ties
2043 @cindex Laissez vibrer
2044 @cindex Ties, laissez vibrer
2045
2046 L.v. ties (laissez vibrer) indicate that notes must not be damped at the
2047 end. It is used in notation for piano, harp and other string and
2048 percussion instruments. They can be entered using @code{\laissezVibrer},
2049
2050 @lilypond[fragment,ragged-right,verbatim,relative=1]
2051 <c f g>\laissezVibrer
2052 @end lilypond
2053
2054 @seealso
2055
2056 Program reference:
2057 @internalsref{LaissezVibrerTie}
2058 @internalsref{LaissezVibrerTieColumn}
2059
2060 Example files:
2061 @inputfileref{input/regression,laissez-vibrer-tie.ly}
2062
2063
2064 @node Automatic beams
2065 @subsection Automatic beams
2066
2067 LilyPond inserts beams automatically
2068
2069 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
2070 \time 2/4 c8 c c c \time 6/8 c c c c8. c16 c8
2071 @end lilypond
2072
2073 When these automatic decisions are not good enough, beaming can be
2074 entered explicitly.  It is also possible to define beaming patterns
2075 that differ from the defaults.  See @ref{Setting automatic beam behavior}
2076 for details.
2077
2078 Individual notes may be marked with @code{\noBeam} to prevent them
2079 from being beamed
2080
2081 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
2082 \time 2/4 c8 c\noBeam c c
2083 @end lilypond
2084
2085
2086 @seealso
2087
2088 Program reference: @internalsref{Beam}.
2089
2090
2091 @node Manual beams
2092 @subsection Manual beams
2093
2094 @cindex beams, manual
2095 @funindex ]
2096 @funindex [
2097
2098 In some cases it may be necessary to override the automatic beaming
2099 algorithm.  For example, the autobeamer will not put beams over rests
2100 or bar lines.  Such beams are specified manually by marking the begin
2101 and end point with @code{[} and @code{]}
2102
2103 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
2104 {
2105   r4 r8[ g' a r8] r8 g[ | a] r8
2106 }
2107 @end lilypond
2108
2109
2110 @commonprop
2111
2112 @funindex stemLeftBeamCount
2113 @funindex stemRightBeamCount
2114
2115 Normally, beaming patterns within a beam are determined automatically.
2116 If necessary, the properties @code{stemLeftBeamCount} and
2117 @code{stemRightBeamCount} can be used to override the defaults.  If
2118 either property is set, its value will be used only once, and then it
2119 is erased
2120
2121 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
2122 {
2123    f8[ r16
2124       f g a]
2125    f8[ r16
2126    \set stemLeftBeamCount = #1
2127       f g a]
2128 }
2129 @end lilypond
2130
2131 The property @code{subdivideBeams} can be set in order to subdivide
2132 all 16th or shorter beams at beat positions, as defined by the
2133 @code{beatLength} property.
2134
2135 @lilypond[fragment,quote,relative=2,verbatim]
2136 c16[ c c c c c c c]
2137 \set subdivideBeams = ##t
2138 c16[ c c c c c c c]
2139 \set Score.beatLength = #(ly:make-moment 1 8)
2140 c16[ c c c c c c c]
2141 @end lilypond
2142 @funindex subdivideBeams
2143
2144 @noindent
2145 For more information about @code{make-moment}, see
2146 @ref{Time administration}.
2147
2148 Line breaks are normally forbidden when beams cross bar lines.  This
2149 behavior can be changed by setting @code{allowBeamBreak}.
2150
2151 @funindex allowBeamBreak
2152 @cindex beams and line breaks
2153 @cindex beams, kneed
2154 @cindex kneed beams
2155 @cindex auto-knee-gap
2156
2157
2158 @refbugs
2159
2160 Kneed beams are inserted automatically when a large gap is detected
2161 between the note heads.  This behavior can be tuned through the object.
2162
2163 Automatically kneed cross-staff beams cannot be used together with
2164 hidden staves.  See @ref{Hiding staves}.
2165
2166 Beams do not avoid collisions with symbols around the notes, such as
2167 texts and accidentals.
2168
2169
2170 @node Grace notes
2171 @subsection Grace notes
2172
2173 @funindex \grace
2174 @cindex ornaments
2175 @cindex grace notes
2176 @cindex appoggiatura
2177 @cindex acciaccatura
2178
2179 Grace notes are ornaments that are written out.  The most common ones
2180 are acciaccatura, which should be played as very short.  It is denoted
2181 by a slurred small note with a slashed stem.  The appoggiatura is a
2182 grace note that takes a fixed fraction of the main note, and is
2183 denoted as a slurred note in small print without a slash.  They
2184 are entered with the commands @code{\acciaccatura} and
2185 @code{\appoggiatura}, as demonstrated in the following example
2186
2187 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
2188 b4 \acciaccatura d8 c4 \appoggiatura e8 d4
2189 \acciaccatura { g16[ f] } e4
2190 @end lilypond
2191
2192 Both are special forms of the @code{\grace} command.  By prefixing this
2193 keyword to a music expression, a new one is formed, which will be
2194 printed in a smaller font and takes up no logical time in a measure.
2195
2196 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
2197 c4 \grace c16 c4
2198 \grace { c16[ d16] } c2 c4
2199 @end lilypond
2200
2201 @noindent
2202 Unlike @code{\acciaccatura} and @code{\appoggiatura}, the
2203 @code{\grace} command does not start a slur.
2204
2205 Internally, timing for grace notes is done using a second, `grace'
2206 timing.  Every point in time consists of two rational numbers: one
2207 denotes the logical time, one denotes the grace timing.  The above
2208 example is shown here with timing tuples
2209
2210 @lilypond[quote,ragged-right]
2211 <<
2212   \relative c''{
2213     c4 \grace c16 c4 \grace {
2214     c16[ d16] } c2 c4
2215   }
2216   \new Lyrics \lyricmode {
2217     \override LyricText #'font-family = #'typewriter
2218
2219     \markup { (0,0) } 4
2220     \grace { \markup {
2221       ( \fraction 1 4 , \fraction -1 16 ) } 16 }
2222     \markup { (\fraction 1 4 , 0 ) } 4
2223     \grace {
2224       \markup { (\fraction 2 4 , \fraction "-1" 8 ) } 16
2225       \markup { (\fraction 2 4 , \fraction "-1" 16 ) } 16
2226     }
2227     \markup { ( \fraction 2 4 , 0 ) }
2228   }
2229 >>
2230 @end lilypond
2231
2232 The placement of grace notes is synchronized between different staves.
2233 In the following example, there are two sixteenth grace notes for
2234 every eighth grace note
2235
2236 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
2237 << \new Staff { e4 \grace { c16[ d e f] } e4 }
2238    \new Staff { c4 \grace { g8[ b] } c4 } >>
2239 @end lilypond
2240
2241 @funindex \afterGrace
2242
2243 If you want to end a note with a grace, use the @code{\afterGrace}
2244 command.  It takes two arguments: the main note, and the grace notes
2245 following the main note.
2246
2247 @lilypond[ragged-right, verbatim,relative=2,fragment]
2248 c1 \afterGrace d1 { c16[ d] } c4
2249 @end lilypond
2250
2251 This will put the grace notes after a ``space'' lasting 3/4 of the
2252 length of the main note.  The fraction 3/4 can be changed by setting
2253 @code{afterGraceFraction}, ie.
2254
2255 @example
2256 afterGraceFraction = #(cons 7 8)
2257 @end example
2258
2259 @noindent
2260 will put the grace note at 7/8 of the main note.
2261
2262 The same effect can be achieved manually by doing
2263
2264 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
2265 \new Voice {
2266   << { d1^\trill_( }
2267      { s2 \grace { c16[ d] } } >>
2268   c4)
2269 }
2270 @end lilypond
2271
2272 @noindent
2273 By adjusting the duration of the skip note (here it is a half-note),
2274 the space between the main-note and the grace is adjusted.
2275
2276 A @code{\grace} section will introduce special typesetting settings,
2277 for example, to produce smaller type, and set directions.  Hence, when
2278 introducing layout tweaks, they should be inside the grace section,
2279 for example,
2280
2281 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
2282 \new Voice {
2283   \acciaccatura {
2284     \stemDown
2285     f16->
2286     \stemNeutral
2287   }
2288   g4
2289 }
2290 @end lilypond
2291
2292 @noindent
2293 The overrides should also be reverted inside the grace section.
2294
2295 The layout of grace sections can be changed throughout the music using
2296 the function @code{add-grace-property}.  The following example
2297 undefines the @code{Stem} direction for this grace, so
2298 that stems do not always point up.
2299
2300 @example
2301 \new Staff @{
2302   #(add-grace-property 'Voice 'Stem 'direction '())
2303   @dots{}
2304 @}
2305 @end example
2306
2307 @noindent
2308 Another option is to change the variables @code{startGraceMusic},
2309 @code{stopGraceMusic}, @code{startAcciaccaturaMusic},
2310 @code{stopAcciaccaturaMusic}, @code{startAppoggiaturaMusic},
2311 @code{stopAppoggiaturaMusic}.  More information is in the file
2312 @file{ly/@/grace@/-init@/.ly}.
2313
2314 @noindent
2315 The slash through the stem in acciaccaturas can be obtained
2316 in other situations by @code{\override Stem  #'stroke-style = #"grace"}.
2317
2318
2319 @commonprop
2320
2321 Grace notes may be forced to use floating spacing,
2322
2323 @lilypond[relative=2,ragged-right]
2324 <<
2325   \override Score.SpacingSpanner #'strict-grace-spacing = ##t
2326   \new Staff {
2327      c'4
2328      \afterGrace
2329      c'4
2330      { c'16[ c'8 c'16] }
2331      c'4
2332   }  
2333   \new Staff {
2334      c'16[ c'16 c'16 c'16]
2335      c'16[ c'16 c'16 c'16]
2336      c'4
2337   }
2338 >>
2339 @end lilypond
2340
2341
2342 @seealso
2343
2344 Program reference: @internalsref{GraceMusic}.
2345
2346
2347 @refbugs
2348
2349 A score that starts with a @code{\grace} section needs an explicit
2350 @code{\new Voice} declaration, otherwise the main note and the grace
2351 note end up on different staves.
2352
2353 Grace note synchronization can also lead to surprises.  Staff notation,
2354 such as key signatures, bar lines, etc., are also synchronized.  Take
2355 care when you mix staves with grace notes and staves without, for example,
2356
2357 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
2358 << \new Staff { e4 \bar "|:" \grace c16 d4 }
2359    \new Staff { c4 \bar "|:" d4 } >>
2360 @end lilypond
2361
2362 @noindent
2363 This can be remedied by inserting grace skips of the corresponding
2364 durations in the other staves. For the above example
2365
2366 @example
2367 \new Staff @{ c4 \bar "|:" \grace s16 d4 @}
2368 @end example
2369
2370 Grace sections should only be used within sequential music
2371 expressions.  Nesting or juxtaposing grace sections is not supported,
2372 and might produce crashes or other errors.
2373
2374
2375
2376 @node Expressive marks
2377 @section Expressive marks
2378
2379 Expressive marks help musicians to bring more to the music than simple
2380 notes and rhythms.
2381
2382 @menu
2383 * Articulations::               
2384 * Fingering instructions::      
2385 * Dynamics::                    
2386 * Breath marks::                
2387 * Trills::                      
2388 * Glissando::                   
2389 * Arpeggio::                    
2390 * Falls and doits::             
2391 @end menu
2392
2393
2394 @node Articulations
2395 @subsection Articulations
2396
2397 @cindex Articulations
2398 @cindex scripts
2399 @cindex ornaments
2400
2401 A variety of symbols can appear above and below notes to indicate
2402 different characteristics of the performance.  They are added to a note
2403 by adding a dash and the character signifying the
2404 articulation.  They are demonstrated here
2405
2406 @lilypondfile[quote,ragged-right]{script-abbreviations.ly}
2407
2408 The meanings of these shorthands can be changed.  See
2409 @file{ly/@/script@/-init@/.ly} for examples.
2410
2411 The script is automatically placed, but the direction can be forced as
2412 well.  Like other pieces of LilyPond code, @code{_} will place them
2413 below the staff, and @code{^} will place them above.
2414
2415 @lilypond[quote,ragged-right,fragment,verbatim]
2416 c''4^^ c''4_^
2417 @end lilypond
2418
2419 Other symbols can be added using the syntax
2420 @var{note}@code{\}@var{name}.  Again, they
2421 can be forced up or down using @code{^} and @code{_},
2422 e.g.,
2423
2424 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
2425 c\fermata c^\fermata c_\fermata
2426 @end lilypond
2427
2428 @cindex accent
2429 @cindex marcato
2430 @cindex staccatissimo
2431 @cindex espressivo
2432 @cindex fermata
2433 @cindex stopped
2434 @cindex staccato
2435 @cindex portato
2436 @cindex tenuto
2437 @cindex upbow
2438 @cindex downbow
2439 @cindex foot marks
2440 @cindex organ pedal marks
2441 @cindex turn
2442 @cindex open
2443 @cindex flageolet
2444 @cindex reverseturn
2445 @cindex trill
2446 @cindex prall
2447 @cindex mordent
2448 @cindex prallprall
2449 @cindex prallmordent
2450 @cindex prall, up
2451 @cindex prall, down
2452 @cindex mordent
2453 @cindex thumb marking
2454 @cindex segno
2455 @cindex coda
2456 @cindex varcoda
2457
2458 Here is a chart showing all scripts available,
2459
2460 @lilypondfile[ragged-right,quote]{script-chart.ly}
2461
2462
2463 @commonprop
2464
2465 The vertical ordering of scripts is controlled with the
2466 @code{script-priority} property.  The lower this number, the closer it
2467 will be put to the note.  In this example, the
2468 @internalsref{TextScript} (the sharp symbol) first has the lowest
2469 priority, so it is put lowest in the first example.  In the second, the
2470 prall trill (the @internalsref{Script}) has the lowest, so it is on the
2471 inside.  When two objects have the same priority, the order in which
2472 they are entered decides which one comes first.
2473
2474 @lilypond[verbatim,relative=3,ragged-right,fragment,quote]
2475 \once \override TextScript #'script-priority = #-100
2476 a4^\prall^\markup { \sharp }
2477
2478 \once \override Script #'script-priority = #-100
2479 a4^\prall^\markup { \sharp }
2480 @end lilypond
2481
2482
2483 @seealso
2484
2485 Program reference: @internalsref{Script}.
2486
2487
2488 @refbugs
2489
2490 These signs appear in the printed output but have no effect on the
2491 MIDI rendering of the music.
2492
2493
2494 @node Fingering instructions
2495 @subsection Fingering instructions
2496
2497 @cindex fingering
2498 @cindex finger change
2499
2500 Fingering instructions can be entered using
2501 @example
2502 @var{note}-@var{digit}
2503 @end example
2504 For finger changes, use markup texts
2505
2506 @lilypond[quote,verbatim,ragged-right,fragment,relative=1]
2507 c4-1 c-2 c-3 c-4
2508 c^\markup { \finger "2 - 3" }
2509 @end lilypond
2510
2511 You can use the thumb-script to indicate that a note should be
2512 played with the thumb (e.g., in cello music)
2513 @lilypond[quote,verbatim,ragged-right,fragment,relative=2]
2514 <a_\thumb a'-3>8 <b_\thumb b'-3>
2515 @end lilypond
2516
2517 Fingerings for chords can also be added to individual notes
2518 of the chord by adding them after the pitches
2519 @lilypond[quote,verbatim,ragged-right,fragment,relative=2]
2520 < c-1 e-2 g-3 b-5 >4
2521 @end lilypond
2522
2523
2524 @commonprop
2525
2526 You may exercise greater control over fingering chords by
2527 setting @code{fingeringOrientations}
2528
2529 @lilypond[quote,verbatim,ragged-right,fragment,relative=1]
2530 \set fingeringOrientations = #'(left down)
2531 <c-1 es-2 g-4 bes-5 > 4
2532 \set fingeringOrientations = #'(up right down)
2533 <c-1 es-2 g-4 bes-5 > 4
2534 @end lilypond
2535
2536 Using this feature, it is also possible to put fingering instructions
2537 very close to note heads in monophonic music,
2538
2539 @lilypond[verbatim,ragged-right,quote,fragment]
2540 \set fingeringOrientations = #'(right)
2541 <es'-2>4
2542 @end lilypond
2543
2544
2545 @seealso
2546
2547 Program reference: @internalsref{Fingering}.
2548
2549 Examples: @inputfileref{input/@/regression,finger@/-chords@/.ly}.
2550
2551
2552 @node Dynamics
2553 @subsection Dynamics
2554
2555 @cindex Dynamics
2556 @funindex \pppp
2557 @funindex \ppp
2558 @funindex \pp
2559 @funindex \p
2560 @funindex \mp
2561 @funindex \mf
2562 @funindex \f
2563 @funindex \ff
2564 @funindex \fff
2565 @funindex \ffff
2566 @funindex \fp
2567 @funindex \sf
2568 @funindex \sff
2569 @funindex \sp
2570 @funindex \spp
2571 @funindex \sfz
2572 @funindex \rfz
2573
2574 Absolute dynamic marks are specified using a command after a note
2575 @code{c4\ff}.  The available dynamic marks are @code{\ppppp},
2576 @code{\pppp}, @code{\ppp},
2577 @code{\pp}, @code{\p}, @code{\mp}, @code{\mf}, @code{\f}, @code{\ff},
2578 @code{\fff}, @code{\ffff}, @code{\fp}, @code{\sf}, @code{\sff},
2579 @code{\sp}, @code{\spp}, @code{\sfz}, and @code{\rfz}.
2580
2581 @lilypond[quote,verbatim,ragged-right,fragment,relative=2]
2582 c\ppp c\pp c \p c\mp c\mf c\f c\ff c\fff
2583 c2\fp c\sf c\sff c\sp c\spp c\sfz c\rfz
2584 @end lilypond
2585
2586 @funindex \<
2587 @funindex \>
2588 @funindex \!
2589
2590 A crescendo mark is started with @code{\<} and terminated with
2591 @code{\!} or an absolute dynamic.  A decrescendo is started with
2592 @code{\>} and is also terminated with @code{\!} or an absolute
2593 dynamic.  @code{\cr} and @code{\decr} may be used instead of
2594 @code{\<} and @code{\>}.  Because these marks are bound to notes, you must
2595 use spacer notes if multiple marks are needed during one note
2596
2597 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
2598 c\< c\! d\> e\!
2599 << f1 { s4 s4\< s4\! \> s4\! } >>
2600 @end lilypond
2601
2602 @noindent
2603 A hairpin starts at the left edge of the beginning note and ends on the
2604 right edge of the ending note.  This may be modified by setting
2605 the @code{hairpinToBarline} property,
2606
2607 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
2608 \set hairpinToBarline = ##t
2609 c4\< c2. c4\!
2610 @end lilypond
2611
2612 In some situations the @code{\espressivo} articulation mark may
2613 be suitable to indicate a crescendo and decrescendo on the one note,
2614
2615 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
2616 c2 b4 a g1\espressivo
2617 @end lilypond
2618
2619 This may give rise to very short hairpins.  Use @code{minimum-length}
2620 in @internalsref{Voice}.@internalsref{Hairpin} to lengthen them, for
2621 example
2622
2623 @example
2624 \override Voice.Hairpin #'minimum-length = #5
2625 @end example
2626
2627 @cindex al niente
2628 @cindex niente, al
2629
2630 Hairpins may be printed with a circled tip (al niente notation) by
2631 setting the @code{circled-tip} property,
2632
2633 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
2634 \override Hairpin #'circled-tip = ##t
2635 c2\< c\!
2636 c4\> c\< c2\!
2637 @end lilypond
2638
2639
2640 @cindex crescendo
2641 @cindex decrescendo
2642 @cindex diminuendo
2643
2644 You can also use text saying @emph{cresc.} instead of hairpins
2645
2646 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
2647 \setTextCresc
2648 c\< d e f\!
2649 \setHairpinCresc
2650 e\> d c b\!
2651 \setTextDecresc
2652 c\> d e f\!
2653 \setTextDim
2654 e\> d c b\!
2655 @end lilypond
2656
2657 You can also supply your own texts
2658 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
2659 \set crescendoText = \markup { \italic "cresc. poco" }
2660 \set crescendoSpanner = #'dashed-line
2661 a'2\< a a a\!\mf
2662 @end lilypond
2663
2664 To create new dynamic marks or text that should be aligned
2665 with dynamics, see @ref{New dynamic marks}.
2666
2667
2668 @commonprop
2669
2670 Dynamics that occur at, begin on, or end on, the same note
2671 will be vertically aligned.  If you want to ensure that dynamics
2672 are aligned when they do not occur on the same note, you can
2673 increase the @code{staff-padding} property.
2674
2675 @example
2676 \override DynamicLineSpanner #'staff-padding = #4
2677 @end example
2678
2679 You may also use this property if the dynamics are colliding
2680 with other notation.
2681
2682 Crescendi and decrescendi that end on the first note of a
2683 new line are not printed.  To change this behavior, use
2684
2685 @example
2686 \override Score.Hairpin #'after-line-breaking = ##t
2687 @end example
2688
2689 Text style dynamic changes (such as @emph{cresc.} and @emph{dim.})
2690 are printed with a
2691 dashed line showing their extent.  To surpress printing this line, use
2692
2693 @example
2694 \override DynamicTextSpanner #'dash-period = #-1.0
2695 @end example
2696
2697
2698 @refcommands
2699
2700 @funindex \dynamicUp
2701 @code{\dynamicUp},
2702 @funindex \dynamicDown
2703 @code{\dynamicDown},
2704 @funindex \dynamicNeutral
2705 @code{\dynamicNeutral}.
2706
2707
2708 @seealso
2709
2710 Program reference: @internalsref{DynamicText}, @internalsref{Hairpin}.
2711 Vertical positioning of these symbols is handled by
2712 @internalsref{DynamicLineSpanner}.
2713
2714
2715 @node Breath marks
2716 @subsection Breath marks
2717
2718 Breath marks are entered using @code{\breathe}
2719
2720 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
2721 c'4 \breathe d4
2722 @end lilypond
2723
2724
2725 @commonprop
2726
2727 The glyph of the breath mark can be tuned by overriding the
2728 @code{text} property of the @code{BreathingSign} layout object with
2729 any markup text.  For example,
2730 @lilypond[quote,ragged-right,fragment,verbatim,relative=1]
2731 c'4
2732 \override BreathingSign #'text
2733   = #(make-musicglyph-markup "scripts.rvarcomma")
2734 \breathe
2735 d4
2736 @end lilypond
2737
2738 @seealso
2739
2740 Program reference: @internalsref{BreathingSign}.
2741
2742 Examples: @inputfileref{input/@/regression,breathing@/-sign@/.ly}.
2743
2744
2745 @node Trills
2746 @subsection Trills
2747
2748 Short trills are printed like normal articulation; see @ref{Articulations}.
2749
2750 Long running trills are made with @code{\startTrillSpan} and
2751 @code{\stopTrillSpan},
2752
2753 @lilypond[verbatim,ragged-right,relative=2,quote,fragment]
2754 \new Voice {
2755   << { c1 \startTrillSpan }
2756      { s2. \grace { d16[\stopTrillSpan e] } } >>
2757   c4 }
2758 @end lilypond
2759
2760 @cindex Pitched trills
2761
2762 Trills that should be executed on an explicitly specified pitch can be
2763 typeset with the command @code{pitchedTrill},
2764
2765 @lilypond[ragged-right,verbatim,fragment,relative=1,quote]
2766 \pitchedTrill c4\startTrillSpan fis
2767 f\stopTrillSpan
2768 @end lilypond
2769
2770 The first argument is the main note.  The pitch of the second
2771 is printed as a stemless note head in parentheses.
2772
2773
2774 @refcommands
2775
2776 @code{\startTrillSpan},
2777 @funindex \startTrillSpan
2778 @code{\stopTrillSpan}.
2779 @funindex \stopTrillSpan
2780
2781
2782 @seealso
2783
2784 Program reference: @internalsref{TrillSpanner}.
2785
2786
2787 @node Glissando
2788 @subsection Glissando
2789
2790 @cindex Glissando
2791 @funindex \glissando
2792
2793 A glissando is a smooth change in pitch.  It is denoted by a line or a
2794 wavy line between two notes.  It is requested by attaching
2795 @code{\glissando} to a note
2796
2797 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
2798 c2\glissando c'
2799 \override Glissando #'style = #'zigzag
2800 c2\glissando c,
2801 @end lilypond
2802
2803
2804 @seealso
2805
2806 Program reference: @internalsref{Glissando}.
2807
2808 Example files: @file{input/@/regression/@/glissando@/.ly}.
2809
2810
2811 @refbugs
2812
2813 Printing text over the line (such as @emph{gliss.}) is not supported.
2814
2815
2816 @node Arpeggio
2817 @subsection Arpeggio
2818
2819 @cindex Arpeggio
2820 @cindex broken chord
2821 @funindex \arpeggio
2822
2823 You can specify an arpeggio sign (also known as broken chord) on a
2824 chord by attaching an @code{\arpeggio} to a chord
2825
2826 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
2827 <c e g c>\arpeggio
2828 @end lilypond
2829
2830 A square bracket on the left indicates that the player should not
2831 arpeggiate the chord
2832
2833 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
2834 \arpeggioBracket
2835 <c' e g c>\arpeggio
2836 @end lilypond
2837
2838 The direction of the arpeggio is sometimes denoted by adding an
2839 arrowhead to the wiggly line
2840
2841 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
2842 \new Voice {
2843   \arpeggioUp
2844   <c e g c>\arpeggio
2845   \arpeggioDown
2846   <c e g c>\arpeggio
2847 }
2848 @end lilypond
2849
2850
2851 @commonprop
2852
2853 When an arpeggio crosses staves, you may attach an arpeggio to the chords
2854 in both staves and set
2855 @internalsref{PianoStaff}.@code{connectArpeggios}
2856
2857 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
2858 \new PianoStaff <<
2859   \set PianoStaff.connectArpeggios = ##t
2860   \new Staff { <c' e g c>\arpeggio }
2861   \new Staff { \clef bass <c,, e g>\arpeggio }
2862 >>
2863 @end lilypond
2864
2865
2866 @refcommands
2867
2868 @code{\arpeggio},
2869 @funindex \arpeggioUp
2870 @code{\arpeggioUp},
2871 @funindex \arpeggioDown
2872 @code{\arpeggioDown},
2873 @funindex \arpeggioNeutral
2874 @code{\arpeggioNeutral},
2875 @funindex \arpeggioBracket
2876 @code{\arpeggioBracket}.
2877
2878
2879 @seealso
2880
2881 Notation manual: @ref{Ties}, for writing out arpeggios.
2882
2883 Program reference: @internalsref{Arpeggio}.
2884
2885
2886 @refbugs
2887
2888 It is not possible to mix connected arpeggios and unconnected
2889 arpeggios in one @internalsref{PianoStaff} at the same point in time.
2890
2891
2892 @node Falls and doits
2893 @subsection Falls and doits
2894
2895 Falls and doits can be added to notes using the @code{\bendAfter}
2896 command,
2897
2898 @lilypond[fragment,ragged-right,relative=2]
2899 \override Score.SpacingSpanner #'shortest-duration-space = #3.0
2900 c4-\bendAfter #+5
2901 c4-\bendAfter #-3
2902 @end lilypond
2903
2904
2905 @node Repeats
2906 @section Repeats
2907
2908 Repetition is a central concept in music, and multiple notations exist
2909 for repetitions.
2910
2911 @menu
2912 * Repeat types::                
2913 * Repeat syntax::               
2914 * Repeats and MIDI::            
2915 * Manual repeat commands::      
2916 * Tremolo repeats::             
2917 * Tremolo subdivisions::        
2918 * Measure repeats::             
2919 @end menu
2920
2921
2922 @node Repeat types
2923 @subsection Repeat types
2924
2925 @cindex repeats
2926 @funindex \repeat
2927
2928 The following types of repetition are supported
2929
2930 @table @code
2931 @item unfold
2932 Repeated music is fully written (played) out.  This is useful when
2933 entering repetitious music.  This is the only kind of repeat that
2934 is included in MIDI output.
2935
2936 @item volta
2937 Repeats are not written out, but alternative endings (volte) are
2938 printed, left to right with brackets.  This is the standard notation
2939 for repeats with alternatives.  These are not played in MIDI output by
2940 default.
2941
2942 @ignore
2943 @item fold
2944 Alternative endings are written stacked.  This has limited use but may be
2945 used to typeset two lines of lyrics in songs with repeats, see
2946 @inputfileref{input,star-spangled-banner@/.ly}.
2947 @end ignore
2948
2949 @item tremolo
2950 Make tremolo beams.  These are not played in MIDI output by default.
2951
2952 @item percent
2953 Make beat or measure repeats.  These look like percent signs.  These
2954 are not played in MIDI output by default.  Percent repeats must be
2955 declared within a @code{Voice} context.
2956
2957 @end table
2958
2959
2960 @node Repeat syntax
2961 @subsection Repeat syntax
2962
2963 LilyPond has one syntactic construct for specifying different types of
2964 repeats.  The syntax is
2965
2966 @example
2967 \repeat @var{variant} @var{repeatcount} @var{repeatbody}
2968 @end example
2969
2970 If you have alternative endings, you may add
2971 @funindex \alternative
2972 @example
2973 \alternative @{
2974   @var{alternative1}
2975   @var{alternative2}
2976   @var{alternative3}
2977   @dots{}
2978 @}
2979 @end example
2980
2981 @noindent
2982 where each @var{alternative} is a music expression.  If you do not
2983 give enough alternatives for all of the repeats, the first alternative
2984 is assumed to be played more than once.
2985
2986 Standard repeats are used like this
2987 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
2988 c1
2989 \repeat volta 2 { c4 d e f }
2990 \repeat volta 2 { f e d c }
2991 @end lilypond
2992
2993 With alternative endings
2994 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
2995 c1
2996 \repeat volta 2 {c4 d e f}
2997 \alternative { {d2 d} {f f,} }
2998 @end lilypond
2999
3000 In the following example, the first ending is not a complete
3001 bar (it only had 3 beats).  The beginning of the second ending
3002 contains the 4th beat from the first ending.  This ``extra''
3003 beat in the second ending is due to the first time ending,
3004 and has nothing to do with the @code{\partial} at the
3005 beginning of the example.
3006
3007 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
3008 \new Staff {
3009   \partial 4
3010   \repeat volta 4 { e | c2 d2 | e2 f2 | }
3011   \alternative { { g4 g g } { a | a a a a | b2. } }
3012 }
3013 @end lilypond
3014
3015 @funindex \repeatTie
3016
3017 Ties may be added to a second ending,
3018
3019 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
3020 c1
3021 \repeat volta 2 {c4 d e f ~ }
3022 \alternative { {f2 d} {f\repeatTie f,} }
3023 @end lilypond
3024
3025 It is possible to shorten volta brackets
3026 by setting @code{voltaSpannerDuration}.  In the next example, the
3027 bracket only lasts one measure, which is a duration of 3/4.
3028
3029 @lilypond[verbatim,ragged-right,quote]
3030 \relative c''{
3031   \time 3/4
3032   c c c
3033   \set Staff.voltaSpannerDuration = #(ly:make-moment 3 4)
3034   \repeat "volta" 5 { d d d }
3035   \alternative { { e e e f f f }
3036   { g g g } }
3037 }
3038 @end lilypond
3039
3040
3041 @seealso
3042
3043 Examples:
3044
3045 Brackets for the repeat are normally only printed over the topmost
3046 staff.  This can be adjusted by setting the @code{voltaOnThisStaff}
3047 property; see @inputfileref{input/@/regression,volta@/-multi@/-staff@/.ly}.
3048
3049
3050 @refbugs
3051
3052 @cindex repeat, ambiguous
3053
3054 A nested repeat like
3055
3056 @example
3057 \repeat @dots{}
3058 \repeat @dots{}
3059 \alternative
3060 @end example
3061
3062 @noindent
3063 is ambiguous, since it is is not clear to which @code{\repeat} the
3064 @code{\alternative} belongs.  This ambiguity is resolved by always
3065 having the @code{\alternative} belong to the inner @code{\repeat}.
3066 For clarity, it is advisable to use braces in such situations.
3067
3068 Timing information is not remembered at the start of an alternative,
3069 so after a repeat timing information must be reset by hand; for
3070 example, by setting @code{Score.measurePosition} or entering
3071 @code{\partial}.  Similarly, slurs or ties are also not repeated.
3072
3073
3074 @node Repeats and MIDI
3075 @subsection Repeats and MIDI
3076
3077 @cindex expanding repeats
3078 @funindex \unfoldRepeats
3079
3080 With a little bit of tweaking, all types of repeats can be present
3081 in the MIDI output.  This is achieved by applying the
3082 @code{\unfoldRepeats} music function.  This function changes all
3083 repeats to unfold repeats.
3084
3085 @lilypond[quote,verbatim,fragment,line-width=8.0\cm]
3086 \unfoldRepeats {
3087   \repeat tremolo 8 {c'32 e' }
3088   \repeat percent 2 { c''8 d'' }
3089   \repeat volta 2 {c'4 d' e' f'}
3090   \alternative {
3091     { g' a' a' g' }
3092     {f' e' d' c' }
3093   }
3094 }
3095 \bar "|."
3096 @end lilypond
3097
3098 When creating a score file using @code{\unfoldRepeats} for MIDI,
3099 it is necessary to make two @code{\score} blocks: one for MIDI (with
3100 unfolded repeats) and one for notation (with volta, tremolo, and
3101 percent repeats).  For example,
3102
3103 @example
3104 \score @{
3105   @var{..music..}
3106   \layout @{ .. @}
3107 @}
3108 \score @{
3109   \unfoldRepeats @var{..music..}
3110   \midi @{ .. @}
3111 @}
3112 @end example
3113
3114
3115 @node Manual repeat commands
3116 @subsection Manual repeat commands
3117
3118 @funindex repeatCommands
3119
3120 The property @code{repeatCommands} can be used to control the layout of
3121 repeats.  Its value is a Scheme list of repeat commands.
3122
3123 @table @asis
3124 @item @code{start-repeat}
3125 Print a @code{|:} bar line.
3126
3127 @item @code{end-repeat}
3128 Print a @code{:|} bar line.
3129
3130 @item @code{(volta @var{text})}
3131 Print a volta bracket saying @var{text}: The text can be specified as
3132 a text string or as a markup text, see @ref{Text markup}.  Do not
3133 forget to change the font, as the default number font does not contain
3134 alphabetic characters;
3135
3136 @item @code{(volta #f)}
3137 Stop a running volta bracket.
3138 @end table
3139
3140 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
3141 c4
3142   \set Score.repeatCommands = #'((volta "93") end-repeat)
3143 c4 c4
3144   \set Score.repeatCommands = #'((volta #f))
3145 c4 c4
3146 @end lilypond
3147
3148
3149 @seealso
3150
3151 Program reference: @internalsref{VoltaBracket},
3152 @internalsref{RepeatedMusic},
3153 @internalsref{VoltaRepeatedMusic},
3154 @internalsref{UnfoldedRepeatedMusic}, and
3155 @internalsref{FoldedRepeatedMusic}.
3156
3157
3158 @node Tremolo repeats
3159 @subsection Tremolo repeats
3160
3161 @cindex tremolo beams
3162
3163 To place tremolo marks between notes, use @code{\repeat} with tremolo
3164 style
3165 @lilypond[quote,verbatim,ragged-right]
3166 \new Voice \relative c' {
3167   \repeat "tremolo" 8 { c16 d16 }
3168   \repeat "tremolo" 4 { c16 d16 }
3169   \repeat "tremolo" 2 { c16 d16 }
3170 }
3171 @end lilypond
3172
3173 Tremolo marks can also be put on a single note.  In this case, the
3174 note should not be surrounded by braces.
3175 @lilypond[quote,verbatim,ragged-right]
3176 \repeat "tremolo" 4 c'16
3177 @end lilypond
3178
3179 Similar output is obtained using the tremolo subdivision, described in
3180 @ref{Tremolo subdivisions}.
3181
3182
3183 @seealso
3184
3185 In this manual: @ref{Tremolo subdivisions}, @ref{Repeats}.
3186
3187 Program reference: @internalsref{Beam}, @internalsref{StemTremolo}.
3188
3189 Example files: @inputfileref{input/@/regression,chord@/-tremolo@/.ly},
3190 @inputfileref{input/@/regression,stem@/-tremolo@/.ly}.
3191
3192
3193 @node Tremolo subdivisions
3194 @subsection Tremolo subdivisions
3195
3196 @cindex tremolo marks
3197 @funindex tremoloFlags
3198
3199 Tremolo marks can be printed on a single note by adding
3200 `@code{:}[@var{number}]' after the note.  The number indicates the
3201 duration of the subdivision, and it must be at least 8.  A
3202 @var{length} value of 8 gives one line across the note stem.  If the
3203 length is omitted, the last value (stored in @code{tremoloFlags}) is
3204 used
3205
3206 @lilypond[quote,ragged-right,verbatim,fragment]
3207 c'2:8 c':32 | c': c': |
3208 @end lilypond
3209
3210
3211 @refbugs
3212
3213 Tremolos entered in this way do not carry over into the MIDI output.
3214
3215
3216 @seealso
3217
3218 In this manual: @ref{Tremolo repeats}.
3219
3220 Elsewhere: @internalsref{StemTremolo}.
3221
3222
3223 @node Measure repeats
3224 @subsection Measure repeats
3225
3226 @cindex percent repeats
3227 @cindex measure repeats
3228
3229 In the @code{percent} style, a note pattern can be repeated.  It is
3230 printed once, and then the pattern is replaced with a special sign.
3231 Patterns of one and two measures are replaced by percent-like signs,
3232 patterns that divide the measure length are replaced by slashes.
3233 Percent repeats must be declared within a @code{Voice} context.
3234
3235 @lilypond[quote,verbatim,ragged-right]
3236 \new Voice \relative c' {
3237   \repeat "percent" 4 { c4 }
3238   \repeat "percent" 2 { c2 es2 f4 fis4 g4 c4 }
3239 }
3240 @end lilypond
3241
3242 Measure repeats of more than 2 measures get a counter, if you switch
3243 on the @code{countPercentRepeats} property,
3244
3245 @lilypond[relative=2,fragment,quote,verbatim,ragged-right]
3246 \new Voice {
3247 \set countPercentRepeats = ##t
3248   \repeat "percent" 4 { c1 }
3249 }
3250 @end lilypond
3251
3252
3253
3254 Isolated percents can also be printed. This is done by putting a
3255 multi-measure rest with a different print function,
3256
3257 @lilypond[fragment,verbatim,quote]
3258 \override MultiMeasureRest #'stencil
3259   = #ly:multi-measure-rest::percent
3260 R1
3261 @end lilypond
3262
3263
3264
3265
3266 @seealso
3267
3268 Program reference: @internalsref{RepeatSlash},
3269 @internalsref{PercentRepeat}, @internalsref{DoublePercentRepeat},
3270 @internalsref{DoublePercentRepeatCounter},
3271 @internalsref{PercentRepeatCounter},
3272 @internalsref{PercentRepeatedMusic}.
3273
3274
3275