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