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