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