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