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