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