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