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