]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/rhythms.itely
Standardize on "Notation Reference: "
[lilypond.git] / Documentation / user / rhythms.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @ignore
3     Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
4
5     When revising a translation, copy the HEAD committish of the
6     version that you are working on.  See TRANSLATION for details.
7 @end ignore
8
9 @node Rhythms
10 @section Rhythms
11
12 @lilypondfile[ragged-right,line-width=16\cm,staffsize=16,quote]
13 {rhythms-headword.ly}
14
15 This section discusses rhythms, durations, and bars.
16
17 @menu
18 * Writing rhythms::             
19 * Writing rests::               
20 * Displaying rhythms::          
21 * Beams::                       
22 * Bars::                        
23 * Special rhythmic concerns::   
24 @end menu
25
26
27 @node Writing rhythms
28 @subsection Writing rhythms
29
30 @menu
31 * Durations::                   
32 * Tuplets::                     
33 * Scaling durations::           
34 * Ties::                        
35 @end menu
36
37 @node Durations
38 @unnumberedsubsubsec Durations
39
40 @cindex duration
41 @funindex \longa
42 @funindex \breve
43 @funindex \maxima
44
45 When entering notes, durations are designated by numbers and dots:
46 durations are entered as their reciprocal values.  For example, a
47 quarter note is entered using a @code{4} (since it is a 1/4 note),
48 while a half note is entered using a @code{2} (since it is a 1/2
49 note).  For notes longer than a whole you must use the
50 @code{\longa} (a double breve) and @code{\breve} commands.  Note
51 durations as short as 64th notes may be specified.  Shorter values
52 are possible, but only as beamed notes.
53
54 @c Two 64th notes are needed to obtain beams
55 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
56 \time 8/1
57 c\longa c\breve c1 c2
58 c4 c8 c16 c32 c64 c64
59 @end lilypond
60
61 @noindent
62 and the same durations with automatic beaming turned off 
63 see @ref{Automatic beams}:
64
65 @c not strictly "writing rhythms"; more of a "displaying" thing,
66 @c but it's ok here.  -gp
67 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
68 \time 8/1
69 \autoBeamOff
70 c\longa c\breve c1 c2
71 c4 c8 c16 c32 c64 c64
72 @end lilypond
73
74 If the duration is omitted then it is set to the previously
75 entered duration.  The default for the first note is a quarter
76 note.
77
78 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
79 a a a2 a a4 a a1 a
80 @end lilypond
81
82
83 @funindex .
84
85 To obtain dotted note lengths, simply add a dot (@code{.}) to the
86 number.  Double-dotted notes are produced in a similar way.
87
88 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
89 a4 b c4. b8 a4. b4.. c8.
90 @end lilypond
91
92 Some durations cannot be entered using only binary durations
93 and dots, and can only be represented by tying two or more 
94 notes together.  Tied notes are covered in @ref{Ties}.
95
96 @refcommands
97
98 Dots are normally moved up to avoid staff lines, except in
99 polyphonic situations.  The following commands may be used to
100 force a particular direction manually:
101
102 @funindex \dotsUp
103 @code{\dotsUp},
104 @funindex \dotsDown
105 @code{\dotsDown},
106 @funindex \dotsNeutral
107 @code{\dotsNeutral}.
108
109 @c TODO: after deciding the link question, fix these.  -gp
110 Durations are entered in the same way in @code{drummode},
111 @code{chordmode}, @code{figuremode}, and (optionally) 
112 in @code{lyricmode}.
113
114 @seealso
115
116 For ways of specifying durations for the syllables of lyrics
117 and ways of aligning lyrics to notes see @ref{Vocal music}.
118
119 For a description of how to enter rests see @ref{Writing rests}.
120
121 A note with the duration of a quadruple breve may be
122 entered with \maxima, but this is supported only within
123 ancient music notation; see @ref{Ancient notation}.
124
125 Optionally, notes can be spaced proportionately to their duration.
126 For details of this and other settings which control
127 proportional notation see @ref{Proportional notation}.
128
129 Snippets: @lsrdir{rhythms}
130
131 Internals Reference: @internalsref{Dots}, and
132 @internalsref{DotColumn}.
133
134
135 @refbugs
136
137 @c duplicated in Durations and Rests.  -gp
138 There is no fundamental limit to note durations (both in terms of
139 longest and shortest), but the number of glyphs is limited: there
140 are flags up to 64th and rests up to 128th.  At the other extreme,
141 there are note heads up to longa (4x whole note) and rests up to
142 maxima (8 x whole).  Since beams can be stacked without needing
143 extra glyphs, beamed notes can be arbitrarily short.
144
145
146
147 @node Tuplets
148 @unnumberedsubsubsec Tuplets
149
150 @cindex tuplets
151 @cindex triplets
152 @funindex \times
153
154 @c TODO Add Tuplet to glossary
155
156 Tuplets are made out of a music expression by multiplying all
157 durations with a fraction:
158
159 @example
160 \times @var{fraction} @var{musicexpr}
161 @end example
162
163 @noindent
164 The duration of @var{musicexpr} will be multiplied by the 
165 fraction.  The fraction's denominator will be printed over or 
166 under the notes, optionally with a bracket.  The most common 
167 tuplet is the triplet in which 3 notes have the length of 2, so 
168 the notes are 2/3 of their written length.
169
170 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
171 g4 \times 2/3 {c4 c c} d4 d4
172 @end lilypond
173
174 Tuplets may be nested, for example,
175
176 @lilypond[fragment,ragged-right,verbatim,relative=2]
177 \times 2/3 {
178   a4 a
179   \times 3/5 { a a a a a }
180 }
181 @end lilypond
182
183 @refcommands
184
185 @funindex \tupletUp
186 @code{\tupletUp},
187 @funindex \tupletDown
188 @code{\tupletDown},
189 @funindex \tupletNeutral
190 @code{\tupletNeutral}.
191
192
193 @commonprop
194
195 @funindex tupletNumberFormatFunction
196 @cindex tuplet formatting
197
198 The property @code{tupletSpannerDuration} specifies how long each
199 bracket should last.  With this, you can make lots of tuplets
200 while typing @code{\times} only once, thus saving lots of typing.
201 In the next example, there are two triplets shown, while
202 @code{\times} was only used once.
203
204 @lilypond[quote,fragment,relative=2,ragged-right,verbatim]
205 \set tupletSpannerDuration = #(ly:make-moment 1 4)
206 \times 2/3 { c8 c c c c c }
207 @end lilypond
208
209 @noindent
210 For more information about @code{make-moment}, see
211 @ref{Time administration}.
212
213 The format of the number is determined by the property @code{text}
214 in @code{TupletNumber}.  The default prints only the denominator,
215 but if the property is set with @code{\override
216 TupletNumber #'text = #tuplet-number::calc-fraction-text},
217 @var{num}:@var{den} will be printed instead.
218
219 To print tuplets without tuplet numbers, use
220 @code{\override TupletNumber #'transparent = ##t}:
221
222 @lilypond[quote,fragment,relative=2,ragged-right,verbatim]
223 \times 2/3 { c8 c c } \times 2/3 { c8 c c }
224 \override TupletNumber #'text = #tuplet-number::calc-fraction-text
225 \times 2/3 { c8 c c }
226 \override TupletNumber #'transparent = ##t
227 \times 2/3 { c8 c c }
228 @end lilypond
229
230 To change the appearance of nested tuplets beginning at the same
231 music moment individually, the @code{\tweak} function must be used
232 (see @ref{Objects connected to the input}).  In the following
233 example, @code{\tweak} specifies fraction text for the outer
234 @code{TupletNumber} and denominator text for the
235 @code{TupletNumber} of the first of the three inner tuplets.
236
237 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
238 \tweak #'text #tuplet-number::calc-fraction-text
239 \times 4/3 {
240    \tweak #'text #tuplet-number::calc-denominator-text
241    \times 2/3 { c8[ c8 c8] }
242    \times 2/3 { c8[ c8 c8] }
243    \times 2/3 { c8[ c8 c8] }
244 }
245 @end lilypond
246
247 @c TODO: after LM 6 Tweaks includes \tweak info, look at this.-gp
248 @c It *should* be explained why \tweak must be used here, and why
249 @c \override doesn't work. I've made an attempt, but I'm not sure
250 @c if it is factually correct to say that \tweak must be used.
251 In the next example, @code{\tweak} and @code{\override} work
252 together to specify @code{TupletBracket} direction.  The first
253 @code{\tweak} positions the @code{TupletBracket} of the outer
254 tuplet above the staff.  The second @code{\tweak} positions the
255 @code{TupletBracket} of the first of the three inner tuplets below
256 the staff.  Note that the @code{\tweak} function affects only
257 events that begin at the same music moment: the outer tuplet and
258 the first of the three inner tuplets.  To position the
259 @code{TupletBrackets} of the second and third of the inner tuplets
260 below the staff, we use @code{\override} in the usual way.
261
262 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
263 \tweak #'text #tuplet-number::calc-fraction-text
264 \tweak #'direction #up
265 \times 4/3 {
266    \tweak #'direction #down
267    \times 2/3 { c8[ c8 c8] }
268    \override TupletBracket #'direction = #down
269    \times 2/3 { c8[ c8 c8] }
270    \times 2/3 { c8[ c8 c8] }
271 }
272 @end lilypond
273
274 Tuplet brackets can be made to run to prefatory matter or the next
275 note:
276
277 @lilypond[ragged-right,verbatim,quote]
278 \new RhythmicStaff {
279   \set tupletFullLength = ##t
280   \set tupletFullLengthNote = ##t
281   \time 2/4
282   \times 2/3 { c4 c c }
283   \set tupletFullLengthNote = ##f
284   \time 4/4
285   \times 4/5 { c4 c1 }
286   \time 3/4
287   c4 
288 }
289 @end lilypond
290
291 @refbugs
292
293 Tuplets which cross bar lines will prevent a line break at that
294 point.
295
296 @seealso
297
298 @code{\compressMusic} works similarly to \times, but does not
299 create a tuplet bracket; see @ref{Polymetric notation}.
300
301 FIXME: totally irrelevant link to real-music for
302 discussion/demonstration purposes.
303
304 Snippets: @lsrdir{rhythms},
305 @lsr{real-music,creating-music-with-scheme.ly}.
306
307 Internals Reference: @internalsref{TupletBracket},
308 @internalsref{TupletNumber}, and @internalsref{TimeScaledMusic}.
309
310
311
312 @node Scaling durations
313 @unnumberedsubsubsec Scaling durations
314
315 You can alter the length of a duration by a fraction @var{N/M}
316 by appending @code{*@var{N/M}} (or @code{*@var{N}} if @var{M=1}).
317 This will not affect the appearance of the notes or rests
318 produced, but the altered duration will be used in calculating the
319 position within the measure and setting the duration in the MIDI
320 output.  Multiplying factors may be combined
321 such as @code{*M*N}.
322
323 In the following example, the first three notes take up exactly
324 two beats, but no triplet bracket is printed.
325
326 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
327 \time 2/4
328 a4*2/3 gis4*2/3 a4*2/3
329 a4 a4 a4*2
330 b16*4 c4
331 @end lilypond
332
333 The duration of skip or spacing notes may also be modified by
334 a multiplier.  This is useful for skipping many measures, e.g., 
335 @code{s1*23}.
336
337 @seealso
338
339 This manual: @ref{Tuplets}, @ref{Skips}, @ref{Polymetric notation}.
340
341 Snippets: @lsrdir{rhythms}
342
343 @node Ties
344 @unnumberedsubsubsec Ties
345
346 @cindex tie
347 @funindex ~
348
349 A tie connects two adjacent note heads of the same pitch.  The tie
350 in effect extends the length of a note. 
351
352 @warning{Ties should not be confused with @emph{slurs}, which
353 indicate articulation, or @emph{phrasing slurs}, which indicate
354 musical phrasing. A tie is just a way of extending a note
355 duration, similar to the augmentation dot.}
356
357 A tie is entered using the tilde symbol @code{~}
358
359 @lilypond[quote,ragged-right,fragment,verbatim]
360 e' ~ e'
361 @end lilypond
362
363
364 @noindent
365 Ties are used either when the note crosses a bar line, or when
366 dots cannot be used to denote the rhythm.  Ties should also be
367 used when note values cross larger subdivisions of the measure:
368
369 @lilypond[fragment,quote,ragged-right]
370 \relative {
371   r8 c8 ~ c2 r4 | r8^"not" c2 ~ c8 r4
372 }
373 @end lilypond
374
375 If you need to tie a lot of notes across bar lines, it may be
376 easier to use automatic note splitting (see @ref{Automatic note
377 splitting}).  This mechanism automatically splits long notes, and
378 ties them across bar lines.
379
380 @funindex \repeatTie
381 @cindex repeating ties
382 @cindex volta brackets and ties
383
384 When a tie is applied to a chord, all note heads whose pitches
385 match are connected.  When no note heads match, no ties will be
386 created.  Chords may be partially tied by placing the tie inside
387 the chord.
388
389 @lilypond[quote,ragged-right,fragment,verbatim,relative=1]
390  <c e g> ~ <c e g>
391 <c~ e g~ b> <c e g b>
392 @end lilypond
393
394 When a second alternative of a repeat starts with a tied note, you
395 have to repeat the tie.  This can be achieved with
396 @code{\repeatTie},
397
398 @lilypond[fragment,quote,ragged-right,relative=2,verbatim]
399 \repeat volta 2 { c g <c e>2 ~ }
400 \alternative {{ <c e>2. r4 } {<c e>2\repeatTie d4 c }} 
401 @end lilypond
402
403 @cindex Laissez vibrer
404 @cindex Ties, laissez vibrer
405
406 @notation{L.v.} ties (@notation{laissez vibrer}) indicate that
407 notes must not be damped at the end.  It is used in notation for
408 piano, harp and other string and percussion instruments.  They can
409 be entered using @code{\laissezVibrer}:
410
411 @lilypond[fragment,ragged-right,verbatim,relative=1]
412 <c f g>\laissezVibrer
413 @end lilypond
414
415 The direction of a tie can be specified with @code{\tieUp} or
416 @code{\tieDown} (see example below).  @code{\tieNeutral} reverts
417 to the default behaviour again.
418
419 However, as with other music elements of this kind, there is a
420 convenient shorthand for forcing tie directions.  By adding
421 @code{_} or @code{^} before the tilde, the direction is also set:
422
423 @lilypond[relative=2,ragged-right,quote,verbatim,fragment]
424 c4_~ c c^~ c)
425 @end lilypond
426
427
428 @seealso
429
430 Snippets: @lsrdir{rhythms}
431
432 Internals Reference:
433 @internalsref{LaissezVibrerTie}
434 @internalsref{LaissezVibrerTieColumn}
435
436 Example files:
437 @lsr{connecting,laissez-vibrer-ties.ly}
438
439
440 @commonprop
441
442 Ties are sometimes used to write out arpeggios.  In this case, two
443 tied notes need not be consecutive.  This can be achieved by
444 setting the @code{tieWaitForNote} property to true.  The same
445 feature is also useful, for example, to tie a tremolo to a chord,
446 but in principle, it can also be used for ordinary, consecutive
447 notes:
448
449 @lilypond[fragment,verbatim,relative=1,ragged-right,quote]
450 \set tieWaitForNote = ##t
451 \grace { c16[~ e~ g]~ } <c, e g>2
452 \repeat tremolo 8 { c32~ c'~ } <c c,>1
453 e8~ c~ a~ f~ <e' c a f>2
454 \tieUp c8~ a \tieDown \tieDotted g~ c g2
455 @end lilypond
456
457 Ties may be engraved manually by changing the
458 @code{tie-configuration} property of the @code{TieColumn} object.
459 The first number indicates the distance from the center of the
460 staff in staff-spaces, and the second number indicates the
461 direction (1=up, -1=down).
462
463 @lilypond[fragment,verbatim,relative=1,ragged-right,quote]
464 <c e g>2~ <c e g> |
465 \override TieColumn #'tie-configuration =
466   #'((0.0 . 1) (-2.0 . 1) (-4.0 . 1))
467 <c e g>~ <c e g> |
468 @end lilypond
469
470
471 @refcommands
472
473
474 @funindex \tieUp
475 @code{\tieUp},
476 @funindex \tieDown
477 @code{\tieDown},
478 @funindex \tieNeutral
479 @code{\tieNeutral},
480 @funindex \tieDotted
481 @code{\tieDotted},
482 @funindex \tieDashed
483 @code{\tieDashed},
484 @funindex \tieSolid
485 @code{\tieSolid}.
486
487
488 @seealso
489
490
491
492 Notation Reference: @ref{Automatic note splitting}.
493
494 Snippets: @lsrdir{rhythms}
495
496 Internals Reference: @internalsref{Tie}.
497
498
499 @refbugs
500
501 Switching staves when a tie is active will not produce a slanted
502 tie.
503
504 Changing clefs or octavations during a tie is not really
505 well-defined.  In these cases, a slur may be preferable.
506
507
508
509
510
511 @node Writing rests
512 @subsection Writing rests
513
514 @menu
515 * Rests::                       
516 * Skips::                       
517 * Multi measure rests::         
518 @end menu
519
520 @node Rests
521 @unnumberedsubsubsec Rests
522 @cindex Rests
523
524 @funindex \rest
525 @funindex r
526 @funindex \maxima
527
528 Rests are entered like notes with the note name @code{r}:
529
530 @c \time 16/1 is used to avoid spurious bar lines
531 @c and long tracts of empty measures
532 @lilypond[fragment,quote,ragged-right,verbatim]
533 \new Staff {
534   \time 16/1
535   \override Staff.TimeSignature #'stencil = ##f
536   r\maxima
537   r\longa r\breve r1 r2
538   r4 r8 r16 r32 r64
539 }
540 @end lilypond
541
542 Whole measure rests, centered in middle of the measure, must be entered as
543 multi-measure rests.  They can be used for a single measure as well as
544 many measures and are discussed in @ref{Multi measure rests}.
545
546 To explicitly specify a rest's vertical position, write a note
547 followed by @code{\rest}.  A rest will be placed in the position
548 where the note would appear.  This allows for precise manual
549 formatting of polyphonic music, since the automatic rest collision
550 formatter will leave these rests alone.
551
552 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
553 a4\rest d4\rest
554 @end lilypond
555
556
557 @seealso
558
559 Snippets: @lsrdir{rhythms}
560
561 Internals Reference: @internalsref{Rest}.
562
563
564 @refbugs
565
566 @c duplicated in Durations and Rests.  -gp
567 There is no fundamental limit to note durations (both in terms of
568 longest and shortest), but the number of glyphs is limited: there
569 are flags up 64th and rests up to 128th.  At the other extreme,
570 there are note heads up to longa (4x whole note) and rests up to
571 maxima (8 x whole).  Since beams can be stacked without needing
572 extra glyphs, beamed notes can be arbitrarily short.
573
574
575 @node Skips
576 @unnumberedsubsubsec Skips
577
578 @cindex Skip
579 @cindex Invisible rest
580 @cindex Space note
581 @funindex \skip
582 @funindex s
583
584 An invisible rest (also called a @q{skip}) can be entered like a
585 note with note name @code{s} or with @code{\skip @var{duration}}
586
587 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
588 a4 a4 s4 a4 \skip 1 a4
589 @end lilypond
590
591 The @code{s} syntax is only available in note mode and chord mode.
592 In other situations, for example, when entering lyrics, one must
593 use the @code{\skip} command:
594
595 @lilypond[quote,ragged-right,verbatim,relative=2]
596 <<
597   { a2 a2 }
598   \new Lyrics \lyricmode { \skip 2 bla2 }
599 >>
600 @end lilypond
601
602 The skip command is merely an empty musical placeholder.  It does
603 not produce any output, not even transparent output.
604
605 The @code{s} skip command does create @internalsref{Staff} and
606 @internalsref{Voice} when necessary, similar to note and rest
607 commands.  For example, the following results in an empty staff.
608
609 @lilypond[quote,verbatim]
610 { s4 }
611 @end lilypond
612 @c with ragged-right, the staff lines are cut BEFORE the time
613 @c signature, which makes for a VERY empty staff
614
615 @c The fragment @code{@{ \skip 4 @} } would produce an empty page.
616 @c Misleading -- it doesn't produce anything, not even an empty page.
617 @c Ppl who want to make empty sheets will see this and wonder what's
618 @c happening.  -eo
619
620 @seealso
621
622 Snippets: @lsrdir{rhythms}
623
624 Internals Reference: @internalsref{SkipMusic}.
625
626
627 @node Multi measure rests
628 @unnumberedsubsubsec Multi measure rests
629
630 @cindex multi measure rests
631 @cindex full measure rests
632 @cindex Rests, multi measure
633 @cindex Rests, full measure
634 @cindex whole rests for a full measure
635 @funindex R
636
637 Rests for one or more full measures are entered using @code{R}
638 followed by a duration (see @ref{Durations}).  The duration should
639 correspond to an integral number of measures, otherwise a barcheck
640 warning is printed.  Multi-measure rests are principally used to
641 indicate that a part in a multi-part score should be silent:
642
643 @lilypond[quote,fragment,verbatim,relative=2]
644 \set Score.skipBars = ##t
645 R1*4
646 R1*24
647 R1*4
648 b2^"Tutti" b4 a4
649 @end lilypond
650
651 A multi-measure rest can be expanded in the printed score
652 to show all the rest measures explicitly, or, as above, it can be 
653 condensed to a single measure
654 containing a multi-measure rest symbol, with the number of
655 measures of rest printed above the measure.  This expansion
656 is controlled by the property @code{Score.skipBars}.  If this is
657 set to true, empty measures will be condensed to a single measure.
658
659 @lilypond[quote,ragged-right,fragment,verbatim]
660 \time 4/4 r1 | R1 | R1*2 | 
661 \time 2/4 R2 | 
662 \time 4/4
663 \set Score.skipBars = ##t 
664 R1*17 | R1*4 |
665 @end lilypond
666
667 The @code{1} in @code{R1} is similar to the duration notation 
668 used for notes and is the length of a measure in 2/2 or 4/4 time.
669 The duration in a multi-measure rest must always be an integral
670 number of measure-lengths, so in other time signatures augmentation
671 dots or fractions must be used:
672
673 @lilypond[quote,ragged-right,fragment,verbatim]
674 \set Score.skipBars = ##t
675 \time 3/4
676 R2. | R2.*2
677 \time 13/8
678 R1*13/8 | R1*13/8*12 |
679 \time 10/8 
680 R4*5*4 |
681 @end lilypond
682
683 An @code{R} spanning a single measure is printed as either a whole
684 or breve rest, centered in the measure, regardless of the time
685 signature.
686
687 If there are 10 or fewer measures of rest, LilyPond prints
688 @rglos{church rests} (a series of longa and breve rests)
689 in the staff and
690 prints a simple line otherwise.  This default number of 10
691 may be changed by overriding 
692 @code{MultiMeasureRest.expand-limit}.
693
694 @lilypond[quote,ragged-right,fragment,verbatim]
695 \set Score.skipBars = ##t
696 R1*2 | R1*5 | R1*9
697 \override MultiMeasureRest #'expand-limit = 3
698 R1*2 | R1*5 | R1*9
699 @end lilypond
700
701 Note that unlike ordinary rests, the vertical position on the
702 staff of the multi-measure rest symbol of either form cannot be
703 changed.
704
705 @cindex text on multi-measure rest
706 @cindex script on multi-measure rest
707 @cindex fermata on multi-measure rest
708
709 Text can be added to multi-measure rests by using the
710 @var{note}-@code{markup} syntax described in @ref{Text markup}.
711 The variable @code{\fermataMarkup} is provided for adding
712 fermatas.
713
714 @lilypond[quote,ragged-right,verbatim,fragment]
715 \set Score.skipBars = ##t
716 \time 3/4
717 R2.*10^\markup { \italic "ad lib." }
718 R2.^\fermataMarkup
719 @end lilypond
720
721 @warning{Text attached to a multi-measure rest is created 
722 by @code{MultiMeasureRestText}, not
723 @code{TextScript}.  Overrides must be directed to the correct
724 object, or they will be ignored.  See the following example.}
725
726 @lilypond[quote,ragged-right,verbatim,fragment]
727 \override TextScript #'padding = #5
728 R1^"low"
729 \override MultiMeasureRestText #'padding = #5
730 R1^"high"
731 @end lilypond
732
733 Text attached to a multi-measure rest will be centered above or
734 below it.  Long text attached in this way does not cause the
735 measure to expand, and may collide with text in adjacent measures.
736 Long text is better attached to a zero-length skip note preceding
737 the rest, preceded by @code{\fatText} (turn off again with
738 @code{\emptyText}), since this will cause the measure to expand to
739 accommodate the length of the text:
740
741 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
742 \set Score.skipBars = ##t
743 \fatText
744 s1*0^\markup {[MAJOR GENERAL]}
745 R1*19
746 s1*0^\markup {[MABEL] }
747 s1*0_\markup {\italic {Cue: ... it is yours}}
748 R1*30
749 c4^\markup {CHORUS} d f c
750 @end lilypond
751
752
753 @seealso
754
755 This manual: @ref{Text}, @ref{Text scripts}.
756
757 Snippets: @lsrdir{rhythms}
758
759 Internals Reference: 
760
761 @internalsref{MultiMeasureRest}.
762
763 The layout object @internalsref{MultiMeasureRestNumber} is for the
764 default number, and @internalsref{MultiMeasureRestText} for user
765 specified texts.
766
767
768 @refbugs
769
770 If an attempt is made to use fingerings (e.g., 
771 @code{R1*10-4}) to put numbers over multi-measure rests, the
772 fingering numeral (4) may collide with the bar counter 
773 numeral (10).  
774
775 @cindex condensing rests
776
777 There is no way to automatically condense multiple rests into a
778 single multi-measure rest.  Multi-measure rests do not take part
779 in rest collisions.
780
781 Be careful when entering multi-measure rests followed by whole
782 notes.  The following will enter two notes lasting four measures
783 each:
784
785 @example
786 R1*4 cis cis
787 @end example
788
789
790 @node Displaying rhythms
791 @subsection Displaying rhythms
792
793 @menu
794 * Time signature::              
795 * Upbeats::                     
796 * Unmetered music::             
797 * Polymetric notation::         
798 * Automatic note splitting::    
799 @end menu
800
801 @node Time signature
802 @unnumberedsubsubsec Time signature
803
804 @cindex Time signature
805 @cindex meter
806 @funindex \time
807
808 The time signature is set with the @code{\time} command:
809
810 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
811 \time 2/4 c2 \time 3/4 c2.
812 @end lilypond
813
814 @commonprop
815
816 The symbol that is printed can be customized with the @code{style}
817 property.  Setting it to @code{#'()} uses fraction style for 4/4
818 and 2/2 time,
819
820 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
821 \time 4/4 c1
822 \time 2/2 c1
823 \override Staff.TimeSignature #'style = #'()
824 \time 4/4 c1
825 \time 2/2 c1
826 @end lilypond
827
828 A time signature symbol is normally printed whenever the time
829 signature changes.  If this takes place at the end of a line a
830 warning time signature sign is printed at the end of the line and
831 again at the start of a new line.  This default behaviour can be
832 modified by setting the value of the @code{break-visibility}
833 property.  This takes three values which may be set to @code{#t}
834 or @code{#f} to specify whether the corresponding time signature
835 is visible or not.  The order of the three values is @code{end of
836 line visible}, @code{middle of line visible}, @code{beginning of
837 line visible}.
838
839 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
840 % Do not print any time signatures at end of line
841 \override Staff.TimeSignature #'break-visibility = ##(#f #t #t)
842 \time 4/4 c1
843 \time 3/4 c2.
844 % Do not print the following 9/8 time signature
845 \once \override Staff.TimeSignature #'break-visibility = ##(#t #f #t)
846 \time 9/8 c4. c c
847 \time 2/2 c1
848 \break
849 \time 9/8 c4. c c
850 \time 12/8 c2. c2.
851 @end lilypond
852
853 There are many more options for its layout.  See @ref{Ancient time
854 signatures}, for more examples.
855
856 @code{\time} sets the properties @code{timeSignatureFraction},
857 @code{beatLength}, and @code{measureLength} in the @code{Timing}
858 context, which is normally aliased to @internalsref{Score}.  The
859 property @code{measureLength} determines where bar lines should be
860 inserted, and how automatic beams should be generated.  Changing
861 the value of @code{timeSignatureFraction} also causes the symbol
862 to be printed.
863
864 @cindex Measure groupings
865  
866 More options are available through the Scheme function
867 @code{set-time-signature}, which takes three arguments: the number
868 of beats, the beat length, and the internal grouping of beats in
869 the measure.  If the @internalsref{Measure_grouping_engraver} is
870 included, the function will also create
871 @internalsref{MeasureGrouping} signs.  Such signs ease reading
872 rhythmically complex modern music.  In the following example, the
873 9/8 measure is subdivided in 2, 2, 2 and 3.  This is passed to
874 @code{set-time-signature} as the third argument @code{(2 2 2 3)}:
875
876 @lilypond[quote,ragged-right,verbatim]
877 \score {
878   \relative c'' {
879     #(set-time-signature 9 8 '(2 2 2 3))
880     g8[ g] d[ d] g[ g] a8[( bes g]) |
881     #(set-time-signature 5 8 '(3 2))
882     a4. g4
883   }
884   \layout {
885     \context {
886       \Staff
887       \consists "Measure_grouping_engraver"
888     }
889   }
890 }
891 @end lilypond
892
893
894 @seealso
895
896 Snippets: @lsrdir{rhythms}
897
898 Internals Reference: @internalsref{TimeSignature}, and
899 @internalsref{Timing_translator}.
900
901 Examples: @lsr{contemporary,compound-time-signature.ly}.
902
903
904 @refbugs
905
906 Automatic beaming does not use the measure grouping specified with
907 @code{set-time-signature}.
908
909
910 @node Upbeats
911 @unnumberedsubsubsec Upbeats
912
913 @cindex anacrusis
914 @cindex upbeat
915 @cindex partial measure
916 @cindex measure, partial
917 @cindex pickup measure
918 @cindex shorten measures
919 @funindex \partial
920
921 Partial or pickup measures, such as an anacrusis or upbeat, are
922 entered using the @code{\partial} command, with the syntax
923
924 @example
925 \partial @var{duration}
926 @end example
927
928 where @code{duration} is the rhythmic length to be added before
929 the next measure:
930
931 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
932 \partial 16*5 c16 cis d dis e | a2. c,4 | b2
933 @end lilypond
934
935 Internally, this is translated into
936
937 @example
938 \set Timing.measurePosition = -@var{length of duration}
939 @end example
940
941 The property @code{measurePosition} contains a rational number
942 indicating how much of the measure has passed at this point.  Note
943 that this is a negative number; @code{\partial 4} is internally
944 translated to mean @qq{there is a quarter note left in the bar.}
945
946
947 @refbugs
948
949 This command does not take into account grace notes at the start
950 of the music.  When a piece starts with grace notes in the
951 pickup, then the @code{\partial} should follow the grace notes:
952
953 @lilypond[verbatim,quote,ragged-right,relative,fragment]
954 \grace f16
955 \partial 4
956 g4
957 a2 g2
958 @end lilypond
959
960 @code{\partial} is only intended to be used at the beginning of a
961 piece.  If you use it after the beginning, some odd warnings may
962 occur.
963
964 @seealso
965
966 Snippets: @lsrdir{rhythms}
967
968 @node Unmetered music
969 @unnumberedsubsubsec Unmetered music
970
971 @cindex cadenza
972 @funindex \cadenzaOn
973 @funindex \cadenzaOff
974
975 Bar lines and bar numbers are calculated automatically.  For
976 unmetered music (cadenzas, for example), this is not desirable.
977 To turn off automatic bar lines and bar numbers, use the commands
978 @code{\cadenzaOn} and @code{\cadenzaOff}.
979
980 @lilypond[verbatim,quote,ragged-right,relative=2,fragment]
981 c4 d e d
982 \cadenzaOn
983 c4 c d8 d d f4 g4.
984 \cadenzaOff
985 \bar "|"
986 d4 e d c
987 @end lilypond
988
989
990 @refbugs
991
992 LilyPond will only insert line breaks and page breaks at a
993 bar line.  Unless the unmetered music ends before the end of the
994 staff line, you will need to insert invisible bar lines with
995
996 @example
997 \bar ""
998 @end example
999
1000 @noindent
1001 to indicate where breaks can occur.
1002
1003 @seealso
1004
1005 Snippets: @lsrdir{rhythms}
1006
1007
1008 @node Polymetric notation
1009 @unnumberedsubsubsec Polymetric notation
1010
1011 @cindex double time signatures
1012 @cindex signatures, polymetric
1013 @cindex polymetric signatures
1014 @cindex meter, polymetric
1015
1016 Double time signatures are not supported explicitly, but they can
1017 be faked.  In the next example, the markup for the time signature
1018 is created with a markup text.  This markup text is inserted in
1019 the @internalsref{TimeSignature} grob.  See also
1020 @lsr{contemporary,compound-time-signature}.
1021
1022 @lilypond[verbatim,ragged-right]
1023 % create 2/4 + 5/8
1024 tsMarkup = \markup {
1025   \override #'(baseline-skip . 2) \number {
1026     \column { "2" "4" }
1027     \vcenter "+"
1028     \bracket \column { "5" "8" }
1029   }
1030 }
1031
1032 {
1033   \override Staff.TimeSignature #'stencil =
1034     #ly:text-interface::print
1035   \override Staff.TimeSignature #'text = #tsMarkup
1036   \time 3/2
1037   c'2 \bar ":" c'4 c'4.
1038 }
1039 @end lilypond
1040
1041 Each staff can also have its own time signature.  This is done by
1042 moving the @internalsref{Timing_translator} to the
1043 @internalsref{Staff} context.
1044
1045 @lilypond[quote,verbatim,ragged-right]
1046 \layout {
1047   \context {
1048     \Score
1049     \remove "Timing_translator"
1050     \remove "Default_bar_line_engraver"
1051   }
1052   \context {
1053     \Staff
1054     \consists "Timing_translator"
1055     \consists "Default_bar_line_engraver"
1056   }
1057 }
1058 %Now, each staff has its own time signature.
1059
1060 \relative c' <<
1061   \new Staff {
1062     \time 3/4
1063     c4 c c | c c c |
1064   }
1065   \new Staff {
1066     \time 2/4
1067     c4 c | c c | c c
1068   }
1069   \new Staff {
1070     \time 3/8
1071     c4. c8 c c c4. c8 c c
1072   }
1073 >>
1074 @end lilypond
1075
1076
1077 A different form of polymetric notation is where note lengths have
1078 different values across staves, but the measures are all the same 
1079 length.
1080
1081 This notation can be created by setting a common time signature
1082 for each staff but replacing it manually using
1083 @code{timeSignatureFraction} to the desired fraction.  Then the
1084 printed durations in each staff are scaled to the common time
1085 signature.  The latter is done with @code{\compressMusic}, which
1086 is used in a similar way to @code{\times}, but does not create 
1087 a tuplet bracket.  The syntax is 
1088 @funindex \compressMusic
1089
1090 @example 
1091 \compressMusic 
1092 #'(@var{numerator} . @var{denominator}) @var{musicexpr} 
1093 @end example
1094
1095
1096
1097 In this example, music with the time signatures of 3/4, 9/8, and
1098 10/8 are used in parallel.  In the second staff, shown durations
1099 are multiplied by 2/3, so that 2/3 * 9/8 = 3/4, and in the third
1100 staff, shown durations are multiplied by 3/5, so that 3/5 * 10/8 =
1101 3/4.
1102
1103 @lilypond[quote,ragged-right,verbatim,fragment]
1104 \relative c' { <<
1105   \new Staff {
1106     \time 3/4
1107     c4 c c | c c c |
1108   }
1109   \new Staff {
1110     \time 3/4
1111     \set Staff.timeSignatureFraction = #'(9 . 8)
1112     \compressMusic #'(2 . 3)
1113       \repeat unfold 6 { c8[ c c] }
1114   }
1115   \new Staff {
1116     \time 3/4
1117     \set Staff.timeSignatureFraction = #'(10 . 8)
1118     \compressMusic #'(3 . 5) {
1119       \repeat unfold 2 { c8[ c c] }
1120       \repeat unfold 2 { c8[ c] }
1121       | c4. c4. \times 2/3 { c8 c c } c4
1122     }
1123   }
1124 >> }
1125 @end lilypond
1126
1127
1128 @refbugs
1129
1130 When using different time signatures in parallel, the spacing is
1131 aligned vertically, but bar lines distort the regular spacing.
1132
1133 @seealso
1134
1135 Snippets: @lsrdir{rhythms}
1136
1137
1138 @node Automatic note splitting
1139 @unnumberedsubsubsec Automatic note splitting
1140
1141 Long notes which overrun bar lines can be converted automatically
1142 to tied notes.  This is done by replacing the
1143 @internalsref{Note_heads_engraver} by the
1144 @internalsref{Completion_heads_engraver}.  In the following
1145 examples, notes crossing the bar line are split and tied.
1146
1147 @lilypond[quote,fragment,verbatim,relative=1,line-width=12\cm]
1148 \new Voice \with {
1149   \remove "Note_heads_engraver"
1150   \consists "Completion_heads_engraver"
1151 } {
1152   c2. c8 d4 e f g a b c8 c2 b4 a g16 f4 e d c8. c2
1153 }
1154 @end lilypond
1155
1156 This engraver splits all running notes at the bar line, and
1157 inserts ties.  One of its uses is to debug complex scores: if the
1158 measures are not entirely filled, then the ties exactly show how
1159 much each measure is off.
1160
1161 If you want to allow line breaking on the bar lines where
1162 @internalsref{Completion_heads_engraver} splits notes, you must
1163 also remove @internalsref{Forbid_line_break_engraver}.
1164
1165
1166 @refbugs
1167
1168 Not all durations (especially those containing tuplets) can be
1169 represented exactly with normal notes and dots, but the engraver
1170 will not insert tuplets.
1171
1172 @code{Completion_heads_engraver} only affects notes; it does not
1173 split rests.
1174
1175
1176 @seealso
1177
1178 Snippets: @lsrdir{rhythms}
1179
1180 Internals Reference: @internalsref{Completion_heads_engraver},
1181 @internalsref{Forbid_line_break_engraver}.
1182
1183
1184
1185
1186
1187 @node Beams
1188 @subsection Beams
1189
1190 @menu
1191 * Automatic beams::             
1192 * Setting automatic beam behavior::  
1193 * Manual beams::                
1194 @end menu
1195
1196 @node Automatic beams
1197 @unnumberedsubsubsec Automatic beams
1198
1199 By default beams are inserted automatically:
1200
1201 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
1202 \time 2/4 c8 c c c
1203 \time 6/8 c c c c8. c16 c8
1204 @end lilypond
1205
1206 If these automatic decisions are not satisfactory, beaming can be
1207 entered explicitly; see @ref{Manual beams}.  It is also possible
1208 to define beaming patterns that differ from the defaults; see
1209 @ref{Setting automatic beam behavior}.  The default beaming rules
1210 are defined in @file{scm/@/auto@/-beam@/.scm}.
1211
1212 @cindex autoBeamOn
1213 @cindex autoBeamOff
1214
1215 @noindent
1216 Automatic beaming may be turned off and on with
1217 @code{\autoBeamOff} and @code{\autoBeamOn} commands:
1218
1219 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
1220 c4 c8 c8. c16 c8. c16 c8
1221 \autoBeamOff
1222 c4 c8 c8. c16 c8.
1223 \autoBeamOn
1224 c16 c8
1225 @end lilypond
1226
1227
1228 @commonprop
1229
1230 Beaming patterns may be altered with the @code{beatGrouping} property,
1231
1232 @lilypond[quote,verbatim,relative=2,fragment,ragged-right]
1233 \time 5/16
1234 \set beatGrouping = #'(2 3)
1235 c8[^"(2+3)" c16 c8]
1236 \set beatGrouping = #'(3 2)
1237 c8[^"(3+2)" c16 c8]
1238 @end lilypond
1239
1240 The property @code{subdivideBeams} can be set in order to
1241 subdivide all 16th or shorter beams.  When set, multiple beams
1242 will be sub-divided at beat positions, defined by the current
1243 value of @code{beatLength} (defaults to a quarter note), by
1244 drawing only one beam over the beat.
1245
1246 @lilypond[fragment,ragged-right,quote,relative=2,verbatim]
1247 c32[ c c c c c c c]
1248 \set subdivideBeams = ##t
1249 c32[ c c c c c c c]
1250 \set Score.beatLength = #(ly:make-moment 1 8)
1251 c32[ c c c c c c c]
1252 \set Score.beatLength = #(ly:make-moment 1 16)
1253 c32[ c c c c c c c]
1254 @end lilypond
1255 @funindex subdivideBeams
1256
1257 @noindent
1258 For more information about @code{make-moment}, see
1259 @ref{Time administration}.
1260
1261 @funindex breakable
1262
1263 Line breaks are normally forbidden when beams cross bar lines.
1264 This behavior can be changed by setting the @code{breakable} 
1265 property: @code{\override Beam #'breakable = ##t}.
1266
1267 @lilypond[ragged-right,relative=2,fragment,verbatim,quote]
1268 \override Beam #'breakable = ##t
1269 c8 \repeat unfold 15 {c[ c] } c
1270 @end lilypond
1271
1272 @cindex beams and line breaks
1273 @cindex beams, kneed
1274 @cindex kneed beams
1275 @cindex auto-knee-gap
1276
1277 Kneed beams are inserted automatically when a large gap is
1278 detected between the note heads.  This behavior can be tuned
1279 through the @code{auto-knee-gap} property.  A kneed beam is
1280 drawn if the gap is larger than the value of 
1281 @code{auto-knee-gap} plus the width of the beam object (which
1282 depends on the duration of the notes and the slope of the beam).
1283 By default @code{auto-knee-gap} is set to 5.5 staff spaces.
1284
1285 @lilypond[fragment,ragged-right,quote,verbatim]
1286 f8 f''8 f8 f''8
1287 \override Beam #'auto-knee-gap = #6
1288 f8 f''8 f8 f''8
1289 @end lilypond
1290
1291
1292 @seealso
1293
1294 Snippets: @lsrdir{rhythms}
1295
1296 Internals Reference: @internalsref{Beam}.
1297
1298
1299 @refbugs
1300
1301 Automatically kneed cross-staff beams cannot be used together with
1302 hidden staves.  See @ref{Hiding staves}.
1303
1304 Beams can collide with noteheads and accidentals in other voices
1305
1306
1307 @node Setting automatic beam behavior
1308 @unnumberedsubsubsec Setting automatic beam behavior
1309
1310 @funindex autoBeamSettings
1311 @funindex (end * * * *)
1312 @funindex (begin * * * *)
1313 @cindex automatic beams, tuning
1314 @cindex tuning automatic beaming
1315
1316 @c [TODO: use \applyContext]
1317
1318 In normal time signatures, automatic beams can start on any note
1319 but can only end in a few positions within the measure: beams can
1320 end on a beat, or at durations specified by the properties in
1321 @code{autoBeamSettings}.  The properties in
1322 @code{autoBeamSettings} consist of a list of rules for where beams
1323 can begin and end.  The default @code{autoBeamSettings} rules are
1324 defined in @file{scm/@/auto@/-beam@/.scm}.
1325
1326 In order to add a rule to the list, use
1327 @example
1328 #(override-auto-beam-setting '(be p q n m) a b [context])
1329 @end example
1330
1331 @itemize
1332
1333 @item @code{be} is either @code{begin} or @code{end}.
1334
1335 @item @code{p/q} is the duration of the note for which you want
1336 to add a rule.  A beam is considered to have the duration of its
1337 shortest note.  Set @code{p} and @code{q} to @code{'*'} to
1338 have this apply to any beam.
1339
1340 @item @code{n/m} is the time signature to which
1341 this rule should apply.  Set @code{n} and @code{m} to @code{'*'}
1342 to have this apply in any time signature.
1343
1344 @item @code{a/b} is the position in the bar at which the beam should
1345 begin/end.
1346
1347 @item @code{context} is optional, and it specifies the context at which
1348 the change should be made.  The default is @code{'Voice}.
1349
1350 @code{#(score-override-auto-beam-setting '(A B C D) E F)} is equivalent to
1351 @code{#(override-auto-beam-setting '(A B C D) E F 'Score)}.
1352
1353 @end itemize
1354
1355 For example, if automatic beams should always end on the first quarter
1356 note, use
1357
1358 @example
1359 #(override-auto-beam-setting '(end * * * *) 1 4)
1360 @end example
1361
1362 You can force the beam settings to only take effect on beams whose shortest
1363 note is a certain duration
1364
1365 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1366 \time 2/4
1367 #(override-auto-beam-setting '(end 1 16 * *) 1 16)
1368 a16 a a a a a a a |
1369 a32 a a a a16 a a a a a |
1370 #(override-auto-beam-setting '(end 1 32 * *) 1 16)
1371 a32 a a a a16 a a a a a |
1372 @end lilypond
1373
1374 You can force the beam settings to only take effect in certain time
1375 signatures
1376
1377 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1378 \time 5/8
1379 #(override-auto-beam-setting '(end * * 5 8) 2 8)
1380 c8 c d d d
1381 \time 4/4
1382 e8 e f f e e d d
1383 \time 5/8
1384 c8 c d d d
1385 @end lilypond
1386
1387 You can also remove a previously set beam-ending rule by using
1388
1389 @example
1390 #(revert-auto-beam-setting '(be p q n m) a b [context])
1391 @end example
1392
1393 @noindent
1394 be, p, q, n, m, a, b and context are the same as above.  Note that the
1395 default rules are specified in @file{scm/@/auto@/-beam@/.scm},
1396 so you can revert rules that you did not explicitly create.
1397
1398 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1399 \time 4/4
1400 a16 a a a a a a a a a a a a a a a
1401 #(revert-auto-beam-setting '(end 1 16 4 4) 1 4)
1402 a16 a a a a a a a a a a a a a a a
1403 @end lilypond
1404
1405 The rule in a revert-auto-beam-setting statement must exactly match the
1406 original rule.  That is, no wildcard expansion is taken into account.
1407
1408 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1409 \time 1/4
1410 #(override-auto-beam-setting '(end 1 16 1 4) 1 8)
1411 a16 a a a
1412 #(revert-auto-beam-setting '(end 1 16 * *) 1 8) % this won't revert it!
1413 a a a a
1414 #(revert-auto-beam-setting '(end 1 16 1 4) 1 8) % this will
1415 a a a a
1416 @end lilypond
1417
1418
1419
1420 @c TODO:  old material -- not covered by above stuff, I think.
1421 If automatic beams should end on every quarter in 5/4 time, specify
1422 all endings
1423 @example
1424 #(override-auto-beam-setting '(end * * * *) 1 4 'Staff)
1425 #(override-auto-beam-setting '(end * * * *) 1 2 'Staff)
1426 #(override-auto-beam-setting '(end * * * *) 3 4 'Staff)
1427 #(override-auto-beam-setting '(end * * * *) 5 4 'Staff)
1428 @dots{}
1429 @end example
1430
1431 The same syntax can be used to specify beam starting points.  In this
1432 example, automatic beams can only end on a dotted quarter note
1433 @example
1434 #(override-auto-beam-setting '(end * * * *) 3 8)
1435 #(override-auto-beam-setting '(end * * * *) 1 2)
1436 #(override-auto-beam-setting '(end * * * *) 7 8)
1437 @end example
1438 In 4/4 time signature, this means that automatic beams could end only on
1439 3/8 and on the fourth beat of the measure (after 3/4, that is 2 times
1440 3/8, has passed within the measure).
1441
1442 If any unexpected beam behaviour occurs, check the default automatic beam
1443 settings in @file{scm/@/auto@/-beam@/.scm}
1444 for possible interference, because the beam
1445 endings defined there will still apply on top of your own overrides.  Any
1446 unwanted endings in the default vales must be reverted for your time
1447 signature(s).
1448
1449 For example, to typeset @code{(3 4 3 2)}-beam endings in 12/8, begin
1450 with
1451
1452 @example
1453 %%% revert default values in scm/auto-beam.scm regarding 12/8 time
1454 #(revert-auto-beam-setting '(end * * 12 8) 3 8)
1455 #(revert-auto-beam-setting '(end * * 12 8) 3 4)
1456 #(revert-auto-beam-setting '(end * * 12 8) 9 8)
1457
1458 %%% your new values
1459 #(override-auto-beam-setting '(end 1 8 12 8) 3 8)
1460 #(override-auto-beam-setting '(end 1 8 12 8) 7 8)
1461 #(override-auto-beam-setting '(end 1 8 12 8) 10 8)
1462 @end example
1463
1464 @cindex automatic beam generation
1465 @cindex autobeam
1466 @funindex autoBeaming
1467 @cindex lyrics
1468
1469 If beams are used to indicate melismata in songs, then automatic
1470 beaming should be switched off with @code{\autoBeamOff}.
1471
1472
1473 @refcommands
1474
1475 @funindex \autoBeamOff
1476 @code{\autoBeamOff},
1477 @funindex \autoBeamOn
1478 @code{\autoBeamOn}.
1479
1480
1481 @refbugs
1482
1483 If a score ends while an automatic beam has not been ended and is
1484 still accepting notes, this last beam will not be typeset at all.
1485 The same holds for polyphonic voices, entered with @code{<<
1486 @dots{} \\ @dots{} >>}.  If a polyphonic voice ends while an
1487 automatic beam is still accepting notes, it is not typeset.
1488
1489 @seealso
1490
1491 Snippets: @lsrdir{rhythms}
1492
1493
1494 @node Manual beams
1495 @unnumberedsubsubsec Manual beams
1496
1497 @cindex beams, manual
1498
1499 In some cases it may be necessary to override the automatic
1500 beaming algorithm.  For example, the autobeamer will not put beams
1501 over rests or bar lines, and in choral scores the beaming is
1502 often set to follow the meter of the lyrics rather than the
1503 notes. Such beams can be specified manually by
1504 marking the begin and end point with @code{[} and @code{]}
1505
1506 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
1507 {
1508   r4 r8[ g' a r8] r8 g[ | a] r8
1509 }
1510 @end lilypond
1511
1512
1513 Individual notes may be marked with @code{\noBeam} to prevent them
1514 from being beamed:
1515
1516 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
1517 \time 2/4 c8 c\noBeam c c
1518 @end lilypond
1519
1520 @funindex ]
1521 @funindex [
1522
1523 @funindex stemLeftBeamCount
1524 @funindex stemRightBeamCount
1525
1526 Even more strict manual control with the beams can be achieved by
1527 setting the properties @code{stemLeftBeamCount} and
1528 @code{stemRightBeamCount}.  They specify the number of beams to
1529 draw on the left and right side, respectively, of the next note.
1530 If either property is set, its value will be used only once, and
1531 then it is erased.  In this example, the last @code{f} is printed
1532 with only one beam on the left side, i.e. the eigth-note beam of
1533 the group as a whole.
1534
1535 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
1536 {
1537   f8[ r16 f g a]
1538   f8[ r16
1539   \set stemLeftBeamCount = #1
1540   f g a]
1541 }
1542 @end lilypond
1543
1544
1545 @commonprop
1546
1547 @cindex beams, feathered
1548 @funindex \featherDurations 
1549
1550 Feathered beams are used to indicate that a small group of notes
1551 should be played at an increasing (or decreasing) tempo, without
1552 changing the overall tempo of the piece.  The extent of the 
1553 feathered beam must be indicated manually using @code{[} and
1554 @code{]}, and the beam feathering is turned on by specifying a 
1555 direction to the Beam property @code{grow-direction}.
1556
1557 If the placement of the notes and the sound in the MIDI output
1558 is to reflect the ritardando or accelerando indicated by the
1559 feathered beam the notes must be grouped as a
1560 music expression delimited by braces and preceded by a
1561 @code{featheredDurations} command which specifies the ratio
1562 between the durations of the first and last notes in the group.
1563
1564 The square brackets
1565 show the extent of the beam and the braces show
1566 which notes are to have their durations modified.  Normally 
1567 these would delimit the same group of notes, but this is not
1568 required: the two commands are independent. 
1569
1570 In the following example the eight 16th notes occupy exactly
1571 the same time as a half note, but the first note is twice
1572 as short as the last one, with the intermediate notes gradually
1573 lengthening.  The first four 32nd notes gradually speed up,
1574 while the last four 32nd notes are at a constant tempo.
1575
1576 @lilypond[ragged-right,relative=1,fragment,verbatim,quote]
1577 \override Beam #'grow-direction = #LEFT
1578 \featherDurations #(ly:make-moment 2 1)
1579 { c16[ c c c c c c c] }
1580 \override Beam #'grow-direction = #RIGHT
1581 \featherDurations #(ly:make-moment 2 3)
1582 { c32[ d e f] }
1583 % revert to non-feathered beams
1584 \override Beam #'grow-direction = #'()
1585 { g32[ a b c] }
1586 @end lilypond
1587
1588 @noindent
1589 The spacing in the printed output represents the 
1590 note durations only approximately, but the midi output is exact.
1591
1592 @refbugs
1593
1594 The @code{\featherDurations} command only works with very short
1595 music snippets, and when numbers in the fraction are small.
1596
1597 @seealso
1598
1599 Snippets: @lsrdir{rhythms}
1600
1601
1602
1603 @node Bars
1604 @subsection Bars
1605
1606
1607 @menu
1608 * Bar lines::                   
1609 * Bar numbers::                 
1610 * Bar and bar number checks::   
1611 * Rehearsal marks::             
1612 @end menu
1613
1614 @node Bar lines
1615 @unnumberedsubsubsec Bar lines
1616
1617 @cindex Bar lines
1618 @cindex Barlines
1619 @funindex \bar
1620 @cindex measure lines
1621 @cindex repeat bars
1622
1623 Bar lines delimit measures, and are also used to indicate
1624 repeats.  Normally, simple bar lines are automatically inserted
1625 into the printed output at places based on the current time 
1626 signature.  
1627
1628 The simple bar lines inserted automatically can be changed to 
1629 other types with the @code{\bar} command.  For example, a closing
1630 double bar line is usually placed at the end of a piece:
1631
1632 @lilypond[quote,ragged-right,relative=1,fragment,verbatim]
1633 e4 d c2 \bar "|."
1634 @end lilypond
1635
1636 @warning{An incorrect duration can lead to poorly formatted
1637 music.}
1638  
1639 It is not invalid if the final note in a bar does not 
1640 end on the automatically entered bar line: the note is assumed 
1641 to carry over into the next bar.  But if a long sequence
1642 of such carry-over bars appears the music can appear compressed
1643 or even flowing off the page.  This is because automatic line
1644 breaks happen only at the end of complete bars, i.e. where 
1645 the end of a note coincides with the end of a bar.
1646
1647 Line breaks are also permitted at manually inserted bar lines
1648 even within incomplete bars.  To allow a line break without 
1649 printing a bar line, use
1650
1651 @example
1652 \bar ""
1653 @end example
1654
1655 @noindent
1656 This will insert an invisible bar line and allow (but not
1657 force) a line break to occur at this point.  The bar number 
1658 counter is not increased.  To force a line break see 
1659 @ref{Line breaking}.
1660
1661 This and other special bar lines may be inserted manually at any
1662 point.  When they coincide with the end of a bar they replace
1663 the simple bar line which would have been inserted there 
1664 automatically.  When they do not coincide
1665 with the end of a bar the specified bar line is inserted at that
1666 point in the printed output.  Such insertions do not affect
1667 the calculation and placement of subsequent automatic bar lines.  
1668
1669 The simple bar line and four types of double bar line are available
1670 for manual insertion:
1671
1672 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
1673 f1 \bar "|" g \bar "||" a \bar ".|" b \bar ".|." c \bar "|." d
1674 @end lilypond
1675
1676 @noindent
1677 together with dotted and dashed bar lines:
1678
1679 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
1680 f1 \bar ":" g \bar "dashed" a
1681 @end lilypond
1682
1683 @noindent
1684 and three types of repeat bar line:
1685
1686 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
1687 f1 \bar "|:" g \bar ":|:" a \bar ":|" b
1688 @end lilypond
1689
1690 Although the bar line types signifying repeats may be inserted
1691 manually they do not in themselves cause LilyPond to recognise
1692 a repeated section.  Such repeated sections are better entered
1693 using the various repeat commands (see @ref{Repeats}), which
1694 automatically print the appropriate bar lines.
1695
1696 In addition, you can specify @code{"||:"}, which is equivalent to
1697 @code{"|:"} except at line breaks, where it gives a double bar
1698 line at the end of the line and a start repeat at the beginning of
1699 the next line. 
1700
1701 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1702 \override Score.RehearsalMark #'padding = #3
1703 c c c c
1704 \bar "||:" 
1705 c c c c \break
1706 \bar "||:" 
1707 c c c c
1708 @end lilypond
1709
1710 In scores with many staves, a @code{\bar} command in one staff is
1711 automatically applied to all staves.  The resulting bar lines are
1712 connected between different staves of a @code{StaffGroup},
1713 @code{PianoStaff}, or @code{GrandStaff}.
1714
1715 @lilypond[quote,ragged-right,fragment,verbatim]
1716 <<
1717   \new StaffGroup <<
1718     \new Staff {
1719       e'4 d'
1720       \bar "||"
1721       f' e'
1722     }
1723     \new Staff { \clef bass c4 g e g }
1724   >>
1725   \new Staff { \clef bass c2 c2 }
1726 >>
1727 @end lilypond
1728
1729
1730 @commonprop
1731
1732 @funindex whichBar
1733 @funindex defaultBarType
1734
1735 The command @code{\bar }@var{bartype} is a shortcut for
1736 @code{\set Timing.whichBar = }@var{bartype}.  A bar line is 
1737 created whenever the @code{whichBar} property is
1738 set.  
1739
1740 The default bar type used for automatically inserted bar lines is
1741 @code{"|"}.  This may be changed at any time
1742 with @code{\set Timing.defaultBarType = }@var{bartype}.  
1743
1744 @seealso
1745
1746 Notation Reference: @ref{Repeats}, @ref{System start delimiters}.
1747
1748 Snippets: @lsrdir{rhythms}
1749
1750 Internals Reference: @internalsref{BarLine} (created at
1751 @internalsref{Staff} level), @internalsref{SpanBar} (across
1752 staves), @internalsref{Timing_translator} (for Timing 
1753 properties).
1754
1755
1756 @node Bar numbers
1757 @unnumberedsubsubsec Bar numbers
1758
1759 @cindex Bar numbers
1760 @cindex measure numbers
1761 @funindex currentBarNumber
1762
1763 Bar numbers are typeset by default at the start of every line
1764 except the first line.  The
1765 number itself is stored in the @code{currentBarNumber} property,
1766 which is normally updated automatically for every measure.  It
1767 may also be set manually:
1768
1769 @lilypond[verbatim,ragged-right,quote,fragment,relative]
1770 c1 c c c
1771 \break
1772 \set Score.currentBarNumber = #50
1773 c1 c c c
1774 @end lilypond
1775
1776
1777 @commonprop
1778
1779 @funindex barNumberVisibility
1780 @cindex bar numbers, regular spacing
1781
1782 Bar numbers can be typeset at regular intervals instead of just at
1783 the beginning of every line.  To do this the default behaviour
1784 must be overridden to permit bar numbers to be printed at places
1785 other than the start of a line.  This is controlled by the
1786 @code{break-visibility} property of @code{BarNumber}.  This takes
1787 three values which may be set to @code{#t} or @code{#f} to specify
1788 whether the corresponding bar number is visible or not.  The order
1789 of the three values is @code{end of line visible}, @code{middle of
1790 line visible}, @code{beginning of line visible}.  In the following
1791 example bar numbers are printed at all possible places:
1792
1793 @lilypond[verbatim,ragged-right,quote,fragment,relative]
1794 \override Score.BarNumber #'break-visibility = ##(#t #t #t)
1795 \set Score.currentBarNumber = #11
1796 \bar ""  % Permit first bar number to be printed
1797 c1 c c c
1798 \break
1799 c c c c
1800 @end lilypond
1801
1802 @c  All the rest of these examples will be added to LSR
1803 @c  and moved into the Snippets.  -gp
1804
1805 @noindent
1806 and here the bar numbers are printed every two bars
1807 except at the end of the line:
1808
1809 @lilypond[verbatim,ragged-right,quote,fragment,relative]
1810 \override Score.BarNumber #'break-visibility = ##(#f #t #t)
1811 \set Score.currentBarNumber = #11
1812 \bar ""  % Permit first bar number to be printed
1813 % Print a bar number every 2nd bar
1814 \set Score.barNumberVisibility = #(every-nth-bar-number-visible 2)
1815 c1 c c c c
1816 \break
1817 c c c c c
1818 @end lilypond
1819
1820 The size of the bar number may be changed.  This is illustrated
1821 in the following example, which also shows how to enclose bar 
1822 numbers in boxes and circles, and shows an alternative way
1823 of specifying @code{#(#f #t #t)} for @code{break-visibility}.
1824
1825 @lilypond[verbatim,ragged-right,quote,fragment,relative]
1826 % Prevent bar numbers at the end of a line and permit them elsewhere
1827 \override Score.BarNumber #'break-visibility
1828   = #end-of-line-invisible
1829
1830 % Increase the size of the bar number by 2 
1831 \override Score.BarNumber #'font-size = #2
1832 \repeat unfold 3 { c1 } \bar "|"
1833
1834 % Draw a box round the following bar number(s)
1835 \override Score.BarNumber  #'stencil
1836   = #(make-stencil-boxer 0.1 0.25 ly:text-interface::print)
1837 \repeat unfold 3 { c1 } \bar "|"
1838
1839 % Draw a circle round the following bar number(s)
1840 \override Score.BarNumber  #'stencil
1841   = #(make-stencil-circler 0.1 0.25 ly:text-interface::print)
1842 \repeat unfold 4 { c1 } \bar "|."
1843 @end lilypond
1844
1845 @cindex Bar number alignment
1846
1847 Bar numbers by default are left-aligned to their parent object.
1848 This is usually the left edge of a line or, if numbers are printed
1849 within a line, the left bar line of the bar.  The numbers may also
1850 be positioned directly on the bar line or right-aligned to the 
1851 bar line:
1852
1853 @lilypond[verbatim,ragged-right,quote,fragment,relative]
1854 \set Score.currentBarNumber = #111
1855 \override Score.BarNumber #'break-visibility = ##(#t #t #t)
1856 % Increase the size of the bar number by 2
1857 \override Score.BarNumber #'font-size = #2
1858 % Print a bar number every 2nd bar
1859 \set Score.barNumberVisibility = #(every-nth-bar-number-visible 2)
1860 c1 c1
1861 % Centre-align bar numbers
1862 \override Score.BarNumber #'self-alignment-X = #0
1863 c1 c1
1864 % Right-align bar numbers
1865 \override Score.BarNumber #'self-alignment-X = #-1
1866 c1 c1
1867 @end lilypond
1868
1869 Bar numbers can be removed entirely by removing the Bar number
1870 engraver from the score context.
1871
1872 @lilypond[verbatim,ragged-right,quote]
1873 \layout {
1874   \context {
1875     \Score
1876     \remove "Bar_number_engraver"
1877   }
1878 }
1879 \relative c''{
1880   c4 c c c \break
1881   c4 c c c
1882 }
1883 @end lilypond
1884
1885
1886 @seealso
1887
1888 Snippets: @lsrdir{rhythms}
1889
1890 Internals Reference: @internalsref{BarNumber}.
1891
1892 Examples: @lsrdir{bar number}
1893
1894
1895 @refbugs
1896
1897 Bar numbers may collide with the top of the
1898 @internalsref{StaffGroup} bracket, if there is one.  To solve
1899 this, the @code{padding} property of @internalsref{BarNumber} can
1900 be used to position the number correctly.
1901
1902 Bar numbers may only be printed at bar lines; to print a bar
1903 number at the beginning of a piece, an empty bar line must be
1904 inserted there, and a value other than @code{1} must be placed
1905 in @code{currentBarNumber}:
1906
1907 @lilypond[verbatim,ragged-right,quote,fragment,relative]
1908 \set Score.currentBarNumber = #50
1909 \bar ""
1910 c1 c c c
1911 c1 c c c
1912 \break
1913 @end lilypond
1914
1915
1916
1917 @node Bar and bar number checks
1918 @unnumberedsubsubsec Bar and bar number checks
1919
1920 @cindex Bar check
1921 @funindex barCheckSynchronize
1922 @funindex |
1923
1924 Bar checks help detect errors in the entered durations.
1925 A bar check may be entered using the bar symbol, @code{|}, 
1926 at any place where a bar line is expected to fall.  
1927 If bar check lines are encountered at other places, 
1928 a list of warnings is printed in the log file,
1929 showing the line numbers and lines  
1930 in which the bar checks failed.  In the next
1931 example, the second bar check will signal an error
1932
1933 @example
1934 \time 3/4 c2 e4 | g2 |
1935 @end example
1936
1937 Bar checks can also be used in lyrics, for example
1938
1939 @example
1940 \lyricmode @{
1941   \time 2/4
1942   Twin -- kle | Twin -- kle |
1943 @}
1944 @end example
1945
1946 An incorrect duration can result in a completely garbled score,
1947 especially if the score is polyphonic, so a good place to start
1948 correcting input is by scanning for failed bar checks and
1949 incorrect durations.
1950
1951 @funindex |
1952 @funindex pipeSymbol
1953
1954 It is also possible to redefine the action taken when a bar check 
1955 or pipe symbol, @code{|}, is encountered in the input, so that 
1956 it does something other than a bar check.  This is done by 
1957 assigning a music expression to @code{pipeSymbol}.  
1958 In the following example @code{|} is set to insert a double bar 
1959 line wherever it appears in the input, rather than checking 
1960 for end of bar.
1961
1962 @lilypond[quote,ragged-right,verbatim]
1963 pipeSymbol = \bar "||"
1964
1965   c'2 c'2 |
1966   c'2 c'2
1967   c'2 | c'2
1968   c'2 c'2
1969 }
1970 @end lilypond
1971
1972 When copying large pieces of music, it can be helpful to check
1973 that the LilyPond bar number corresponds to the original that you
1974 are entering from.  This can be checked with
1975 @code{\barNumberCheck}, for example,
1976
1977 @verbatim
1978 \barNumberCheck #123
1979 @end verbatim
1980
1981 @noindent
1982 will print a warning if the @code{currentBarNumber} is not 123
1983 when it is processed.
1984
1985 @seealso
1986
1987 Snippets: @lsrdir{rhythms}
1988
1989
1990 @node Rehearsal marks
1991 @unnumberedsubsubsec Rehearsal marks
1992
1993 @cindex Rehearsal marks
1994 @funindex \mark
1995
1996 To print a rehearsal mark, use the @code{\mark} command
1997
1998 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
1999 c1 \mark \default
2000 c1 \mark \default
2001 c1 \mark #8
2002 c1 \mark \default
2003 c1 \mark \default
2004 @end lilypond
2005
2006 @noindent
2007 The letter@tie{}@q{I} is skipped in accordance with engraving
2008 traditions.  If you wish to include the letter @q{I}, then use
2009
2010 @example
2011 \set Score.markFormatter = #format-mark-alphabet
2012 @end example
2013
2014 The mark is incremented automatically if you use @code{\mark
2015 \default}, but you can also use an integer argument to set the
2016 mark manually.  The value to use is stored in the property
2017 @code{rehearsalMark}.
2018
2019 The style is defined by the property @code{markFormatter}.  It is
2020 a function taking the current mark (an integer) and the current
2021 context as argument.  It should return a markup object.  In the
2022 following example, @code{markFormatter} is set to a pre-defined
2023 procedure.  After a few measures, it is set to a procedure that
2024 produces a boxed number.
2025
2026 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
2027 \set Score.markFormatter = #format-mark-numbers
2028 c1 \mark \default
2029 c1 \mark \default
2030 \set Score.markFormatter = #format-mark-box-numbers
2031 c1 \mark \default
2032 c1 \mark \default
2033 c1
2034 @end lilypond
2035
2036 The file @file{scm/@/translation@/-functions@/.scm} contains the
2037 definitions of @code{format-mark-numbers} (the default format),
2038 @code{format-mark-box-numbers}, @code{format-mark-letters} and
2039 @code{format-mark-box-letters}.  These can be used as inspiration
2040 for other formatting functions.
2041
2042 You may use @code{format-mark-barnumbers},
2043 @code{format-mark-box-barnumbers}, and
2044 @code{format-mark-circle-barnumbers} to get bar numbers instead of
2045 incremented numbers or letters.
2046
2047 Other styles of rehearsal mark can be specified manually
2048
2049 @example
2050 \mark "A1"
2051 @end example
2052
2053 @noindent
2054 @code{Score.markFormatter} does not affect marks specified in this
2055 manner.  However, it is possible to apply a @code{\markup} to the
2056 string.
2057
2058 @example
2059 \mark \markup@{ \box A1 @}
2060 @end example
2061
2062 @cindex segno
2063 @cindex coda
2064 @cindex D.S al Fine
2065
2066 Music glyphs (such as the segno sign) may be printed inside a
2067 @code{\mark}
2068
2069 @lilypond[fragment,quote,ragged-right,verbatim,relative]
2070 c1 \mark \markup { \musicglyph #"scripts.segno" }
2071 c1 \mark \markup { \musicglyph #"scripts.coda" }
2072 c1 \mark \markup { \musicglyph #"scripts.ufermata" }
2073 c1
2074 @end lilypond
2075
2076 @noindent
2077 See @ref{The Feta font}, for a list of symbols which may be
2078 printed with @code{\musicglyph}.
2079
2080 For common tweaks to the positioning of rehearsal marks, see
2081 @ref{Text marks}.
2082
2083 @seealso
2084
2085 Snippets: @lsrdir{rhythms}
2086
2087 This manual: @ref{Text marks}.
2088
2089 Internals Reference: @internalsref{RehearsalMark}.
2090
2091 Init files: @file{scm/@/translation@/-functions@/.scm} contains
2092 the definition of @code{format-mark-numbers} and
2093 @code{format-mark-letters}.  They can be used as inspiration for
2094 other formatting functions.
2095
2096 Examples: @lsr{parts,rehearsal-mark-numbers.ly}
2097
2098
2099 @node Special rhythmic concerns
2100 @subsection Special rhythmic concerns
2101
2102
2103 @menu
2104 * Grace notes::                 
2105 * Aligning to cadenzas::        
2106 * Time administration::         
2107 @end menu
2108
2109 @node Grace notes
2110 @unnumberedsubsubsec Grace notes
2111
2112 @funindex \grace
2113 @cindex ornaments
2114 @cindex grace notes
2115 @cindex appoggiatura
2116 @cindex acciaccatura
2117
2118 Grace notes are ornaments that are written out. They are made with
2119 the @code{\grace} command.  By prefixing this keyword to a music
2120 expression, a new one is formed, which will be printed in a
2121 smaller font and takes up no logical time in a measure.
2122
2123 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
2124 c4 \grace c16 c4
2125 \grace { c16[ d16] } c2 c4
2126 @end lilypond
2127
2128 Two special forms of the @code{\grace} command exist.
2129 An @emph{acciaccatura}, which should be played as very short,
2130 is denoted by a slurred small note with a slashed stem.  The
2131 @emph{appoggiatura}, a grace note that takes a fixed fraction of the
2132 main note, is denoted as a slurred note in small print without
2133 a slash.  They are entered with the commands @code{\acciaccatura}
2134 and @code{\appoggiatura}, as demonstrated in the following
2135 example:
2136
2137 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
2138 b4 \acciaccatura d8 c4 
2139 \appoggiatura e8 d4
2140 \acciaccatura { g16[ f] } e4
2141 @end lilypond
2142
2143 @noindent
2144 @code{\acciaccatura} and @code{\appoggiatura} start a slur, 
2145 @code{\grace} does not.
2146
2147 The placement of grace notes is synchronized between different
2148 staves.  In the following example, there are two sixteenth grace
2149 notes for every eighth grace note
2150
2151 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
2152 << \new Staff { e4 \grace { c16[ d e f] } e4 }
2153    \new Staff { c4 \grace { g8[ b] } c4 } >>
2154 @end lilypond
2155
2156 @funindex \afterGrace
2157
2158 If you want to end a note with a grace, use the @code{\afterGrace}
2159 command.  It takes two arguments: the main note, and the grace
2160 notes following the main note.
2161
2162 @lilypond[ragged-right, verbatim,relative=2,fragment]
2163 c1 \afterGrace d1 { c16[ d] } c4
2164 @end lilypond
2165
2166 This will put the grace notes after a @q{space} lasting 3/4 of the
2167 length of the main note.  The fraction 3/4 can be changed by
2168 setting @code{afterGraceFraction}, ie.
2169
2170 @example
2171 #(define afterGraceFraction (cons 7 8))
2172 @end example
2173
2174 @noindent
2175 will put the grace note at 7/8 of the main note.
2176
2177 The same effect can be achieved manually by doing
2178
2179 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
2180 \new Voice {
2181   << { d1^\trill_( }
2182      { s2 \grace { c16[ d] } } >>
2183   c4)
2184 }
2185 @end lilypond
2186
2187 @noindent
2188 By adjusting the duration of the skip note (here it is a
2189 half-note), the space between the main-note and the grace
2190 may be adjusted.
2191
2192 A @code{\grace} music expression will introduce special
2193 typesetting settings, for example, to produce smaller type, and
2194 set directions.  Hence, when introducing layout tweaks, they
2195 should be inside the grace expression, for example,
2196
2197 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
2198 \new Voice {
2199   \acciaccatura {
2200     \stemDown
2201     f16->
2202     \stemNeutral
2203   }
2204   g4
2205 }
2206 @end lilypond
2207
2208 @noindent
2209 The overrides should also be reverted inside the grace expression.
2210
2211 The layout of grace expressions can be changed throughout the
2212 music using the function @code{add-grace-property}.  The following
2213 example undefines the @code{Stem} direction for this grace, so
2214 that stems do not always point up.
2215
2216 @example
2217 \new Staff @{
2218   #(add-grace-property 'Voice 'Stem 'direction '())
2219   @dots{}
2220 @}
2221 @end example
2222
2223 @noindent
2224 Another option is to change the variables @code{startGraceMusic},
2225 @code{stopGraceMusic}, @code{startAcciaccaturaMusic},
2226 @code{stopAcciaccaturaMusic}, @code{startAppoggiaturaMusic},
2227 @code{stopAppoggiaturaMusic}.  The default values of these can be
2228 seen in the file @file{ly/@/grace@/-init@/.ly}.  By redefining
2229 them other effects may be obtained.
2230
2231 @noindent
2232 The slash through the stem in @emph{acciaccatura}s can be obtained in
2233 other situations by @code{\override Stem  #'stroke-style =
2234 #"grace"}.
2235
2236
2237 @commonprop
2238
2239 Grace notes may be forced to use align with regular notes
2240 in other staves by setting @code{strict-grace-spacing} to
2241 ##t:
2242
2243 @lilypond[relative=2,ragged-right]
2244 <<
2245   \override Score.SpacingSpanner #'strict-grace-spacing = ##t
2246   \new Staff {
2247      c'4
2248      \afterGrace
2249      c'4
2250      { c'16[ c'8 c'16] }
2251      c'4
2252   }  
2253   \new Staff {
2254      c'16[ c'16 c'16 c'16]
2255      c'16[ c'16 c'16 c'16]
2256      c'4
2257   }
2258 >>
2259 @end lilypond
2260
2261
2262 @seealso
2263
2264 Snippets: @lsrdir{rhythms}
2265
2266 Internals Reference: @internalsref{GraceMusic}.
2267
2268
2269 @refbugs
2270
2271 A multi-note beamed @emph{acciaccatura} is printed without a slash, 
2272 and looks exactly the same as a multi-note beamed
2273 @emph{appoggiatura}.
2274 @c TODO Add link to LSR snippet to add slash when available 
2275
2276 Grace note synchronization can also lead to surprises.  Staff
2277 notation, such as key signatures, bar lines, etc., are also
2278 synchronized.  Take care when you mix staves with grace notes and
2279 staves without, for example,
2280
2281 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
2282 << \new Staff { e4 \bar "|:" \grace c16 d4 }
2283    \new Staff { c4 \bar "|:" d4 } >>
2284 @end lilypond
2285
2286 @noindent
2287 This can be remedied by inserting grace skips of the corresponding
2288 durations in the other staves.  For the above example
2289
2290 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
2291 << \new Staff { e4 \bar "|:" \grace c16 d4 }
2292    \new Staff { c4 \bar "|:" \grace s16 d4 } >>
2293 @end lilypond
2294
2295 Grace sections should only be used within sequential music
2296 expressions.  Nesting or juxtaposing grace sections is not
2297 supported, and might produce crashes or other errors.
2298
2299 @node Aligning to cadenzas
2300 @unnumberedsubsubsec Aligning to cadenzas
2301
2302 In an orchestral context, cadenzas present a special problem: when
2303 constructing a score that includes a cadenza, all other
2304 instruments should skip just as many notes as the length of the
2305 cadenza, otherwise they will start too soon or too late.
2306
2307 A solution to this problem are the functions
2308 @code{mmrest-of-length} and @code{skip-of-length}.  These Scheme
2309 functions take a piece of music as argument, and generate a
2310 multi-rest or @code{\skip}, exactly as long as the piece.  The use
2311 of @code{mmrest-of-length} is demonstrated in the following
2312 example.
2313
2314 @lilypond[verbatim,ragged-right,quote]
2315 cadenza = \relative c' {
2316   c4 d8 << { e f g } \\ { d4. } >>
2317   g4 f2 g4 g
2318 }
2319
2320 \new GrandStaff <<
2321   \new Staff { \cadenza c'4 }
2322   \new Staff {
2323     #(ly:export (mmrest-of-length cadenza))
2324     c'4
2325   }
2326 >>
2327 @end lilypond
2328
2329 @seealso
2330
2331 Snippets: @lsrdir{rhythms}
2332
2333
2334 @node Time administration
2335 @unnumberedsubsubsec Time administration
2336
2337 @cindex Time administration
2338
2339 @funindex currentBarNumber
2340 @funindex measurePosition
2341 @funindex measureLength
2342
2343 Time is administered by the @code{Timing_translator}, which by
2344 default is to be found in the @code{Score} context.  An alias,
2345 @code{Timing}, is added to the context in which the
2346 @code{Timing_translator} is placed.
2347
2348 The following properties of @code{Timing} are used
2349 to keep track of timing within the score.
2350  
2351 @table @code
2352 @item currentBarNumber
2353 The current measure number.  For an example showing the
2354 use of this property see @ref{Bar numbers}.
2355
2356 @item measureLength
2357 The length of the measures in the current time signature.  For a
2358 4/4 time this is@tie{}1, and for 6/8 it is 3/4.  Its value
2359 determines when bar lines are inserted and how automatic beams
2360 should be generated.
2361
2362 @item measurePosition
2363 The point within the measure where we currently are.  This
2364 quantity is reset by subtracting @code{measureLength} whenever
2365 @code{measureLength} is reached or exceeded.  When that happens, 
2366 @code{currentBarNumber} is incremented.
2367
2368 @item timing
2369 If set to true, the above variables are updated for every time
2370 step.  When set to false, the engraver stays in the current
2371 measure indefinitely.
2372
2373 @end table
2374
2375 Timing can be changed by setting any of these variables
2376 explicitly.  In the next example, the default 4/4 time 
2377 signature is printed, but @code{measureLength} is set to 5/4.
2378 At 4/8 through the third measure, the @code{measurePosition} is
2379 advanced by 1/8 to 5/8, shortening that bar by 1/8.
2380 The next bar line then falls at 9/8 rather than 5/4.
2381
2382 @lilypond[quote,ragged-right,verbatim,relative,fragment]
2383 \set Score.measureLength = #(ly:make-moment 5 4)
2384 c1 c4
2385 c1 c4
2386 c4 c4
2387 \set Score.measurePosition = #(ly:make-moment 5 8)
2388 b4 b4 b8
2389 c4 c1
2390 @end lilypond
2391
2392 @noindent
2393 As the example illustrates, @code{ly:make-moment n m} constructs a
2394 duration of n/m of a whole note.  For example,
2395 @code{ly:make-moment 1 8} is an eighth note duration and
2396 @code{ly:make-moment 7 16} is the duration of seven sixteenths
2397 notes.
2398
2399
2400 @seealso
2401
2402 This manual: @ref{Bar numbers}, @ref{Unmetered music}
2403
2404 Snippets: @lsrdir{rhythms}
2405
2406 Internals Reference: @internalsref{Timing_translator},
2407 @internalsref{Score}
2408
2409
2410