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