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