]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/basic-notation.itely
bd3e94ef20af3e14c4b3e6b8e94c83e05b0b18cd
[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 * Transposition::
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 @end menu
944
945 @node Staff symbol
946 @subsection Staff symbol
947
948 @cindex adjusting staff symbol
949
950 Notes, dynamic signs, etc., are grouped
951 with a set of horizontal lines, into a staff (plural `staves').  In our
952 system, these lines are drawn using a separate layout object called
953 staff symbol.
954
955
956 @cindex staff lines, setting number of
957 @cindex staff lines, setting thickness of
958 @cindex thickness of staff lines, setting
959 @cindex number of staff lines, setting
960
961 @seealso
962
963 Program reference: @internalsref{StaffSymbol}.
964
965 Examples: @inputfileref{input/@/test,staff@/-lines@/.ly},
966 @inputfileref{input/@/test,staff@/-size@/.ly}.
967
968 @refbugs
969
970 If a staff is ended halfway a piece, the staff symbol may not end
971 exactly on the bar line.
972
973
974 @node Key signature
975 @subsection Key signature
976 @cindex Key signature
977
978 @cindex @code{\key}
979
980 The key signature indicates the tonality in which a piece is played.  It
981 is denoted by a set of alterations (flats or sharps) at the start of the
982 staff.
983
984
985 Setting or changing the key signature is done with the @code{\key}
986 command
987 @example
988 @code{\key} @var{pitch} @var{type}
989 @end example
990
991 @cindex @code{\minor}
992 @cindex @code{\major}
993 @cindex @code{\minor}
994 @cindex @code{\ionian}
995 @cindex @code{\locrian}
996 @cindex @code{\aeolian}
997 @cindex @code{\mixolydian}
998 @cindex @code{\lydian}
999 @cindex @code{\phrygian}
1000 @cindex @code{\dorian}
1001
1002 Here, @var{type} should be @code{\major} or @code{\minor} to get
1003 @var{pitch}-major or @var{pitch}-minor, respectively.
1004 The standard mode names @code{\ionian},
1005 @code{\locrian}, @code{\aeolian}, @code{\mixolydian}, @code{\lydian},
1006 @code{\phrygian}, and @code{\dorian} are also defined.
1007
1008 This command sets the context property
1009 @internalsref{Staff}.@code{keySignature}.  Non-standard key signatures
1010 can be specified by setting this property directly.
1011
1012 A natural sign is printed to cancel any previous accidentals.  This
1013 can be suppressed by setting the @code{Staff.printKeyCancellation}
1014 property.
1015
1016 @lilypond[quote,raggedright,fragment,verbatim,relative=2]
1017 {
1018   \key d \major
1019   a b cis d
1020   \key g \minor
1021   a bes c d
1022   \set Staff.printKeyCancellation = ##f
1023   \key d \major
1024   a b cis d
1025   \key g \minor
1026   a bes c d
1027 }
1028 @end lilypond
1029
1030 Accidentals and key signatures often confuse new users, because
1031 unaltered notes get natural signs depending on the key signature.  For
1032 more information, see @ref{More about pitches}.
1033
1034 @seealso
1035
1036 Program reference: @internalsref{KeyChangeEvent},
1037 @internalsref{KeyCancellation} and @internalsref{KeySignature}.
1038
1039 @cindex @code{keySignature}
1040
1041
1042 @node Clef
1043 @subsection Clef
1044 @cindex @code{\clef}
1045
1046 The clef indicates which lines of the staff correspond to which
1047 pitches.
1048
1049
1050 The clef can be set with the @code{\clef} command
1051 @lilypond[quote,raggedright,fragment,verbatim]
1052 { c''2 \clef alto g'2 }
1053 @end lilypond
1054
1055 Supported clef-names include
1056 @c Moved standard clefs to the top /MB
1057 @table @code
1058 @cindex treble clef
1059 @cindex violin clef
1060 @item treble, violin, G, G2
1061 G clef on 2nd line
1062 @item alto, C
1063 @cindex alto clef
1064  C clef on 3rd line
1065 @item tenor
1066 @cindex tenor clef
1067  C clef on 4th line.
1068 @item bass, F
1069 @cindex bass clef
1070  F clef on 4th line
1071 @item french
1072 @cindex french clef
1073  G clef on 1st line, so-called French violin clef
1074 @item soprano
1075 @cindex soprano clef
1076  C clef on 1st line
1077 @item mezzosoprano
1078 @cindex mezzosoprano clef
1079  C clef on 2nd line
1080 @item baritone
1081 @cindex baritone clef
1082  C clef on 5th line
1083 @item varbaritone
1084 @cindex varbaritone clef
1085  F clef on 3rd line
1086 @item subbass
1087 @cindex subbass clef
1088  F clef on 5th line
1089 @item percussion
1090  percussion clef
1091 @item tab
1092  tablature clef
1093 @end table
1094
1095 By adding @code{_8} or @code{^8} to the clef name, the clef is
1096 transposed one octave down or up, respectively, and @code{_15} and
1097 @code{^15} transposes by two octaves.  The argument @var{clefname}
1098 must be enclosed in quotes when it contains underscores or digits.  For
1099 example,
1100
1101
1102 @cindex choral tenor clef
1103 @lilypond[quote,raggedright,verbatim,fragment,relative=1]
1104 \clef "G_8" c4
1105 @end lilypond
1106
1107 This command is equivalent to setting @code{clefGlyph},
1108 @code{clefPosition} (which controls the Y position of the clef),
1109 @code{middleCPosition} and @code{clefOctavation}.  A clef is printed
1110 when any of these properties are changed.  The following example shows
1111 possibilities when setting properties manually.
1112
1113 @lilypond[quote,raggedright,verbatim]
1114 {
1115   \set Staff.clefGlyph = #"clefs.F"
1116   \set Staff.clefPosition = #2
1117   c'4
1118   \set Staff.clefGlyph = #"clefs.G"
1119   c'4
1120   \set Staff.clefGlyph = #"clefs.C"
1121   c'4
1122   \set Staff.clefOctavation = #7
1123   c'4
1124   \set Staff.clefOctavation = #0
1125   \set Staff.clefPosition = #0
1126   c'4
1127   \clef "bass"
1128   c'4
1129   \set Staff.middleCPosition = #4
1130   c'4
1131 }
1132 @end lilypond
1133
1134 @seealso
1135
1136 Program reference: @internalsref{Clef}.
1137
1138
1139
1140 @node Ottava brackets
1141 @subsection Ottava brackets
1142
1143 `Ottava' brackets introduce an extra transposition of an octave for
1144 the staff.  They are created by invoking the function
1145 @code{set-octavation}
1146
1147 @cindex ottava
1148 @cindex 15ma
1149 @cindex octavation
1150
1151 @lilypond[quote,raggedright,verbatim,fragment]
1152 \relative c''' {
1153   a2 b
1154   #(set-octavation 1)
1155   a b
1156   #(set-octavation 0)
1157   a b
1158 }
1159 @end lilypond
1160
1161 The @code{set-octavation} function also takes -1 (for 8va bassa) and 2
1162 (for 15ma) as arguments.  Internally the function sets the properties
1163 @code{ottavation} (e.g., to @code{"8va"}) and
1164 @code{centralCPosition}.  For overriding the text of the bracket, set
1165 @code{ottavation} after invoking @code{set-octavation}, i.e.,
1166
1167 @lilypond[quote,raggedright,verbatim]
1168 {
1169   #(set-octavation 1)
1170   \set Staff.ottavation = #"8"
1171   c'''
1172 }
1173 @end lilypond
1174
1175 @seealso
1176
1177 Program reference: @internalsref{OttavaBracket}.
1178
1179 Examples: @inputfileref{input/@/regression,ottava@/.ly},
1180 @inputfileref{input/@/regression,ottava@/-broken@/.ly}.
1181
1182 @refbugs
1183
1184 @code{set-octavation} will get confused when clef changes happen
1185 during an octavation bracket.
1186
1187
1188
1189
1190 @node Time signature
1191 @subsection Time signature
1192 @cindex Time signature
1193 @cindex meter
1194 @cindex @code{\time}
1195
1196 Time signature indicates the metrum of a piece: a regular pattern of
1197 strong and weak beats.  It is denoted by a fraction at the start of the
1198 staff.
1199
1200
1201 The time signature is set or changed by the @code{\time}
1202 command
1203 @lilypond[quote,raggedright,fragment,verbatim]
1204 \time 2/4 c'2 \time 3/4 c'2.
1205 @end lilypond
1206
1207 The symbol that is printed can be customized with the @code{style}
1208 property.  Setting it to @code{#'()} uses fraction style for 4/4 and
1209 2/2 time,
1210
1211 @lilypond[fragment,quote,raggedright,verbatim]
1212 \time 4/4 c'1
1213 \time 2/2 c'1
1214 \override Staff.TimeSignature #'style = #'()
1215 \time 4/4 c'1
1216 \time 2/2 c'1
1217 @end lilypond
1218
1219
1220
1221 There are many more options for its layout.  See @ref{Ancient time
1222 signatures} for more examples.
1223
1224
1225 This command sets the property @code{timeSignatureFraction},
1226 @code{beatLength} and @code{measureLength} in the @code{Timing}
1227 context, which is normally aliased to @internalsref{Score}.  The
1228 property @code{measureLength} determines where bar lines should be
1229 inserted, and how automatic beams should be generated.  Changing the
1230 value of @code{timeSignatureFraction} also causes the symbol to be
1231 printed.
1232
1233 More options are available through the Scheme function
1234 @code{set-time-signature}.  In combination with the
1235 @internalsref{Measure_grouping_engraver}, it will create
1236 @internalsref{MeasureGrouping} signs.  Such signs ease reading
1237 rhythmically complex modern music.  In the following example, the 9/8
1238 measure is subdivided in 2, 2, 2 and 3.  This is passed to
1239 @code{set-time-signature} as the third argument @code{(2 2 2 3)}
1240
1241 @lilypond[quote,raggedright,verbatim]
1242 \score {
1243   \relative c'' {
1244     #(set-time-signature 9 8 '(2 2 2 3))
1245     g8[ g] d[ d] g[ g] a8[( bes g]) |
1246     #(set-time-signature 5 8 '(3 2))
1247     a4. g4
1248   }
1249   \layout {
1250     \context {
1251       \Staff
1252       \consists "Measure_grouping_engraver"
1253     }
1254   }
1255 }
1256 @end lilypond
1257
1258 @seealso
1259
1260 Program reference: @internalsref{TimeSignature}, and @internalsref{Timing_engraver}.
1261
1262
1263 @refbugs
1264
1265 Automatic beaming does not use the measure grouping specified with
1266 @code{set-time-signature}.
1267
1268 @node Partial measures
1269 @subsection Partial measures
1270 @cindex Partial
1271 @cindex anacrusis
1272 @cindex partial measure
1273 @cindex measure, partial
1274 @cindex shorten measures
1275 @cindex @code{\partial}
1276
1277 Partial measures, for example in upsteps, are entered using the
1278 @code{\partial} command
1279 @lilypond[quote,raggedright,fragment,verbatim,relative=2]
1280 \partial 16*5 c16 cis d dis e | a2. c,4 | b2
1281 @end lilypond
1282
1283 The syntax for this command is
1284 @example
1285 \partial @var{duration}
1286 @end example
1287 This is internally translated into
1288 @example
1289 \set Timing.measurePosition = -@var{length of duration}
1290 @end example
1291 @cindex @code{|}
1292 The property @code{measurePosition} contains a rational number
1293 indicating how much of the measure has passed at this point.
1294
1295 @refbugs
1296
1297 This command does not take into account grace notes at the start of
1298 the music.  When a piece starts with graces notes in the pickup, then
1299 the @code{\partial} should follow the grace notes
1300
1301 @lilypond[verbatim,quote,raggedright,relative,fragment]
1302 {
1303   \grace f16
1304   \partial 4
1305   g4
1306   a2 g2
1307 }
1308 @end lilypond
1309
1310
1311 @node Unmetered music
1312 @subsection Unmetered music
1313
1314 @cindex @code{\bar}
1315
1316 Bar lines and bar numbers are calculated automatically.  For unmetered
1317 music (cadenzas, for example), this is not desirable.  By setting
1318 @code{Score.timing} to false, this automatic timing can be switched
1319 off.  Empty bar lines,
1320
1321 @example
1322 \bar ""
1323 @end example
1324
1325 @noindent
1326 indicate where line breaks can occur.
1327
1328 @refcommands
1329
1330 @cindex @code{\cadenzaOn}
1331 @code{\cadenzaOn},
1332 @cindex @code{\cadenzaOff}
1333 @code{\cadenzaOff}.
1334
1335
1336
1337
1338 @node Bar lines
1339 @subsection Bar lines
1340 @cindex Bar lines
1341
1342 @cindex @code{\bar}
1343 @cindex measure lines
1344 @cindex repeat bars
1345
1346
1347 Bar lines delimit measures, but are also used to indicate repeats.
1348 Normally, they are inserted automatically.  Line breaks may only
1349 happen on bar lines.
1350
1351 Special types of bar lines can be forced with the @code{\bar} command
1352 @c
1353 @lilypond[quote,raggedright,relative=2,fragment,verbatim]
1354 c4 \bar "|:" c4
1355 @end lilypond
1356
1357 The following bar types are available
1358 @lilypondfile[raggedright,quote]{bar-lines.ly}
1359
1360 For allowing line breaks, there is a special command,
1361 @example
1362 \bar ""
1363 @end example
1364 This will insert an invisible bar line, and allow line breaks at this
1365 point.
1366
1367 In scores with many staves, a @code{\bar} command in one staff is
1368 automatically applied to all staves.  The resulting bar lines are
1369 connected between different staves of a @internalsref{StaffGroup}
1370 @c
1371 @lilypond[quote,raggedright,fragment,verbatim]
1372 <<
1373   \context StaffGroup <<
1374     \new Staff {
1375       e'4 d'
1376       \bar "||"
1377       f' e'
1378     }
1379     \new Staff { \clef bass c4 g e g }
1380   >>
1381   \new Staff { \clef bass c2 c2 }
1382 >>
1383 @end lilypond
1384
1385
1386 The command @code{\bar }@var{bartype} is a short cut for doing
1387 @code{\set Timing.whichBar = }@var{bartype}.  Whenever @code{whichBar}
1388 is set to a string, a bar line of that type is created.
1389
1390 A bar line is created whenever the @code{whichBar} property is set.
1391 At the start of a measure it is set to the contents of
1392 @code{Timing.defaultBarType}.  The contents of @code{repeatCommands} are used
1393 to override default measure bars.
1394
1395 @cindex @code{whichBar}
1396 @cindex @code{repeatCommands}
1397 @cindex @code{defaultBarType}
1398
1399 You are encouraged to use @code{\repeat} for repetitions.  See
1400 @ref{Repeats}.
1401
1402
1403
1404 @seealso
1405
1406 In this manual: @ref{Repeats}, @ref{System start delimiters}.
1407
1408
1409 Program reference: @internalsref{BarLine} (created at
1410 @internalsref{Staff} level), @internalsref{SpanBar} (across staves).
1411
1412 @cindex bar lines at start of system
1413 @cindex start of system
1414
1415
1416
1417 Examples: @inputfileref{input/@/test,bar@/-lines@/.ly},
1418
1419
1420 @node Time administration
1421 @subsection Time administration
1422
1423 Time is administered by the @internalsref{Time_signature_engraver},
1424 which usually lives in the @internalsref{Score} context.
1425 The bookkeeping deals with the following variables
1426
1427 @table @code
1428 @item currentBarNumber
1429 The measure number.
1430
1431 @item measureLength
1432 The length of the measures in the current time signature.  For a 4/4
1433 time this is@tie{}1, and for 6/8 it is 3/4.
1434
1435 @item measurePosition
1436 The point within the measure where we currently are.  This quantity
1437 is reset to@tie{}0 whenever it exceeds @code{measureLength}.  When that
1438 happens, @code{currentBarNumber} is incremented.
1439
1440 @item timing
1441 If set to true, the above variables are updated for every time
1442 step.  When set to false, the engraver stays in the current measure
1443 indefinitely.
1444 @end table
1445
1446 Timing can be changed by setting any of these variables explicitly.
1447 In the next example, the 4/4 time signature is printed, but
1448 @code{measureLength} is set to 5/4.  After a while, the measure is
1449 shortened by 1/8, by setting @code{measurePosition} to 7/8 at 2/4
1450 in the measure, so the next bar line will fall at 2/4 + 3/8.  The
1451 3/8 arises because 5/4 normally has 10/8, but we have manually
1452 set the measure position to be 7/8 and 10/8 - 7/8 = 3/8.
1453
1454 @lilypond[quote,raggedright,verbatim,relative,fragment]
1455 \set Score.measureLength = #(ly:make-moment 5 4)
1456 c1 c4
1457 c1 c4
1458 c4 c4
1459 \set Score.measurePosition = #(ly:make-moment 7 8)
1460 b8 b b
1461 c4 c1
1462 @end lilypond
1463
1464
1465 @node Controlling formatting of prefatory matter
1466 @subsection Controlling formatting of prefatory matter
1467
1468 @c  This section will be moved to somewhere else soon. -gp
1469 This example demonstrates how to place prefatory matter
1470 (such as the clef and key signature) at the end of a line.
1471
1472 @lilypond[quote,verbatim]
1473 \transpose c c' {
1474   \override Staff.Clef
1475     #'break-visibility = #end-of-line-visible
1476   \override Staff.KeySignature
1477     #'break-visibility = #end-of-line-visible
1478   \set Staff.explicitClefVisibility = #end-of-line-visible
1479   \set Staff.explicitKeySignatureVisibility = #end-of-line-visible
1480
1481   % We want the time sig to take space, otherwise there is not
1482   % enough white at the start of the line.
1483
1484   \override Staff.TimeSignature #'transparent = ##t
1485   \set Score.defaultBarType = #"empty"
1486
1487   c1 d e f g a b c
1488   \key d \major
1489   \break
1490
1491   % see above.
1492   \time 4/4
1493
1494   d e fis g a b cis d
1495   \key g \major
1496   \break
1497   \time 4/4
1498 }
1499 @end lilypond
1500
1501
1502 @node System start delimiters
1503 @subsection System start delimiters
1504
1505 Polyphonic scores consist of many staves.  These staves can be
1506 constructed in three different ways
1507 @itemize @bullet
1508 @item The group is started with a brace at the left, and bar lines are
1509 connected.  This is done with the @internalsref{GrandStaff} context.
1510
1511 @lilypond[verbatim,raggedright,quote]
1512 \new GrandStaff
1513 \relative <<
1514   \new Staff { c1 c }
1515   \new Staff { c c }
1516 >>
1517 @end lilypond
1518
1519
1520 @item The group is started with a bracket, and bar lines are connected.
1521 This is done with the
1522 @internalsref{StaffGroup} context
1523
1524 @lilypond[verbatim,raggedright,quote]
1525 \new StaffGroup
1526 \relative <<
1527   \new Staff { c1 c }
1528   \new Staff { c c }
1529 >>
1530 @end lilypond
1531
1532
1533 @item The group is started with a vertical line.  Bar lines are not
1534 connected.  This is the default for the score.
1535
1536 @lilypond[verbatim,raggedright,quote]
1537 \relative <<
1538   \new Staff { c1 c }
1539   \new Staff { c c }
1540 >>
1541 @end lilypond
1542
1543 @end itemize
1544
1545 @cindex Staff, multiple
1546 @cindex bracket, vertical
1547 @cindex brace, vertical
1548 @cindex grand staff
1549 @cindex staff group
1550
1551
1552 @seealso
1553
1554 The bar lines at the start of each system are
1555 @internalsref{SystemStartBar}, @internalsref{SystemStartBrace}, and
1556 @internalsref{SystemStartBracket}.  Only one of these types is created
1557 in every context, and that type is determined by the property
1558 @code{systemStartDelimiter}.
1559
1560 @node Aligning to cadenzas
1561 @subsection Aligning to cadenzas
1562
1563
1564 In an orchestral context, cadenzas present a special problem:
1565 when constructing a score that includes a cadenza, all other
1566 instruments should skip just as many notes as the length of the
1567 cadenza, otherwise they will start too soon or too late.
1568
1569 A solution to this problem are the functions @code{mmrest-of-length}
1570 and @code{skip-of-length}.  These Scheme functions take a piece of music
1571 as argument, and generate a @code{\skip} or multi-rest, exactly as
1572 long as the piece.  The use of @code{mmrest-of-length} is demonstrated
1573 in the following example.
1574
1575 @lilypond[verbatim,raggedright,quote]
1576 cadenza = \relative c' {
1577   c4 d8 << { e f g } \\ { d4. } >>
1578   g4 f2 g4 g
1579 }
1580
1581 \new GrandStaff <<
1582   \new Staff { \cadenza c'4 }
1583   \new Staff {
1584     #(ly:export (mmrest-of-length cadenza))
1585     c'4
1586   }
1587 >>
1588 @end lilypond
1589
1590
1591
1592
1593 @node Polyphony
1594 @section Polyphony
1595
1596 Polyphony in music refers to having more than one voice occuring in
1597 a piece of music.  Polyphony in LilyPond refers to having more than
1598 one voice on the same staff.
1599
1600 @menu
1601 * Basic polyphony::    
1602 * Explicitly instantiating voices::
1603 * Collision Resolution::
1604 @end menu
1605
1606 @node Basic polyphony
1607 @subsection Basic polyphony
1608 @cindex polyphony
1609
1610 The easiest way to enter fragments with more than one voice on a staff
1611 is to enter each voice as a sequence (with @code{@{...@}}), and combine 
1612 them simultaneously, separating the voices with @code{\\}
1613
1614 @cindex @code{\\}
1615
1616 @lilypond[quote,verbatim,fragment]
1617 \new Staff \relative c' {
1618         c16 d e f
1619         << { g4 f e | d2 e2 } \\
1620         { r8 e4 d c8 ~ | c b16 a b8 g ~ g2 } \\
1621         { s2. | s4 b4 c2 }
1622         >>
1623 }
1624 @end lilypond
1625
1626 The separator causes @internalsref{Voice} contexts@footnote{Polyphonic
1627 voices are sometimes called ``layers'' in other notation packages}
1628 @cindex layers
1629 to be instantiated.  They bear the names @code{"1"}, @code{"2"}, etc.  In
1630 each of these contexts, vertical direction of slurs, stems, etc., is set
1631 appropriately.  
1632
1633 These voices are all seperate from the voice that contains the notes just 
1634 outside the @code{<< \\ >>} construct.  This should be noted when making 
1635 changes at the voice level.  This also means that slurs and ties cannot go 
1636 into or out of a @code{<< \\ >>} construct.  
1637 Conversely, parallel voices from separate @code{<< \\ >>} constructs on the 
1638 same staff are the the same voice.  
1639 Here is the same example, with different noteheads for each voice.  
1640 Note that the change to the note-head style in the main voice does not affect
1641 the inside of the @code{<< \\ >>} constructs.  Also, the change to the second
1642 voice in the first @code{<< \\ >>} construct is effective in the second
1643 @code{<< \\ >>}, and the voice is tied accross the two constructs.
1644
1645 @lilypond[quote,verbatim,fragment]
1646 \new Staff \relative c' {
1647         \override NoteHead #'style = #'cross
1648         c16 d e f
1649         <<      
1650                 { g4 f e } \\
1651                 { \override NoteHead #'style = #'triangle
1652                         r8 e4 d c8 ~ 
1653                 }
1654         >> |
1655         <<
1656                 { d2 e2 } \\ 
1657                 { c8 b16 a b8 g ~ g2 } \\
1658                 { \override NoteHead #'style = #'slash s4 b4 c2 }
1659         >>
1660 }
1661 @end lilypond
1662
1663 @node Explicitly instantiating voices
1664 @subsection Explicitly instantiating voices
1665
1666 @internalsref{Voice} contexts can also also be instantiated manually
1667 inside a @code{<< >>} block to create polyphonic music, using 
1668 @code{\voiceOne}, up to @code{\voiceFour} to assign stem directions 
1669 and a horizontal shift for each part.
1670
1671 Specifically,
1672 @example
1673 << \upper \\ \lower >>
1674 @end example
1675
1676 @noindent
1677 is equivalent to
1678
1679 @example
1680 <<
1681   \context Voice = "1" @{ \voiceOne \upper @}
1682   \context Voice = "2" @{ \voiceTwo \lower @}
1683 >>
1684 @end example
1685
1686 @cindex @code{\voiceOne}
1687 @cindex @code{\voiceFour}
1688
1689 The @code{\voiceXXX} commands set the direction of stems, slurs, ties,
1690 articulations, text annotations, augmentation dots of dotted
1691 notes, and fingerings.  @code{\voiceOne} and @code{\voiceThree} make
1692 these objects point upwards, while @code{\voiceTwo} and @code{\voiceFour}
1693 make them point downwards.  
1694 The command @code{\oneVoice} will revert back to the normal setting.
1695 @cindex @code{\oneVoice}
1696
1697 An expression that appears directly inside a @code{<< >>} belongs to 
1698 the main voice.  This is useful when extra voices appear while the main
1699 voice is playing.  Here is a more correct rendition of the example from
1700 the previous section.  The crossed noteheads demonstrate that the main
1701 melody is now in a single voice context.
1702
1703 @lilypond[quote,raggedright,verbatim]
1704 \new Staff \relative c' {
1705         \override NoteHead #'style = #'cross
1706         c16 d e f 
1707         \voiceOne
1708         <<      
1709                 { g4 f e | d2 e2}
1710                 \context Voice="1" { \voiceTwo
1711                         r8 e4 d c8 ~ | c8 b16 a b8 g ~ g2 
1712                         \oneVoice
1713                 }
1714                 \new Voice { \voiceThree 
1715                         s2. | s4 b4 c2 
1716                         \oneVoice
1717                 }
1718         >>
1719         \oneVoice
1720 }
1721 @end lilypond
1722
1723 The correct definition of the voices allows the melody to be slurred.
1724 @lilypond[quote,raggedright,verbatim]
1725 \new Staff \relative c' {
1726         c16^( d e f 
1727         \voiceOne
1728         <<      
1729                 { g4 f e | d2 e2) }  
1730                 \context Voice="1" { \voiceTwo
1731                         r8 e4 d c8 ~ | c8 b16 a b8 g ~ g2 
1732                         \oneVoice
1733                 }
1734                 \new Voice { \voiceThree 
1735                         s2. s4 b4 c2 
1736                         \oneVoice
1737                 }
1738         >>
1739         \oneVoice
1740 }
1741 @end lilypond
1742
1743 Avoiding the @code{\\} seperator also allows nesting polyphony 
1744 constructs, which in some case might be a more natural way to typeset
1745 the music.
1746
1747 @lilypond[quote,raggedright,verbatim]
1748 \new Staff \relative c' {
1749         c16^( d e f 
1750         \voiceOne
1751         <<      
1752                 { g4 f e | d2 e2) }  
1753                 \context Voice="1" { \voiceTwo
1754                         r8 e4 d c8 ~ | 
1755                         <<
1756                                 {c8 b16 a b8 g ~ g2} 
1757                                 \new Voice { \voiceThree 
1758                                         s4 b4 c2 
1759                                         \oneVoice
1760                                 }
1761                         >>
1762                         \oneVoice
1763                 }
1764         >>
1765         \oneVoice
1766 }
1767 @end lilypond
1768
1769 @node Collision Resolution
1770 @subsection Collision Resolution
1771
1772 Normally, note heads with a different number of dots are not merged, but
1773 when the object property @code{merge-differently-dotted} is set in
1774 the @internalsref{NoteCollision} object, they are merged
1775 @lilypond[quote,verbatim,fragment,raggedright,relative=2]
1776 \context Voice << {
1777   g8 g8
1778   \override Staff.NoteCollision
1779     #'merge-differently-dotted = ##t
1780   g8 g8
1781 } \\ { g8.[ f16] g8.[ f16] } >>
1782 @end lilypond
1783
1784 Similarly, you can merge half note heads with eighth notes, by setting
1785 @code{merge-differently-headed}
1786 @lilypond[quote,raggedright,fragment,relative=2,verbatim]
1787 \context Voice << {
1788   c8 c4.
1789   \override Staff.NoteCollision
1790     #'merge-differently-headed = ##t
1791 c8 c4. } \\ { c2 c2 } >>
1792 @end lilypond
1793
1794 LilyPond also vertically shifts rests that are opposite of a stem,
1795 for example
1796
1797 @lilypond[quote,raggedright,fragment,verbatim]
1798 \context Voice << c''4 \\ r4 >>
1799 @end lilypond
1800
1801
1802 @refcommands
1803
1804
1805
1806 @cindex @code{\oneVoice}
1807 @code{\oneVoice},
1808 @cindex @code{\voiceOne}
1809 @code{\voiceOne},
1810 @cindex @code{\voiceTwo}
1811 @code{\voiceTwo},
1812 @cindex @code{\voiceThree}
1813 @code{\voiceThree},
1814 @cindex @code{\voiceFour}
1815 @code{\voiceFour}.
1816
1817
1818
1819 @cindex @code{\shiftOn}
1820 @code{\shiftOn},
1821 @cindex @code{\shiftOnn}
1822 @code{\shiftOnn},
1823 @cindex @code{\shiftOnnn}
1824 @code{\shiftOnnn},
1825 @cindex @code{\shiftOff}
1826 @code{\shiftOff}: these commands specify in what chords of the current
1827 voice should be shifted.  The outer voices (normally: voice one and
1828 two) have @code{\shiftOff}, while the inner voices (three and four)
1829 have @code{\shiftOn}.  @code{\shiftOnn} and @code{\shiftOnnn} define
1830 further shift levels.
1831
1832
1833 When LilyPond cannot cope, the @code{force-hshift}
1834 property of the @internalsref{NoteColumn} object and pitched rests can
1835 be used to override typesetting decisions.
1836
1837 @lilypond[quote,verbatim,raggedright]
1838 \relative <<
1839 {
1840   <d g>
1841   <d g>
1842 } \\ {
1843   <b f'>
1844   \once \override NoteColumn #'force-hshift = #1.7
1845   <b f'>
1846 } >>
1847 @end lilypond
1848
1849
1850
1851 @seealso
1852
1853 Program reference: the objects responsible for resolving collisions are
1854 @internalsref{NoteCollision} and @internalsref{RestCollision}.
1855
1856 Examples:
1857 @inputfileref{input/@/regression,collision@/-dots@/.ly},
1858 @inputfileref{input/@/regression,collision@/-head-chords@/.ly},
1859 @inputfileref{input/@/regression,collision@/-heads@/.ly},
1860 @inputfileref{input/@/regression,collision@/-mesh@/.ly}, and
1861 @inputfileref{input/@/regression,collisions@/.ly}.
1862
1863
1864 @refbugs
1865
1866
1867 When using @code{merge-differently-headed} with an upstem eighth or a
1868 shorter note, and a downstem half note, the eighth note gets the wrong
1869 offset.
1870
1871 There is no support for clusters where the same note occurs with
1872 different accidentals in the same chord.  In this case, it is
1873 recommended to use enharmonic transcription, or to use special cluster
1874 notation (see @ref{Clusters}).
1875
1876 @node Beaming
1877 @section Beaming
1878
1879 @c todo: split this up; noBeaming and manual beams stay in basic;
1880 @c  seting automatic beam behavior and beam formatting goes into
1881 @c  advanced.  -gp
1882
1883 Beams are used to group short notes into chunks that are aligned with
1884 the metrum.  LilyPond normally inserts beams automatically, but if you
1885 wish you may control them manually or change how beams are automatically
1886 grouped.
1887
1888 @cindex Automatic beams
1889 @menu
1890 * Automatic beams::             
1891 * Manual beams::                
1892 * Setting automatic beam behavior::  
1893 * Beam formatting::             
1894 @end menu
1895
1896 @node Automatic beams
1897 @subsection Automatic beams
1898
1899 LilyPond inserts beams automatically
1900
1901 @lilypond[quote,raggedright,fragment,verbatim,relative=2]
1902 \time 2/4 c8 c c c \time 6/8 c c c c8. c16 c8
1903 @end lilypond
1904
1905 When these automatic decisions are not good enough, beaming can be
1906 entered explicitly.  It is also possible to define beaming patterns
1907 that differ from the defaults.
1908
1909 Individual notes may be marked with @code{\noBeam}, to prevent them
1910 from being beamed
1911
1912 @lilypond[quote,raggedright,fragment,verbatim,relative=2]
1913 \time 2/4 c8 c\noBeam c c
1914 @end lilypond
1915
1916
1917 @seealso
1918
1919 Program reference: @internalsref{Beam}.
1920
1921
1922 @node Manual beams
1923 @subsection Manual beams
1924 @cindex beams, manual
1925 @cindex @code{]}
1926 @cindex @code{[}
1927
1928 In some cases it may be necessary to override the automatic beaming
1929 algorithm.  For example, the autobeamer will not put beams over rests
1930 or bar lines.  Such beams are specified manually by marking the begin
1931 and end point with @code{[} and @code{]}
1932
1933 @lilypond[quote,raggedright,fragment,relative=1,verbatim]
1934 {
1935   r4 r8[ g' a r8] r8 g[ | a] r8
1936 }
1937 @end lilypond
1938
1939 @cindex @code{stemLeftBeamCount}
1940
1941 Normally, beaming patterns within a beam are determined automatically.
1942 If necessary, the properties @code{stemLeftBeamCount} and
1943 @code{stemRightBeamCount} can be used to override the defaults.  If
1944 either property is set, its value will be used only once, and then it
1945 is erased
1946
1947 @lilypond[quote,raggedright,fragment,relative=1,verbatim]
1948 {
1949    f8[ r16
1950       f g a]
1951    f8[ r16
1952    \set stemLeftBeamCount = #1
1953       f g a]
1954 }
1955 @end lilypond
1956 @cindex @code{stemRightBeamCount}
1957
1958
1959 The property @code{subdivideBeams} can be set in order to subdivide
1960 all 16th or shorter beams at beat positions, as defined by the
1961 @code{beatLength} property.
1962
1963
1964 @lilypond[fragment,quote,relative=2,verbatim]
1965 c16[ c c c c c c c]
1966 \set subdivideBeams = ##t
1967 c16[ c c c c c c c]
1968 \set Score.beatLength = #(ly:make-moment 1 8)
1969 c16[ c c c c c c c]
1970 @end lilypond
1971 @cindex @code{subdivideBeams}
1972
1973 Normally, line breaks are forbidden when beams cross bar lines.  This
1974 behavior can be changed by setting @code{allowBeamBreak}.
1975
1976 @cindex @code{allowBeamBreak}
1977 @cindex beams and line breaks
1978
1979 @cindex beams, kneed
1980 @cindex kneed beams
1981 @cindex auto-knee-gap
1982
1983
1984 @seealso
1985
1986 User manual: @ref{Changing context properties on the fly} for the
1987 @code{\set} command
1988
1989
1990 @refbugs
1991
1992 @cindex Frenched staves
1993 Kneed beams are inserted automatically, when a large gap is detected
1994 between the note heads.  This behavior can be tuned through the object.
1995
1996
1997 Automatically kneed cross-staff beams cannot be used together with
1998 hidden staves.  See @ref{Hiding staves}.
1999
2000 Beams do not avoid collisions with symbols around the notes, such as
2001 texts and accidentals.
2002
2003 @c FIXME.
2004
2005
2006 @node Setting automatic beam behavior
2007 @subsection Setting automatic beam behavior
2008
2009 @cindex @code{autoBeamSettings}
2010 @cindex @code{(end * * * *)}
2011 @cindex @code{(begin * * * *)}
2012 @cindex automatic beams, tuning
2013 @cindex tuning automatic beaming
2014
2015 @c [TODO: use \applycontext]
2016
2017 In normal time signatures, automatic beams can start on any note but can
2018 only end in a few positions within the measure: beams can end on a beat,
2019 or at durations specified by the properties in
2020 @code{autoBeamSettings}.  The defaults for @code{autoBeamSettings}
2021 are defined in @file{scm/@/auto@/-beam@/.scm}.
2022
2023 The value of @code{autoBeamSettings} is changed with three functions,
2024 @example
2025 #(override-auto-beam-setting
2026    '(@var{be} @var{p} @var{q} @var{n} @var{m}) @var{a} @var{b}
2027    [@var{context}])
2028 #(score-override-auto-beam-setting
2029    '(@var{be} @var{p} @var{q} @var{n} @var{m}) @var{a} @var{b})
2030 #(revert-auto-beam-setting '(@var{be} @var{p} @var{q} @var{n} @var{m})
2031    [@var{context}])
2032 @end example
2033 Here, @var{be} is the symbol @code{begin} or @code{end}, and
2034 @var{context} is an optional context (default: @code{'Voice}).  It
2035 determines whether the rule applies to begin or end-points.  The
2036 quantity @var{p}/@var{q} refers to the length of the beamed notes (and
2037 `@code{* *}' designates notes of any length), @var{n}/@var{M} refers
2038 to a time signature (wildcards `@code{* *}' may be entered to
2039 designate all time signatures), @var{a}/@var{b} is a duration.  By
2040 default, this command changes settings for the current voice.  It is
2041 also possible to adjust settings at higher contexts, by adding a
2042 @var{context} argument.  @code{score-override-auto-beam-setting} is
2043 equal to @code{override-auto-beam-setting} with the argument
2044 @var{context} set to @code{'Score}.
2045
2046 For example, if automatic beams should end on every quarter note, use
2047 the following
2048 @example
2049 #(override-auto-beam-setting '(end * * * *) 1 4 'Staff)
2050 @end example
2051 Since the duration of a quarter note is 1/4 of a whole note, it is
2052 entered as @code{(ly:make-moment 1 4)}.
2053
2054 The same syntax can be used to specify beam starting points.  In this
2055 example, automatic beams can only end on a dotted quarter note
2056 @example
2057 #(override-auto-beam-setting '(end * * * *) 3 8)
2058 @end example
2059 In 4/4 time signature, this means that automatic beams could end only on
2060 3/8 and on the fourth beat of the measure (after 3/4, that is 2 times
2061 3/8, has passed within the measure).
2062
2063 Rules can also be restricted to specific time signatures.  A rule that
2064 should only be applied in @var{N}/@var{M} time signature is formed by
2065 replacing the second asterisks by @var{N} and @var{M}.  For example, a
2066 rule for 6/8 time exclusively looks like
2067 @example
2068 #(override-auto-beam-setting '(begin * * 6 8) @dots{})
2069 @end example
2070
2071 If a rule should be to applied only to certain types of beams, use the
2072 first pair of asterisks.  Beams are classified according to the
2073 shortest note they contain.  For a beam ending rule that only applies
2074 to beams with 32nd notes (and no shorter notes), use @code{(end 1 32 *
2075 *)}.
2076
2077 @cindex automatic beam generation
2078 @cindex autobeam
2079 @cindex @code{autoBeaming}
2080 @cindex lyrics
2081
2082 If beams are used to indicate melismata in songs, then automatic
2083 beaming should be switched off.  This is done by setting
2084 @code{autoBeaming} to @code{#f}.
2085
2086 @refcommands
2087
2088 @cindex @code{\autoBeamOff}
2089 @code{\autoBeamOff},
2090 @cindex @code{\autoBeamOn}
2091 @code{\autoBeamOn}.
2092
2093
2094 @refbugs
2095
2096 If a score ends while an automatic beam has not been ended and is
2097 still accepting notes, this last beam will not be typeset at all.  The
2098 same holds polyphonic voices, entered with @code{<< @dots{} \\ @dots{}
2099 >>}.  If a polyphonic voice ends while an automatic beam is still
2100 accepting notes, it is not typeset.
2101
2102 The rules for ending a beam depend on the shortest note in a beam.
2103 So, while it is possible to have different ending rules for eight
2104 beams and sixteenth beams, a beam that contains both eight and
2105 sixteenth notes will use the rules for the sixteenth beam.
2106
2107 In the example below, the autobeamer makes eighth beams and sixteenth
2108 end at three eighths.  The third beam can only be corrected by
2109 specifying manual beaming.
2110
2111 @lilypond[quote,raggedright,fragment,relative=1]
2112 #(override-auto-beam-setting '(end * * * *) 3 8)
2113 % rather show case where it goes wrong
2114 %\time 12/8 c'8 c c c16 c c c c c c[ c c c] c8[ c] c4
2115 \time 12/8 c'8 c c c16 c c c c c c c c c c8 c c4
2116 @end lilypond
2117 It is not possible to specify beaming parameters that act differently in
2118 different parts of a measure.  This means that it is not possible to use
2119 automatic beaming in irregular meters such as @code{5/8}.
2120
2121 @node Beam formatting
2122 @subsection Beam formatting
2123
2124
2125 When a beam falls in the middle of the staff, the beams point normally
2126 down.  However, this behaviour can be altered with the
2127 @code{neutral-direction} property.
2128
2129
2130 @lilypond[quote,raggedright,relative=2,fragment,verbatim]
2131 {
2132   b8[ b]
2133   \override Beam #'neutral-direction = #-1
2134   b[ b]
2135   \override Beam #'neutral-direction = #1
2136   b[ b]
2137 }
2138 @end lilypond
2139
2140
2141 @node Repeats
2142 @section Repeats
2143
2144 Repetition is a central concept in music, and multiple notations exist
2145 for repetitions.
2146
2147 @menu
2148 * Repeat types::                
2149 * Repeat syntax::               
2150 * Repeats and MIDI::            
2151 * Manual repeat commands::      
2152 * Tremolo repeats::             
2153 * Tremolo subdivisions::        
2154 * Measure repeats::             
2155 @end menu
2156
2157 @node Repeat types
2158 @subsection Repeat types
2159
2160 @cindex repeats
2161 @cindex @code{\repeat}
2162
2163 The following types of repetition are supported
2164
2165 @table @code
2166 @item unfold
2167 Repeated music is fully written (played) out.  This is useful when
2168 entering repetitious music.  This is the only kind of repeat that
2169 is included in MIDI output.
2170
2171 @item volta
2172 Repeats are not written out, but alternative endings (volte) are
2173 printed, left to right with brackets.  This is the standard notation
2174 for repeats with alternatives.  These are not played in MIDI output by default.
2175
2176 @ignore
2177 @item fold
2178 Alternative endings are written stacked.  This has limited use but may be
2179 used to typeset two lines of lyrics in songs with repeats, see
2180 @inputfileref{input,star-spangled-banner@/.ly}.
2181 @end ignore
2182
2183 @c tremolo, beamed
2184 @item tremolo
2185 Make tremolo beams.  These are not played in MIDI output by default.
2186
2187 @item percent
2188 Make beat or measure repeats.  These look like percent signs.  These
2189 are not played in MIDI output by default.  Percent repeats must be
2190 declared within a Voice context.
2191
2192 @end table
2193
2194 @node Repeat syntax
2195 @subsection Repeat syntax
2196
2197
2198 LilyPond has one syntactic construct for specifying different types of
2199 repeats.  The syntax is
2200
2201 @example
2202 \repeat @var{variant} @var{repeatcount} @var{repeatbody}
2203 @end example
2204
2205 If you have alternative endings, you may add
2206 @cindex @code{\alternative}
2207 @example
2208 \alternative @{ @var{alternative1}
2209                @var{alternative2}
2210                @var{alternative3} @dots{} @}
2211 @end example
2212 where each @var{alternative} is a music expression.  If you do not
2213 give enough alternatives for all of the repeats, the first alternative
2214 is assumed to be played more than once.
2215
2216 Standard repeats are used like this
2217 @lilypond[quote,raggedright,fragment,verbatim,relative=2]
2218 c1
2219 \repeat volta 2 { c4 d e f }
2220 \repeat volta 2 { f e d c }
2221 @end lilypond
2222
2223 With alternative endings
2224 @lilypond[quote,raggedright,fragment,verbatim,relative=2]
2225 c1
2226 \repeat volta 2 {c4 d e f}
2227 \alternative { {d2 d} {f f,} }
2228 @end lilypond
2229
2230
2231 @lilypond[quote,raggedright,fragment,verbatim,relative=2]
2232 \context Staff {
2233   \partial 4
2234   \repeat volta 4 { e | c2 d2 | e2 f2 | }
2235   \alternative { { g4 g g } { a | a a a a | b2. } }
2236 }
2237 @end lilypond
2238
2239 It is possible to shorten volta brackets
2240 by setting @code{voltaSpannerDuration}.  In the next example, the
2241 bracket only lasts one measure, which is a duration of 3/4.
2242
2243
2244
2245 @lilypond[verbatim,raggedright,quote]
2246 \relative c''{
2247   \time 3/4
2248   c c c
2249   \set Staff.voltaSpannerDuration = #(ly:make-moment 3 4)
2250   \repeat "volta" 5 { d d d }
2251   \alternative { { e e e f f f }
2252   { g g g } }
2253 }
2254 @end lilypond
2255
2256
2257 @seealso
2258
2259 Examples:
2260
2261 Brackets for the repeat are normally only printed over the topmost
2262 staff.  This can be adjusted by setting the @code{voltaOnThisStaff}
2263 property; see @inputfileref{input/@/regression,volta@/-multi@/-staff@/.ly}.
2264
2265 @c not necessary
2266 @c @inputfileref{input/@/regression,volta@/-chord@/-names@/.ly}.
2267
2268
2269 @refbugs
2270
2271 A nested repeat like
2272
2273 @example
2274 \repeat @dots{}
2275 \repeat @dots{}
2276 \alternative
2277 @end example
2278
2279 @noindent
2280 is ambiguous, since it is is not clear to which @code{\repeat} the
2281 @code{\alternative} belongs.  This ambiguity is resolved by always
2282 having the @code{\alternative} belong to the inner @code{\repeat}.
2283 For clarity, it is advisable to use braces in such situations.
2284 @cindex ambiguity
2285
2286
2287
2288 Timing information is not remembered at the start of an alternative,
2289 so after a repeat timing information must be reset by hand, for
2290 example by setting @code{Score.measurePosition} or entering
2291 @code{\partial}.  Similarly, slurs or ties are also not repeated.
2292
2293
2294
2295
2296 @node Repeats and MIDI
2297 @subsection Repeats and MIDI
2298
2299 @cindex expanding repeats
2300
2301 With a little bit of tweaking, all types of repeats can be present
2302 in the MIDI output.  This is achieved by applying the
2303 @code{\unfoldrepeats} music function.  This functions changes all
2304 repeats to unfold repeats.
2305
2306 @lilypond[quote,verbatim,fragment,linewidth=8.0\cm]
2307 \unfoldrepeats {
2308   \repeat tremolo 8 {c'32 e' }
2309   \repeat percent 2 { c''8 d'' }
2310   \repeat volta 2 {c'4 d' e' f'}
2311   \alternative {
2312     { g' a' a' g' }
2313     {f' e' d' c' }
2314   }
2315 }
2316 \bar "|."
2317 @end lilypond
2318
2319 When creating a score file using @code{\unfoldrepeats} for midi, then
2320 it is necessary to make two @code{\score} blocks.  One for MIDI (with
2321 unfolded repeats) and one for notation (with volta, tremolo, and
2322 percent repeats).  For example,
2323
2324 @example
2325 \score @{
2326   @var{..music..}
2327   \layout @{ .. @}
2328 @}
2329 \score @{
2330   \unfoldrepeats @var{..music..}
2331   \midi @{ .. @}
2332 @}
2333 @end example
2334
2335 @node Manual repeat commands
2336 @subsection Manual repeat commands
2337
2338 @cindex @code{repeatCommands}
2339
2340 The property @code{repeatCommands} can be used to control the layout of
2341 repeats.  Its value is a Scheme list of repeat commands.
2342
2343 @table @asis
2344 @item @code{start-repeat}
2345 Print a @code{|:} bar line.
2346
2347 @item @code{end-repeat}
2348 Print a @code{:|} bar line.
2349
2350 @item @code{(volta @var{text})}
2351 Print a volta bracket saying @var{text}: The text can be specified as
2352 a text string or as a markup text, see @ref{Text markup}.  Do not
2353 forget to change the font, as the default number font does not contain
2354 alphabetic characters;
2355
2356 @item @code{(volta #f)}
2357 Stop a running volta bracket.
2358 @end table
2359
2360 @lilypond[quote,raggedright,verbatim,fragment,relative=2]
2361 c4
2362   \set Score.repeatCommands = #'((volta "93") end-repeat)
2363 c4 c4
2364   \set Score.repeatCommands = #'((volta #f))
2365 c4 c4
2366 @end lilypond
2367
2368
2369
2370 @seealso
2371
2372 Program reference: @internalsref{VoltaBracket}, @internalsref{RepeatedMusic},
2373 @internalsref{VoltaRepeatedMusic},
2374 @internalsref{UnfoldedRepeatedMusic}, and
2375 @internalsref{FoldedRepeatedMusic}.
2376
2377 @node Tremolo repeats
2378 @subsection Tremolo repeats
2379 @cindex tremolo beams
2380
2381 To place tremolo marks between notes, use @code{\repeat} with tremolo
2382 style
2383 @lilypond[quote,verbatim,raggedright]
2384 \new Voice \relative c' {
2385   \repeat "tremolo" 8 { c16 d16 }
2386   \repeat "tremolo" 4 { c16 d16 }
2387   \repeat "tremolo" 2 { c16 d16 }
2388 }
2389 @end lilypond
2390
2391 Tremolo marks can also be put on a single note.  In this case, the
2392 note should not be surrounded by braces.
2393 @lilypond[quote,verbatim,raggedright]
2394 \repeat "tremolo" 4 c'16
2395 @end lilypond
2396
2397 Similar output is obtained using the tremolo subdivision, described in
2398 @ref{Tremolo subdivisions}.
2399
2400 @seealso
2401
2402 In this manual: @ref{Tremolo subdivisions}, @ref{Repeats}.
2403
2404 Program reference: tremolo beams are @internalsref{Beam} objects.  Single stem
2405 tremolos are @internalsref{StemTremolo} objects.  The music expression is
2406 @internalsref{TremoloEvent}.
2407
2408 Example files: @inputfileref{input/@/regression,chord@/-tremolo@/.ly},
2409 @inputfileref{input/@/regression,stem@/-tremolo@/.ly}.
2410
2411 @node Tremolo subdivisions
2412 @subsection Tremolo subdivisions
2413 @cindex tremolo marks
2414 @cindex @code{tremoloFlags}
2415
2416 Tremolo marks can be printed on a single note by adding
2417 `@code{:}[@var{number}]' after the note.  The number indicates the
2418 duration of the subdivision, and it must be at least 8.  A
2419 @var{length} value of 8 gives one line across the note stem.  If the
2420 length is omitted, the last value (stored in @code{tremoloFlags}) is
2421 used
2422
2423 @lilypond[quote,raggedright,verbatim,fragment]
2424 c'2:8 c':32 | c': c': |
2425 @end lilypond
2426
2427 @c [TODO: stok is te kort bij 32en]
2428 @c   somebody want to translate that into English?
2429 @c   `Stem is too short for 32nds' (wl)
2430
2431 @refbugs
2432
2433 Tremolos entered in this way do not carry over into the MIDI output.
2434
2435 @seealso
2436
2437 In this manual: @ref{Tremolo repeats}.
2438
2439 Elsewhere: @internalsref{StemTremolo}, @internalsref{TremoloEvent}.
2440
2441 @node Measure repeats
2442 @subsection Measure repeats
2443
2444 @cindex percent repeats
2445 @cindex measure repeats
2446
2447 In the @code{percent} style, a note pattern can be repeated.  It is
2448 printed once, and then the pattern is replaced with a special sign.
2449 Patterns of one and two measures are replaced by percent-like signs,
2450 patterns that divide the measure length are replaced by slashes.
2451 Percent repeats must be declared within a @code{Voice} context.
2452
2453 @lilypond[quote,verbatim,raggedright]
2454 \new Voice \relative c' {
2455   \repeat "percent" 4 { c4 }
2456   \repeat "percent" 2 { c2 es2 f4 fis4 g4 c4 }
2457 }
2458 @end lilypond
2459
2460 @seealso
2461
2462 Program reference: @internalsref{RepeatSlash}, @internalsref{PercentRepeat},
2463 @internalsref{PercentRepeatedMusic}, and
2464 @internalsref{DoublePercentRepeat}.
2465
2466
2467 @node Expressive marks
2468 @section Expressive marks
2469
2470
2471 @c todo: should change ordering
2472 @c where to put text spanners, metronome marks,
2473 @c fingering?
2474
2475 Expressive marks help musicians to bring more to the music than simple
2476 notes and rhythms.
2477
2478 @menu
2479 * Slurs::
2480 * Phrasing slurs::
2481 * Breath marks::
2482 * Articulations::
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