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