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