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