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