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