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