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