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