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