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