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