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