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