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