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