]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/basic-notation.itely
* Documentation/user/basic-notation.itely (Barnumber check): add section.
[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 @cindex @code{whichBar}
1215 @cindex @code{repeatCommands}
1216 @cindex @code{defaultBarType}
1217
1218 The command @code{\bar }@var{bartype} is a short cut for doing
1219 @code{\set Timing.whichBar = }@var{bartype}.  Whenever @code{whichBar}
1220 is set to a string, a bar line of that type is created.
1221
1222 A bar line is created whenever the @code{whichBar} property is set.
1223 At the start of a measure it is set to the contents of
1224 @code{Timing.defaultBarType}.  The contents of @code{repeatCommands} are used
1225 to override default measure bars.
1226
1227 You are encouraged to use @code{\repeat} for repetitions.  See
1228 @ref{Repeats}.
1229
1230
1231 @seealso
1232
1233 In this manual: @ref{Repeats}, @ref{System start delimiters}.
1234
1235 Program reference: @internalsref{BarLine} (created at
1236 @internalsref{Staff} level), @internalsref{SpanBar} (across staves).
1237
1238 Examples: @inputfileref{input/@/test,bar@/-lines@/.ly},
1239
1240
1241 @node Unmetered music
1242 @subsection Unmetered music
1243
1244 @cindex cadenza
1245 @cindex @code{\cadenzaOn}
1246 @cindex @code{\cadenzaOff}
1247
1248 Bar lines and bar numbers are calculated automatically.  For unmetered
1249 music (cadenzas, for example), this is not desirable.  To turn off
1250 automatic bar lines and bar numbers, use the commands @code{\cadenzaOn}
1251 and @code{\cadenzaOff}.
1252
1253 @lilypond[verbatim,quote,raggedright,relative=2,fragment]
1254 c4 d e d
1255 \cadenzaOn
1256 c4 c d8 d d f4 g4.
1257 \cadenzaOff
1258 \bar "|"
1259 d4 e d c
1260 @end lilypond
1261
1262
1263 @refbugs
1264
1265 LilyPond will only insert page breaks at a barline.  Unless the unmetered
1266 music ends before the end of the staff line, you will need to insert
1267 invisible bar lines
1268
1269 @example
1270 \bar ""
1271 @end example
1272
1273 @noindent
1274 to indicate where line breaks can occur.
1275
1276
1277 @node System start delimiters
1278 @subsection System start delimiters
1279
1280 @cindex start of system
1281 @cindex Staff, multiple
1282 @cindex bracket, vertical
1283 @cindex brace, vertical
1284 @cindex grand staff
1285 @cindex staff group
1286 @cindex staff, choir
1287
1288 Many scores consist of more than one staff.  These staves can be
1289 joined in four different ways
1290
1291 @itemize @bullet
1292 @item The group is started with a brace at the left, and bar lines are
1293 connected.  This is done with the @internalsref{GrandStaff} context.
1294
1295 @lilypond[verbatim,raggedright,quote]
1296 \new GrandStaff
1297 \relative <<
1298   \new Staff { c1 c }
1299   \new Staff { c c }
1300 >>
1301 @end lilypond
1302
1303 @item The group is started with a bracket, and bar lines are connected.
1304 This is done with the
1305 @internalsref{StaffGroup} context
1306
1307 @lilypond[verbatim,raggedright,quote]
1308 \new StaffGroup
1309 \relative <<
1310   \new Staff { c1 c }
1311   \new Staff { c c }
1312 >>
1313 @end lilypond
1314
1315 @item The group is started with a bracket, but bar lines are not
1316 connected.  This is done with the @internalsref{ChoirStaff} context.
1317
1318 @lilypond[verbatim,raggedright,quote]
1319 \new ChoirStaff
1320 \relative <<
1321   \new Staff { c1 c }
1322   \new Staff { c c }
1323 >>
1324 @end lilypond
1325
1326 @item The group is started with a vertical line.  Bar lines are not
1327 connected.  This is the default for the score.
1328
1329 @lilypond[verbatim,raggedright,quote]
1330 \relative <<
1331   \new Staff { c1 c }
1332   \new Staff { c c }
1333 >>
1334 @end lilypond
1335 @end itemize
1336
1337
1338 @seealso
1339
1340 The bar lines at the start of each system are
1341 @internalsref{SystemStartBar}, @internalsref{SystemStartBrace}, and
1342 @internalsref{SystemStartBracket}.  Only one of these types is created
1343 in every context, and that type is determined by the property
1344 @code{systemStartDelimiter}.
1345
1346
1347 @node Staff symbol
1348 @subsection Staff symbol
1349
1350 @cindex adjusting staff symbol
1351
1352 Notes, dynamic signs, etc., are grouped
1353 with a set of horizontal lines, called a staff (plural `staves').  In
1354 LilyPond, these lines are drawn using a separate layout object called
1355 staff symbol.
1356
1357 The staff symbol may be tuned in the number, thickness and distance
1358 of lines, using properties.  This is demonstrated in the example files
1359 @inputfileref{input/@/test,staff@/-lines@/.ly},
1360 @inputfileref{input/@/test,staff@/-size@/.ly}.
1361
1362 In addition, staves may be started and stopped at will. This is done
1363 with @code{\startStaff} and @code{\stopStaff}.
1364
1365 @lilypond[verbatim,relative=2,fragment]
1366 b4 b
1367 \override Staff.StaffSymbol #'line-count = 2
1368 \stopStaff \startStaff
1369 b b
1370 \revert Staff.StaffSymbol #'line-count
1371 \stopStaff \startStaff
1372 b b  
1373 @end lilypond
1374
1375 In combination with Frenched staves, this may be used to typeset ossia
1376 sections. An example is in @inputfileref{input/@/test@/,ossia.ly},
1377 shown here
1378
1379 @cindex ossia
1380
1381 @lilypondfile{ossia.ly}
1382
1383 @cindex staff lines, setting number of
1384 @cindex staff lines, setting thickness of
1385 @cindex thickness of staff lines, setting
1386 @cindex number of staff lines, setting
1387
1388 @seealso
1389
1390 Program reference: @internalsref{StaffSymbol}.
1391
1392 Examples: @inputfileref{input/@/test,staff@/-lines@/.ly},
1393 @inputfileref{input/@/test@/,ossia.ly},
1394 @inputfileref{input/@/test,staff@/-size@/.ly}.
1395
1396
1397
1398 @node Connecting notes
1399 @section Connecting notes
1400
1401 This section deals with notation that affects groups of notes.
1402
1403 @menu
1404 * Ties::                        
1405 * Slurs::                       
1406 * Phrasing slurs::              
1407 * Automatic beams::             
1408 * Manual beams::                
1409 * Grace notes::                 
1410 @end menu
1411
1412
1413 @node Ties
1414 @subsection Ties
1415
1416 @cindex tie
1417 @cindex @code{~}
1418
1419 A tie connects two adjacent note heads of the same pitch.  The tie in
1420 effect extends the length of a note.  Ties should not be confused with
1421 slurs, which indicate articulation, or phrasing slurs, which indicate
1422 musical phrasing.  A tie is entered using the tilde symbol `@code{~}'
1423
1424 @lilypond[quote,raggedright,fragment,verbatim]
1425 e' ~ e' <c' e' g'> ~ <c' e' g'>
1426 @end lilypond
1427
1428 When a tie is applied to a chord, all note heads whose pitches match
1429 are connected.  When no note heads match, no ties will be created.
1430
1431 A tie is just a way of extending a note duration, similar to the
1432 augmentation dot.  The following example shows two ways of notating
1433 exactly the same concept
1434
1435 @lilypond[quote,fragment,raggedright]
1436 \time 3/4 c'2. c'2 ~ c'4
1437 @end lilypond
1438
1439 @noindent
1440 Ties are used either when the note crosses a bar line, or when dots
1441 cannot be used to denote the rhythm.  When using ties, larger note
1442 values should be aligned to subdivisions of the measure, eg.
1443
1444 @lilypond[fragment,quote,raggedright]
1445 \relative {
1446   r8 c8 ~ c2 r4 | r8^"not" c2 ~ c8 r4
1447 }
1448 @end lilypond
1449
1450 If you need to tie a lot of notes over bars, it may be easier to use
1451 automatic note splitting (see @ref{Automatic note splitting}).  This
1452 mechanism automatically splits long notes, and ties them across bar
1453 lines.
1454
1455
1456 @commonprop
1457
1458 Ties are sometimes used to write out arpeggios.  In this case, two tied
1459 notes need not be consecutive.  This can be achieved by setting the
1460 @code{tieWaitForNote} property to true.  For example,
1461
1462 @lilypond[fragment,verbatim,relative=1,raggedright]
1463 \set tieWaitForNote = ##t
1464 \grace { c16[~ e~ g]~ } <c, e g>4   
1465 @end lilypond
1466
1467
1468 @refcommands
1469
1470
1471 @cindex @code{\tieUp}
1472 @code{\tieUp},
1473 @cindex @code{\tieDown}
1474 @code{\tieDown},
1475 @cindex @code{\tieNeutral}
1476 @code{\tieNeutral},
1477 @cindex @code{\tieDotted}
1478 @code{\tieDotted},
1479 @cindex @code{\tieDashed}
1480 @code{\tieDashed},
1481 @cindex @code{\tieSolid}
1482 @code{\tieSolid}.
1483
1484
1485 @seealso
1486
1487 In this manual: @ref{Automatic note splitting}.
1488
1489 Program reference: @internalsref{Tie}.
1490
1491
1492 @refbugs
1493
1494 Switching staves when a tie is active will not produce a slanted tie.
1495
1496 Formatting of ties is a difficult subject.  The results are often not
1497 optimal.
1498
1499
1500 @node Slurs
1501 @subsection Slurs
1502
1503 @cindex Slurs
1504
1505 A slur indicates that notes are to be played bound or
1506 @emph{legato}.  They are entered using parentheses
1507
1508 @lilypond[quote,raggedright,relative=2,fragment,verbatim]
1509 f( g a) a8 b( a4 g2 f4)
1510 <c e>2( <b d>2)
1511 @end lilypond
1512
1513 The direction of a slur can be specified with
1514 @code{\slur@emph{DIR}}, where @code{@emph{DIR}} is
1515 either @code{Up}, @code{Down}, or @code{Neutral} (automatically
1516 selected).
1517
1518 However, there is a convenient shorthand for forcing slur
1519 directions.  By adding @code{_} or @code{^} before the opening
1520 parentheses, the direction is also set.  For example,
1521
1522 @lilypond[relative=2,raggedright,quote,verbatim,fragment]
1523 c4_( c) c^( c)
1524 @end lilypond
1525
1526 Only one slur can be printed at once.  If you need to print a long
1527 slur over a few small slurs, please see @ref{Phrasing slurs}.
1528
1529
1530 @commonprop
1531
1532 Some composers write two slurs when they want legato chords.  This can
1533 be achieved in LilyPond by setting @code{doubleSlurs},
1534
1535 @lilypond[verbatim,raggedright,relative,fragment,quote]
1536 \set doubleSlurs = ##t
1537 <c e>4 ( <d f> <c e> <d f> )
1538 @end lilypond
1539
1540
1541 @refcommands
1542
1543 @cindex @code{\slurUp}
1544 @code{\slurUp},
1545 @cindex @code{\slurDown}
1546 @code{\slurDown},
1547 @cindex @code{\slurNeutral}
1548 @code{\slurNeutral},
1549 @cindex @code{\slurDashed}
1550 @code{\slurDashed},
1551 @cindex @code{\slurDotted}
1552 @code{\slurDotted},
1553 @cindex @code{\slurSolid}
1554 @code{\slurSolid}.
1555
1556 @seealso
1557
1558 Program reference: @seeinternals{Slur}.
1559
1560
1561 @node Phrasing slurs
1562 @subsection Phrasing slurs
1563
1564 @cindex phrasing slurs
1565 @cindex phrasing marks
1566
1567 A phrasing slur (or phrasing mark) connects notes and is used to
1568 indicate a musical sentence.  It is written using @code{\(} and @code{\)}
1569 respectively
1570
1571 @lilypond[quote,raggedright,fragment,verbatim,relative=1]
1572 \time 6/4 c'\( d( e) f( e) d\)
1573 @end lilypond
1574
1575 Typographically, the phrasing slur behaves almost exactly like a
1576 normal slur.  However, they are treated as different objects.  A
1577 @code{\slurUp} will have no effect on a phrasing slur; instead, use
1578 @code{\phrasingSlurUp}, @code{\phrasingSlurDown}, and
1579 @code{\phrasingSlurNeutral}.
1580
1581 You cannot have simultaneous phrasing slurs.
1582
1583
1584 @refcommands
1585
1586 @cindex @code{\phrasingSlurUp}
1587 @code{\phrasingSlurUp},
1588 @cindex @code{\phrasingSlurDown}
1589 @code{\phrasingSlurDown},
1590 @cindex @code{\phrasingSlurNeutral}
1591 @code{\phrasingSlurNeutral}.
1592
1593
1594 @seealso
1595
1596 Program reference: @internalsref{PhrasingSlur}.
1597
1598
1599 @node Automatic beams
1600 @subsection Automatic beams
1601
1602 LilyPond inserts beams automatically
1603
1604 @lilypond[quote,raggedright,fragment,verbatim,relative=2]
1605 \time 2/4 c8 c c c \time 6/8 c c c c8. c16 c8
1606 @end lilypond
1607
1608 When these automatic decisions are not good enough, beaming can be
1609 entered explicitly.  It is also possible to define beaming patterns
1610 that differ from the defaults.  See @ref{Setting automatic beam behavior}
1611 for details.
1612
1613 Individual notes may be marked with @code{\noBeam} to prevent them
1614 from being beamed
1615
1616 @lilypond[quote,raggedright,fragment,verbatim,relative=2]
1617 \time 2/4 c8 c\noBeam c c
1618 @end lilypond
1619
1620
1621 @seealso
1622
1623 Program reference: @internalsref{Beam}.
1624
1625
1626 @node Manual beams
1627 @subsection Manual beams
1628
1629 @cindex beams, manual
1630 @cindex @code{]}
1631 @cindex @code{[}
1632
1633 In some cases it may be necessary to override the automatic beaming
1634 algorithm.  For example, the autobeamer will not put beams over rests
1635 or bar lines.  Such beams are specified manually by marking the begin
1636 and end point with @code{[} and @code{]}
1637
1638 @lilypond[quote,raggedright,fragment,relative=1,verbatim]
1639 {
1640   r4 r8[ g' a r8] r8 g[ | a] r8
1641 }
1642 @end lilypond
1643
1644
1645 @commonprop
1646
1647 @cindex @code{stemLeftBeamCount}
1648 @cindex @code{stemRightBeamCount}
1649
1650 Normally, beaming patterns within a beam are determined automatically.
1651 If necessary, the properties @code{stemLeftBeamCount} and
1652 @code{stemRightBeamCount} can be used to override the defaults.  If
1653 either property is set, its value will be used only once, and then it
1654 is erased
1655
1656 @lilypond[quote,raggedright,fragment,relative=1,verbatim]
1657 {
1658    f8[ r16
1659       f g a]
1660    f8[ r16
1661    \set stemLeftBeamCount = #1
1662       f g a]
1663 }
1664 @end lilypond
1665
1666 The property @code{subdivideBeams} can be set in order to subdivide
1667 all 16th or shorter beams at beat positions, as defined by the
1668 @code{beatLength} property.
1669
1670 @lilypond[fragment,quote,relative=2,verbatim]
1671 c16[ c c c c c c c]
1672 \set subdivideBeams = ##t
1673 c16[ c c c c c c c]
1674 \set Score.beatLength = #(ly:make-moment 1 8)
1675 c16[ c c c c c c c]
1676 @end lilypond
1677 @cindex @code{subdivideBeams}
1678
1679 Line breaks are normally forbidden when beams cross bar lines.  This
1680 behavior can be changed by setting @code{allowBeamBreak}.
1681
1682 @cindex @code{allowBeamBreak}
1683 @cindex beams and line breaks
1684 @cindex beams, kneed
1685 @cindex kneed beams
1686 @cindex auto-knee-gap
1687
1688
1689 @refbugs
1690
1691 Kneed beams are inserted automatically when a large gap is detected
1692 between the note heads.  This behavior can be tuned through the object.
1693
1694 Automatically kneed cross-staff beams cannot be used together with
1695 hidden staves.  See @ref{Hiding staves}.
1696
1697 Beams do not avoid collisions with symbols around the notes, such as
1698 texts and accidentals.
1699
1700
1701 @node Grace notes
1702 @subsection Grace notes
1703
1704 @cindex @code{\grace}
1705 @cindex ornaments
1706 @cindex grace notes
1707 @cindex appoggiatura
1708 @cindex acciaccatura
1709
1710 Grace notes are ornaments that are written out.  The most common ones
1711 are acciaccatura, which should be played as very short.  It is denoted
1712 by a slurred small note with a slashed stem.  The appoggiatura is a
1713 grace note that takes a fixed fraction of the main note, and is
1714 denoted as a slurred note in small print without a slash.  They
1715 are entered with the commands @code{\acciaccatura} and
1716 @code{\appoggiatura}, as demonstrated in the following example
1717
1718 @lilypond[quote,raggedright,relative=2,verbatim,fragment]
1719 b4 \acciaccatura d8 c4 \appoggiatura e8 d4
1720 \acciaccatura { g16[ f] } e4
1721 @end lilypond
1722
1723 Both are special forms of the @code{\grace} command.  By prefixing this
1724 keyword to a music expression, a new one is formed, which will be
1725 printed in a smaller font and takes up no logical time in a measure.
1726
1727 @lilypond[quote,raggedright,relative=2,verbatim,fragment]
1728 c4 \grace c16 c4
1729 \grace { c16[ d16] } c2 c4
1730 @end lilypond
1731
1732 @noindent
1733 Unlike @code{\acciaccatura} and @code{\appoggiatura}, the
1734 @code{\grace} command does not start a slur.
1735
1736 Internally, timing for grace notes is done using a second, `grace'
1737 timing.  Every point in time consists of two rational numbers: one
1738 denotes the logical time, one denotes the grace timing.  The above
1739 example is shown here with timing tuples
1740
1741 @lilypond[quote,raggedright]
1742 <<
1743   \relative c''{
1744     c4 \grace c16 c4 \grace {
1745     c16[ d16] } c2 c4
1746   }
1747   \new Lyrics \lyricmode {
1748     \override LyricText #'font-family = #'typewriter
1749
1750     \markup { (0,0) } 4
1751     \grace { \markup {
1752       ( \fraction 1 4 , \fraction -1 16 ) } 16 }
1753     \markup { (\fraction 1 4 , 0 ) } 4
1754     \grace {
1755       \markup { (\fraction 2 4 , \fraction "-1" 8 ) } 16
1756       \markup { (\fraction 2 4 , \fraction "-1" 16 ) } 16
1757     }
1758     \markup { ( \fraction 2 4 , 0 ) }
1759   }
1760 >>
1761 @end lilypond
1762
1763 The placement of grace notes is synchronized between different staves.
1764 In the following example, there are two sixteenth grace notes for
1765 every eighth grace note
1766
1767 @lilypond[quote,raggedright,relative=2,verbatim,fragment]
1768 << \new Staff { e4 \grace { c16[ d e f] } e4 }
1769    \new Staff { c4 \grace { g8[ b] } c4 } >>
1770 @end lilypond
1771
1772 If you want to end a note with a grace, use the @code{\afterGrace}
1773 command.  It takes two arguments: the main note, and the grace notes
1774 following the main note. 
1775
1776 @lilypond[raggedright, verbatim,relative=2,fragment]
1777 c1 \afterGrace d1 { c16[ d] } c4   
1778 @end lilypond
1779
1780 This will put the grace notes after a ``space'' lasting 3/4 of the
1781 length of the main note.  The fraction 3/4 can be changed by setting
1782 @code{afterGraceFraction}, ie.
1783
1784 @example
1785 afterGraceFraction = #(cons 7 8) 
1786 @end example
1787
1788 @noindent
1789 will put the grace note at 7/8 of the main note. 
1790
1791 The same effect can be achieved manually by doing
1792
1793 @lilypond[quote,raggedright,fragment,verbatim,relative=2]
1794 \context Voice {
1795   << { d1^\trill_( }
1796      { s2 \grace { c16[ d] } } >>
1797   c4)
1798 }
1799 @end lilypond
1800
1801 @noindent
1802 By adjusting the duration of the skip note (here it is a half-note),
1803 the space between the main-note and the grace is adjusted.
1804
1805 A @code{\grace} section will introduce special typesetting settings,
1806 for example, to produce smaller type, and set directions.  Hence, when
1807 introducing layout tweaks, they should be inside the grace section,
1808 for example,
1809 @lilypond[quote,raggedright,fragment,verbatim,relative=2]
1810 \new Voice {
1811   \acciaccatura {
1812     \stemDown
1813     f16->
1814     \stemNeutral
1815   }
1816   g4
1817 }
1818 @end lilypond
1819
1820 @noindent
1821 The overrides should also be reverted inside the grace section.
1822
1823 The layout of grace sections can be changed throughout the music using
1824 the function @code{add-grace-property}.  The following example
1825 undefines the Stem direction for this grace, so stems do not always
1826 point up.
1827
1828 @example
1829 \new Staff @{
1830   #(add-grace-property 'Voice 'Stem 'direction '())
1831   @dots{}
1832 @}
1833 @end example
1834
1835 @noindent
1836 Another option is to change the variables @code{startGraceMusic},
1837 @code{stopGraceMusic}, @code{startAcciaccaturaMusic},
1838 @code{stopAcciaccaturaMusic}, @code{startAppoggiaturaMusic},
1839 @code{stopAppoggiaturaMusic}.  More information is in the file
1840 @file{ly/@/grace@/-init@/.ly}.
1841
1842
1843 @seealso
1844
1845 Program reference: @internalsref{GraceMusic}.
1846
1847
1848 @refbugs
1849
1850 A score that starts with a @code{\grace} section needs an explicit
1851 @code{\context Voice} declaration, otherwise the main note and the grace
1852 note end up on different staves.
1853
1854 Grace note synchronization can also lead to surprises.  Staff notation,
1855 such as key signatures, bar lines, etc., are also synchronized.  Take
1856 care when you mix staves with grace notes and staves without, for example,
1857
1858 @lilypond[quote,raggedright,relative=2,verbatim,fragment]
1859 << \new Staff { e4 \bar "|:" \grace c16 d4 }
1860    \new Staff { c4 \bar "|:" d4 } >>
1861 @end lilypond
1862
1863 @noindent
1864 This can be remedied by inserting grace skips, for the above example
1865
1866 @example
1867 \new Staff @{ c4 \bar "|:" \grace s16 d4 @}
1868 @end example
1869
1870 Grace sections should only be used within sequential music
1871 expressions.  Nesting or juxtaposing grace sections is not supported,
1872 and might produce crashes or other errors.
1873
1874
1875
1876 @node Expressive marks
1877 @section Expressive marks
1878
1879 Expressive marks help musicians to bring more to the music than simple
1880 notes and rhythms.
1881
1882 @menu
1883 * Articulations::               
1884 * Fingering instructions::      
1885 * Dynamics::                    
1886 * Breath marks::                
1887 * Running trills::              
1888 * Glissando::                   
1889 * Arpeggio::                    
1890 @end menu
1891
1892
1893 @node Articulations
1894 @subsection Articulations
1895
1896 @cindex Articulations
1897 @cindex scripts
1898 @cindex ornaments
1899
1900 A variety of symbols can appear above and below notes to indicate
1901 different characteristics of the performance.  They are added to a note
1902 by adding a dash and the character signifying the
1903 articulation.  They are demonstrated here
1904
1905 @lilypondfile[quote,raggedright]{script-abbreviations.ly}
1906
1907 The meanings of these shorthands can be changed.  See
1908 @file{ly/@/script@/-init@/.ly} for examples.
1909
1910 The script is automatically placed, but the direction can be forced as
1911 well.  Like other pieces of LilyPond code, @code{_} will place them
1912 below the staff, and @code{^} will place them above.
1913
1914 @lilypond[quote,raggedright,fragment,verbatim]
1915 c''4^^ c''4_^
1916 @end lilypond
1917
1918 Other symbols can be added using the syntax
1919 @var{note}@code{\}@var{name}.  Again, they
1920 can be forced up or down using @code{^} and @code{_},
1921 e.g.,
1922
1923 @lilypond[quote,raggedright,verbatim,fragment,relative=2]
1924 c\fermata c^\fermata c_\fermata
1925 @end lilypond
1926
1927 @cindex accent
1928 @cindex marcato
1929 @cindex staccatissimo
1930 @cindex espressivo
1931 @cindex fermata
1932 @cindex stopped
1933 @cindex staccato
1934 @cindex portato
1935 @cindex tenuto
1936 @cindex upbow
1937 @cindex downbow
1938 @cindex foot marks
1939 @cindex organ pedal marks
1940 @cindex turn
1941 @cindex open
1942 @cindex flageolet
1943 @cindex reverseturn
1944 @cindex trill
1945 @cindex prall
1946 @cindex mordent
1947 @cindex prallprall
1948 @cindex prallmordent
1949 @cindex prall, up
1950 @cindex prall, down
1951 @cindex mordent
1952 @cindex thumb marking
1953 @cindex segno
1954 @cindex coda
1955 @cindex varcoda
1956
1957 Here is a chart showing all scripts available,
1958
1959 @lilypondfile[raggedright,quote]{script-chart.ly}
1960
1961
1962 @commonprop
1963
1964 The vertical ordering of scripts is controlled with the
1965 @code{script-priority} property.  The lower this number, the closer it
1966 will be put to the note.  In this example, the
1967 @internalsref{TextScript} (the sharp symbol) first has the lowest
1968 priority, so it is put lowest in the first example.  In the second, the
1969 prall trill (the @internalsref{Script}) has the lowest, so it is on the
1970 inside.  When two objects have the same priority, the order in which
1971 they are entered decides which one comes first.
1972
1973 @lilypond[verbatim,relative=3,raggedright,fragment,quote]
1974 \once \override TextScript #'script-priority = #-100
1975 a4^\prall^\markup { \sharp }
1976
1977 \once \override Script #'script-priority = #-100
1978 a4^\prall^\markup { \sharp }
1979 @end lilypond
1980
1981
1982 @seealso
1983
1984 Program reference: @internalsref{Script}.
1985
1986
1987 @refbugs
1988
1989 These signs appear in the printed output but have no effect on the
1990 MIDI rendering of the music.
1991
1992
1993 @node Fingering instructions
1994 @subsection Fingering instructions
1995
1996 @cindex fingering
1997 @cindex finger change
1998
1999 Fingering instructions can be entered using
2000 @example
2001 @var{note}-@var{digit}
2002 @end example
2003 For finger changes, use markup texts
2004
2005 @lilypond[quote,verbatim,raggedright,fragment,relative=1]
2006 c4-1 c-2 c-3 c-4
2007 c^\markup { \finger "2 - 3" }
2008 @end lilypond
2009
2010 You can use the thumb-script to indicate that a note should be
2011 played with the thumb (e.g., in cello music)
2012 @lilypond[quote,verbatim,raggedright,fragment,relative=2]
2013 <a_\thumb a'-3>8 <b_\thumb b'-3>
2014 @end lilypond
2015
2016 Fingerings for chords can also be added to individual notes
2017 of the chord by adding them after the pitches
2018 @lilypond[quote,verbatim,raggedright,fragment,relative=2]
2019 < c-1 e-2 g-3 b-5 >4
2020 @end lilypond
2021
2022
2023 @commonprop
2024
2025 You may exercise greater control over fingering chords by
2026 setting @code{fingeringOrientations}
2027
2028 @lilypond[quote,verbatim,raggedright,fragment,relative=1]
2029 \set fingeringOrientations = #'(left down)
2030 <c-1 es-2 g-4 bes-5 > 4
2031 \set fingeringOrientations = #'(up right down)
2032 <c-1 es-2 g-4 bes-5 > 4
2033 @end lilypond
2034
2035 Using this feature, it is also possible to put fingering instructions
2036 very close to note heads in monophonic music,
2037
2038 @lilypond[verbatim,raggedright,quote,fragment]
2039 \set fingeringOrientations = #'(right)
2040 <es'-2>4
2041 @end lilypond
2042
2043
2044 @seealso
2045
2046 Program reference: @internalsref{Fingering}.
2047
2048 Examples: @inputfileref{input/@/regression,finger@/-chords@/.ly}.
2049
2050
2051 @node Dynamics
2052 @subsection Dynamics
2053
2054 @cindex Dynamics
2055 @cindex @code{\ppp}
2056 @cindex @code{\pp}
2057 @cindex @code{\p}
2058 @cindex @code{\mp}
2059 @cindex @code{\mf}
2060 @cindex @code{\f}
2061 @cindex @code{\ff}
2062 @cindex @code{\fff}
2063 @cindex @code{\ffff}
2064 @cindex @code{\fp}
2065 @cindex @code{\sf}
2066 @cindex @code{\sff}
2067 @cindex @code{\sp}
2068 @cindex @code{\spp}
2069 @cindex @code{\sfz}
2070 @cindex @code{\rfz}
2071
2072 Absolute dynamic marks are specified using a command after a note
2073 @code{c4\ff}.  The available dynamic marks are @code{\ppp},
2074 @code{\pp}, @code{\p}, @code{\mp}, @code{\mf}, @code{\f}, @code{\ff},
2075 @code{\fff}, @code{\fff}, @code{\fp}, @code{\sf}, @code{\sff},
2076 @code{\sp}, @code{\spp}, @code{\sfz}, and @code{\rfz}.
2077
2078 @lilypond[quote,verbatim,raggedright,fragment,relative=2]
2079 c\ppp c\pp c \p c\mp c\mf c\f c\ff c\fff
2080 c2\fp c\sf c\sff c\sp c\spp c\sfz c\rfz
2081 @end lilypond
2082
2083 @cindex @code{\<}
2084 @cindex @code{\>}
2085 @cindex @code{\!}
2086
2087 A crescendo mark is started with @code{\<} and terminated with
2088 @code{\!} or an absolute dynamic.  A decrescendo is started with
2089 @code{\>} and is also terminated with @code{\!} or an absolute
2090 dynamic.  Because these marks are bound to notes, you must
2091 use spacer notes if multiple marks are needed during one note
2092
2093 @lilypond[quote,raggedright,fragment,verbatim,relative=2]
2094 c\< c\! d\> e\!
2095 << f1 { s4 s4\< s4\! \> s4\! } >>
2096 @end lilypond
2097 This may give rise to very short hairpins.  Use @code{minimum-length}
2098 in @internalsref{Voice}.@internalsref{Hairpin} to lengthen them, for
2099 example
2100
2101 @example
2102 \override Staff.Hairpin #'minimum-length = #5
2103 @end example
2104
2105 @cindex crescendo
2106 @cindex decrescendo
2107 @cindex diminuendo
2108
2109 You can also use a text saying @emph{cresc.} instead of hairpins
2110
2111 @lilypond[quote,raggedright,fragment,relative=2,verbatim]
2112 \setTextCresc
2113 c\< d e f\!
2114 \setHairpinCresc
2115 e\> d c b\!
2116 \setTextDecresc
2117 c\> d e f\!
2118 \setTextDim
2119 e\> d c b\!
2120 @end lilypond
2121
2122 You can also supply your own texts
2123 @lilypond[quote,raggedright,fragment,relative=1,verbatim]
2124 \set crescendoText = \markup { \italic "cresc. poco" }
2125 \set crescendoSpanner = #'dashed-line
2126 a'2\< a a a\!\mf
2127 @end lilypond
2128
2129 To create new dynamic marks or text that should be aligned
2130 with dynamics, see @ref{New dynamic marks}.
2131
2132
2133 @refcommands
2134
2135 @cindex @code{\dynamicUp}
2136 @code{\dynamicUp},
2137 @cindex @code{\dynamicDown}
2138 @code{\dynamicDown},
2139 @cindex @code{\dynamicNeutral}
2140 @code{\dynamicNeutral}.
2141
2142
2143 @seealso
2144
2145 Program reference: @internalsref{DynamicText}, @internalsref{Hairpin}.
2146 Vertical positioning of these symbols is handled by
2147 @internalsref{DynamicLineSpanner}.
2148
2149
2150 @node Breath marks
2151 @subsection Breath marks
2152
2153 Breath marks are entered using @code{\breathe}
2154
2155 @lilypond[quote,raggedright,fragment,relative=1,verbatim]
2156 c'4 \breathe d4
2157 @end lilypond
2158
2159
2160 @commonprop
2161
2162 The glyph of the breath mark can be tuned by overriding the
2163 @code{text} property of the @code{BreathingSign} layout object with
2164 any markup text.  For example,
2165 @lilypond[quote,raggedright,fragment,verbatim,relative=1]
2166 c'4
2167 \override BreathingSign #'text
2168   = #(make-musicglyph-markup "scripts.rvarcomma")
2169 \breathe
2170 d4
2171 @end lilypond
2172
2173 @seealso
2174
2175 Program reference: @internalsref{BreathingSign}.
2176
2177 Examples: @inputfileref{input/@/regression,breathing@/-sign@/.ly}.
2178
2179
2180 @node Running trills
2181 @subsection Running trills
2182
2183 Long running trills are made with @code{\startTrillSpan} and
2184 @code{\stopTrillSpan},
2185
2186 @lilypond[verbatim,raggedright,relative=2,quote,fragment]
2187 \new Voice {
2188   << { c1 \startTrillSpan }
2189      { s2. \grace { d16[\stopTrillSpan e] } } >>
2190   c4 }
2191 @end lilypond
2192
2193
2194 @refcommands
2195
2196 @code{\startTrillSpan},
2197 @cindex @code{\startTrillSpan}
2198 @code{\stopTrillSpan}.
2199 @cindex @code{\stopTrillSpan}
2200
2201
2202 @seealso
2203
2204 Program reference: @internalsref{TrillSpanner}.
2205
2206
2207 @node Glissando
2208 @subsection Glissando
2209
2210 @cindex Glissando
2211 @cindex @code{\glissando}
2212
2213 A glissando is a smooth change in pitch.  It is denoted by a line or a
2214 wavy line between two notes.  It is requested by attaching
2215 @code{\glissando} to a note
2216
2217 @lilypond[quote,raggedright,fragment,relative=2,verbatim]
2218 c2\glissando c'
2219 \override Glissando #'style = #'zigzag
2220 c2\glissando c,
2221 @end lilypond
2222
2223
2224 @seealso
2225
2226 Program reference: @internalsref{Glissando}.
2227
2228 Example files: @file{input/@/regression/@/glissando@/.ly}.
2229
2230
2231 @refbugs
2232
2233 Printing text over the line (such as @emph{gliss.}) is not supported.
2234
2235
2236 @node Arpeggio
2237 @subsection Arpeggio
2238
2239 @cindex Arpeggio
2240 @cindex broken chord
2241 @cindex @code{\arpeggio}
2242
2243 You can specify an arpeggio sign (also known as broken chord) on a
2244 chord by attaching an @code{\arpeggio} to a chord
2245
2246 @lilypond[quote,raggedright,fragment,relative=1,verbatim]
2247 <c e g c>\arpeggio
2248 @end lilypond
2249
2250 A square bracket on the left indicates that the player should not
2251 arpeggiate the chord
2252
2253 @lilypond[quote,raggedright,fragment,relative=1,verbatim]
2254 \arpeggioBracket
2255 <c' e g c>\arpeggio
2256 @end lilypond
2257
2258 The direction of the arpeggio is sometimes denoted by adding an
2259 arrowhead to the wiggly line
2260
2261 @lilypond[quote,raggedright,fragment,relative=1,verbatim]
2262 \context Voice {
2263   \arpeggioUp
2264   <c e g c>\arpeggio
2265   \arpeggioDown
2266   <c e g c>\arpeggio
2267 }
2268 @end lilypond
2269
2270
2271 @commonprop
2272
2273 When an arpeggio crosses staves, you may attach an arpeggio to the chords
2274 in both staves and set
2275 @internalsref{PianoStaff}.@code{connectArpeggios}
2276
2277 @lilypond[quote,raggedright,fragment,relative=1,verbatim]
2278 \context PianoStaff <<
2279   \set PianoStaff.connectArpeggios = ##t
2280   \new Staff { <c' e g c>\arpeggio }
2281   \new Staff { \clef bass <c,, e g>\arpeggio }
2282 >>
2283 @end lilypond
2284
2285
2286 @refcommands
2287
2288 @code{\arpeggio},
2289 @cindex @code{\arpeggioUp}
2290 @code{\arpeggioUp},
2291 @cindex @code{\arpeggioDown}
2292 @code{\arpeggioDown},
2293 @cindex @code{\arpeggioNeutral}
2294 @code{\arpeggioNeutral},
2295 @cindex @code{\arpeggioBracket}
2296 @code{\arpeggioBracket}.
2297
2298
2299 @seealso
2300
2301 Notation manual: @ref{Ties}, for writing out arpeggios.
2302
2303 Program reference: @internalsref{Arpeggio}.
2304
2305
2306 @refbugs
2307
2308 It is not possible to mix connected arpeggios and unconnected
2309 arpeggios in one @internalsref{PianoStaff} at the same point in time.
2310
2311
2312
2313 @node Polyphony
2314 @section Polyphony
2315
2316 Polyphony in music refers to having more than one voice occuring in
2317 a piece of music.  Polyphony in LilyPond refers to having more than
2318 one voice on the same staff.
2319
2320 @menu
2321 * Basic polyphony::             
2322 * Explicitly instantiating voices::  
2323 * Collision Resolution::        
2324 @end menu
2325
2326
2327 @node Basic polyphony
2328 @subsection Basic polyphony
2329
2330 @cindex polyphony
2331
2332 The easiest way to enter fragments with more than one voice on a staff
2333 is to enter each voice as a sequence (with @code{@{...@}}), and combine 
2334 them simultaneously, separating the voices with @code{\\}
2335
2336 @cindex @code{\\}
2337
2338 @lilypond[quote,verbatim,fragment]
2339 \new Staff \relative c' {
2340   c16 d e f
2341   <<
2342     { g4 f e | d2 e2 } \\
2343     { r8 e4 d c8 ~ | c b16 a b8 g ~ g2 } \\
2344     { s2. | s4 b4 c2 }
2345   >>
2346 }
2347 @end lilypond
2348
2349 The separator causes @internalsref{Voice} contexts@footnote{Polyphonic
2350 voices are sometimes called ``layers'' in other notation packages}
2351 @cindex layers
2352 to be instantiated.  They bear the names @code{"1"}, @code{"2"}, etc.  In
2353 each of these contexts, vertical direction of slurs, stems, etc., is set
2354 appropriately.  
2355
2356 These voices are all seperate from the voice that contains the notes just 
2357 outside the @code{<< \\ >>} construct.  This should be noted when making 
2358 changes at the voice level.  This also means that slurs and ties cannot go 
2359 into or out of a @code{<< \\ >>} construct.  Conversely, parallel voices
2360 from separate @code{<< \\ >>} constructs on the same staff are the the
2361 same voice.  Here is the same example, with different noteheads for each
2362 voice.  Note that the change to the note-head style in the main voice does not affect
2363 the inside of the @code{<< \\ >>} constructs.  Also, the change to the second
2364 voice in the first @code{<< \\ >>} construct is effective in the second
2365 @code{<< \\ >>}, and the voice is tied accross the two constructs.
2366
2367 @lilypond[quote,verbatim,fragment]
2368 \new Staff \relative c' {
2369   \override NoteHead #'style = #'cross
2370   c16 d e f
2371   <<    
2372     { g4 f e } \\
2373     { \override NoteHead #'style = #'triangle
2374     r8 e4 d c8 ~ }
2375   >> |
2376   <<
2377     { d2 e2 } \\ 
2378     { c8 b16 a b8 g ~ g2 } \\
2379     { \override NoteHead #'style = #'slash s4 b4 c2 }
2380   >>
2381 }
2382 @end lilypond
2383
2384 Polyphony does not change the relationship of notes within a
2385 @code{\relative @{ @}} block.  Each note is calculated relative
2386 to the note immediately preceding it.
2387
2388 @example
2389 \relative @{ noteA << noteB \\ noteC >> noteD @}
2390 @end example
2391
2392 @code{noteC} is relative to @code{noteB}, not @code{noteA};
2393 @code{noteD} is relative to @code{noteC}, not @code{noteB} or
2394 @code{noteA}.
2395
2396 @node Explicitly instantiating voices
2397 @subsection Explicitly instantiating voices
2398
2399 @internalsref{Voice} contexts can also also be instantiated manually
2400 inside a @code{<< >>} block to create polyphonic music, using 
2401 @code{\voiceOne}, up to @code{\voiceFour} to assign stem directions 
2402 and a horizontal shift for each part.
2403
2404 Specifically,
2405 @example
2406 << \upper \\ \lower >>
2407 @end example
2408
2409 @noindent
2410 is equivalent to
2411
2412 @example
2413 <<
2414   \context Voice = "1" @{ \voiceOne \upper @}
2415   \context Voice = "2" @{ \voiceTwo \lower @}
2416 >>
2417 @end example
2418
2419 The @code{\voiceXXX} commands set the direction of stems, slurs, ties,
2420 articulations, text annotations, augmentation dots of dotted
2421 notes, and fingerings.  @code{\voiceOne} and @code{\voiceThree} make
2422 these objects point upwards, while @code{\voiceTwo} and @code{\voiceFour}
2423 make them point downwards.  
2424 The command @code{\oneVoice} will revert back to the normal setting.
2425
2426 An expression that appears directly inside a @code{<< >>} belongs to 
2427 the main voice.  This is useful when extra voices appear while the main
2428 voice is playing.  Here is a more correct rendition of the example from
2429 the previous section.  The crossed noteheads demonstrate that the main
2430 melody is now in a single voice context.
2431
2432 @lilypond[quote,raggedright,verbatim]
2433 \new Staff \relative c' {
2434   \override NoteHead #'style = #'cross
2435   c16 d e f 
2436   \voiceOne
2437   <<    
2438     { g4 f e | d2 e2 }
2439     \context Voice="1" { \voiceTwo
2440       r8 e4 d c8 ~ | c8 b16 a b8 g ~ g2 
2441       \oneVoice
2442     }
2443     \new Voice { \voiceThree 
2444       s2. | s4 b4 c2 
2445       \oneVoice
2446     }
2447   >>
2448   \oneVoice
2449 }
2450 @end lilypond
2451
2452 The correct definition of the voices allows the melody to be slurred.
2453 @lilypond[quote,raggedright,verbatim]
2454 \new Staff \relative c' {
2455   c16^( d e f 
2456   \voiceOne
2457   <<    
2458     { g4 f e | d2 e2) }  
2459     \context Voice="1" { \voiceTwo
2460       r8 e4 d c8 ~ | c8 b16 a b8 g ~ g2 
2461       \oneVoice
2462     }
2463     \new Voice { \voiceThree 
2464       s2. s4 b4 c2 
2465       \oneVoice
2466     }
2467   >>
2468   \oneVoice
2469 }
2470 @end lilypond
2471
2472 Avoiding the @code{\\} seperator also allows nesting polyphony 
2473 constructs, which in some case might be a more natural way to typeset
2474 the music.
2475
2476 @lilypond[quote,raggedright,verbatim]
2477 \new Staff \relative c' {
2478   c16^( d e f 
2479   \voiceOne
2480   <<    
2481     { g4 f e | d2 e2) }  
2482     \context Voice="1" { \voiceTwo
2483       r8 e4 d c8 ~ | 
2484       <<
2485         {c8 b16 a b8 g ~ g2} 
2486         \new Voice { \voiceThree 
2487           s4 b4 c2 
2488           \oneVoice
2489         }
2490       >>
2491     \oneVoice
2492     }
2493   >>
2494   \oneVoice
2495 }
2496 @end lilypond
2497
2498
2499 @node Collision Resolution
2500 @subsection Collision Resolution
2501
2502 Normally, note heads with a different number of dots are not merged, but
2503 when the object property @code{merge-differently-dotted} is set in
2504 the @internalsref{NoteCollision} object, they are merged
2505 @lilypond[quote,verbatim,fragment,raggedright,relative=2]
2506 \context Voice << {
2507   g8 g8
2508   \override Staff.NoteCollision
2509     #'merge-differently-dotted = ##t
2510   g8 g8
2511 } \\ { g8.[ f16] g8.[ f16] } >>
2512 @end lilypond
2513
2514 Similarly, you can merge half note heads with eighth notes, by setting
2515 @code{merge-differently-headed}
2516 @lilypond[quote,raggedright,fragment,relative=2,verbatim]
2517 \context Voice << {
2518   c8 c4.
2519   \override Staff.NoteCollision
2520     #'merge-differently-headed = ##t
2521 c8 c4. } \\ { c2 c2 } >>
2522 @end lilypond
2523
2524 LilyPond also vertically shifts rests that are opposite of a stem,
2525 for example
2526
2527 @lilypond[quote,raggedright,fragment,verbatim]
2528 \context Voice << c''4 \\ r4 >>
2529 @end lilypond
2530
2531
2532 @refcommands
2533
2534 @cindex @code{\oneVoice}
2535 @code{\oneVoice},
2536 @cindex @code{\voiceOne}
2537 @code{\voiceOne},
2538 @cindex @code{\voiceTwo}
2539 @code{\voiceTwo},
2540 @cindex @code{\voiceThree}
2541 @code{\voiceThree},
2542 @cindex @code{\voiceFour}
2543 @code{\voiceFour}.
2544
2545 @cindex @code{\shiftOn}
2546 @code{\shiftOn},
2547 @cindex @code{\shiftOnn}
2548 @code{\shiftOnn},
2549 @cindex @code{\shiftOnnn}
2550 @code{\shiftOnnn},
2551 @cindex @code{\shiftOff}
2552 @code{\shiftOff}: these commands specify in what chords of the current
2553 voice should be shifted.  The outer voices (normally: voice one and
2554 two) have @code{\shiftOff}, while the inner voices (three and four)
2555 have @code{\shiftOn}.  @code{\shiftOnn} and @code{\shiftOnnn} define
2556 further shift levels.
2557
2558 When LilyPond cannot cope, the @code{force-hshift}
2559 property of the @internalsref{NoteColumn} object and pitched rests can
2560 be used to override typesetting decisions.
2561
2562 @lilypond[quote,verbatim,raggedright]
2563 \relative <<
2564 {
2565   <d g>
2566   <d g>
2567 } \\ {
2568   <b f'>
2569   \once \override NoteColumn #'force-hshift = #1.7
2570   <b f'>
2571 } >>
2572 @end lilypond
2573
2574
2575 @seealso
2576
2577 Program reference: the objects responsible for resolving collisions are
2578 @internalsref{NoteCollision} and @internalsref{RestCollision}.
2579
2580 Examples:
2581 @inputfileref{input/@/regression,collision@/-dots@/.ly},
2582 @inputfileref{input/@/regression,collision@/-head-chords@/.ly},
2583 @inputfileref{input/@/regression,collision@/-heads@/.ly},
2584 @inputfileref{input/@/regression,collision@/-mesh@/.ly}, and
2585 @inputfileref{input/@/regression,collisions@/.ly}.
2586
2587
2588 @refbugs
2589
2590 When using @code{merge-differently-headed} with an upstem eighth or a
2591 shorter note, and a downstem half note, the eighth note gets the wrong
2592 offset.
2593
2594 There is no support for clusters where the same note occurs with
2595 different accidentals in the same chord.  In this case, it is
2596 recommended to use enharmonic transcription, or to use special cluster
2597 notation (see @ref{Clusters}).
2598
2599
2600
2601 @node Repeats
2602 @section Repeats
2603
2604 Repetition is a central concept in music, and multiple notations exist
2605 for repetitions.
2606
2607 @menu
2608 * Repeat types::                
2609 * Repeat syntax::               
2610 * Repeats and MIDI::            
2611 * Manual repeat commands::      
2612 * Tremolo repeats::             
2613 * Tremolo subdivisions::        
2614 * Measure repeats::             
2615 @end menu
2616
2617
2618 @node Repeat types
2619 @subsection Repeat types
2620
2621 @cindex repeats
2622 @cindex @code{\repeat}
2623
2624 The following types of repetition are supported
2625
2626 @table @code
2627 @item unfold
2628 Repeated music is fully written (played) out.  This is useful when
2629 entering repetitious music.  This is the only kind of repeat that
2630 is included in MIDI output.
2631
2632 @item volta
2633 Repeats are not written out, but alternative endings (volte) are
2634 printed, left to right with brackets.  This is the standard notation
2635 for repeats with alternatives.  These are not played in MIDI output by default.
2636
2637 @ignore
2638 @item fold
2639 Alternative endings are written stacked.  This has limited use but may be
2640 used to typeset two lines of lyrics in songs with repeats, see
2641 @inputfileref{input,star-spangled-banner@/.ly}.
2642 @end ignore
2643
2644 @item tremolo
2645 Make tremolo beams.  These are not played in MIDI output by default.
2646
2647 @item percent
2648 Make beat or measure repeats.  These look like percent signs.  These
2649 are not played in MIDI output by default.  Percent repeats must be
2650 declared within a Voice context.
2651
2652 @end table
2653
2654
2655 @node Repeat syntax
2656 @subsection Repeat syntax
2657
2658 LilyPond has one syntactic construct for specifying different types of
2659 repeats.  The syntax is
2660
2661 @example
2662 \repeat @var{variant} @var{repeatcount} @var{repeatbody}
2663 @end example
2664
2665 If you have alternative endings, you may add
2666 @cindex @code{\alternative}
2667 @example
2668 \alternative @{
2669   @var{alternative1}
2670   @var{alternative2}
2671   @var{alternative3}
2672   @dots{}
2673 @}
2674 @end example
2675
2676 @noindent
2677 where each @var{alternative} is a music expression.  If you do not
2678 give enough alternatives for all of the repeats, the first alternative
2679 is assumed to be played more than once.
2680
2681 Standard repeats are used like this
2682 @lilypond[quote,raggedright,fragment,verbatim,relative=2]
2683 c1
2684 \repeat volta 2 { c4 d e f }
2685 \repeat volta 2 { f e d c }
2686 @end lilypond
2687
2688 With alternative endings
2689 @lilypond[quote,raggedright,fragment,verbatim,relative=2]
2690 c1
2691 \repeat volta 2 {c4 d e f}
2692 \alternative { {d2 d} {f f,} }
2693 @end lilypond
2694
2695 @lilypond[quote,raggedright,fragment,verbatim,relative=2]
2696 \context Staff {
2697   \partial 4
2698   \repeat volta 4 { e | c2 d2 | e2 f2 | }
2699   \alternative { { g4 g g } { a | a a a a | b2. } }
2700 }
2701 @end lilypond
2702
2703 It is possible to shorten volta brackets
2704 by setting @code{voltaSpannerDuration}.  In the next example, the
2705 bracket only lasts one measure, which is a duration of 3/4.
2706
2707 @lilypond[verbatim,raggedright,quote]
2708 \relative c''{
2709   \time 3/4
2710   c c c
2711   \set Staff.voltaSpannerDuration = #(ly:make-moment 3 4)
2712   \repeat "volta" 5 { d d d }
2713   \alternative { { e e e f f f }
2714   { g g g } }
2715 }
2716 @end lilypond
2717
2718
2719 @seealso
2720
2721 Examples:
2722
2723 Brackets for the repeat are normally only printed over the topmost
2724 staff.  This can be adjusted by setting the @code{voltaOnThisStaff}
2725 property; see @inputfileref{input/@/regression,volta@/-multi@/-staff@/.ly}.
2726
2727
2728 @refbugs
2729
2730 @cindex repeat, ambiguous
2731
2732 A nested repeat like
2733
2734 @example
2735 \repeat @dots{}
2736 \repeat @dots{}
2737 \alternative
2738 @end example
2739
2740 @noindent
2741 is ambiguous, since it is is not clear to which @code{\repeat} the
2742 @code{\alternative} belongs.  This ambiguity is resolved by always
2743 having the @code{\alternative} belong to the inner @code{\repeat}.
2744 For clarity, it is advisable to use braces in such situations.
2745
2746 Timing information is not remembered at the start of an alternative,
2747 so after a repeat timing information must be reset by hand, for
2748 example by setting @code{Score.measurePosition} or entering
2749 @code{\partial}.  Similarly, slurs or ties are also not repeated.
2750
2751
2752 @node Repeats and MIDI
2753 @subsection Repeats and MIDI
2754
2755 @cindex expanding repeats
2756 @cindex @code{\unfoldRepeats}
2757
2758 With a little bit of tweaking, all types of repeats can be present
2759 in the MIDI output.  This is achieved by applying the
2760 @code{\unfoldRepeats} music function.  This functions changes all
2761 repeats to unfold repeats.
2762
2763 @lilypond[quote,verbatim,fragment,linewidth=8.0\cm]
2764 \unfoldRepeats {
2765   \repeat tremolo 8 {c'32 e' }
2766   \repeat percent 2 { c''8 d'' }
2767   \repeat volta 2 {c'4 d' e' f'}
2768   \alternative {
2769     { g' a' a' g' }
2770     {f' e' d' c' }
2771   }
2772 }
2773 \bar "|."
2774 @end lilypond
2775
2776 When creating a score file using @code{\unfoldRepeats} for midi, then
2777 it is necessary to make two @code{\score} blocks.  One for MIDI (with
2778 unfolded repeats) and one for notation (with volta, tremolo, and
2779 percent repeats).  For example,
2780
2781 @example
2782 \score @{
2783   @var{..music..}
2784   \layout @{ .. @}
2785 @}
2786 \score @{
2787   \unfoldRepeats @var{..music..}
2788   \midi @{ .. @}
2789 @}
2790 @end example
2791
2792
2793 @node Manual repeat commands
2794 @subsection Manual repeat commands
2795
2796 @cindex @code{repeatCommands}
2797
2798 The property @code{repeatCommands} can be used to control the layout of
2799 repeats.  Its value is a Scheme list of repeat commands.
2800
2801 @table @asis
2802 @item @code{start-repeat}
2803 Print a @code{|:} bar line.
2804
2805 @item @code{end-repeat}
2806 Print a @code{:|} bar line.
2807
2808 @item @code{(volta @var{text})}
2809 Print a volta bracket saying @var{text}: The text can be specified as
2810 a text string or as a markup text, see @ref{Text markup}.  Do not
2811 forget to change the font, as the default number font does not contain
2812 alphabetic characters;
2813
2814 @item @code{(volta #f)}
2815 Stop a running volta bracket.
2816 @end table
2817
2818 @lilypond[quote,raggedright,verbatim,fragment,relative=2]
2819 c4
2820   \set Score.repeatCommands = #'((volta "93") end-repeat)
2821 c4 c4
2822   \set Score.repeatCommands = #'((volta #f))
2823 c4 c4
2824 @end lilypond
2825
2826
2827 @seealso
2828
2829 Program reference: @internalsref{VoltaBracket}, @internalsref{RepeatedMusic},
2830 @internalsref{VoltaRepeatedMusic},
2831 @internalsref{UnfoldedRepeatedMusic}, and
2832 @internalsref{FoldedRepeatedMusic}.
2833
2834
2835 @node Tremolo repeats
2836 @subsection Tremolo repeats
2837
2838 @cindex tremolo beams
2839
2840 To place tremolo marks between notes, use @code{\repeat} with tremolo
2841 style
2842 @lilypond[quote,verbatim,raggedright]
2843 \new Voice \relative c' {
2844   \repeat "tremolo" 8 { c16 d16 }
2845   \repeat "tremolo" 4 { c16 d16 }
2846   \repeat "tremolo" 2 { c16 d16 }
2847 }
2848 @end lilypond
2849
2850 Tremolo marks can also be put on a single note.  In this case, the
2851 note should not be surrounded by braces.
2852 @lilypond[quote,verbatim,raggedright]
2853 \repeat "tremolo" 4 c'16
2854 @end lilypond
2855
2856 Similar output is obtained using the tremolo subdivision, described in
2857 @ref{Tremolo subdivisions}.
2858
2859
2860 @seealso
2861
2862 In this manual: @ref{Tremolo subdivisions}, @ref{Repeats}.
2863
2864 Program reference: @internalsref{Beam}, @internalsref{StemTremolo}.
2865
2866 Example files: @inputfileref{input/@/regression,chord@/-tremolo@/.ly},
2867 @inputfileref{input/@/regression,stem@/-tremolo@/.ly}.
2868
2869
2870 @node Tremolo subdivisions
2871 @subsection Tremolo subdivisions
2872
2873 @cindex tremolo marks
2874 @cindex @code{tremoloFlags}
2875
2876 Tremolo marks can be printed on a single note by adding
2877 `@code{:}[@var{number}]' after the note.  The number indicates the
2878 duration of the subdivision, and it must be at least 8.  A
2879 @var{length} value of 8 gives one line across the note stem.  If the
2880 length is omitted, the last value (stored in @code{tremoloFlags}) is
2881 used
2882
2883 @lilypond[quote,raggedright,verbatim,fragment]
2884 c'2:8 c':32 | c': c': |
2885 @end lilypond
2886
2887
2888 @refbugs
2889
2890 Tremolos entered in this way do not carry over into the MIDI output.
2891
2892
2893 @seealso
2894
2895 In this manual: @ref{Tremolo repeats}.
2896
2897 Elsewhere: @internalsref{StemTremolo}.
2898
2899
2900 @node Measure repeats
2901 @subsection Measure repeats
2902
2903 @cindex percent repeats
2904 @cindex measure repeats
2905
2906 In the @code{percent} style, a note pattern can be repeated.  It is
2907 printed once, and then the pattern is replaced with a special sign.
2908 Patterns of one and two measures are replaced by percent-like signs,
2909 patterns that divide the measure length are replaced by slashes.
2910 Percent repeats must be declared within a @code{Voice} context.
2911
2912 @lilypond[quote,verbatim,raggedright]
2913 \new Voice \relative c' {
2914   \repeat "percent" 4 { c4 }
2915   \repeat "percent" 2 { c2 es2 f4 fis4 g4 c4 }
2916 }
2917 @end lilypond
2918
2919
2920 @seealso
2921
2922 Program reference: @internalsref{RepeatSlash}, @internalsref{PercentRepeat},
2923 @internalsref{PercentRepeatedMusic}, and
2924 @internalsref{DoublePercentRepeat}.
2925