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