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