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