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