]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/rhythms.itely
adcba92fb1e93b69a93f47e19818def3bd9d63eb
[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 This section discusses rhythms, durations, and bars.
13
14 @menu
15 * Writing rhythms::             
16 * Writing rests::               
17 * Displaying rhythms::          
18 * Beams::                       
19 * Bars::                        
20 * Special rhythmic concerns::   
21 @end menu
22
23
24 @node Writing rhythms
25 @subsection Writing rhythms
26
27 @menu
28 * Durations::                   
29 * Augmentation dots::           
30 * Tuplets::                     
31 * Scaling durations::           
32 @end menu
33
34 @node Durations
35 @unnumberedsubsubsec Durations
36
37 @cindex duration
38 @funindex \longa
39 @funindex \breve
40 @funindex \maxima
41
42 In Note, Chord, and Lyrics mode, durations are designated by
43 numbers and dots: durations are entered as their reciprocal
44 values.  For example, a quarter note is entered using a @code{4}
45 (since it is a 1/4 note), while a half note is entered using a
46 @code{2} (since it is a 1/2 note).  For notes longer than a whole
47 you must use the @code{\longa} and @code{\breve} commands
48
49 @example
50 c'\breve
51 c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64
52 r\longa r\breve
53 r1 r2 r4 r8 r16 r32 r64 r64
54 @end example
55
56 @lilypond[quote]
57 \score {
58 \relative c'' {
59     a\breve*1/2 \autoBeamOff
60     a1 a2 a4 a8 a16 a32 a64 a64
61    \bar "empty"
62    \break
63     r\longa*1/4 r\breve *1/2
64     r1 r2 r4 r8 r16 r32 r64 r64
65   }
66   \layout {
67     ragged-right = ##t
68     indent=0\mm
69     \context {
70       \Score
71         \remove "Bar_number_engraver"
72     }
73     \context {
74       \Staff
75         \remove "Clef_engraver"
76         \override StaffSymbol #'transparent = ##t
77         \override TimeSignature #'transparent = ##t
78         \override BarLine #'transparent = ##t
79         \consists "Pitch_squash_engraver"
80     }
81   }
82 }
83 @end lilypond
84
85 If the duration is omitted then it is set to the previously
86 entered duration.  The default for the first note is a quarter
87 note.
88
89 @lilypond[quote,ragged-right,verbatim,fragment]
90 { a a a2 a a4 a a1 a }
91 @end lilypond
92
93
94 @node Augmentation dots
95 @unnumberedsubsubsec Augmentation dots
96
97 @funindex .
98
99 To obtain dotted note lengths, simply add a dot (@samp{.}) to the
100 number.  Double-dotted notes are produced in a similar way.
101
102 @lilypond[quote,ragged-right,fragment,verbatim]
103 a'4 b' c''4. b'8 a'4. b'4.. c''8.
104 @end lilypond
105
106 @refcommands
107
108 Dots are normally moved up to avoid staff lines, except in
109 polyphonic situations.  The following commands may be used to
110 force a particular direction manually
111
112 @funindex \dotsUp
113 @code{\dotsUp},
114 @funindex \dotsDown
115 @code{\dotsDown},
116 @funindex \dotsNeutral
117 @code{\dotsNeutral}.
118
119 @seealso
120
121 Program reference: @internalsref{Dots}, and
122 @internalsref{DotColumn}.
123
124
125 @node Tuplets
126 @unnumberedsubsubsec Tuplets
127
128 @cindex tuplets
129 @cindex triplets
130 @funindex \times
131
132 Tuplets are made out of a music expression by multiplying all
133 durations with a fraction
134
135 @example
136 \times @var{fraction} @var{musicexpr}
137 @end example
138
139 @noindent
140 The duration of @var{musicexpr} will be multiplied by the
141 fraction.  The fraction's denominator will be printed over the
142 notes, optionally with a bracket.  The most common tuplet is the
143 triplet in which 3 notes have the length of 2, so the notes are
144 2/3 of their written length
145
146 @lilypond[quote,ragged-right,fragment,verbatim]
147 g'4 \times 2/3 {c'4 c' c'} d'4 d'4
148 @end lilypond
149
150 Tuplets may be nested, for example,
151
152 @lilypond[fragment,ragged-right,verbatim,relative=2]
153 \override TupletNumber #'text = #tuplet-number::calc-fraction-text
154 \times 4/6 {
155   a4 a
156   \times 3/5 { a a a a a }
157 }
158 @end lilypond
159
160 @refcommands
161
162 @funindex \tupletUp
163 @code{\tupletUp},
164 @funindex \tupletDown
165 @code{\tupletDown},
166 @funindex \tupletNeutral
167 @code{\tupletNeutral}.
168
169
170 @commonprop
171
172 @funindex tupletNumberFormatFunction
173 @cindex tuplet formatting
174
175 The property @code{tupletSpannerDuration} specifies how long each
176 bracket should last.  With this, you can make lots of tuplets
177 while typing @code{\times} only once, thus saving lots of typing.
178 In the next example, there are two triplets shown, while
179 @code{\times} was only used once
180
181 @lilypond[quote,fragment,relative=2,ragged-right,verbatim]
182 \set tupletSpannerDuration = #(ly:make-moment 1 4)
183 \times 2/3 { c8 c c c c c }
184 @end lilypond
185
186 @noindent
187 For more information about @code{make-moment}, see
188 @ref{Time administration}.
189
190 The format of the number is determined by the property @code{text}
191 in @code{TupletNumber}.  The default prints only the denominator,
192 but if it is set to the function
193 @code{tuplet-number::calc-fraction-text}, @var{num}:@var{den} will
194 be printed instead.
195
196 To avoid printing tuplet numbers, use
197
198 @lilypond[quote,fragment,relative=2,ragged-right,verbatim]
199 \times 2/3 { c8 c c } \times 2/3 { c8 c c }
200 \override TupletNumber #'transparent = ##t
201 \times 2/3 { c8 c c } \times 2/3 { c8 c c }
202 @end lilypond
203
204 Use the @code{\tweak} function to override nested tuplets
205 beginning at the same music moment.  In this example,
206 @code{\tweak} specifies fraction text for the outer
207 @code{TupletNumber} and denominator text for the
208 @code{TupletNumber} of the first of the three inner tuplets.
209
210 @lilypond[quote,ragged-right,verbatim]
211 \new Staff {
212   \tweak #'text #tuplet-number::calc-fraction-text
213   \times 4/3 {
214      \tweak #'text #tuplet-number::calc-denominator-text
215      \times 2/3 { c'8[ c'8 c'8] }
216      \times 2/3 { c'8[ c'8 c'8] }
217      \times 2/3 { c'8[ c'8 c'8] }
218   }
219 }
220 @end lilypond
221
222 Here @code{\tweak} and @code{\override} work together to specify
223 @code{TupletBracket} direction.  The first @code{\tweak} positions
224 the @code{TupletBracket} of the outer tuplet above the staff.  The
225 second @code{\tweak} positions the @code{TupletBracket} of the
226 first of the three inner tuplets below the staff.  Note that this
227 pair of @code{\tweak} functions affects only the outer tuplet and
228 the first of the three inner tuplets because only those two
229 tuplets begin at the same music moment.  We use @code{\override}
230 in the usual way to position the @code{TupletBrackets} of the
231 second and third of the inner tuplets below the staff.
232
233 @lilypond[quote,ragged-right,verbatim]
234 \new Staff {
235   \tweak #'text #tuplet-number::calc-fraction-text
236   \tweak #'direction #up
237   \times 4/3 {
238      \tweak #'direction #down
239      \times 2/3 { c'8[ c'8 c'8] }
240      \override TupletBracket #'direction = #down
241      \times 2/3 { c'8[ c'8 c'8] }
242      \times 2/3 { c'8[ c'8 c'8] }
243   }
244 }
245 @end lilypond
246
247 Tuplet brackets can be made to run to prefatory matter or the next
248 note
249
250 @lilypond[ragged-right]
251 \new RhythmicStaff {
252   \set tupletFullLength = ##t
253   \time 4/4
254   \times 4/5 {
255     c4 c1
256   }
257   \set tupletFullLengthNote = ##t
258   \time 2/4
259   \times 2/3 {
260     c4 c c 
261   }
262   \time 3/4
263   c4 
264 }
265 @end lilypond
266
267
268 @seealso
269
270 Program reference: @internalsref{TupletBracket},
271 @internalsref{TupletNumber}, and @internalsref{TimeScaledMusic}.
272
273
274
275 @node Scaling durations
276 @unnumberedsubsubsec Scaling durations
277
278 You can alter the length of duration by a fraction @var{N/M}
279 appending @samp{*@var{N/M}} (or @samp{*@var{N}} if @var{M=1}).
280 This will not affect the appearance of the notes or rests
281 produced.  These may be combined such as @samp{*M*N}.
282
283 In the following example, the first three notes take up exactly
284 two beats, but no triplet bracket is printed.
285
286 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
287 \time 2/4
288 a4*2/3 gis4*2/3 a4*2/3
289 a4 a4 a4*2
290 b16*4 c4
291 @end lilypond
292
293
294 @seealso
295
296 This manual: @ref{Tuplets}.
297
298
299 @node Writing rests
300 @subsection Writing rests
301
302 @menu
303 * Rests::                       
304 * Skips::                       
305 * Multi measure rests::         
306 @end menu
307
308 @node Rests
309 @unnumberedsubsubsec Rests
310 @cindex Rests
311
312 @funindex \rest
313 @funindex r
314
315 Rests are entered like notes with the note name @code{r}
316
317 @lilypond[fragment,quote,ragged-right,verbatim]
318 r1 r2 r4 r8
319 @end lilypond
320
321 Whole bar rests, centered in middle of the bar, must be done with
322 multi-measure rests.  They can be used for a single bar as well as
323 many bars, and are discussed in @ref{Multi measure rests}.
324
325 To explicitly specify a rest's vertical position, write a note
326 followed by @code{\rest}.  A rest will be placed in the position
327 where the note would appear,
328
329 @lilypond[fragment,quote,ragged-right,verbatim]
330 a'4\rest d'4\rest
331 @end lilypond
332
333 @noindent
334 This makes manual formatting of polyphonic music much easier,
335 since the automatic rest collision formatter will leave these
336 rests alone.
337
338 @seealso
339
340 Program reference: @internalsref{Rest}.
341
342
343 @node Skips
344 @unnumberedsubsubsec Skips
345
346 @cindex Skip
347 @cindex Invisible rest
348 @cindex Space note
349 @funindex \skip
350 @funindex s
351
352 An invisible rest (also called a @q{skip}) can be entered like a
353 note with note name @samp{s} or with @code{\skip @var{duration}}
354
355 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
356 a4 a4 s4 a4 \skip 1 a4
357 @end lilypond
358
359 The @code{s} syntax is only available in note mode and chord mode.
360 In other situations, for example, when entering lyrics, you should
361 use the @code{\skip} command
362
363 @lilypond[quote,ragged-right,verbatim]
364 <<
365   \relative { a'2 a2 }
366   \new Lyrics \lyricmode { \skip 2 bla2 }
367 >>
368 @end lilypond
369
370 The skip command is merely an empty musical placeholder.  It does
371 not produce any output, not even transparent output.
372
373 The @code{s} skip command does create @internalsref{Staff} and
374 @internalsref{Voice} when necessary, similar to note and rest
375 commands.  For example, the following results in an empty staff.
376
377 @lilypond[quote,ragged-right,verbatim]
378 { s4 }
379 @end lilypond
380
381 The fragment @code{@{ \skip 4 @} } would produce an empty page.
382
383 @seealso
384
385 Program reference: @internalsref{SkipMusic}.
386
387
388 @node Multi measure rests
389 @unnumberedsubsubsec Multi measure rests
390
391 @cindex multi measure rests
392 @cindex full measure rests
393 @cindex Rests, multi measure
394 @cindex Rests, full measure
395 @cindex whole rests for a full measure
396 @funindex R
397
398 Rests for one full measure (or many bars) are entered using
399 @samp{R}.  It is specifically meant for full bar rests and for
400 entering parts: the rest can expand to fill a score with rests, or
401 it can be printed as a single multi-measure rest.  This expansion
402 is controlled by the property @code{Score.skipBars}.  If this is
403 set to true, empty measures will not be expanded, and the
404 appropriate number is added automatically
405
406 @lilypond[quote,ragged-right,fragment,verbatim]
407 \time 4/4 r1 | R1 | R1*2 \time 3/4 R2. \time 2/4 R2 \time 4/4
408 \set Score.skipBars = ##t R1*17 R1*4
409 @end lilypond
410
411 The @code{1} in @code{R1} is similar to the duration notation used
412 for notes.  Hence, for time signatures other than 4/4, you must
413 enter other durations.  This can be done with augmentation dots or
414 fractions
415
416 @lilypond[quote,ragged-right,fragment,verbatim]
417 \set Score.skipBars = ##t
418 \time 3/4
419 R2. | R2.*2
420 \time 13/8
421 R1*13/8
422 R1*13/8*12 |
423 \time 10/8 R4*5*4 |
424 @end lilypond
425
426 An @code{R} spanning a single measure is printed as either a whole
427 rest or a breve, centered in the measure regardless of the time
428 signature.
429
430 If there are only a few measures of rest, LilyPond prints
431 @q{church rests} (a series of rectangles) in the staff.  To
432 replace that with a simple rest, use
433 @code{MultiMeasureRest.expand-limit}.
434
435 @lilypond[quote,ragged-right,fragment,verbatim]
436 \set Score.skipBars = ##t
437 R1*2 | R1*5 | R1*9
438 \override MultiMeasureRest #'expand-limit = 1
439 R1*2 | R1*5 | R1*9
440 @end lilypond
441
442 @cindex text on multi-measure rest
443 @cindex script on multi-measure rest
444 @cindex fermata on multi-measure rest
445
446 Texts can be added to multi-measure rests by using the
447 @var{note}-@code{markup} syntax @ref{Text markup}.  A variable
448 (@code{\fermataMarkup}) is provided for adding fermatas
449
450 @lilypond[quote,ragged-right,verbatim,fragment]
451 \set Score.skipBars = ##t
452 \time 3/4
453 R2.*10^\markup { \italic "ad lib." }
454 R2.^\fermataMarkup
455 @end lilypond
456
457 Warning!  This text is created by @code{MultiMeasureRestText}, not
458 @code{TextScript}.
459
460 @lilypond[quote,ragged-right,verbatim,fragment]
461 \override TextScript #'padding = #5
462 R1^"low"
463 \override MultiMeasureRestText #'padding = #5
464 R1^"high"
465 @end lilypond
466
467 If you want to have text on the left end of a multi-measure rest,
468 attach the text to a zero-length skip note, i.e.,
469
470 @example
471 s1*0^"Allegro"
472 R1*4
473 @end example
474
475
476 @seealso
477
478 Program reference: @internalsref{MultiMeasureRestMusicGroup},
479 @internalsref{MultiMeasureRest}.
480
481 The layout object @internalsref{MultiMeasureRestNumber} is for the
482 default number, and @internalsref{MultiMeasureRestText} for user
483 specified texts.
484
485
486 @refbugs
487
488 It is not possible to use fingerings (e.g., @code{R1-4}) to put
489 numbers over multi-measure rests.  And the pitch of multi-measure
490 rests (or staff-centered rests) can not be influenced.
491
492 @cindex condensing rests
493
494 There is no way to automatically condense multiple rests into a
495 single multi-measure rest.  Multi-measure rests do not take part
496 in rest collisions.
497
498 Be careful when entering multi-measure rests followed by whole
499 notes.  The following will enter two notes lasting four measures
500 each
501
502 @example
503 R1*4 cis cis
504 @end example
505
506 When @code{skipBars} is
507 set, the result will look OK, but the bar numbering will be off.
508
509
510
511 @node Displaying rhythms
512 @subsection Displaying rhythms
513
514 @menu
515 * Time signature::              
516 * Upbeats::                     
517 * Unmetered music::             
518 * Polymetric notation::         
519 * Automatic note splitting::    
520 @end menu
521
522 @node Time signature
523 @unnumberedsubsubsec Time signature
524
525 @cindex Time signature
526 @cindex meter
527 @funindex \time
528
529 Time signature indicates the metrum of a piece: a regular pattern
530 of strong and weak beats.  It is denoted by a fraction at the
531 start of the staff.
532
533 The time signature is set with the @code{\time} command
534
535 @lilypond[quote,ragged-right,fragment,verbatim]
536 \time 2/4 c'2 \time 3/4 c'2.
537 @end lilypond
538
539 @commonprop
540
541 The symbol that is printed can be customized with the @code{style}
542 property.  Setting it to @code{#'()} uses fraction style for 4/4
543 and 2/2 time,
544
545 @lilypond[fragment,quote,ragged-right,verbatim]
546 \time 4/4 c'1
547 \time 2/2 c'1
548 \override Staff.TimeSignature #'style = #'()
549 \time 4/4 c'1
550 \time 2/2 c'1
551 @end lilypond
552
553 There are many more options for its layout.  See @ref{Ancient time
554 signatures}, for more examples.
555
556 @code{\time} sets the property @code{timeSignatureFraction},
557 @code{beatLength} and @code{measureLength} in the @code{Timing}
558 context, which is normally aliased to @internalsref{Score}.  The
559 property @code{measureLength} determines where bar lines should be
560 inserted, and how automatic beams should be generated.  Changing
561 the value of @code{timeSignatureFraction} also causes the symbol
562 to be printed.
563
564 More options are available through the Scheme function
565 @code{set-time-signature}.  In combination with the
566 @internalsref{Measure_grouping_engraver}, it will create
567 @internalsref{MeasureGrouping} signs.  Such signs ease reading
568 rhythmically complex modern music.  In the following example, the
569 9/8 measure is subdivided in 2, 2, 2 and 3.  This is passed to
570 @code{set-time-signature} as the third argument @code{(2 2 2 3)}
571
572 @lilypond[quote,ragged-right,verbatim]
573 \score {
574   \relative c'' {
575     #(set-time-signature 9 8 '(2 2 2 3))
576     g8[ g] d[ d] g[ g] a8[( bes g]) |
577     #(set-time-signature 5 8 '(3 2))
578     a4. g4
579   }
580   \layout {
581     \context {
582       \Staff
583       \consists "Measure_grouping_engraver"
584     }
585   }
586 }
587 @end lilypond
588
589
590 @seealso
591
592 Program reference: @internalsref{TimeSignature}, and
593 @internalsref{Timing_translator}.
594
595 Examples: @lsr{contemporary,compound-time-signature.ly}.
596
597
598 @refbugs
599
600 Automatic beaming does not use the measure grouping specified with
601 @code{set-time-signature}.
602
603
604 @node Upbeats
605 @unnumberedsubsubsec Upbeats
606
607 @cindex anacrusis
608 @cindex upbeat
609 @cindex partial measure
610 @cindex measure, partial
611 @cindex shorten measures
612 @funindex \partial
613
614 Partial measures, such as an anacrusis or upbeat, are entered using the
615
616 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
617 \partial 16*5 c16 cis d dis e | a2. c,4 | b2
618 @end lilypond
619
620 The syntax for this command is
621
622 @example
623 \partial @var{duration}
624 @end example
625
626 where @code{duration} is the rhythmic length to be added before
627 the next bar.
628
629 This is internally translated into
630
631 @example
632 \set Timing.measurePosition = -@var{length of duration}
633 @end example
634
635 The property @code{measurePosition} contains a rational number
636 indicating how much of the measure has passed at this point.  Note
637 that this is a negative number; @code{\partial 4} is internally
638 translated to mean @qq{there is a quarter note left in the bar.}
639
640
641 @refbugs
642
643 This command does not take into account grace notes at the start
644 of the music.  When a piece starts with graces notes in the
645 pickup, then the @code{\partial} should follow the grace notes
646
647 @lilypond[verbatim,quote,ragged-right,relative,fragment]
648 \grace f16
649 \partial 4
650 g4
651 a2 g2
652 @end lilypond
653
654 @code{\partial} is only intended to be used at the beginning of a
655 piece.  If you use it after the beginning, some odd warnings may
656 occur.
657
658
659 @node Unmetered music
660 @unnumberedsubsubsec Unmetered music
661
662 @cindex cadenza
663 @funindex \cadenzaOn
664 @funindex \cadenzaOff
665
666 Bar lines and bar numbers are calculated automatically.  For
667 unmetered music (cadenzas, for example), this is not desirable.
668 To turn off automatic bar lines and bar numbers, use the commands
669 @code{\cadenzaOn} and @code{\cadenzaOff}.
670
671 @lilypond[verbatim,quote,ragged-right,relative=2,fragment]
672 c4 d e d
673 \cadenzaOn
674 c4 c d8 d d f4 g4.
675 \cadenzaOff
676 \bar "|"
677 d4 e d c
678 @end lilypond
679
680
681 @refbugs
682
683 LilyPond will only insert line breaks and page breaks at a
684 barline.  Unless the unmetered music ends before the end of the
685 staff line, you will need to insert invisible bar lines
686
687 @example
688 \bar ""
689 @end example
690
691 @noindent
692 to indicate where breaks can occur.
693
694
695 @node Polymetric notation
696 @unnumberedsubsubsec Polymetric notation
697
698 @cindex double time signatures
699 @cindex signatures, polymetric
700 @cindex polymetric signatures
701 @cindex meter, polymetric
702
703 Double time signatures are not supported explicitly, but they can
704 be faked.  In the next example, the markup for the time signature
705 is created with a markup text.  This markup text is inserted in
706 the @internalsref{TimeSignature} grob. See also
707 @lsr{contemporary,compound-time-signature}.
708
709 @lilypond[verbatim,ragged-right]
710 % create 2/4 + 5/8
711 tsMarkup =\markup {
712   \override #'(baseline-skip . 2) \number {
713     \column { "2" "4" }
714     \vcenter "+"
715     \bracket \column { "5" "8" }
716   }
717 }
718
719 {
720   \override Staff.TimeSignature #'stencil = #ly:text-interface::print
721   \override Staff.TimeSignature #'text = #tsMarkup
722   \time 3/2
723   c'2 \bar ":" c'4 c'4.
724 }
725 @end lilypond
726
727 Each staff can also have its own time signature.  This is done by
728 moving the @internalsref{Timing_translator} to the
729 @internalsref{Staff} context.
730
731 @example
732 \layout @{
733   \context @{ \Score
734      \remove "Timing_translator"
735      \remove "Default_bar_line_engraver"
736   @}
737   \context @{
738     \Staff
739     \consists "Timing_translator"
740     \consists "Default_bar_line_engraver"
741   @}
742
743 @}
744 @end example
745
746
747 Now, each staff has its own time signature.
748
749 @example
750 <<
751   \new Staff @{
752     \time 3/4
753     c4 c c | c c c |
754   @}
755   \new Staff @{
756     \time 2/4
757     c4 c | c c | c c
758   @}
759   \new Staff @{
760     \time 3/8
761     c4. c8 c c c4. c8 c c
762   @}
763 >>
764 @end example
765
766 @lilypond[quote,ragged-right]
767 \layout{
768   \context{
769      \Score
770      \remove "Timing_translator"
771      \remove "Default_bar_line_engraver"
772     }
773   \context{ \Staff
774     \consists "Timing_translator"
775     \consists "Default_bar_line_engraver"
776   }
777 }
778
779 \relative c' <<
780   \new Staff {
781     \time 3/4
782     c4 c c | c c c |
783   }
784   \new Staff {
785     \time 2/4
786     c4 c | c c | c c
787   }
788   \new Staff {
789     \time 3/8
790     c4. c8 c c c4. c8 c c
791   }
792 >>
793 @end lilypond
794
795
796 A different form of polymetric notation is where note lengths have
797 different values across staves.
798
799 This notation can be created by setting a common time signature
800 for each staff but replacing it manually using
801 @code{timeSignatureFraction} to the desired fraction.  Then the
802 printed durations in each staff are scaled to the common time
803 signature.  The latter is done with @code{\compressMusic}, which
804 is used similar to @code{\times}, but does not create a tuplet
805 bracket. The syntax is @example \compressMusic #'(@var{numerator}
806 . @var{denominator}) @var{musicexpr} @end example
807
808
809
810 In this example, music with the time signatures of 3/4, 9/8, and
811 10/8 are used in parallel.  In the second staff, shown durations
812 are multiplied by 2/3, so that 2/3 * 9/8 = 3/4, and in the third
813 staff, shown durations are multiplied by 3/5, so that 3/5 * 10/8 =
814 3/4.
815
816 @lilypond[quote,ragged-right,verbatim,fragment]
817 \relative c' { <<
818   \new Staff {
819     \time 3/4
820     c4 c c | c c c |
821   }
822   \new Staff {
823     \time 3/4
824     \set Staff.timeSignatureFraction = #'(9 . 8)
825     \compressMusic #'(2 . 3)
826       \repeat unfold 6 { c8[ c c] }
827   }
828   \new Staff {
829     \time 3/4
830     \set Staff.timeSignatureFraction = #'(10 . 8)
831     \compressMusic #'(3 . 5) {
832       \repeat unfold 2 { c8[ c c] }
833       \repeat unfold 2 { c8[ c] }
834       | c4. c4. \times 2/3 { c8 c c } c4
835     }
836   }
837 >> }
838 @end lilypond
839
840
841 @refbugs
842
843 When using different time signatures in parallel, the spacing is
844 aligned vertically, but bar lines distort the regular spacing.
845
846
847 @node Automatic note splitting
848 @unnumberedsubsubsec Automatic note splitting
849
850 Long notes can be converted automatically to tied notes.  This is
851 done by replacing the @internalsref{Note_heads_engraver} by the
852 @internalsref{Completion_heads_engraver}.  In the following
853 examples, notes crossing the bar line are split and tied.
854
855 @lilypond[quote,fragment,verbatim,relative=1,line-width=12\cm]
856 \new Voice \with {
857   \remove "Note_heads_engraver"
858   \consists "Completion_heads_engraver"
859 } {
860   c2. c8 d4 e f g a b c8 c2 b4 a g16 f4 e d c8. c2
861 }
862 @end lilypond
863
864 This engraver splits all running notes at the bar line, and
865 inserts ties.  One of its uses is to debug complex scores: if the
866 measures are not entirely filled, then the ties exactly show how
867 much each measure is off.
868
869 If you want to allow line breaking on the bar lines where
870 @internalsref{Completion_heads_engraver} splits notes, you must
871 also remove @internalsref{Forbid_line_break_engraver}.
872
873
874 @refbugs
875
876 Not all durations (especially those containing tuplets) can be
877 represented exactly with normal notes and dots, but the engraver
878 will not insert tuplets.
879
880 @code{Completion_heads_engraver} only affects notes; it does not
881 split rests.
882
883
884 @seealso
885
886 Program reference: @internalsref{Completion_heads_engraver}.
887
888
889
890
891 @node Beams
892 @subsection Beams
893
894 @menu
895 * Automatic beams::             
896 * Manual beams::                
897 * Feathered beams::             
898 @end menu
899
900 @node Automatic beams
901 @unnumberedsubsubsec Automatic beams
902
903 LilyPond inserts beams automatically
904
905 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
906 \time 2/4 c8 c c c \time 6/8 c c c c8. c16 c8
907 @end lilypond
908
909 When these automatic decisions are not good enough, beaming can be
910 entered explicitly.  It is also possible to define beaming
911 patterns that differ from the defaults.  See @ref{Setting
912 automatic beam behavior}, for details.
913
914 Individual notes may be marked with @code{\noBeam} to prevent them
915 from being beamed
916
917 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
918 \time 2/4 c8 c\noBeam c c
919 @end lilypond
920
921
922 @seealso
923
924 Program reference: @internalsref{Beam}.
925
926
927 @node Manual beams
928 @unnumberedsubsubsec Manual beams
929
930 @cindex beams, manual
931 @funindex ]
932 @funindex [
933
934 In some cases it may be necessary to override the automatic
935 beaming algorithm.  For example, the autobeamer will not put beams
936 over rests or bar lines.  Such beams are specified manually by
937 marking the begin and end point with @code{[} and @code{]}
938
939 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
940 {
941   r4 r8[ g' a r8] r8 g[ | a] r8
942 }
943 @end lilypond
944
945
946 @commonprop
947
948 @funindex stemLeftBeamCount
949 @funindex stemRightBeamCount
950
951
952 LilyPond can automatically determine beaming patterns within a
953 beam, but this automatic behavior can sometimes produce odd
954 results; therefore the @code{stemLeftBeamCount} and
955 @code{stemRightBeamCount} properties can be used to override the
956 defaults.  If either property is set, its value will be used only
957 once, and then it is erased.
958
959 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
960 {
961    f8[ r16
962       f g a]
963    f8[ r16
964    \set stemLeftBeamCount = #1
965       f g a]
966 }
967 @end lilypond
968
969 The property @code{subdivideBeams} can be set in order to
970 subdivide all 16th or shorter beams at beat positions, as defined
971 by the @code{beatLength} property.
972
973 @lilypond[fragment,quote,relative=2,verbatim]
974 c16[ c c c c c c c]
975 \set subdivideBeams = ##t
976 c16[ c c c c c c c]
977 \set Score.beatLength = #(ly:make-moment 1 8)
978 c16[ c c c c c c c]
979 @end lilypond
980 @funindex subdivideBeams
981
982 @noindent
983 For more information about @code{make-moment}, see
984 @ref{Time administration}.
985
986 Line breaks are normally forbidden when beams cross bar lines.
987 This behavior can be changed by setting @code{breakable}.
988
989 @funindex breakable
990
991 @cindex beams and line breaks
992 @cindex beams, kneed
993 @cindex kneed beams
994 @cindex auto-knee-gap
995
996 Kneed beams are inserted automatically when a large gap is
997 detected between the note heads.  This behavior can be tuned
998 through the @code{auto-knee-gap} object.
999
1000
1001 @refbugs
1002
1003 Automatically kneed cross-staff beams cannot be used together with
1004 hidden staves.  See @ref{Hiding staves}.
1005
1006 @c Is this still true with skyline spacing stuff? -J.Mandereau
1007 Beams do not avoid collisions with symbols around the notes, such
1008 as texts and accidentals.
1009
1010
1011 @node Feathered beams
1012 @unnumberedsubsubsec Feathered beams
1013
1014 Feathered beams are printed by setting the @code{grow-direction}
1015 property of a @code{Beam}.  The @code{\featherDurations} function
1016 can be used to adjust note durations.
1017
1018 @lilypond[ragged-right,relative=1,fragment,verbatim,quote]
1019 \override Beam #'grow-direction = #LEFT
1020 \featherDurations #(ly:make-moment 5 4) 
1021 {
1022   c16[ c c c c c c]
1023 }
1024 @end lilypond
1025
1026 @refbugs
1027
1028 The @code{\featherDurations} command only works with very short
1029 music snippets.
1030
1031
1032 @node Bars
1033 @subsection Bars
1034
1035
1036 @menu
1037 * Bar check::                   
1038 * Bar lines::                   
1039 * Bar numbers::                 
1040 * Barnumber check::             
1041 * Rehearsal marks::             
1042 @end menu
1043
1044 @node Bar check
1045 @unnumberedsubsubsec Bar check
1046
1047 @cindex Bar check
1048 @funindex barCheckSynchronize
1049 @funindex |
1050
1051 Bar checks help detect errors in the durations.  A bar check is
1052 entered using the bar symbol, @samp{|}.  Whenever it is
1053 encountered during interpretation, it should fall on a measure
1054 boundary.  If it does not, a warning is printed.  In the next
1055 example, the second bar check will signal an error
1056
1057 @example
1058 \time 3/4 c2 e4 | g2 |
1059 @end example
1060
1061 Bar checks can also be used in lyrics, for example
1062
1063 @example
1064 \lyricmode @{
1065   \time 2/4
1066   Twin -- kle | Twin -- kle
1067 @}
1068 @end example
1069
1070 Failed bar checks are caused by entering incorrect durations.
1071 Incorrect durations often completely garble up the score,
1072 especially if the score is polyphonic, so a good place to start
1073 correcting input is by scanning for failed bar checks and
1074 incorrect durations.
1075
1076 @funindex |
1077 @funindex pipeSymbol
1078
1079 It is also possible to redefine the meaning of @code{|}.  This is
1080 done by assigning a music expression to @code{pipeSymbol},
1081
1082 @lilypond[quote,ragged-right,verbatim]
1083 pipeSymbol = \bar "||"
1084
1085 { c'2 c' | c'2 c' }
1086 @end lilypond
1087
1088
1089 @node Bar lines
1090 @unnumberedsubsubsec Bar lines
1091
1092 @cindex Bar lines
1093 @funindex \bar
1094 @cindex measure lines
1095 @cindex repeat bars
1096
1097 Bar lines delimit measures, but are also used to indicate repeats.
1098 Normally they are inserted automatically.  Line breaks may only
1099 happen on bar lines.
1100
1101 Special types of bar lines can be forced with the @code{\bar} command
1102
1103 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1104 c4 \bar "|:" c4
1105 @end lilypond
1106
1107 The following bar types are available
1108
1109 @lilypondfile[ragged-right,quote]{bar-lines.ly}
1110
1111 In addition, you can specify @code{"||:"}, which is equivalent to
1112 @code{"|:"} except at line breaks, where it gives a double bar
1113 line at the end of the line and a start repeat at the beginning of
1114 the next line. 
1115
1116 To allow a line break where there is no visible bar line, use
1117
1118 @example
1119 \bar ""
1120 @end example
1121
1122 @noindent
1123 This will insert an invisible bar line and allow line breaks at
1124 this point (without increasing the bar number counter).
1125
1126 In scores with many staves, a @code{\bar} command in one staff is
1127 automatically applied to all staves.  The resulting bar lines are
1128 connected between different staves of a @code{StaffGroup},
1129 @code{PianoStaff}, or @code{GrandStaff}.
1130
1131 @lilypond[quote,ragged-right,fragment,verbatim]
1132 <<
1133   \new StaffGroup <<
1134     \new Staff {
1135       e'4 d'
1136       \bar "||"
1137       f' e'
1138     }
1139     \new Staff { \clef bass c4 g e g }
1140   >>
1141   \new Staff { \clef bass c2 c2 }
1142 >>
1143 @end lilypond
1144
1145
1146 @commonprop
1147
1148 @funindex whichBar
1149 @funindex repeatCommands
1150 @funindex defaultBarType
1151
1152 The command @code{\bar }@var{bartype} is a short cut for doing
1153 @code{\set Timing.whichBar = }@var{bartype}.  Whenever
1154 @code{whichBar} is set to a string, a bar line of that type is
1155 created.
1156
1157 A bar line is created whenever the @code{whichBar} property is
1158 set.  At the start of a measure it is set to the contents of
1159 @code{Timing.defaultBarType}.  The contents of
1160 @code{repeatCommands} are used to override default measure bars.
1161
1162 You are encouraged to use @code{\repeat} for repetitions.  See
1163 @ref{Repeats}.
1164
1165
1166 @seealso
1167
1168 In this manual: @ref{Repeats}, @ref{System start delimiters}.
1169
1170 Program reference: @internalsref{BarLine} (created at
1171 @internalsref{Staff} level), @internalsref{SpanBar} (across
1172 staves).
1173
1174
1175 @node Bar numbers
1176 @unnumberedsubsubsec Bar numbers
1177
1178 @cindex Bar numbers
1179 @cindex measure numbers
1180 @funindex currentBarNumber
1181
1182 Bar numbers are printed by default at the start of the line.  The
1183 number itself is stored in the @code{currentBarNumber} property,
1184 which is normally updated automatically for every measure.
1185
1186 @lilypond[verbatim,ragged-right,quote,fragment,relative]
1187 \repeat unfold 4 {c4 c c c} \break
1188 \set Score.currentBarNumber = #50
1189 \repeat unfold 4 {c4 c c c}
1190 @end lilypond
1191
1192 Bar numbers may only be printed at bar lines; to print a bar
1193 number at the beginning of a piece, an empty bar line must be
1194 added
1195
1196 @lilypond[verbatim,ragged-right,quote,fragment,relative]
1197 \set Score.currentBarNumber = #50
1198 \bar ""
1199 \repeat unfold 4 {c4 c c c} \break
1200 \repeat unfold 4 {c4 c c c}
1201 @end lilypond
1202
1203 Bar numbers can be typeset at regular intervals instead of at the
1204 beginning of each line.  This is illustrated in the following
1205 example, whose source is available as
1206 @lsr{staff,making-bar-numbers-appear-at-regular-intervals.ly}.
1207
1208 @lilypondfile[ragged-right,quote]{bar-number-regular-interval.ly}
1209
1210 Bar numbers can be removed entirely by removing the Bar number
1211 engraver from the score.
1212
1213 @lilypond[verbatim,ragged-right,quote]
1214 \layout {
1215   \context {
1216     \Score
1217     \remove "Bar_number_engraver"
1218   }
1219 }
1220 \relative c''{
1221 c4 c c c \break
1222 c4 c c c
1223 }
1224 @end lilypond
1225
1226
1227 @seealso
1228
1229 Program reference: @internalsref{BarNumber}.
1230
1231 Examples: @lsrdir{staff}
1232
1233
1234 @refbugs
1235
1236 Bar numbers can collide with the @internalsref{StaffGroup}
1237 bracket, if there is one at the top.  To solve this, the
1238 @code{padding} property of @internalsref{BarNumber} can be used to
1239 position the number correctly.
1240
1241
1242 @node Barnumber check
1243 @unnumberedsubsubsec Barnumber check
1244
1245 When copying large pieces of music, it can be helpful to check
1246 that the LilyPond bar number corresponds to the original that you
1247 are entering from.  This can be checked with
1248 @code{\barNumberCheck}, for example,
1249
1250 @verbatim
1251 \barNumberCheck #123
1252 @end verbatim
1253
1254 @noindent
1255 will print a warning if the @code{currentBarNumber} is not 123
1256 when it is processed.
1257
1258
1259 @node Rehearsal marks
1260 @unnumberedsubsubsec Rehearsal marks
1261
1262 @cindex Rehearsal marks
1263 @funindex \mark
1264
1265 To print a rehearsal mark, use the @code{\mark} command
1266
1267 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
1268 c1 \mark \default
1269 c1 \mark \default
1270 c1 \mark #8
1271 c1 \mark \default
1272 c1 \mark \default
1273 @end lilypond
1274
1275 @noindent
1276 The letter@tie{}@q{I} is skipped in accordance with engraving
1277 traditions.  If you wish to include the letter @q{I}, then use
1278
1279 @example
1280 \set Score.markFormatter = #format-mark-alphabet
1281 @end example
1282
1283 The mark is incremented automatically if you use @code{\mark
1284 \default}, but you can also use an integer argument to set the
1285 mark manually.  The value to use is stored in the property
1286 @code{rehearsalMark}.
1287
1288 The style is defined by the property @code{markFormatter}.  It is
1289 a function taking the current mark (an integer) and the current
1290 context as argument.  It should return a markup object.  In the
1291 following example, @code{markFormatter} is set to a canned
1292 procedure.  After a few measures, it is set to function that
1293 produces a boxed number.
1294
1295 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
1296 \set Score.markFormatter = #format-mark-numbers
1297 c1 \mark \default
1298 c1 \mark \default
1299 \set Score.markFormatter = #format-mark-box-numbers
1300 c1 \mark \default
1301 c1 \mark \default
1302 c1
1303 @end lilypond
1304
1305 The file @file{scm/@/translation@/-functions@/.scm} contains the
1306 definitions of @code{format-mark-numbers} (the default format),
1307 @code{format-mark-box-numbers}, @code{format-mark-letters} and
1308 @code{format-mark-box-letters}.  These can be used as inspiration
1309 for other formatting functions.
1310
1311 You may use @code{format-mark-barnumbers},
1312 @code{format-mark-box-barnumbers}, and
1313 @code{format-mark-circle-barnumbers} to get bar numbers instead of
1314 incremented numbers or letters.
1315
1316 Other styles of rehearsal mark can be specified manually
1317
1318 @example
1319 \mark "A1"
1320 @end example
1321
1322 @noindent
1323 @code{Score.markFormatter} does not affect marks specified in this
1324 manner.  However, it is possible to apply a @code{\markup} to the
1325 string.
1326
1327 @example
1328 \mark \markup@{ \box A1 @}
1329 @end example
1330
1331 @cindex segno
1332 @cindex coda
1333 @cindex D.S al Fine
1334
1335 Music glyphs (such as the segno sign) may be printed inside a
1336 @code{\mark}
1337
1338 @lilypond[fragment,quote,ragged-right,verbatim,relative]
1339 c1 \mark \markup { \musicglyph #"scripts.segno" }
1340 c1 \mark \markup { \musicglyph #"scripts.coda" }
1341 c1 \mark \markup { \musicglyph #"scripts.ufermata" }
1342 c1
1343 @end lilypond
1344
1345 @noindent
1346 See @ref{The Feta font}, for a list of symbols which may be
1347 printed with @code{\musicglyph}.
1348
1349 For common tweaks to the positioning of rehearsal marks, see
1350 @ref{Text marks}.
1351
1352 @seealso
1353
1354 This manual: @ref{Text marks}.
1355
1356 Program reference: @internalsref{RehearsalMark}.
1357
1358 Init files: @file{scm/@/translation@/-functions@/.scm} contains
1359 the definition of @code{format-mark-numbers} and
1360 @code{format-mark-letters}.  They can be used as inspiration for
1361 other formatting functions.
1362
1363 Examples: @lsr{parts,rehearsal-mark-numbers.ly}
1364
1365
1366 @node Special rhythmic concerns
1367 @subsection Special rhythmic concerns
1368
1369
1370 @menu
1371 * Grace notes::                 
1372 * Aligning to cadenzas::        
1373 * Time administration::         
1374 * Proportional notation (introduction)::  
1375 @end menu
1376
1377 @node Grace notes
1378 @unnumberedsubsubsec Grace notes
1379
1380 @funindex \grace
1381 @cindex ornaments
1382 @cindex grace notes
1383 @cindex appoggiatura
1384 @cindex acciaccatura
1385
1386 Grace notes are ornaments that are written out.  The most common
1387 ones are acciaccatura, which should be played as very short.  It
1388 is denoted by a slurred small note with a slashed stem.  The
1389 appoggiatura is a grace note that takes a fixed fraction of the
1390 main note, and is denoted as a slurred note in small print without
1391 a slash.  They are entered with the commands @code{\acciaccatura}
1392 and @code{\appoggiatura}, as demonstrated in the following example
1393
1394 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
1395 b4 \acciaccatura d8 c4 \appoggiatura e8 d4
1396 \acciaccatura { g16[ f] } e4
1397 @end lilypond
1398
1399 Both are special forms of the @code{\grace} command.  By prefixing
1400 this keyword to a music expression, a new one is formed, which
1401 will be printed in a smaller font and takes up no logical time in
1402 a measure.
1403
1404 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
1405 c4 \grace c16 c4
1406 \grace { c16[ d16] } c2 c4
1407 @end lilypond
1408
1409 @noindent
1410 Unlike @code{\acciaccatura} and @code{\appoggiatura}, the
1411 @code{\grace} command does not start a slur.
1412
1413 @cindex timing, internal
1414
1415 Internally, timing for grace notes is done using a second,
1416 @q{grace} timing.  Every point in time consists of two rational
1417 numbers: one denotes the logical time, one denotes the grace
1418 timing.  The above example is shown here with timing tuples
1419
1420 @lilypond[quote,ragged-right]
1421 <<
1422   \relative c''{
1423     c4 \grace c16 c4 \grace {
1424     c16[ d16] } c2 c4
1425   }
1426   \new Lyrics \lyricmode {
1427     \override LyricText #'font-family = #'typewriter
1428
1429     \markup { (0,0) } 4
1430     \grace { \markup {
1431       ( \fraction 1 4 , \fraction -1 16 ) } 16 }
1432     \markup { (\fraction 1 4 , 0 ) } 4
1433     \grace {
1434       \markup { (\fraction 2 4 , \fraction "-1" 8 ) } 16
1435       \markup { (\fraction 2 4 , \fraction "-1" 16 ) } 16
1436     }
1437     \markup { ( \fraction 2 4 , 0 ) }
1438   }
1439 >>
1440 @end lilypond
1441
1442 The placement of grace notes is synchronized between different
1443 staves.  In the following example, there are two sixteenth grace
1444 notes for every eighth grace note
1445
1446 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
1447 << \new Staff { e4 \grace { c16[ d e f] } e4 }
1448    \new Staff { c4 \grace { g8[ b] } c4 } >>
1449 @end lilypond
1450
1451 @funindex \afterGrace
1452
1453 If you want to end a note with a grace, use the @code{\afterGrace}
1454 command.  It takes two arguments: the main note, and the grace
1455 notes following the main note.
1456
1457 @lilypond[ragged-right, verbatim,relative=2,fragment]
1458 c1 \afterGrace d1 { c16[ d] } c4
1459 @end lilypond
1460
1461 This will put the grace notes after a @q{space} lasting 3/4 of the
1462 length of the main note.  The fraction 3/4 can be changed by
1463 setting @code{afterGraceFraction}, ie.
1464
1465 @example
1466 #(define afterGraceFraction (cons 7 8))
1467 @end example
1468
1469 @noindent
1470 will put the grace note at 7/8 of the main note.
1471
1472 The same effect can be achieved manually by doing
1473
1474 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
1475 \new Voice {
1476   << { d1^\trill_( }
1477      { s2 \grace { c16[ d] } } >>
1478   c4)
1479 }
1480 @end lilypond
1481
1482 @noindent
1483 By adjusting the duration of the skip note (here it is a
1484 half-note), the space between the main-note and the grace is
1485 adjusted.
1486
1487 A @code{\grace} music expression will introduce special
1488 typesetting settings, for example, to produce smaller type, and
1489 set directions.  Hence, when introducing layout tweaks, they
1490 should be inside the grace expression, for example,
1491
1492 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
1493 \new Voice {
1494   \acciaccatura {
1495     \stemDown
1496     f16->
1497     \stemNeutral
1498   }
1499   g4
1500 }
1501 @end lilypond
1502
1503 @noindent
1504 The overrides should also be reverted inside the grace expression.
1505
1506 The layout of grace expressions can be changed throughout the
1507 music using the function @code{add-grace-property}.  The following
1508 example undefines the @code{Stem} direction for this grace, so
1509 that stems do not always point up.
1510
1511 @example
1512 \new Staff @{
1513   #(add-grace-property 'Voice 'Stem 'direction '())
1514   @dots{}
1515 @}
1516 @end example
1517
1518 @noindent
1519 Another option is to change the variables @code{startGraceMusic},
1520 @code{stopGraceMusic}, @code{startAcciaccaturaMusic},
1521 @code{stopAcciaccaturaMusic}, @code{startAppoggiaturaMusic},
1522 @code{stopAppoggiaturaMusic}.  More information is in the file
1523 @file{ly/@/grace@/-init@/.ly}.
1524
1525 @noindent
1526 The slash through the stem in acciaccaturas can be obtained in
1527 other situations by @code{\override Stem  #'stroke-style =
1528 #"grace"}.
1529
1530
1531 @commonprop
1532
1533 Grace notes may be forced to use floating spacing,
1534
1535 @lilypond[relative=2,ragged-right]
1536 <<
1537   \override Score.SpacingSpanner #'strict-grace-spacing = ##t
1538   \new Staff {
1539      c'4
1540      \afterGrace
1541      c'4
1542      { c'16[ c'8 c'16] }
1543      c'4
1544   }  
1545   \new Staff {
1546      c'16[ c'16 c'16 c'16]
1547      c'16[ c'16 c'16 c'16]
1548      c'4
1549   }
1550 >>
1551 @end lilypond
1552
1553
1554 @seealso
1555
1556 Program reference: @internalsref{GraceMusic}.
1557
1558
1559 @refbugs
1560
1561 A score that starts with a @code{\grace} expression needs an
1562 explicit @code{\new Voice} declaration, otherwise the main note
1563 and the grace note end up on different staves.
1564
1565 Grace note synchronization can also lead to surprises.  Staff
1566 notation, such as key signatures, bar lines, etc., are also
1567 synchronized.  Take care when you mix staves with grace notes and
1568 staves without, for example,
1569
1570 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
1571 << \new Staff { e4 \bar "|:" \grace c16 d4 }
1572    \new Staff { c4 \bar "|:" d4 } >>
1573 @end lilypond
1574
1575 @noindent
1576 This can be remedied by inserting grace skips of the corresponding
1577 durations in the other staves. For the above example
1578
1579 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
1580 << \new Staff { e4 \bar "|:" \grace c16 d4 }
1581    \new Staff { c4 \bar "|:" \grace s16 d4 } >>
1582 @end lilypond
1583
1584 Grace sections should only be used within sequential music
1585 expressions.  Nesting or juxtaposing grace sections is not
1586 supported, and might produce crashes or other errors.
1587
1588
1589 @node Aligning to cadenzas
1590 @unnumberedsubsubsec Aligning to cadenzas
1591
1592 In an orchestral context, cadenzas present a special problem: when
1593 constructing a score that includes a cadenza, all other
1594 instruments should skip just as many notes as the length of the
1595 cadenza, otherwise they will start too soon or too late.
1596
1597 A solution to this problem are the functions
1598 @code{mmrest-of-length} and @code{skip-of-length}.  These Scheme
1599 functions take a piece of music as argument, and generate a
1600 @code{\skip} or multi-rest, exactly as long as the piece.  The use
1601 of @code{mmrest-of-length} is demonstrated in the following
1602 example.
1603
1604 @lilypond[verbatim,ragged-right,quote]
1605 cadenza = \relative c' {
1606   c4 d8 << { e f g } \\ { d4. } >>
1607   g4 f2 g4 g
1608 }
1609
1610 \new GrandStaff <<
1611   \new Staff { \cadenza c'4 }
1612   \new Staff {
1613     #(ly:export (mmrest-of-length cadenza))
1614     c'4
1615   }
1616 >>
1617 @end lilypond
1618
1619
1620 @node Time administration
1621 @unnumberedsubsubsec Time administration
1622
1623 @cindex Time administration
1624
1625 Time is administered by the
1626 @internalsref{Time_signature_engraver}, which usually lives in the
1627 @internalsref{Score} context.  The bookkeeping deals with the
1628 following variables
1629
1630 @table @code
1631 @item currentBarNumber
1632 The measure number.
1633
1634 @item measureLength
1635 The length of the measures in the current time signature.  For a
1636 4/4 time this is@tie{}1, and for 6/8 it is 3/4.
1637
1638 @item measurePosition
1639 The point within the measure where we currently are.  This
1640 quantity is reset to@tie{}0 whenever it exceeds
1641 @code{measureLength}.  When that happens, @code{currentBarNumber}
1642 is incremented.
1643
1644 @item timing
1645 If set to true, the above variables are updated for every time
1646 step.  When set to false, the engraver stays in the current
1647 measure indefinitely.
1648
1649 @end table
1650
1651 Timing can be changed by setting any of these variables
1652 explicitly.  In the next example, the 4/4 time signature is
1653 printed, but @code{measureLength} is set to 5/4.  After a while,
1654 the measure is shortened by 1/8, by setting @code{measurePosition}
1655 to 7/8 at 2/4 in the measure, so the next bar line will fall at
1656 2/4 + 3/8.  The 3/8 arises because 5/4 normally has 10/8, but we
1657 have manually set the measure position to be 7/8 and 10/8 - 7/8 =
1658 3/8.
1659
1660 @lilypond[quote,ragged-right,verbatim,relative,fragment]
1661 \set Score.measureLength = #(ly:make-moment 5 4)
1662 c1 c4
1663 c1 c4
1664 c4 c4
1665 \set Score.measurePosition = #(ly:make-moment 7 8)
1666 b8 b b
1667 c4 c1
1668 @end lilypond
1669
1670 @noindent
1671 As the example illustrates, @code{ly:make-moment n m} constructs a
1672 duration of n/m of a whole note.  For example,
1673 @code{ly:make-moment 1 8} is an eighth note duration and
1674 @code{ly:make-moment 7 16} is the duration of seven sixteenths
1675 notes.
1676
1677
1678 @node Proportional notation (introduction)
1679 @unnumberedsubsubsec Proportional notation (introduction)
1680 @cindex Proportional notation
1681
1682 See @ref{Proportional notation}.
1683
1684
1685 TODO: remove all this stuff?
1686
1687 Notes can be spaced proportionally to their time-difference by
1688 assigning a duration to @code{proportionalNotationDuration}
1689
1690 @lilypond[quote,ragged-right,verbatim,relative=2,fragment]
1691 <<
1692   \set Score.proportionalNotationDuration = #(ly:make-moment 1 16)
1693   \new Staff { c8[ c c c c c]  c4 c2 r2 }
1694   \new Staff { c2  \times 2/3 { c8 c c } c4 c1 }
1695 >>
1696 @end lilypond
1697
1698 Setting this property only affects the ideal spacing between
1699 consecutive notes.  For true proportional notation, the following
1700 settings are also required.
1701
1702 @itemize @bullet
1703
1704 @item True proportional notation requires that symbols are allowed
1705 to overstrike each other.  That is achieved by removing the
1706 @internalsref{Separating_line_group_engraver} from
1707 @internalsref{Staff} context.
1708
1709 @item Spacing influence of  prefatory matter (clefs, bar lines,
1710 etc.) is removed by setting the @code{strict-note-spacing}
1711 property to @code{#t} in @internalsref{SpacingSpanner} grob.
1712
1713 @item Optical spacing tweaks are switched by setting
1714 @code{uniform-stretching} in @internalsref{SpacingSpanner} to
1715 true.
1716
1717 @end itemize
1718
1719 @seealso
1720
1721 Examples: @lsr{spacing,proportional@/-spacing@/.ly}, 
1722 @lsr{spacing,proportional@/-strict@/-grace@/-notes@/.ly}, and
1723 @lsr{spacing,proportional@/-strict@/-notespacing@/.ly}
1724
1725 An example of strict proportional notation is in the
1726 example file @file{input/proportional.ly}.
1727
1728