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