]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/notation/rhythms.itely
35a85e9214116edd67c00ea7489058c059e07c69
[lilypond.git] / Documentation / notation / 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.  For details, see the Contributors'
7     Guide, node Updating translation committishes..
8 @end ignore
9
10 @c \version "2.19.40"
11
12 @node Rhythms
13 @section Rhythms
14
15 @lilypondfile[quote]{rhythms-headword.ly}
16
17 This section discusses rhythms, rests, durations, beaming and bars.
18
19 @menu
20 * Writing rhythms::
21 * Writing rests::
22 * Displaying rhythms::
23 * Beams::
24 * Bars::
25 * Special rhythmic concerns::
26 @end menu
27
28
29 @node Writing rhythms
30 @subsection Writing rhythms
31
32 @menu
33 * Durations::
34 * Tuplets::
35 * Scaling durations::
36 * Ties::
37 @end menu
38
39 @node Durations
40 @unnumberedsubsubsec Durations
41
42 @cindex durations, of notes
43 @cindex note durations
44 @cindex length of notes
45 @cindex note lengths
46
47 @funindex \longa
48 @funindex \breve
49 @funindex \maxima
50
51 Durations are designated by numbers and dots.  Durations are entered
52 as their reciprocal values.  For example, a quarter note is entered
53 using a @code{4} (since it is a 1/4 note), and a half note is entered
54 using a @code{2} (since it is a 1/2 note).  For notes longer than a
55 whole you must use the @code{\longa} (a double breve) and
56 @code{\breve} commands.  Durations as short as 128th notes may be
57 specified.  Shorter values are possible, but only as beamed notes.
58
59 @c Two 64th notes are needed to obtain beams
60 @lilypond[quote,verbatim]
61 \relative {
62   \time 8/1
63   c''\longa c\breve c1 c2
64   c4 c8 c16 c32 c64 c128 c128
65 }
66 @end lilypond
67
68 Here are the same durations with automatic beaming turned off.
69
70 @c not strictly "writing rhythms"; more of a "displaying" thing,
71 @c but it's ok here.  -gp
72 @lilypond[quote,verbatim]
73 \relative {
74   \time 8/1
75   \autoBeamOff
76   c''\longa c\breve c1 c2
77   c4 c8 c16 c32 c64 c128 c128
78 }
79 @end lilypond
80
81 A note with the duration of a quadruple breve may be entered with
82 @code{\maxima}, but this is supported only within ancient music
83 notation.  For details, see @ref{Ancient notation}.
84
85 @cindex duration, default
86 @cindex default note duration
87 @cindex note duration, default
88
89 If the duration is omitted, it is set to the previously
90 entered duration.  The default for the first note is a quarter
91 note.
92
93 @lilypond[quote,verbatim]
94 \relative { a' a a2 a a4 a a1 a }
95 @end lilypond
96
97 Durations occuring on their own within a music sequence will take
98 their pitches from the preceding note or chord.
99
100 @lilypond[quote,verbatim]
101 \relative {
102   \time 8/1
103   c'' \longa \breve 1 2
104   4 8 16 32 64 128 128
105 }
106 @end lilypond
107
108 @cindex notes, dotted
109 @cindex dotted notes
110 @cindex notes, double-dotted
111 @cindex double-dotted notes
112
113 @funindex .
114
115 To obtain dotted note lengths, place a dot (@code{.}) after the
116 duration.  Double-dotted notes are specified by appending two
117 dots, and so on.
118
119 @lilypond[quote,verbatim]
120 \relative { a'4 b c4. b8 a4. b4.. c8. }
121 @end lilypond
122
123 Some durations cannot be represented with just binary durations
124 and dots; they can be represented only by tying two or more
125 notes together.  For details, see @ref{Ties}.
126
127 For ways of specifying durations for the syllables of lyrics and
128 ways of aligning lyrics to notes, see @ref{Vocal music}.
129
130 Optionally, notes can be spaced strictly proportionately to their
131 duration.  For details of this and other settings which control
132 proportional notation, see @ref{Proportional notation}.
133
134 @funindex \dotsUp
135 @funindex \dotsDown
136 @funindex \dotsNeutral
137
138 Dots are normally moved up to avoid staff lines, except in
139 polyphonic situations.  Dots may be manually placed above or below
140 the staff; see @ref{Direction and placement}.
141
142
143 @predefined
144 @code{\autoBeamOn},
145 @code{\autoBeamOff},
146 @code{\dotsUp},
147 @code{\dotsDown},
148 @code{\dotsNeutral}.
149 @endpredefined
150
151
152 @snippets
153
154 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
155 {alternative-breve-notes.ly}
156
157 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
158 {changing-the-number-of-augmentation-dots-per-note.ly}
159
160 @seealso
161 Music Glossary:
162 @rglos{breve},
163 @rglos{longa},
164 @rglos{maxima},
165 @rglos{note value},
166 @rglos{Duration names notes and rests}.
167
168 Notation Reference:
169 @ref{Automatic beams},
170 @ref{Ties},
171 @ref{Stems},
172 @ref{Writing rhythms},
173 @ref{Writing rests},
174 @ref{Vocal music},
175 @ref{Ancient notation},
176 @ref{Proportional notation}.
177
178 Snippets:
179 @rlsr{Rhythms}.
180
181 Internals Reference:
182 @rinternals{Dots},
183 @rinternals{DotColumn}.
184
185 @knownissues
186 @c Deliberately duplicated in Durations and Rests.  -gp
187 There is no fundamental limit to rest durations (both in terms of
188 longest and shortest), but the number of glyphs is limited:
189 rests from 128th to maxima (8× whole) may be printed.
190
191
192 @node Tuplets
193 @unnumberedsubsubsec Tuplets
194
195 @cindex tuplets
196 @cindex triplets
197
198 @funindex \tuplet
199
200 Tuplets are made from a music expression with the @code{\tuplet}
201 command, multiplying the speed of the music expression by a fraction:
202
203 @example
204 \tuplet @var{fraction} @{ @var{music} @}
205 @end example
206
207 @noindent
208 The fraction's numerator will be printed over or under the notes,
209 optionally with a bracket.  The most common tuplets are triplets
210 (3@tie{}notes sound within the duration normally allowed for@tie{}2).
211
212 @lilypond[quote,verbatim]
213 \relative {
214   a'2 \tuplet 3/2 { b4 4 4 }
215   c4 c \tuplet 3/2 { b4 a g }
216 }
217 @end lilypond
218
219 @cindex tuplet grouping
220 @noindent
221 When entering long passages of tuplets, having to write a separate
222 @code{\tuplet} command for each group is inconvenient.  It is possible
223 to specify the duration of one tuplet group directly before the music
224 in order to have the tuplets grouped automatically:
225
226 @lilypond[quote,verbatim]
227 \relative {
228   g'2 r8 \tuplet 3/2 8 { cis16 d e e f g g f e }
229 }
230 @end lilypond
231
232 @cindex tuplet bracket placement
233
234 @funindex \tupletUp
235 @funindex \tupletDown
236 @funindex \tupletNeutral
237
238 Tuplet brackets may be manually placed above or below the staff:
239
240 @lilypond[quote,verbatim]
241 \relative {
242   \tupletUp \tuplet 3/2 { c''8 d e }
243   \tupletNeutral \tuplet 3/2 { c8 d e }
244   \tupletDown \tuplet 3/2 { f,8 g a }
245   \tupletNeutral \tuplet 3/2 { f8 g a }
246 }
247 @end lilypond
248
249 Tuplets may be nested:
250
251 @lilypond[quote,verbatim]
252 \relative {
253   \autoBeamOff
254   c''4 \tuplet 5/4 { f8 e f \tuplet 3/2 { e[ f g] } } f4
255 }
256 @end lilypond
257
258 Modifying nested tuplets which begin at the same musical moment must be
259 done with @code{\tweak}.
260
261 To modify the duration of notes without printing a tuplet bracket, see
262 @ref{Scaling durations}.
263
264 @predefined
265 @code{\tupletUp},
266 @code{\tupletDown},
267 @code{\tupletNeutral}.
268 @endpredefined
269
270
271 @snippets
272
273 @cindex tuplet formatting
274 @cindex triplet formatting
275
276 @funindex tupletNumberFormatFunction
277 @funindex tupletSpannerDuration
278
279 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
280 {entering-several-tuplets-using-only-one--tuplet-command.ly}
281
282 @cindex Tuplet number changes
283
284 @funindex TupletNumber
285
286 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
287 {changing-the-tuplet-number.ly}
288
289 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
290 {non-default-tuplet-numbers.ly}
291
292 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
293 {controlling-tuplet-bracket-visibility.ly}
294
295 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
296 {permitting-line-breaks-within-beamed-tuplets.ly}
297
298 @seealso
299 Music Glossary:
300 @rglos{triplet},
301 @rglos{tuplet},
302 @rglos{polymetric}.
303
304 Learning Manual:
305 @rlearning{Tweaking methods}.
306
307 Notation Reference:
308 @ref{Direction and placement},
309 @ref{Time administration},
310 @ref{Scaling durations},
311 @ref{The tweak command},
312 @ref{Polymetric notation}.
313
314 Snippets:
315 @rlsr{Rhythms}.
316
317 Internals Reference:
318 @rinternals{TupletBracket},
319 @rinternals{TupletNumber},
320 @rinternals{TimeScaledMusic}.
321
322
323 @node Scaling durations
324 @unnumberedsubsubsec Scaling durations
325
326 @cindex scaling durations
327 @cindex durations, scaling
328
329 The duration of single notes, rests or chords may be multiplied by a
330 fraction @code{N/M} by appending @code{*N/M} (or @code{*N} if @code{M}
331 is 1) to the duration.  This will not affect the appearance of the
332 notes or rests produced, but the altered duration will be used in
333 calculating the position within the measure and setting the duration
334 in the MIDI output.  Multiplying factors may be combined like
335 @code{*L*M/N}.  Factors are part of the duration: if a duration is
336 not specified for subsequent notes, the default duration taken from
337 the preceding note will include any scaling factor.
338
339 In the following example, the first three notes take up exactly
340 two beats, but no triplet bracket is printed.
341
342 @lilypond[quote,verbatim]
343 \relative {
344   \time 2/4
345   % Alter durations to triplets
346   a'4*2/3 gis a
347   % Normal durations
348   a4 a
349   % Double the duration of chord
350   <a d>4*2
351   % Duration of quarter, appears like sixteenth
352   b16*4 c4
353 }
354 @end lilypond
355
356 The duration of spacer rests may also be modified by
357 a multiplier.  This is useful for skipping many measures, e.g.,
358 @code{s1*23}.
359
360 @cindex compressing music
361 @cindex expanding music
362
363 @funindex \scaleDurations
364
365 Longer stretches of music may be compressed by a fraction in the
366 same way, as if every note, chord or rest had the fraction as a
367 multiplier.  This leaves the appearance of the music unchanged but
368 the internal duration of the notes will be multiplied by the
369 fraction @emph{num}/@emph{den}.  Here is an example showing how music
370 can be compressed and expanded:
371
372 @lilypond[quote,verbatim]
373 \relative {
374   \time 2/4
375   % Normal durations
376   <c'' a>4 c8 a
377   % Scale music by *2/3
378   \scaleDurations 2/3 {
379     <c a f>4. c8 a f
380   }
381   % Scale music by *2
382   \scaleDurations 2/1 {
383     <c' a>4 c8 b
384   }
385 }
386 @end lilypond
387
388 One application of this command is in polymetric
389 notation, see @ref{Polymetric notation}.
390
391 @seealso
392 Notation Reference:
393 @ref{Tuplets},
394 @ref{Invisible rests},
395 @ref{Polymetric notation}.
396
397 Snippets:
398 @rlsr{Rhythms}.
399
400 @knownissues
401 The calculation of the position within a measure must take into
402 account all the scaling factors applied to the notes within that
403 measure and any fractional carry-out from earlier measures.  This
404 calculation is carried out using rational numbers.  If an intermediate
405 numerator or denominator in that calculation exceeds 2^30 the
406 execution and typesetting will stop at that point without indicating
407 an error.
408
409
410 @node Ties
411 @unnumberedsubsubsec Ties
412
413 @cindex tie
414
415 @funindex ~
416
417 A tie connects two adjacent note heads of the same pitch.  The tie
418 in effect extends the duration of a note.
419
420 @warning{Ties should not be confused with @emph{slurs}, which
421 indicate articulation, or @emph{phrasing slurs}, which indicate
422 musical phrasing.  A tie is just a way of extending a note
423 duration, similar to the augmentation dot.}
424
425 A tie is entered by appending a tilde symbol (@code{~}) to the first
426 of each pair of notes being tied.  This indicates that the note
427 should be tied to the following note, which must be at the same pitch.
428
429 @lilypond[quote,verbatim]
430 { a'2~ 4~ 16 r r8 }
431 @end lilypond
432
433 Ties can make use of the @q{last explicit pitch} interpretation of
434 isolated durations:
435
436 @lilypond[quote,verbatim]
437 { a'2~ 4~ 16 r r8 }
438 @end lilypond
439
440 Ties are used either when the note crosses a bar line, or when
441 dots cannot be used to denote the rhythm.  Ties should also be
442 used when note values cross larger subdivisions of the measure:
443
444 @lilypond[verbatim,quote]
445 \relative {
446   r8 c'4.~ 4 r4 |
447   r8^"not" c2~ 8 r4
448 }
449 @end lilypond
450
451 If you need to tie many notes across bar lines, it may be
452 easier to use automatic note splitting, see @ref{Automatic note
453 splitting}.  This mechanism automatically splits long notes, and
454 ties them across bar lines.
455
456 @cindex ties and chords
457 @cindex chords and ties
458
459 When a tie is applied to a chord, all note heads whose pitches
460 match are connected.  When no note heads match, no ties will be
461 created.  Chords may be partially tied by placing the ties inside
462 the chord.
463
464 @lilypond[quote,verbatim]
465 \relative c' {
466   <c e g>2~ 2 |
467   <c e g>4~ <c e g c>
468     <c~ e g~ b> <c e g b> |
469 }
470 @end lilypond
471
472 @cindex repeating ties
473 @cindex ties, repeating
474 @cindex volta brackets and ties
475 @cindex ties and volta brackets
476
477 @funindex \repeatTie
478
479 When a second alternative of a repeat starts with a tied note, you
480 have to specify the repeated tie as follows:
481
482 @lilypond[quote,verbatim]
483 \relative {
484   \repeat volta 2 { c'' g <c e>2~ }
485   \alternative {
486     % First alternative: following note is tied normally
487     { <c e>2. r4 }
488     % Second alternative: following note has a repeated tie
489     { <c e>2\repeatTie d4 c }
490   }
491 }
492 @end lilypond
493
494 @cindex laissez vibrer
495 @cindex ties, laissez vibrer
496
497 @funindex \laissezVibrer
498
499 @notation{L.v.}@: ties (@notation{laissez vibrer}) indicate that
500 notes must not be damped at the end.  It is used in notation for
501 piano, harp and other string and percussion instruments.  They can
502 be entered as follows:
503
504 @lilypond[quote,verbatim,fragment]
505 <c' f' g'>1\laissezVibrer
506 @end lilypond
507
508 @cindex ties, placement
509
510 @funindex \tieUp
511 @funindex \tieDown
512 @funindex \tieNeutral
513
514 Ties may be made to curve up or down manually; see
515 @ref{Direction and placement}.
516
517 @cindex ties, appearance
518 @cindex ties, dotted
519 @cindex ties, dashed
520 @cindex dashed ties
521 @cindex dotted ties
522
523 @funindex \tieDotted
524 @funindex \tieDashed
525 @funindex \tieSolid
526
527 Ties may be made dashed, dotted, or a combination of solid and
528 dashed.
529
530 @lilypond[quote, verbatim]
531 \relative c' {
532   \tieDotted
533   c2~ 2
534   \tieDashed
535   c2~ 2
536   \tieHalfDashed
537   c2~ 2
538   \tieHalfSolid
539   c2~ 2
540   \tieSolid
541   c2~ 2
542 }
543 @end lilypond
544
545 Custom dash patterns can be specified:
546
547 @lilypond[quote, verbatim]
548 \relative c' {
549   \tieDashPattern #0.3 #0.75
550   c2~ 2
551   \tieDashPattern #0.7 #1.5
552   c2~ 2
553   \tieSolid
554   c2~ 2
555 }
556 @end lilypond
557
558 Dash pattern definitions for ties have the same structure as dash
559 pattern definitions for slurs. For more information about complex dash
560 patterns, see @ref{Slurs}.
561
562 Override @var{whiteout} and @var{layer} layout properties of objects
563 that should cause a gap in ties.
564
565 @lilypond[verbatim,quote,ragged-right]
566 \relative {
567   \override Tie.layer = #-2
568   \override Staff.TimeSignature.layer = #-1
569   \override Staff.KeySignature.layer = #-1
570   \override Staff.TimeSignature.whiteout = ##t
571   \override Staff.KeySignature.whiteout = ##t
572   b'2 b~
573   \time 3/4
574   \key a \major
575   b r4
576 }
577 @end lilypond
578
579 @predefined
580 @code{\tieUp},
581 @code{\tieDown},
582 @code{\tieNeutral},
583 @code{\tieDotted},
584 @code{\tieDashed},
585 @code{\tieDashPattern},
586 @code{\tieHalfDashed},
587 @code{\tieHalfSolid},
588 @code{\tieSolid}.
589 @endpredefined
590
591 @snippets
592
593 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
594 {using-ties-with-arpeggios.ly}
595
596 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
597 {engraving-ties-manually.ly}
598
599 @seealso
600 Music Glossary:
601 @rglos{tie},
602 @rglos{laissez vibrer}.
603
604 Notation Reference:
605 @ref{Slurs},
606 @ref{Automatic note splitting}.
607
608 Snippets:
609 @rlsr{Expressive marks},
610 @rlsr{Rhythms}.
611
612 Internals Reference:
613 @rinternals{LaissezVibrerTie},
614 @rinternals{LaissezVibrerTieColumn},
615 @rinternals{TieColumn},
616 @rinternals{Tie}.
617
618 @knownissues
619 Switching staves when a tie is active will not produce a slanted tie.
620
621 Changing clefs or ottavations during a tie is not really well-defined.
622 In these cases, a slur may be preferable.
623
624
625 @node Writing rests
626 @subsection Writing rests
627
628 Rests are entered as part of the music in music expressions.
629
630 @menu
631 * Rests::
632 * Invisible rests::
633 * Full measure rests::
634 @end menu
635
636 @node Rests
637 @unnumberedsubsubsec Rests
638
639 @cindex rest
640 @cindex rest, entering durations
641 @cindex maxima rest
642 @cindex longa rest
643 @cindex breve rest
644
645 @funindex \rest
646 @funindex r
647 @funindex \maxima
648 @funindex \longa
649 @funindex \breve
650
651 Rests are entered like notes with the note name @code{r}.
652 Durations longer than a whole rest use the following predefined
653 commands:
654
655 @c \time 16/1 is used to avoid spurious bar lines
656 @c and long tracts of empty measures
657 @lilypond[quote,verbatim]
658 \new Staff {
659   % These two lines are just to prettify this example
660   \time 16/1
661   \omit Staff.TimeSignature
662   % Print a maxima rest, equal to four breves
663   r\maxima
664   % Print a longa rest, equal to two breves
665   r\longa
666   % Print a breve rest
667   r\breve
668   r1 r2 r4 r8 r16 r32 r64 r128
669 }
670 @end lilypond
671
672 @cindex rest, multi-measure
673 @cindex rest, whole-measure
674
675 Whole measure rests, centered in the middle of the measure, must be
676 entered as multi-measure rests.  They can be used for a single
677 measure as well as many measures and are discussed in
678 @ref{Full measure rests}.
679
680 @cindex rest, specifying vertical position
681
682 To explicitly specify a rest's vertical position, write a note
683 followed by @code{\rest}.  A rest of the duration of the note will
684 be placed at the staff position where the note would appear.  This
685 allows for precise manual formatting of polyphonic music, since the
686 automatic rest collision formatter will not move these rests.
687
688 @lilypond[quote,verbatim]
689 \relative { a'4\rest d4\rest }
690 @end lilypond
691
692 @snippets
693
694 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
695 {rest-styles.ly}
696
697 @seealso
698 Music Glossary:
699 @rglos{breve},
700 @rglos{longa},
701 @rglos{maxima}.
702
703 Notation Reference:
704 @ref{Full measure rests}.
705
706 Snippets:
707 @rlsr{Rhythms}.
708
709 Internals Reference:
710 @rinternals{Rest}.
711
712 @knownissues
713 @c Deliberately duplicated in Durations and Rests.  -gp
714 There is no fundamental limit to rest durations (both in terms of
715 longest and shortest), but the number of glyphs is limited: there
716 are rests from 128th to maxima (8× whole).
717
718
719 @node Invisible rests
720 @unnumberedsubsubsec Invisible rests
721
722 @cindex skip
723 @cindex invisible rest
724 @cindex rest, invisible
725 @cindex spacer note
726 @cindex spacer rest
727
728 @funindex s
729 @funindex \skip
730
731 An invisible rest (also called a @q{spacer rest}) can be entered
732 like a note with the note name@tie{}@code{s}:
733
734 @lilypond[verbatim,quote]
735 \relative c'' {
736   c4 c s c |
737   s2 c |
738 }
739 @end lilypond
740
741 @cindex lyrics, skip
742
743 Spacer rests are available only in note mode and chord mode.  In
744 other situations, for example, when entering lyrics, the
745 command @code{\skip} is used to skip a musical moment.
746 @code{\skip} requires an explicit duration, but this is ignored if
747 the lyrics derive their durations from the notes in an associated
748 melody through @code{\addlyrics} or @code{\lyricsto}.
749
750 @lilypond[quote,verbatim]
751 <<
752   {
753     a'2 \skip2 a'2 a'2
754   }
755   \new Lyrics {
756     \lyricmode {
757       foo2 \skip 1 bla2
758     }
759   }
760 >>
761 @end lilypond
762
763 Because @code{\skip} is a command, it does not affect the default
764 durations of following notes, unlike@tie{}@code{s}.
765
766 @lilypond[quote,verbatim]
767 <<
768   {
769     \repeat unfold 8 { a'4 }
770   }
771   {
772     a'4 \skip 2 a' |
773     s2 a'
774   }
775 >>
776 @end lilypond
777
778
779 A spacer rest implicitly causes @code{Staff} and @code{Voice}
780 contexts to be created if none exist, just like notes and rests
781 do:
782
783 @lilypond[quote,verbatim]
784 { s1 s s }
785 @end lilypond
786
787 @code{\skip} simply skips musical time; it creates no output of
788 any kind.
789
790 @lilypond[quote,verbatim]
791 % This is valid input, but does nothing
792 { \skip 1 \skip1 \skip 1 }
793 @end lilypond
794
795 @seealso
796 Learning Manual:
797 @rlearning{Visibility and color of objects}.
798
799 Notation Reference:
800 @ref{Hidden notes},
801 @ref{Visibility of objects}.
802
803 Snippets:
804 @rlsr{Rhythms}.
805
806 Internals Reference:
807 @rinternals{SkipMusic}.
808
809
810 @node Full measure rests
811 @unnumberedsubsubsec Full measure rests
812
813 @cindex multi-measure rests
814 @cindex full-measure rests
815 @cindex rest, multi-measure
816 @cindex rest, full-measure
817 @cindex whole rest for a full measure
818 @cindex rest, whole for a full measure
819
820 @funindex \compressMMRests
821 @funindex R
822
823 Rests for one or more full measures are entered like notes with
824 the note name uppercase @code{R}:
825
826 @lilypond[quote,verbatim]
827 % Rest measures contracted to single measure
828 \compressMMRests {
829   R1*4
830   R1*24
831   R1*4
832   b'2^"Tutti" b'4 a'4
833 }
834 @end lilypond
835
836 The duration of full-measure rests is identical to the duration
837 notation used for notes.  The duration in a multi-measure rest must
838 always be an integral number of measure-lengths, so augmentation dots
839 or fractions must often be used:
840
841 @lilypond[quote,verbatim]
842 \compressMMRests {
843   \time 2/4
844   R1 | R2 |
845   \time 3/4
846   R2. | R2.*2 |
847   \time 13/8
848   R1*13/8 | R1*13/8*12 |
849   \time 10/8
850   R4*5*4 |
851 }
852 @end lilypond
853
854 A full-measure rest is printed as either a whole or breve rest,
855 centered in the measure, depending on the time signature.
856
857 @lilypond[quote,verbatim,fragment]
858 \time 4/4
859 R1 |
860 \time 6/4
861 R1*3/2 |
862 \time 8/4
863 R1*2 |
864 @end lilypond
865
866 @cindex multi-measure rest, expanding
867 @cindex multi-measure rest, contracting
868
869 By default a multi-measure rest is expanded in the printed score to
870 show all the rest measures explicitly.  Alternatively, a multi-measure
871 rest can be shown as a single measure containing a multi-measure rest
872 symbol, with the number of measures of rest printed above the measure:
873
874 @lilypond[quote,verbatim,fragment]
875 % Default behavior
876 \time 3/4 r2. | R2.*2 |
877 \time 2/4 R2 |
878 \time 4/4
879 % Rest measures contracted to single measure
880 \compressMMRests {
881   r1 | R1*17 | R1*4 |
882 }
883 % Rest measures expanded again
884 \time 3/4
885 R2.*2 |
886 @end lilypond
887
888
889 @cindex text on multi-measure rest
890 @cindex multi-measure rest, attaching text
891 @cindex script on multi-measure rest
892 @cindex multi-measure rest, script
893 @cindex fermata on multi-measure rest
894 @cindex multi-measure rest, attaching fermata
895 @cindex markup on multi-measure rest
896 @cindex multi-measure rest with markup
897
898 @funindex \fermataMarkup
899 @funindex MultiMeasureRestText
900
901 Markups can be added to multi-measure rests.
902 The predefined command @code{\fermataMarkup}
903 is provided for adding fermatas.
904
905 @lilypond[quote,verbatim]
906 \compressMMRests {
907   \time 3/4
908   R2.*10^\markup { \italic "ad lib." }
909   R2.^\fermataMarkup
910 }
911 @end lilypond
912
913 @warning{Markups attached to a multi-measure rest are objects of type
914 @code{MultiMeasureRestText}, not @code{TextScript}.  Overrides must
915 be directed to the correct object, or they will be ignored.  See the
916 following example:}
917
918 @lilypond[quote,verbatim,fragment]
919 % This fails, as the wrong object name is specified
920 \override TextScript.padding = #5
921 R1^"wrong"
922 % This is the correct object name to be specified
923 \override MultiMeasureRestText.padding = #5
924 R1^"right"
925 @end lilypond
926
927 When a multi-measure rest immediately follows a @code{\partial}
928 setting, resulting bar-check warnings may not be displayed.
929
930
931 @funindex \textLengthOn
932 @funindex \textLengthOff
933 @funindex \fermataMarkup
934 @funindex \compressMMRests
935
936 @predefined
937 @code{\textLengthOn},
938 @code{\textLengthOff},
939 @code{\fermataMarkup},
940 @code{\compressMMRests}.
941 @endpredefined
942
943
944 @snippets
945
946 @cindex church rest
947 @cindex rest, church
948 @cindex kirchenpausen
949
950 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
951 {changing-form-of-multi-measure-rests.ly}
952
953 @cindex multi-measure rests, positioning
954 @cindex positioning multi-measure rests
955
956 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
957 {positioning-multi-measure-rests.ly}
958
959 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
960 {multi-measure-rest-markup.ly}
961
962 @seealso
963 Music Glossary:
964 @rglos{multi-measure rest}.
965
966 Notation Reference:
967 @ref{Durations},
968 @ref{Text},
969 @ref{Formatting text},
970 @ref{Text scripts}.
971
972 Snippets:
973 @rlsr{Rhythms}.
974
975 Internals Reference:
976 @rinternals{MultiMeasureRest},
977 @rinternals{MultiMeasureRestNumber},
978 @rinternals{MultiMeasureRestText}.
979
980 @cindex fingerings and multi-measure rests
981 @cindex multi-measure rests and fingerings
982
983 @knownissues
984 Fingerings over multi-measure rests (e.g., @code{R1*10-4}) may result
985 in the fingering numeral colliding with the bar counter
986 numeral.
987
988 @cindex condensing rests
989 @cindex rest, condensing ordinary
990
991 There is no way to automatically condense multiple ordinary rests
992 into a single multi-measure rest.
993
994 @cindex rest, collisions of
995
996 Multi-measure rests do not take part in rest collisions.
997
998
999 @node Displaying rhythms
1000 @subsection Displaying rhythms
1001
1002 @menu
1003 * Time signature::
1004 * Metronome marks::
1005 * Upbeats::
1006 * Unmetered music::
1007 * Polymetric notation::
1008 * Automatic note splitting::
1009 * Showing melody rhythms::
1010 @end menu
1011
1012 @node Time signature
1013 @unnumberedsubsubsec Time signature
1014
1015 @cindex time signature
1016 @cindex meter
1017
1018 @funindex \time
1019
1020 The time signature is set as follows:
1021
1022 @lilypond[quote,verbatim,fragment]
1023 \time 2/4 c''2
1024 \time 3/4 c''2.
1025 @end lilypond
1026
1027 Mid-measure time signature changes are covered in @ref{Upbeats}.
1028
1029 @cindex time signature visibility
1030
1031 Time signatures are printed at the beginning of a piece
1032 and whenever the time signature changes.  If a change takes place
1033 at the end of a line a warning time signature sign is printed
1034 there.  This default behavior may be changed, see
1035 @ref{Visibility of objects}.
1036
1037 @lilypond[quote,verbatim]
1038 \relative c'' {
1039   \time 2/4
1040   c2 c
1041   \break
1042   c c
1043   \break
1044   \time 4/4
1045   c c c c
1046 }
1047 @end lilypond
1048
1049 @cindex time signature style
1050 @cindex meter style
1051
1052 @funindex \numericTimeSignature
1053 @funindex \defaultTimeSignature
1054
1055 The time signature symbol that is used in 2/2 and 4/4 time can be
1056 changed to a numeric style:
1057
1058 @lilypond[quote,verbatim]
1059 \relative c'' {
1060   % Default style
1061   \time 4/4 c1
1062   \time 2/2 c1
1063   % Change to numeric style
1064   \numericTimeSignature
1065   \time 4/4 c1
1066   \time 2/2 c1
1067   % Revert to default style
1068   \defaultTimeSignature
1069   \time 4/4 c1
1070   \time 2/2 c1
1071 }
1072 @end lilypond
1073
1074
1075 Mensural time signatures are covered in
1076 @ref{Mensural time signatures}.
1077
1078 @cindex time signature default settings
1079 @cindex autobeaming properties for time signatures
1080 @cindex beaming, time signature default properties
1081 @funindex \overrideTimeSignatureSettings
1082
1083 In addition to setting the printed time signature, the @code{\time}
1084 command also sets the values of the time-signature-based properties
1085 @code{baseMoment}, @code{beatStructure}, and @code{beamExceptions}.
1086 The predefined default values for these properties can be found in
1087 @file{scm/time-signature-settings.scm}.
1088
1089 The default value of @code{beatStructure} can be overridden in the
1090 @code{\time} command itself by supplying it as the optional first
1091 argument:
1092
1093 @lilypond[quote,verbatim]
1094 \score {
1095   \new Staff {
1096     \relative {
1097       \time 2,2,3 7/8
1098       \repeat unfold 7 { c'8 } |
1099       \time 3,2,2 7/8
1100       \repeat unfold 7 { c8 } |
1101     }
1102   }
1103 }
1104 @end lilypond
1105
1106 Alternatively, the default values of all these time-signature-based
1107 variables, including @code{baseMoment} and @code{beamExceptions},
1108 can be set together.  The values can be set independently for several
1109 different time signatures.  The new values take effect when a
1110 subsequent @code{\time} command with the same value of the time
1111 signature is executed:
1112
1113 @lilypond[quote,verbatim]
1114 \score {
1115   \new Staff {
1116     \relative c' {
1117       \overrideTimeSignatureSettings
1118         4/4        % timeSignatureFraction
1119         1/4        % baseMomentFraction
1120         3,1        % beatStructure
1121         #'()       % beamExceptions
1122       \time 4/4
1123       \repeat unfold 8 { c8 } |
1124     }
1125   }
1126 }
1127 @end lilypond
1128
1129 @code{\overrideTimeSignatureSettings} takes four arguments:
1130
1131 @enumerate
1132
1133 @item
1134 @code{@var{timeSignatureFraction}}, a fraction describing the
1135 time signature to which these values apply.
1136
1137 @item
1138 @code{@var{baseMomentFraction}}, a fraction containing the numerator
1139 and denominator of the basic timing unit for the time signature.
1140
1141 @item
1142 @code{@var{beatStructure}}, a Scheme list indicating the structure
1143 of the beats in the measure, in units of the base moment.
1144
1145 @item
1146 @code{@var{beamExceptions}}, an alist containing any beaming rules
1147 for the time signature that go beyond ending at every beat, as
1148 described in @ref{Setting automatic beam behavior}.
1149 @end enumerate
1150
1151
1152 @cindex time signature properties, restoring default values
1153 @cindex restoring default properties for time signatures
1154 @funindex \revertTimeSignatureSettings
1155
1156 Changed values of default time signature properties can be restored
1157 to the original values:
1158
1159 @lilypond[quote,verbatim]
1160 \score{
1161   \relative {
1162     \repeat unfold 8 { c'8 } |
1163     \overrideTimeSignatureSettings
1164       4/4        % timeSignatureFraction
1165       1/4        % baseMomentFraction
1166       3,1        % beatStructure
1167       #'()       % beamExceptions
1168     \time 4/4
1169     \repeat unfold 8 { c8 } |
1170     \revertTimeSignatureSettings 4/4
1171     \time 4/4
1172     \repeat unfold 8 { c8 } |
1173   }
1174 }
1175 @end lilypond
1176
1177 Different values of default time signature properties can be established
1178 for different staves by moving the @code{Timing_translator} and the
1179 @code{Default_bar_line_engraver} from the @code{Score} context to the
1180 @code{Staff} context.
1181
1182 @lilypond[quote, verbatim]
1183 \score {
1184   \new StaffGroup <<
1185      \new Staff {
1186         \overrideTimeSignatureSettings
1187           4/4        % timeSignatureFraction
1188           1/4        % baseMomentFraction
1189           3,1        % beatStructure
1190           #'()       % beamExceptions
1191         \time 4/4
1192         \repeat unfold 8 {c''8}
1193      }
1194      \new Staff {
1195         \overrideTimeSignatureSettings
1196           4/4        % timeSignatureFraction
1197           1/4        % baseMomentFraction
1198           1,3        % beatStructure
1199           #'()       % beamExceptions
1200         \time 4/4
1201         \repeat unfold 8 {c''8}
1202      }
1203   >>
1204   \layout {
1205     \context {
1206       \Score
1207       \remove "Timing_translator"
1208       \remove "Default_bar_line_engraver"
1209     }
1210     \context {
1211       \Staff
1212       \consists "Timing_translator"
1213       \consists "Default_bar_line_engraver"
1214     }
1215   }
1216 }
1217 @end lilypond
1218
1219 A further method of changing these time-signature-related variables,
1220 which avoids reprinting the time signature at the time of the change,
1221 is shown in @ref{Setting automatic beam behavior}.
1222
1223 @predefined
1224 @code{\numericTimeSignature},
1225 @code{\defaultTimeSignature}.
1226 @endpredefined
1227
1228
1229 @snippets
1230 @lilypondfile[verbatim,quote,texidoc,doctitle]
1231 {time-signature-printing-only-the-numerator-as-a-number-instead-of-the-fraction.ly}
1232
1233 @seealso
1234 Music Glossary:
1235 @rglos{time signature}
1236
1237 Notation Reference:
1238 @ref{Mensural time signatures},
1239 @ref{Setting automatic beam behavior},
1240 @ref{Time administration}.
1241
1242 Installed Files:
1243 @file{scm/time-signature-settings.scm}.
1244
1245 Snippets:
1246 @rlsr{Rhythms}.
1247
1248 Internals Reference:
1249 @rinternals{TimeSignature},
1250 @rinternals{Timing_translator}.
1251
1252
1253 @node Metronome marks
1254 @unnumberedsubsubsec Metronome marks
1255
1256 @cindex tempo
1257 @cindex beats per minute
1258 @cindex metronome mark
1259 @cindex metronome marking with text
1260
1261 @funindex \tempo
1262
1263 A basic metronome mark is simple to write:
1264
1265 @lilypond[verbatim,quote]
1266 \relative {
1267   \tempo 4 = 120
1268   c'2 d
1269   e4. d8 c2
1270 }
1271 @end lilypond
1272
1273 Metronome marks may also be printed as a range of two numbers:
1274
1275 @lilypond[verbatim,quote]
1276 \relative {
1277   \tempo 4 = 40 - 46
1278   c'4. e8 a4 g
1279   b,2 d4 r
1280 }
1281 @end lilypond
1282
1283 Tempo indications with text can be used instead:
1284
1285 @lilypond[verbatim,quote]
1286 \relative {
1287   \tempo "Allegretto"
1288     c''4 e d c
1289     b4. a16 b c4 r4
1290 }
1291 @end lilypond
1292
1293 Combining a metronome mark and text will automatically place the
1294 metronome mark within parentheses:
1295
1296 @lilypond[verbatim,quote]
1297 \relative {
1298   \tempo "Allegro" 4 = 160
1299   g'4 c d e
1300   d4 b g2
1301 }
1302 @end lilypond
1303
1304 In general, the text can be any markup object:
1305
1306 @lilypond[verbatim,quote]
1307 \relative {
1308   \tempo \markup { \italic Faster } 4 = 132
1309   a'8-. r8 b-. r gis-. r a-. r
1310 }
1311 @end lilypond
1312
1313 A parenthesized metronome mark with no textual indication may be
1314 written by including an empty string in the input:
1315
1316 @lilypond[verbatim,quote]
1317 \relative {
1318   \tempo "" 8 = 96
1319   d''4 g e c
1320 }
1321 @end lilypond
1322
1323 @funindex \markLengthOn
1324 @funindex \markLengthOff
1325
1326 In a part for an instrument with long periods of rests,
1327 tempo indications sometimes follow each other closely.
1328 The command @code{\markLengthOn} provides extra horizontal space
1329 to prevent tempo indications from overlapping, and @code{\markLengthOff}
1330 restores the default behavior of ignoring tempo marks
1331 for horizontal spacing.
1332
1333 @lilypond[verbatim,quote]
1334 \compressMMRests {
1335   \markLengthOn
1336   \tempo "Molto vivace"
1337   R1*12
1338   \tempo "Meno mosso"
1339   R1*16
1340   \markLengthOff
1341   \tempo "Tranquillo"
1342   R1*20
1343 }
1344 @end lilypond
1345
1346 @snippets
1347
1348 @lilypondfile[verbatim,quote,texidoc,doctitle]
1349 {printing-metronome-and-rehearsal-marks-below-the-staff.ly}
1350
1351 @c perhaps also an example of how to move it horizontally?
1352
1353 @lilypondfile[verbatim,quote,texidoc,doctitle]
1354 {changing-the-tempo-without-a-metronome-mark.ly}
1355
1356 @lilypondfile[verbatim,quote,texidoc,doctitle]
1357 {creating-metronome-marks-in-markup-mode.ly}
1358
1359 For more details, see @ref{Formatting text}.
1360
1361 @seealso
1362 Music Glossary:
1363 @rglos{metronome},
1364 @rglos{metronomic indication},
1365 @rglos{tempo indication},
1366 @rglos{metronome mark}.
1367
1368 Notation Reference:
1369 @ref{Formatting text},
1370 @ref{Creating MIDI output}.
1371
1372 Snippets:
1373 @rlsr{Staff notation}.
1374
1375 Internals Reference:
1376 @rinternals{MetronomeMark}.
1377
1378
1379 @node Upbeats
1380 @unnumberedsubsubsec Upbeats
1381
1382 @cindex anacrusis
1383 @cindex upbeat
1384 @cindex partial measure
1385 @cindex measure, partial
1386 @cindex measure, pickup
1387 @cindex pickup measure
1388 @cindex time signature, mid-measure
1389
1390 @funindex measurePosition
1391 @funindex \partial
1392
1393 Partial or pick-up measures, such as an @emph{anacrusis} or an
1394 @emph{upbeat}, are entered using the @code{\partial} command:
1395
1396 @example
1397 \partial @var{duration}
1398 @end example
1399
1400 When @code{\partial} is used at the beginning of a score,
1401 @code{@var{duration}} is the length of the music preceding the
1402 first bar.
1403
1404 @lilypond[quote,verbatim]
1405 \relative {
1406   \time 3/4
1407   \partial 4.
1408   r4 e'8 | a4 c8 b c4 |
1409 }
1410 @end lilypond
1411
1412 When @code{\partial} is used after the beginning of a score,
1413 @code{@var{duration}} is the @emph{remaining} length of the
1414 current measure.  It does not create a new numbered bar.
1415
1416 @lilypond[quote,verbatim]
1417 \relative {
1418   \set Score.barNumberVisibility = #all-bar-numbers-visible
1419   \override Score.BarNumber.break-visibility =
1420             #end-of-line-invisible
1421   \time 9/8
1422   d''4.~ 4 d8 d( c) b | c4.~ 4. \bar "||"
1423   \time 12/8
1424   \partial 4.
1425   c8( d) e | f2.~ 4 f8 a,( c) f |
1426 }
1427 @end lilypond
1428
1429 The @code{\partial} command is @emph{required} when the time
1430 signature changes in mid measure, but it may also be used alone.
1431
1432 @lilypond[quote,verbatim]
1433 \relative {
1434   \set Score.barNumberVisibility = #all-bar-numbers-visible
1435   \override Score.BarNumber.break-visibility =
1436             #end-of-line-invisible
1437   \time 6/8
1438   \partial 8
1439   e'8 | a4 c8 b[ c b] |
1440   \partial 4
1441   r8 e,8 | a4 \bar "||"
1442   \partial 4
1443   r8 e8 | a4
1444   c8 b[ c b] |
1445 }
1446 @end lilypond
1447
1448 The @code{\partial} command sets the @code{Timing.measurePosition}
1449 property, which is a rational number that indicates how much of
1450 the measure has passed.
1451
1452 @seealso
1453 Music Glossary:
1454 @rglos{anacrusis}.
1455
1456 Notation Reference:
1457 @ref{Grace notes}.
1458
1459 Snippets:
1460 @rlsr{Rhythms}.
1461
1462 Internal Reference:
1463 @rinternals{Timing_translator}.
1464
1465
1466 @node Unmetered music
1467 @unnumberedsubsubsec Unmetered music
1468
1469 @cindex cadenza
1470 @cindex cadenza, beams
1471 @cindex cadenza, accidentals
1472 @cindex cadenza, bar lines
1473 @cindex cadenza, bar numbers
1474 @cindex unmetered music
1475 @cindex unmetered music, beams
1476 @cindex unmetered music, accidentals
1477 @cindex unmetered music, bar lines
1478 @cindex unmetered music, bar numbers
1479 @cindex accidentals, cadenzas
1480 @cindex accidentals, unmetered music
1481 @cindex bar lines, cadenzas
1482 @cindex bar lines, unmetered music
1483 @cindex bar numbers, cadenzas
1484 @cindex bar numbers, unmetered music
1485 @cindex beams, cadenzas
1486 @cindex beams, unmetered music
1487
1488 @funindex \cadenzaOn
1489 @funindex \cadenzaOff
1490
1491 In metered music bar lines are inserted and bar numbers are calculated
1492 automatically. In unmetered music (i.e., cadenzas), this is not
1493 desirable and can be @q{switched off} using the command
1494 @code{\cadenzaOn}, then @q{switched back on} at the appropriate place
1495 using @code{\cadenzaOff}.
1496
1497 @lilypond[verbatim,quote]
1498 \relative c'' {
1499   c4 d e d
1500   \cadenzaOn
1501   c4 c d8[ d d] f4 g4.
1502   \cadenzaOff
1503   \bar "|"
1504   d4 e d c
1505 }
1506 @end lilypond
1507
1508 Bar numbering is resumed at the end of the cadenza.
1509
1510 @lilypond[verbatim,quote]
1511 \relative c'' {
1512   % Show all bar numbers
1513   \override Score.BarNumber.break-visibility = #all-visible
1514   c4 d e d
1515   \cadenzaOn
1516   c4 c d8[ d d] f4 g4.
1517   \cadenzaOff
1518   \bar "|"
1519   d4 e d c
1520 }
1521 @end lilypond
1522
1523 Inserting a @code{\bar} command within a cadenza does not start a new
1524 measure, even if a bar line is printed.  So any accidentals -- which
1525 are usually assumed to remain in force until the end of the measure --
1526 will still be valid after the bar line printed by @code{\bar}.  If
1527 subsequent accidentals should be printed, forced accidentals or
1528 reminder accidentals need to be inserted manually, see
1529 @ref{Accidentals}.
1530
1531 @lilypond[verbatim,quote]
1532 \relative c'' {
1533   c4 d e d
1534   \cadenzaOn
1535   cis4 d cis d
1536   \bar "|"
1537   % First cis is printed without alteration even if it's after a \bar
1538   cis4 d cis! d
1539   \cadenzaOff
1540   \bar "|"
1541 }
1542 @end lilypond
1543
1544 Automatic beaming is disabled by @code{\cadenzaOn}. Therefore, all
1545 beaming in cadenzas must be entered manually. See @ref{Manual beams}.
1546
1547 @lilypond[verbatim,quote]
1548 \relative {
1549   \repeat unfold 8 { c''8 }
1550   \cadenzaOn
1551   cis8 c c c c
1552   \bar"|"
1553   c8 c c
1554   \cadenzaOff
1555   \repeat unfold 8 { c8 }
1556 }
1557 @end lilypond
1558
1559 These predefined commands affect all staves in the score, even when
1560 placed in just one @code{Voice} context.  To change this, move the
1561 @code{Timing_translator} from the @code{Score} context to the
1562 @code{Staff} context.  See @ref{Polymetric notation}.
1563
1564 @predefined
1565 @code{\cadenzaOn},
1566 @code{\cadenzaOff}.
1567 @endpredefined
1568
1569 @seealso
1570 Music Glossary:
1571 @rglos{cadenza}.
1572
1573 Notation Reference:
1574 @ref{Visibility of objects},
1575 @ref{Polymetric notation},
1576 @ref{Manual beams},
1577 @ref{Accidentals}.
1578
1579 Snippets:
1580 @rlsr{Rhythms}.
1581
1582 @cindex cadenza, line breaks
1583 @cindex cadenza, page breaks
1584 @cindex unmetered music, line breaks
1585 @cindex unmetered music, page breaks
1586 @cindex breaks in unmetered music
1587 @cindex line breaks, cadenzas
1588 @cindex page breaks, cadenzas
1589 @cindex line breaks, unmetered music
1590 @cindex page breaks, unmetered music
1591
1592 @knownissues
1593 Automatic line and page breaks are inserted only at bar lines, so
1594 @q{invisible} bar lines will need to be inserted manually in long
1595 stretches of unmetered music to permit breaking:
1596
1597 @example
1598 \bar ""
1599 @end example
1600
1601
1602 @node Polymetric notation
1603 @unnumberedsubsubsec Polymetric notation
1604
1605 @c This section necessarily uses \set
1606 @c This is acceptable  -td
1607
1608 @cindex double time signatures
1609 @cindex signatures, polymetric
1610 @cindex time signature, polymetric
1611 @cindex time signature, double
1612 @cindex polymetric signatures
1613 @cindex meter, polymetric
1614
1615 @funindex timeSignatureFraction
1616 @funindex \scaleDurations
1617 @funindex \tuplet
1618
1619 Polymetric notation is supported explicitly or by manually modifying the
1620 visible time signature symbol and/or scaling note durations.
1621
1622 @subsubsubheading Different time signatures with equal-length measures
1623
1624 Set a common time signature for each staff, and set the
1625 @code{timeSignatureFraction} to the desired fraction.  Then use the
1626 @code{\scaleDurations} function to scale the durations of the notes in
1627 each staff to the common time signature.
1628
1629 @cindex beams, with polymetric meters
1630 @cindex polymetric meters, with beams
1631
1632 In the following example, music with the time signatures of 3/4, 9/8 and
1633 10/8 are used in parallel.  In the second staff, shown durations are
1634 multiplied by 2/3 (because 2/3 * 9/8 = 3/4) and in the third staff, the
1635 shown durations are multiplied by 3/5 (because 3/5 * 10/8 = 3/4).  It
1636 may be necessary to insert beams manually, as the duration scaling will
1637 affect the autobeaming rules.
1638
1639 @lilypond[quote,verbatim]
1640 \relative <<
1641   \new Staff {
1642     \time 3/4
1643     c'4 c c |
1644     c4 c c |
1645   }
1646   \new Staff {
1647     \time 3/4
1648     \set Staff.timeSignatureFraction = 9/8
1649     \scaleDurations 2/3
1650       \repeat unfold 6 { c8[ c c] }
1651   }
1652   \new Staff {
1653     \time 3/4
1654     \set Staff.timeSignatureFraction = 10/8
1655     \scaleDurations 3/5 {
1656       \repeat unfold 2 { c8[ c c] }
1657       \repeat unfold 2 { c8[ c] } |
1658       c4. c \tuplet 3/2 { c8[ c c] } c4
1659     }
1660   }
1661 >>
1662 @end lilypond
1663
1664 @subsubsubheading Different time signatures with unequal-length measures
1665
1666 Each staff can be given its own independent time signature by
1667 moving the @code{Timing_translator} and the
1668 @code{Default_bar_line_engraver} to the @code{Staff} context.
1669
1670 @lilypond[quote,verbatim]
1671 \layout {
1672   \context {
1673     \Score
1674     \remove "Timing_translator"
1675     \remove "Default_bar_line_engraver"
1676   }
1677   \context {
1678     \Staff
1679     \consists "Timing_translator"
1680     \consists "Default_bar_line_engraver"
1681   }
1682 }
1683
1684 % Now each staff has its own time signature.
1685
1686 \relative <<
1687   \new Staff {
1688     \time 3/4
1689     c'4 c c |
1690     c4 c c |
1691   }
1692   \new Staff {
1693     \time 2/4
1694     c4 c |
1695     c4 c |
1696     c4 c |
1697   }
1698   \new Staff {
1699     \time 3/8
1700     c4. |
1701     c8 c c |
1702     c4. |
1703     c8 c c |
1704   }
1705 >>
1706 @end lilypond
1707
1708 @funindex \compoundMeter
1709 @cindex compound time signatures
1710 @cindex time signature, compound
1711
1712 @subsubsubheading Compound time signatures
1713
1714 These are created using the @code{\compoundMeter} function.  The syntax
1715 for this is:
1716
1717 @example
1718 \compoundMeter #'(list of lists)
1719 @end example
1720
1721 The simplest construction is a single list, where the @emph{last} number
1722 indicates the bottom number of the time signature and those that come
1723 before it, the top numbers.
1724
1725 @lilypond[quote,verbatim]
1726 \relative {
1727   \compoundMeter #'((2 2 2 8))
1728   \repeat unfold 6 c'8 \repeat unfold 12 c16
1729 }
1730 @end lilypond
1731
1732 More complex meters can be constructed using additional lists.  Also,
1733 automatic beaming settings will be adjusted depending on the values.
1734
1735 @lilypond[quote,verbatim]
1736 \relative {
1737   \compoundMeter #'((1 4) (3 8))
1738   \repeat unfold 5 c'8 \repeat unfold 10 c16
1739 }
1740
1741 \relative {
1742   \compoundMeter #'((1 2 3 8) (3 4))
1743   \repeat unfold 12 c'8
1744 }
1745 @end lilypond
1746
1747 @seealso
1748 Music Glossary:
1749 @rglos{polymetric},
1750 @rglos{polymetric time signature},
1751 @rglos{meter}.
1752
1753 Notation Reference:
1754 @ref{Automatic beams},
1755 @ref{Manual beams},
1756 @ref{Time signature},
1757 @ref{Scaling durations}.
1758
1759 Snippets:
1760 @rlsr{Rhythms}.
1761
1762 Internals Reference:
1763 @rinternals{TimeSignature},
1764 @rinternals{Timing_translator},
1765 @rinternals{Default_bar_line_engraver},
1766 @rinternals{Staff}.
1767
1768 @knownissues
1769 When using different time signatures in parallel, notes at the same
1770 moment will be placed at the same horizontal location.  However, the bar
1771 lines in the different staves will cause the note spacing to be less
1772 regular in each of the individual staves than would be normal without
1773 the different time signatures.
1774
1775
1776 @node Automatic note splitting
1777 @unnumberedsubsubsec Automatic note splitting
1778
1779 @cindex notes, splitting
1780 @cindex splitting notes
1781 @cindex rests, splitting
1782 @cindex splitting rests
1783
1784 @funindex Note_heads_engraver
1785 @funindex Completion_heads_engraver
1786 @funindex Completion_rest_engraver
1787
1788 Long notes which overrun bar lines can be converted automatically to
1789 tied notes.  This is done by replacing the @code{Note_heads_engraver}
1790 with the @code{Completion_heads_engraver}.  Similarly, long rests which
1791 overrun bar lines are split automatically by replacing the
1792 @code{Rest_engraver} with the @code{Completion_rest_engraver}.  In the
1793 following example, notes and rests crossing the bar lines are split,
1794 notes are also tied.
1795
1796 @lilypond[quote,verbatim]
1797 \new Voice \with {
1798   \remove "Note_heads_engraver"
1799   \consists "Completion_heads_engraver"
1800   \remove "Rest_engraver"
1801   \consists "Completion_rest_engraver"
1802 }
1803 \relative {
1804   c'2. c8 d4 e f g a b c8 c2 b4 a g16 f4 e d c8. c2 r1*2
1805 }
1806 @end lilypond
1807
1808 These engravers split all running notes and rests at the bar line, and
1809 inserts ties for notes.  One of its uses is to debug complex scores: if
1810 the measures are not entirely filled, then the ties show exactly how
1811 much each measure is off.
1812
1813 The property @code{completionUnit} sets a preferred duration for
1814 the split notes.
1815
1816 @lilypond[quote,verbatim]
1817 \new Voice \with {
1818   \remove "Note_heads_engraver"
1819   \consists "Completion_heads_engraver"
1820 } \relative {
1821   \time 9/8 g\breve. d''4. \bar "||"
1822   \set completionUnit = #(ly:make-moment 3 8)
1823   g\breve. d4.
1824 }
1825 @end lilypond
1826
1827 These engravers split notes with scaled duration, such as those in tuplets,
1828 into notes with the same scale-factor as in the input note.
1829
1830 @lilypond[quote,verbatim]
1831 \new Voice \with {
1832   \remove "Note_heads_engraver"
1833   \consists "Completion_heads_engraver"
1834 } \relative {
1835   \time 2/4 r4
1836   \tuplet 3/2 {g'4 a b}
1837   \scaleDurations 2/3 {g a b}
1838   g4*2/3 a b
1839   \tuplet 3/2 {g4 a b}
1840   r4
1841 }
1842 @end lilypond
1843
1844 @seealso
1845 Music Glossary:
1846 @rglos{tie}
1847
1848 Learning Manual:
1849 @rlearning{Engravers explained},
1850 @rlearning{Adding and removing engravers}.
1851
1852 Snippets:
1853 @rlsr{Rhythms}.
1854
1855 Internals Reference:
1856 @rinternals{Note_heads_engraver},
1857 @rinternals{Completion_heads_engraver},
1858 @rinternals{Rest_engraver},
1859 @rinternals{Completion_rest_engraver},
1860 @rinternals{Forbid_line_break_engraver}.
1861
1862 @knownissues
1863 For consistency with previous behavior, notes and rests with
1864 duration longer than a measure, such as @code{c1*2}, are split into
1865 notes without any scale factor, @code{@{ c1 c1 @}}.  The property
1866 @code{completionFactor} controls this behavior, and setting it to
1867 @code{#f} cause split notes and rests to have the scale factor
1868 of the input durations.
1869
1870
1871 @node Showing melody rhythms
1872 @unnumberedsubsubsec Showing melody rhythms
1873
1874 @cindex melody rhythms, showing
1875 @cindex rhythms, showing melody
1876
1877 Sometimes you might want to show only the rhythm of a melody.  This
1878 can be done with the rhythmic staff.  All pitches of notes on such a
1879 staff are squashed, and the staff itself has a single line
1880
1881 @lilypond[quote,verbatim]
1882 <<
1883   \new RhythmicStaff {
1884     \new Voice = "myRhythm" \relative {
1885       \time 4/4
1886       c'4 e8 f g2
1887       r4 g g f
1888       g1
1889     }
1890   }
1891   \new Lyrics {
1892     \lyricsto "myRhythm" {
1893       This is my song
1894       I like to sing
1895     }
1896   }
1897 >>
1898 @end lilypond
1899
1900 @cindex guitar chord charts
1901 @cindex strumming rhythms, showing
1902 @cindex guitar strumming rhythms, showing
1903
1904 @funindex Pitch_squash_engraver
1905 @funindex \improvisationOn
1906 @funindex \improvisationOff
1907
1908 Guitar chord charts often show the strumming rhythms.  This can
1909 be done with the @code{Pitch_squash_engraver} and
1910 @code{\improvisationOn}.
1911
1912
1913 @lilypond[quote,verbatim]
1914 <<
1915   \new ChordNames {
1916     \chordmode {
1917       c1 f g c
1918     }
1919   }
1920   \new Voice \with {
1921     \consists "Pitch_squash_engraver"
1922   } \relative c'' {
1923     \improvisationOn
1924     c4 c8 c c4 c8 c
1925     f4 f8 f f4 f8 f
1926     g4 g8 g g4 g8 g
1927     c4 c8 c c4 c8 c
1928   }
1929 >>
1930 @end lilypond
1931
1932 Music containing chords can also be used as input to @code{RhythmicStaff}
1933 and for use with the @code{Pitch_squash_engraver} if the chords are first
1934 reduced to single notes with the @code{\reduceChords} music function:
1935
1936 @lilypond[quote,verbatim]
1937 \new RhythmicStaff {
1938   \time 4/4
1939   \reduceChords {
1940     <c>2
1941     <e>2
1942     <c e g>2
1943     <c e g>4
1944     <c e g>4
1945   }
1946 }
1947 @end lilypond
1948
1949 @predefined
1950 @code{\improvisationOn},
1951 @code{\improvisationOff}.
1952 @endpredefined
1953
1954
1955 @snippets
1956
1957 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
1958 {guitar-strum-rhythms.ly}
1959
1960 @seealso
1961 Snippets:
1962 @rlsr{Rhythms}.
1963
1964 Internals Reference:
1965 @rinternals{RhythmicStaff},
1966 @rinternals{Pitch_squash_engraver}.
1967
1968
1969 @node Beams
1970 @subsection Beams
1971
1972 @menu
1973 * Automatic beams::
1974 * Setting automatic beam behavior::
1975 * Manual beams::
1976 * Feathered beams::
1977 @end menu
1978
1979 @node Automatic beams
1980 @unnumberedsubsubsec Automatic beams
1981
1982 By default, beams are inserted automatically:
1983
1984 @cindex beams, manual
1985 @cindex manual beams
1986 @cindex beams, customizing rules
1987
1988 @funindex \autoBeamOn
1989 @funindex \autoBeamOff
1990
1991 @lilypond[quote,verbatim]
1992 \relative c'' {
1993   \time 2/4 c8 c c c
1994   \time 6/8 c8 c c c8. c16 c8
1995 }
1996 @end lilypond
1997
1998 If these automatic decisions are not satisfactory, beaming can be
1999 entered explicitly; see @ref{Manual beams}.  Beams @emph{must} be
2000 entered manually if beams are to be extended over rests.
2001
2002 If automatic beaming is not required, it may be turned off with
2003 @code{\autoBeamOff} and on with @code{\autoBeamOn}:
2004
2005 @lilypond[quote,verbatim]
2006 \relative c' {
2007   c4 c8 c8. c16 c8. c16 c8
2008   \autoBeamOff
2009   c4 c8 c8. c16 c8.
2010   \autoBeamOn
2011   c16 c8
2012 }
2013 @end lilypond
2014
2015 @cindex melismata, with beams
2016 @cindex beams, with melismata
2017
2018 @warning{If beams are used to indicate melismata in songs, then
2019 automatic beaming should be switched off with @code{@bs{}autoBeamOff}
2020 and the beams indicated manually.  Using @code{@bs{}partcombine} with
2021 @code{@bs{}autoBeamOff} can produce unintended results.  See the
2022 snippets for more information.}
2023
2024 Beaming patterns that differ from the automatic defaults can be
2025 created; see @ref{Setting automatic beam behavior}.
2026
2027 @predefined
2028 @code{\autoBeamOff},
2029 @code{\autoBeamOn}.
2030 @endpredefined
2031
2032 @cindex beams, line breaks
2033 @cindex line breaks, beams
2034 @cindex beams, with knee gap
2035 @cindex knee gap, with beams
2036 @funindex breakable
2037
2038 @snippets
2039 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
2040 {beams-across-line-breaks.ly}
2041
2042 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
2043 {changing-beam-knee-gap.ly}
2044
2045 @cindex beams, \partcombine with \autoBeamOff
2046 @cindex voices, \partcombine with \autoBeamOff
2047
2048 @lilypondfile [verbatim, quote, ragged-right, texidoc, doctitle]
2049 {partcombine-and-autobeamoff.ly}
2050
2051 @seealso
2052 Notation Reference:
2053 @ref{Manual beams},
2054 @ref{Setting automatic beam behavior}.
2055
2056 Installed Files:
2057 @file{scm/auto-beam.scm}.
2058
2059 Snippets:
2060 @rlsr{Rhythms}.
2061
2062 Internals Reference:
2063 @rinternals{Auto_beam_engraver},
2064 @rinternals{Beam_engraver},
2065 @rinternals{Beam},
2066 @rinternals{BeamEvent},
2067 @rinternals{BeamForbidEvent},
2068 @rinternals{beam-interface},
2069 @rinternals{unbreakable-spanner-interface}.
2070
2071 @knownissues
2072 The properties of a beam are determined at the @emph{start} of its
2073 construction and any additional beam-property changes that occur before
2074 the beam has been completed will not take effect until the @emph{next},
2075 new beam starts.
2076
2077
2078 @node Setting automatic beam behavior
2079 @unnumberedsubsubsec Setting automatic beam behavior
2080
2081 @cindex beams, with lyrics
2082 @cindex lyrics, with beams
2083
2084 @funindex autoBeaming
2085 @funindex baseMoment
2086 @funindex \beamExceptions
2087 @funindex beatStructure
2088 @funindex measureLength
2089 @funindex \time
2090 @funindex \set
2091
2092 When automatic beaming is enabled, the placement of automatic beams
2093 is determined by three context properties:
2094 @code{baseMoment}, @code{beatStructure}, and @code{beamExceptions}.
2095 The default values of these variables may be overridden as described
2096 below, or alternatively the default values themselves may be changed
2097 as explained in @ref{Time signature}.
2098
2099 If a @code{beamExceptions} rule is defined for the time signature in
2100 force, that rule alone is used to determine the beam placement; the
2101 values of @code{baseMoment} and @code{beatStructure} are ignored.
2102
2103 If no @code{beamExceptions} rule is defined for the time signature
2104 in force, the beam placement is determined by the values of
2105 @code{baseMoment} and @code{beatStructure}.
2106
2107
2108 @subsubsubheading Beaming based on @code{baseMoment} and @code{beatStructure}
2109
2110 By default, @code{beamExceptions} rules are defined for most common
2111 time signatures, so the @code{beamExceptions} rules must be disabled
2112 if automatic beaming is to be based on @code{baseMoment} and
2113 @code{beatStructure}.  The @code{beamExceptions} rules are disabled
2114 by
2115
2116 @example
2117 \set Timing.beamExceptions = #'()
2118 @end example
2119
2120 When @code{beamExceptions} is set to @code{#'()}, either due to an
2121 explicit setting or because no @code{beamExceptions} rules are defined
2122 internally for the time signature in force, the ending points for
2123 beams are on beats as specified by the context properties
2124 @code{baseMoment} and @code{beatStructure}.  @code{beatStructure} is
2125 a scheme list that defines the length of each beat in the measure in
2126 units of @code{baseMoment}.  By default, @code{baseMoment} is one
2127 over the denominator of the time signature.  By default, each unit of
2128 length @code{baseMoment} is a single beat.
2129
2130 Note that there are separate @code{beatStructure} and @code{baseMoment}
2131 values for each time signature.  Changes to these variables apply only
2132 to the time signature that is currently in force, hence those changes
2133 must be placed after the @code{\time} command which starts a new time
2134 signature section, not before it.  New values given to a particular
2135 time signature are retained and reinstated whenever that time signature
2136 is re-established.
2137
2138 @lilypond[quote,verbatim]
2139 \relative c'' {
2140   \time 5/16
2141   c16^"default" c c c c |
2142   % beamExceptions are unlikely to be defined for 5/16 time,
2143   % but let's disable them anyway to be sure
2144   \set Timing.beamExceptions = #'()
2145   \set Timing.beatStructure = 2,3
2146   c16^"(2+3)" c c c c |
2147   \set Timing.beatStructure = 3,2
2148   c16^"(3+2)" c c c c |
2149 }
2150 @end lilypond
2151
2152 @lilypond[quote,verbatim]
2153 \relative {
2154   \time 4/4
2155   a'8^"default" a a a a a a a
2156   % Disable beamExceptions because they are definitely
2157   % defined for 4/4 time
2158   \set Timing.beamExceptions = #'()
2159   \set Timing.baseMoment = #(ly:make-moment 1/4)
2160   \set Timing.beatStructure = 1,1,1,1
2161   a8^"changed" a a a a a a a
2162 }
2163 @end lilypond
2164
2165 Beam setting changes can be limited to specific contexts.  If no
2166 setting is included in a lower-level context, the setting of the
2167 enclosing context will apply.
2168
2169 @lilypond[quote, verbatim]
2170 \new Staff {
2171   \time 7/8
2172   % No need to disable beamExceptions
2173   % as they are not defined for 7/8 time
2174   \set Staff.beatStructure = 2,3,2
2175   <<
2176     \new Voice = one {
2177       \relative {
2178         a'8 a a a a a a
2179       }
2180     }
2181     \new Voice = two {
2182       \relative {
2183         \voiceTwo
2184         \set Voice.beatStructure = 1,3,3
2185         f'8 f f f f f f
2186       }
2187     }
2188   >>
2189 }
2190 @end lilypond
2191
2192 When multiple voices are used the @code{Staff} context must be
2193 specified if the beaming is to be applied to all voices in the
2194 staff:
2195
2196 @lilypond[quote,verbatim,fragment]
2197 \time 7/8
2198 % rhythm 3-1-1-2
2199 % Change applied to Voice by default --  does not work correctly
2200 % Because of autogenerated voices, all beating will
2201 % be at baseMoment (1 . 8)
2202 \set beatStructure = 3,1,1,2
2203 << \relative {a'8 a a a16 a a a a8 a} \\ \relative {f'4. f8 f f f} >>
2204
2205 % Works correctly with context Staff specified
2206 \set Staff.beatStructure = 3,1,1,2
2207 << \relative {a'8 a a a16 a a a a8 a} \\ \relative {f'4. f8 f f f} >>
2208 @end lilypond
2209
2210 The value of @code{baseMoment} can be adjusted to change
2211 the beaming behavior, if desired. When this is done,
2212 the value of @code{beatStructure} must be set to be
2213 compatible with the new value of @code{baseMoment}.
2214
2215 @lilypond[quote,verbatim,fragment]
2216 \time 5/8
2217 % No need to disable beamExceptions
2218 % as they are not defined for 5/8 time
2219 \set Timing.baseMoment = #(ly:make-moment 1/16)
2220 \set Timing.beatStructure = 7,3
2221 \repeat unfold 10 { a'16 }
2222 @end lilypond
2223
2224 @code{baseMoment} is a @i{moment}; a unit of musical duration.  A
2225 quantity of type @i{moment} is created by the scheme function
2226 @code{ly:make-moment}.  For more information about this function,
2227 see @ref{Time administration}.
2228
2229 By default @code{baseMoment} is set to one over the denominator of
2230 the time signature. Any exceptions to this default can be found in
2231 @file{scm/time-signature-settings.scm}.
2232
2233 @subsubsubheading Beaming based on @code{beamExceptions}
2234
2235 Special autobeaming rules (other than ending a beam on a beat)
2236 are defined in the @code{beamExceptions} property.
2237
2238 The value for @code{beamExceptions}, a somewhat complex Scheme
2239 data structure, is easiest generated with the
2240 @code{\beamExceptions} function.  This function is given one or
2241 more manually beamed measure-length rhythmic patterns (measures
2242 have to be separated by a bar check@tie{}@code{|} since the
2243 function has no other way to discern the measure length).  Here is
2244 a simple example:
2245
2246 @lilypond[quote,verbatim]
2247 \relative c'' {
2248   \time 3/16
2249   \set Timing.beatStructure = 2,1
2250   \set Timing.beamExceptions =
2251     \beamExceptions { 32[ 32] 32[ 32] 32[ 32] }
2252   c16 c c |
2253   \repeat unfold 6 { c32 } |
2254 }
2255 @end lilypond
2256
2257 @warning{A @code{beamExceptions} value must be @emph{complete}
2258 exceptions list.  That is, every exception that should be applied
2259 must be included in the setting.  It is not possible to add, remove,
2260 or change only one of the exceptions. While this may seem cumbersome,
2261 it means that the current beaming settings need not be known in order
2262 to specify a new beaming pattern.}
2263
2264 When the time signature is changed, default values of
2265 @code{Timing.baseMoment}, @code{Timing.beatStructure},
2266 and @code{Timing.beamExceptions} are set.  Setting the time signature
2267 will reset the automatic beaming settings for the @code{Timing}
2268 context to the default behavior.
2269
2270 @lilypond[quote,verbatim]
2271 \relative a' {
2272   \time 6/8
2273   \repeat unfold 6 { a8 }
2274   % group (4 + 2)
2275   \set Timing.beatStructure = 4,2
2276   \repeat unfold 6 { a8 }
2277   % go back to default behavior
2278   \time 6/8
2279   \repeat unfold 6 { a8 }
2280 }
2281 @end lilypond
2282
2283 The default automatic beaming settings for a time signature
2284 are determined in @file{scm/time-signature-settings.scm}.
2285 Changing the default automatic beaming settings
2286 for a time signature is described in @ref{Time signature}.
2287
2288 Many automatic beaming settings for a time signature contain an
2289 entry for @code{beamExceptions}.  For example, 4/4 time tries to
2290 beam the measure in two if there are only eighth notes.  The
2291 @code{beamExceptions} rule can override the @code{beatStructure} setting
2292 if @code{beamExceptions} is not reset.
2293
2294 @lilypond[quote,verbatim,fragment]
2295 \time 4/4
2296 \set Timing.baseMoment = #(ly:make-moment 1/8)
2297 \set Timing.beatStructure = 3,3,2
2298 % This won't beam (3 3 2) because of beamExceptions
2299 \repeat unfold 8 {c''8} |
2300 % This will beam (3 3 2) because we clear beamExceptions
2301 \set Timing.beamExceptions = #'()
2302 \repeat unfold 8 {c''8}
2303 @end lilypond
2304
2305 In a similar fashion, eighth notes in 3/4 time are beamed as a full
2306 measure by default.  To beam eighth notes in 3/4 time on the beat,
2307 reset @code{beamExceptions}.
2308
2309 @lilypond[quote,verbatim,fragment]
2310 \time 3/4
2311 % by default we beam in (6) due to beamExceptions
2312 \repeat unfold 6 {a'8} |
2313 % This will beam (1 1 1) due to default baseMoment and beatStructure
2314 \set Timing.beamExceptions = #'()
2315 \repeat unfold 6 {a'8}
2316 @end lilypond
2317
2318 In engraving from the Romantic and Classical periods,
2319 beams often begin midway through the measure in 3/4 time,
2320 but modern practice is to avoid the false impression of 6/8 time
2321 (see Gould, p. 153).  Similar situations arise in 3/8 time.
2322 This behavior is controlled by the context property @code{beamHalfMeasure},
2323 which has effect only in time signatures with 3 in the numerator:
2324
2325 @lilypond[quote,verbatim]
2326 \relative a' {
2327   \time 3/4
2328   r4. a8 a a |
2329   \set Timing.beamHalfMeasure = ##f
2330   r4. a8 a a |
2331 }
2332 @end lilypond
2333
2334 @subsubsubheading How automatic beaming works
2335
2336 When automatic beaming is enabled, the placement of automatic beams
2337 is determined by the context properties
2338 @code{baseMoment}, @code{beatStructure}, and @code{beamExceptions}.
2339
2340 The following rules, in order of priority, apply when determining
2341 the appearance of beams:
2342
2343 @itemize
2344 @item
2345 If a manual beam is specified with @code{[@dots{}]} set the beam
2346 as specified, otherwise
2347
2348 @item
2349 if a beam-ending rule is defined in @code{beamExceptions}
2350 for the beam-type, use it to determine the valid places where
2351 beams may end, otherwise
2352
2353 @item
2354 if a beam-ending rule is defined in @code{beamExceptions}
2355 for a longer beam-type, use it to determine the valid places
2356 where beams may end, otherwise
2357
2358 @item
2359 use the values of @code{baseMoment} and @code{beatStructure} to
2360 determine the ends of the beats in the measure, and
2361 end beams at the end of beats.
2362
2363 @end itemize
2364
2365 In the rules above, the @emph{beam-type} is the duration of the
2366 shortest note in the beamed group.
2367
2368 The default beaming rules can be found in
2369 @file{scm/time-signature-settings.scm}.
2370
2371 @snippets
2372
2373 @cindex beams, subdividing
2374
2375 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
2376 {subdividing-beams.ly}
2377
2378 @cindex beamlets, orienting
2379
2380 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
2381 {strict-beat-beaming.ly}
2382
2383 @cindex measure groupings
2384 @cindex beats, grouping
2385 @cindex grouping beats
2386 @cindex measure sub-grouping
2387
2388 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
2389 {conducting-signs,-measure-grouping-signs.ly}
2390
2391 @cindex beam, endings in a score
2392 @cindex beam, endings with multiple voices
2393
2394 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
2395 {beam-endings-in-score-context.ly}
2396
2397 @seealso
2398 Notation Reference:
2399 @ref{Time signature}.
2400
2401 Installed Files:
2402 @file{scm/time-signature-settings.scm}.
2403
2404 Snippets:
2405 @rlsr{Rhythms}.
2406
2407 Internals Reference:
2408 @rinternals{Auto_beam_engraver},
2409 @rinternals{Beam},
2410 @rinternals{BeamForbidEvent},
2411 @rinternals{beam-interface}.
2412
2413 @knownissues
2414 If a score ends while an automatic beam has not been ended and is
2415 still accepting notes, this last beam will not be typeset at all.
2416 The same holds for polyphonic voices, entered with
2417 @code{<< @dots{} \\ @dots{} >>}.  If a polyphonic voice ends while an
2418 automatic beam is still accepting notes, it is not typeset.
2419 The workaround for these problems is to manually beam the last
2420 beam in the voice or score.
2421
2422 By default, the @code{Timing} translator is aliased to the
2423 @code{Score} context.  This means that setting the time signature
2424 in one staff will affect the beaming of the other staves as well.
2425 Thus, a time signature setting in a later staff will reset custom
2426 beaming that was set in an earlier staff.
2427 One way to avoid this problem is to set the time signature
2428 in only one staff.
2429
2430 @lilypond[quote,verbatim]
2431 <<
2432   \new Staff {
2433     \time 3/4
2434     \set Timing.baseMoment = #(ly:make-moment 1/8)
2435     \set Timing.beatStructure = 1,5
2436     \set Timing.beamExceptions = #'()
2437     \repeat unfold 6 { a'8 }
2438   }
2439   \new Staff {
2440     \repeat unfold 6 { a'8 }
2441   }
2442 >>
2443 @end lilypond
2444
2445 The default beam settings for the time signature can also be changed, so
2446 that the desired beaming will always be used.  Changes in automatic
2447 beaming settings for a time signature are described in
2448 @ref{Time signature}.
2449
2450 @lilypond[quote,verbatim]
2451 <<
2452   \new Staff {
2453     \overrideTimeSignatureSettings
2454       3/4               % timeSignatureFraction
2455       1/8               % baseMomentFraction
2456       1,5               % beatStructure
2457       #'()              % beamExceptions
2458     \time 3/4
2459     \repeat unfold 6 { a'8 }
2460   }
2461   \new Staff {
2462     \time 3/4
2463     \repeat unfold 6 { a'8 }
2464   }
2465 >>
2466 @end lilypond
2467
2468
2469 @node Manual beams
2470 @unnumberedsubsubsec Manual beams
2471
2472 @cindex beams, manual
2473 @cindex manual beams
2474
2475 @funindex ]
2476 @funindex [
2477
2478 In some cases it may be necessary to override the automatic
2479 beaming algorithm.  For example, the autobeamer will not put beams
2480 over rests or bar lines, and in choral scores the beaming is
2481 often set to follow the meter of the lyrics rather than the
2482 notes.  Such beams can be specified manually by
2483 marking the begin and end point with @code{[} and @code{]}.
2484
2485 @lilypond[quote,verbatim]
2486 \relative { r4 r8[ g' a r] r g[ | a] r }
2487 @end lilypond
2488
2489 @cindex manual beams, direction shorthand for
2490 @cindex manual beams, grace notes
2491
2492 Beaming direction can be set manually using direction indicators:
2493
2494 @lilypond[quote,verbatim]
2495 \relative { c''8^[ d e] c,_[ d e f g] }
2496 @end lilypond
2497
2498 @funindex \noBeam
2499
2500 Individual notes may be marked with @code{\noBeam} to prevent them
2501 from being beamed:
2502
2503 @lilypond[quote,verbatim]
2504 \relative {
2505   \time 2/4
2506   c''8 c\noBeam c c
2507 }
2508 @end lilypond
2509
2510 Grace note beams and normal note beams can occur simultaneously.
2511 Unbeamed grace notes are not put into normal note beams.
2512
2513 @lilypond[quote,verbatim]
2514 \relative {
2515   c''4 d8[
2516   \grace { e32 d c d }
2517   e8] e[ e
2518   \grace { f16 }
2519   e8 e]
2520 }
2521 @end lilypond
2522
2523 @funindex stemLeftBeamCount
2524 @funindex stemRightBeamCount
2525
2526 Even more strict manual control with the beams can be achieved by
2527 setting the properties @code{stemLeftBeamCount} and
2528 @code{stemRightBeamCount}.  They specify the number of beams to
2529 draw on the left and right side, respectively, of the next note.
2530 If either property is set, its value will be used only once, and
2531 then it is erased.  In this example, the last @code{f} is printed
2532 with only one beam on the left side, i.e., the eighth-note beam of
2533 the group as a whole.
2534
2535 @lilypond[quote,verbatim]
2536 \relative a' {
2537   a8[ r16 f g a]
2538   a8[ r16
2539   \set stemLeftBeamCount = #2
2540   \set stemRightBeamCount = #1
2541   f16
2542   \set stemLeftBeamCount = #1
2543   g16 a]
2544 }
2545 @end lilypond
2546
2547
2548 @predefined
2549 @code{\noBeam}.
2550 @endpredefined
2551
2552
2553 @snippets
2554
2555 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
2556 {flat-flags-and-beam-nibs.ly}
2557
2558 @seealso
2559 Notation Reference:
2560 @ref{Direction and placement},
2561 @ref{Grace notes}.
2562
2563 Snippets:
2564 @rlsr{Rhythms}.
2565
2566 Internals Reference:
2567 @rinternals{Beam},
2568 @rinternals{BeamEvent},
2569 @rinternals{Beam_engraver},
2570 @rinternals{beam-interface},
2571 @rinternals{Stem_engraver}.
2572
2573
2574 @node Feathered beams
2575 @unnumberedsubsubsec Feathered beams
2576
2577 @cindex beams, feathered
2578 @cindex feathered beams
2579
2580 @funindex \featherDurations
2581 @funindex grow-direction
2582
2583 Feathered beams are used to indicate that a small group of notes
2584 should be played at an increasing (or decreasing) tempo, without
2585 changing the overall tempo of the piece.  The extent of the
2586 feathered beam must be indicated manually using @code{[} and
2587 @code{]}, and the beam feathering is turned on by specifying a
2588 direction to the @code{Beam} property @code{grow-direction}.
2589
2590 If the placement of the notes and the sound in the MIDI output is to
2591 reflect the @emph{ritardando} or @emph{accelerando} indicated by the
2592 feathered beam the notes must be grouped as a music expression delimited
2593 by braces and preceded by a @code{featherDurations} command which specifies
2594 the ratio between the durations of the first and last notes in the
2595 group.
2596
2597 The square brackets show the extent of the beam and the braces show
2598 which notes are to have their durations modified.  Normally these
2599 would delimit the same group of notes, but this is not required: the
2600 two commands are independent.
2601
2602 In the following example the eight 16th notes occupy exactly the
2603 same time as a half note, but the first note is one half as long
2604 as the last one, with the intermediate notes gradually
2605 lengthening.  The first four 32nd notes gradually speed up, while
2606 the last four 32nd notes are at a constant tempo.
2607
2608 @lilypond[verbatim,quote]
2609 \relative c' {
2610   \override Beam.grow-direction = #LEFT
2611   \featherDurations #(ly:make-moment 2/1)
2612   { c16[ c c c c c c c] }
2613   \override Beam.grow-direction = #RIGHT
2614   \featherDurations #(ly:make-moment 2/3)
2615   { c32[ d e f] }
2616   % revert to non-feathered beams
2617   \override Beam.grow-direction = #'()
2618   { g32[ a b c] }
2619 }
2620 @end lilypond
2621
2622 @noindent
2623 The spacing in the printed output represents the
2624 note durations only approximately, but the MIDI output is exact.
2625
2626 @predefined
2627 @code{\featherDurations}.
2628 @endpredefined
2629
2630 @seealso
2631 Snippets:
2632 @rlsr{Rhythms}.
2633
2634 @knownissues
2635 The @code{\featherDurations} command only works with very short
2636 music snippets, and when numbers in the fraction are small.
2637
2638
2639 @node Bars
2640 @subsection Bars
2641
2642 @menu
2643 * Bar lines::
2644 * Bar numbers::
2645 * Bar and bar number checks::
2646 * Rehearsal marks::
2647 @end menu
2648
2649 @node Bar lines
2650 @unnumberedsubsubsec Bar lines
2651
2652 @cindex bar lines
2653 @cindex measure lines
2654 @cindex closing bar lines
2655 @cindex bar lines, closing
2656 @cindex double bar lines
2657 @cindex bar lines, double
2658 @cindex repeat bars
2659
2660 @funindex \bar
2661
2662 Bar lines delimit measures, and are also used to indicate
2663 repeats.  Normally, simple bar lines are automatically inserted
2664 into the printed output at places based on the current time
2665 signature.
2666
2667 The simple bar lines inserted automatically can be changed to
2668 other types with the @code{\bar} command.  For example, a closing
2669 double bar line is usually placed at the end of a piece:
2670
2671 @lilypond[quote,verbatim]
2672 \relative { e'4 d c2 \bar "|." }
2673 @end lilypond
2674
2675 It is not invalid if the final note in a measure does not
2676 end on the automatically entered bar line: the note is assumed
2677 to carry over into the next measure.  But if a long sequence
2678 of such carry-over measures appears the music can appear compressed
2679 or even flowing off the page.  This is because automatic line
2680 breaks happen only at the end of complete measures, i.e., where
2681 all notes end before the end of a measure.
2682
2683 @warning{An incorrect duration can cause line breaks to be
2684 inhibited, leading to a line of highly compressed music or
2685 music that flows off the page.}
2686
2687 @cindex line breaks
2688 @cindex bar lines, invisible
2689 @cindex measure lines, invisible
2690
2691 Line breaks are also permitted at manually inserted bar lines
2692 even within incomplete measures.  To allow a line break without
2693 printing a bar line, use the following:
2694
2695 @example
2696 \bar ""
2697 @end example
2698
2699 @noindent
2700 This will insert an invisible bar line and allow (but not
2701 force) a line break to occur at this point.  The bar number
2702 counter is not increased.  To force a line break see
2703 @ref{Line breaking}.
2704
2705 @cindex manual bar lines
2706 @cindex manual measure lines
2707 @cindex bar lines, manual
2708 @cindex measure lines, manual
2709
2710 This and other special bar lines may be inserted manually at any
2711 point.  When they coincide with the end of a measure they replace
2712 the simple bar line which would have been inserted there
2713 automatically.  When they do not coincide with the end of a measure
2714 the specified bar line is inserted at that point in the printed
2715 output.
2716
2717 Note that manual bar lines are purely visual.  They do not affect
2718 any of the properties that a normal bar line would affect, such as
2719 measure numbers, accidentals, line breaks, etc.  They do not affect
2720 the calculation and placement of subsequent automatic bar lines.
2721 When a manual bar line is placed where a normal bar line already
2722 exists, the effects of the original bar line are not altered.
2723
2724 Two types of simple bar lines and five types of double bar lines are
2725 available for manual insertion:
2726
2727 @lilypond[quote,verbatim]
2728 \relative {
2729   f'1 \bar "|"
2730   f1 \bar "."
2731   g1 \bar "||"
2732   a1 \bar ".|"
2733   b1 \bar ".."
2734   c1 \bar "|.|"
2735   d1 \bar "|."
2736   e1
2737 }
2738 @end lilypond
2739
2740 @noindent
2741 together with dotted and dashed bar lines:
2742
2743 @lilypond[quote,verbatim]
2744 \relative {
2745   f'1 \bar ";"
2746   g1 \bar "!"
2747   a1
2748 }
2749 @end lilypond
2750
2751 @noindent
2752 and nine types of repeat bar lines:
2753
2754 @lilypond[quote,verbatim]
2755 \relative {
2756   f'1 \bar ".|:"
2757   g1 \bar ":..:"
2758   a1 \bar ":|.|:"
2759   b1 \bar ":|.:"
2760   c1 \bar ":.|.:"
2761   d1 \bar "[|:"
2762   e1 \bar ":|][|:"
2763   f1 \bar ":|]"
2764   g1 \bar ":|."
2765   a1
2766 }
2767 @end lilypond
2768
2769 Additionally, a bar line can be printed as a simple tick:
2770 @lilypond[quote,fragment,verbatim]
2771 f'1 \bar "'" g'1
2772 @end lilypond
2773 However, as such ticks are typically used in Gregorian chant, it is
2774 preferable to use @code{\divisioMinima} there instead, described in
2775 the section @ref{Divisiones} in Gregorian chant.
2776
2777 LilyPond supports kievan notation and provides a special kievan
2778 bar line:
2779 @lilypond[quote,fragment,verbatim]
2780 f'1 \bar "k"
2781 @end lilypond
2782 Further details of this notation are explained in
2783 @ref{Typesetting Kievan square notation}.
2784
2785 @cindex segno
2786
2787 For in-line segno signs, there are three types of bar lines which
2788 differ in their behavior at line breaks:
2789
2790 @lilypond[quote,verbatim]
2791 \relative c'' {
2792   c4 c c c
2793   \bar "S"
2794   c4 c c c \break
2795   \bar "S"
2796   c4 c c c
2797   \bar "S-|"
2798   c4 c c c \break
2799   \bar "S-|"
2800   c4 c c c
2801   \bar "S-S"
2802   c4 c c c \break
2803   \bar "S-S"
2804   c1
2805 }
2806 @end lilypond
2807
2808 @cindex repeats
2809
2810 Although the bar line types signifying repeats may be inserted
2811 manually they do not in themselves cause LilyPond to recognize
2812 a repeated section.  Such repeated sections are better entered
2813 using the various repeat commands (see @ref{Repeats}), which
2814 automatically print the appropriate bar lines.
2815
2816 In addition, you can specify @code{".|:-||"}, which is equivalent to
2817 @code{".|:"} except at line breaks, where it gives a double bar
2818 line at the end of the line and a start repeat at the beginning of
2819 the next line.
2820
2821 @lilypond[quote,verbatim]
2822 \relative c'' {
2823   c4 c c c
2824   \bar ".|:-||"
2825   c4 c c c \break
2826   \bar ".|:-||"
2827   c4 c c c
2828 }
2829 @end lilypond
2830
2831 For combinations of repeats with the segno sign, there are six different
2832 variations:
2833
2834 @lilypond[quote,verbatim]
2835 \relative c'' {
2836   c4 c c c
2837   \bar ":|.S"
2838   c4 c c c \break
2839   \bar ":|.S"
2840   c4 c c c
2841   \bar ":|.S-S"
2842   c4 c c c \break
2843   \bar ":|.S-S"
2844   c4 c c c
2845   \bar "S.|:-S"
2846   c4 c c c \break
2847   \bar "S.|:-S"
2848   c4 c c c
2849   \bar "S.|:"
2850   c4 c c c \break
2851   \bar "S.|:"
2852   c4 c c c
2853   \bar ":|.S.|:"
2854   c4 c c c \break
2855   \bar ":|.S.|:"
2856   c4 c c c
2857   \bar ":|.S.|:-S"
2858   c4 c c c \break
2859   \bar ":|.S.|:-S"
2860   c1
2861 }
2862 @end lilypond
2863
2864 Additionally there is an @code{\inStaffSegno} command which creates
2865 a segno bar line in conjunction with an appropriate repeat bar line
2866 when used with a @code{\repeat volta} command, see
2867 @ref{Normal repeats}.
2868
2869 @funindex \defineBarLine
2870 @cindex bar lines, defining
2871 @cindex defining bar lines
2872
2873 New bar line types can be defined with @code{\defineBarLine}:
2874
2875 @example
2876 \defineBarLine @var{bartype} #'(@var{end} @var{begin} @var{span})
2877 @end example
2878
2879 The @code{\defineBarline} variables can include the
2880 @q{empty} string @code{""}, which is equivalent to an invisible
2881 bar line being printed.  Or they can be set to @code{#f} which
2882 prints no bar line at all.
2883
2884 After the definiton, the new bar line can be used by
2885 @code{\bar} @var{bartype}.
2886
2887 There are currently ten bar line elements available:
2888
2889 @lilypond[quote,verbatim]
2890 \defineBarLine ":" #'("" ":" "")
2891 \defineBarLine "=" #'("=" "" "")
2892 \defineBarLine "[" #'("" "[" "")
2893 \defineBarLine "]" #'("]" "" "")
2894
2895 \new Staff {
2896   s1 \bar "|"
2897   s1 \bar "."
2898   s1 \bar "!"
2899   s1 \bar ";"
2900   s1 \bar ":"
2901   s1 \bar "k"
2902   s1 \bar "S"
2903   s1 \bar "="
2904   s1 \bar "["
2905   s1 \bar "]"
2906   s1 \bar ""
2907 }
2908 @end lilypond
2909
2910 The @code{"="} bar line provides the double span bar line, used
2911 in combination with the segno sign.  Do not use it as a standalone
2912 double thin bar line; here, @code{\bar} @var{"||"} is
2913 preferred.
2914
2915 The @code{"-"} sign starts annotations to bar lines which
2916 are useful to distinguish those with identical appearance
2917 but different behavior at line breaks and/or different span bars.
2918 The part following the @code{"-"} sign is not used for building up
2919 the bar line.
2920
2921 @lilypond[quote,verbatim]
2922 \defineBarLine "||-dashedSpan" #'("||" "" "!!")
2923
2924 \new StaffGroup <<
2925   \new Staff \relative c'' {
2926     c1 \bar "||"
2927     c1 \bar "||-dashedSpan"
2928     c1
2929   }
2930   \new Staff \relative c'' {
2931     c1
2932     c1
2933     c1
2934   }
2935 >>
2936 @end lilypond
2937
2938 Furthermore, the space character @code{" "} serves as a placeholder
2939 for defining span bars correctly aligned to the main bar lines:
2940
2941 @lilypond[quote,verbatim]
2942 \defineBarLine ":|.-wrong" #'(":|." "" "|.")
2943 \defineBarLine ":|.-right" #'(":|." "" " |.")
2944
2945 \new StaffGroup <<
2946   \new Staff \relative c'' {
2947     c1 \bar ":|.-wrong"
2948     c1 \bar ":|.-right"
2949     c1
2950   }
2951   \new Staff \relative c'' {
2952     c1
2953     c1
2954     c1
2955   }
2956 >>
2957 @end lilypond
2958
2959 If additional elements are needed, LilyPond provides a simple
2960 way to define them.  For more information on modifying or adding
2961 bar lines, see file @file{scm/bar-line.scm}.
2962
2963 In scores with many staves, a @code{\bar} command in one staff is
2964 automatically applied to all staves.  The resulting bar lines are
2965 connected between different staves of a @code{StaffGroup},
2966 @code{PianoStaff}, or @code{GrandStaff}.
2967
2968 @lilypond[quote,verbatim]
2969 <<
2970   \new StaffGroup <<
2971     \new Staff \relative {
2972       e'4 d
2973       \bar "||"
2974       f4 e
2975     }
2976     \new Staff \relative { \clef bass c'4 g e g }
2977   >>
2978   \new Staff \relative { \clef bass c'2 c2 }
2979 >>
2980 @end lilypond
2981
2982
2983 @cindex default bar lines, changing
2984 @cindex bar lines, default, changing
2985
2986 @funindex whichBar
2987 @funindex defaultBarType
2988 @funindex \bar
2989 @funindex bartype
2990
2991 The command @samp{\bar @var{bartype}} is a shortcut for
2992 @samp{\set Timing.whichBar = @var{bartype}}.  A bar line is
2993 created whenever the @code{whichBar} property is set.
2994
2995 The default bar type used for automatically inserted bar lines is
2996 @code{"|"}.  This may be changed at any time with
2997 @samp{\set Timing.defaultBarType = @var{bartype}}.
2998
2999 @seealso
3000 Notation Reference:
3001 @ref{Line breaking},
3002 @ref{Repeats},
3003 @ref{Grouping staves}.
3004
3005 Installed Files:
3006 @file{scm/bar-line.scm}.
3007
3008 Snippets:
3009 @rlsr{Rhythms}.
3010
3011 Internals Reference:
3012 @rinternals{BarLine} (created at @code{Staff} level),
3013 @rinternals{SpanBar} (across staves),
3014 @rinternals{Timing_translator} (for Timing properties).
3015
3016
3017 @node Bar numbers
3018 @unnumberedsubsubsec Bar numbers
3019
3020 @cindex bar numbers
3021 @cindex measure numbers
3022 @cindex numbers, bar
3023 @cindex numbers, measure
3024
3025 @funindex currentBarNumber
3026
3027 Bar numbers are typeset by default at the start of every line except
3028 the first line.  The number itself is stored in the
3029 @code{currentBarNumber} property, which is normally updated
3030 automatically for every measure.  It may also be set manually:
3031
3032 @lilypond[verbatim,quote]
3033 \relative c' {
3034   c1 c c c
3035   \break
3036   \set Score.currentBarNumber = #50
3037   c1 c c c
3038 }
3039 @end lilypond
3040
3041 @cindex bar numbers, regular spacing
3042
3043 @funindex barNumberVisibility
3044 @funindex BarNumber
3045
3046 Bar numbers can be typeset at regular intervals instead of just at the
3047 beginning of every line.  To do this the default behavior must be
3048 overridden to permit bar numbers to be printed at places other than the
3049 start of a line.  This is controlled by the @code{break-visibility}
3050 property of @code{BarNumber}.  This takes three values which may be set
3051 to @code{#t} or @code{#f} to specify whether the corresponding bar
3052 number is visible or not.  The order of the three values is
3053 @code{end of line visible}, @code{middle of line visible},
3054 @code{beginning of line visible}.  In the following example bar numbers
3055 are printed at all possible places:
3056
3057 @lilypond[verbatim,quote]
3058 \relative c' {
3059   \override Score.BarNumber.break-visibility = ##(#t #t #t)
3060   \set Score.currentBarNumber = #11
3061   % Permit first bar number to be printed
3062   \bar ""
3063   c1 | c | c | c |
3064   \break
3065   c1 | c | c | c |
3066 }
3067 @end lilypond
3068
3069 @snippets
3070 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
3071 {printing-the-bar-number-for-the-first-measure.ly}
3072
3073 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
3074 {printing-bar-numbers-at-regular-intervals.ly}
3075
3076 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
3077 {printing-bar-numbers-with-changing-regular-intervals.ly}
3078
3079 @cindex measure number, format
3080 @cindex bar number, format
3081
3082 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
3083 {printing-bar-numbers-inside-boxes-or-circles.ly}
3084
3085 @cindex bar numbers, with letters
3086 @cindex bar numbers, with repeats
3087
3088 @lilypondfile[verbatim,quote,texidoc,doctitle]
3089 {alternative-bar-numbering.ly}
3090
3091 @cindex bar number alignment
3092
3093 @lilypondfile[verbatim,quote,texidoc,doctitle]
3094 {aligning-bar-numbers.ly}
3095
3096 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
3097 {removing-bar-numbers-from-a-score.ly}
3098
3099 @seealso
3100 Snippets:
3101 @rlsr{Rhythms}.
3102
3103 Internals Reference:
3104 @rinternals{BarNumber},
3105 @rinternals{Bar_number_engraver}.
3106
3107 @cindex bar number collision
3108 @cindex collision, bar number
3109
3110 @knownissues
3111 Bar numbers may collide with the top of the @code{StaffGroup} bracket,
3112 if there is one.  To solve this, the @code{padding} property of
3113 @code{BarNumber} can be used to position the number correctly.  See
3114 @rinternals{StaffGroup} and @rinternals{BarNumber} for more.
3115
3116
3117 @node Bar and bar number checks
3118 @unnumberedsubsubsec Bar and bar number checks
3119
3120 @cindex bar check
3121 @cindex bar number check
3122 @cindex measure check
3123 @cindex measure number check
3124
3125 @funindex barCheckSynchronize
3126 @funindex |
3127
3128 Bar checks help detect errors in the entered durations.  A bar check
3129 may be entered using the bar symbol, @code{|}, at any place where a
3130 bar line is expected to fall.  If bar check lines are encountered at
3131 other places, a list of warnings is printed in the log file, showing
3132 the line numbers and lines in which the bar checks failed.  In the
3133 next example, the second bar check will signal an error.
3134
3135 @example
3136 \time 3/4 c2 e4 | g2 |
3137 @end example
3138
3139 An incorrect duration can result in a completely garbled score,
3140 especially if the score is polyphonic, so a good place to start
3141 correcting input is by scanning for failed bar checks and
3142 incorrect durations.
3143
3144 If successive bar checks are off by the same musical interval,
3145 only the first warning message is displayed.  This allows the
3146 warning to focus on the source of the timing error.
3147
3148 Bar checks can also be inserted in lyrics:
3149
3150 @example
3151 \lyricmode @{
3152   \time 2/4
3153   Twin -- kle | Twin -- kle |
3154 @}
3155 @end example
3156
3157 Note that bar check marks in lyrics are evaluated at the musical
3158 moment when the syllable @emph{following} the check mark is processed.
3159 If the lyrics are associated with the notes of a voice which has a
3160 rest at the beginning of a bar, then no syllable can be located at the
3161 start of that bar and a warning will be issued if a bar check mark is
3162 placed in the lyrics at that position.
3163
3164
3165 @funindex |
3166 @funindex "|"
3167
3168 It is also possible to redefine the action taken when a bar check
3169 or pipe symbol, @code{|}, is encountered in the input, so that
3170 it does something other than a bar check.  This is done by
3171 assigning a music expression to @code{"|"}.
3172 In the following example @code{|} is set to insert a double bar
3173 line wherever it appears in the input, rather than checking
3174 for end of bar.
3175
3176 @lilypond[quote,verbatim]
3177 "|" = \bar "||"
3178 {
3179   c'2 c' |
3180   c'2 c'
3181   c'2 | c'
3182   c'2 c'
3183 }
3184 @end lilypond
3185
3186 @funindex \barNumberCheck
3187
3188 When copying large pieces of music, it can be helpful to check that
3189 the LilyPond bar number corresponds to the original that you are
3190 entering from.  This can be checked with @code{\barNumberCheck}, for
3191 example,
3192
3193 @verbatim
3194 \barNumberCheck #123
3195 @end verbatim
3196
3197 @noindent
3198 will print a warning if the @code{currentBarNumber} is not 123
3199 when it is processed.
3200
3201 @seealso
3202 Snippets:
3203 @rlsr{Rhythms}.
3204
3205
3206 @node Rehearsal marks
3207 @unnumberedsubsubsec Rehearsal marks
3208
3209 @cindex rehearsal marks
3210 @cindex mark, rehearsal
3211
3212 @funindex \mark
3213
3214 To print a rehearsal mark, use the @code{\mark} command.
3215
3216 @lilypond[quote,verbatim]
3217 \relative c'' {
3218   c1 \mark \default
3219   c1 \mark \default
3220   c1 \mark \default
3221   c1 \mark \default
3222 }
3223 @end lilypond
3224
3225 @noindent
3226 The mark is incremented automatically if you use @code{\mark
3227 \default}, but you can also use an integer argument to set the
3228 mark manually.  The value to use is stored in the property
3229 @code{rehearsalMark}.
3230
3231 @lilypond[quote,verbatim]
3232 \relative c'' {
3233   c1 \mark \default
3234   c1 \mark \default
3235   c1 \mark #8
3236   c1 \mark \default
3237   c1 \mark \default
3238 }
3239 @end lilypond
3240
3241 @noindent
3242 The letter@tie{}@q{I} is skipped in accordance with engraving
3243 traditions.  If you wish to include the letter @q{I}, then use one
3244 of the following commands, depending on which style of rehearsal mark
3245 you want (letters only, letters in a hollow box, or letters in a
3246 hollow circle).
3247
3248 @example
3249 \set Score.markFormatter = #format-mark-alphabet
3250 \set Score.markFormatter = #format-mark-box-alphabet
3251 \set Score.markFormatter = #format-mark-circle-alphabet
3252 @end example
3253
3254 @lilypond[quote,verbatim]
3255 \relative c'' {
3256   \set Score.markFormatter = #format-mark-box-alphabet
3257   c1 \mark \default
3258   c1 \mark \default
3259   c1 \mark #8
3260   c1 \mark \default
3261   c1 \mark \default
3262 }
3263 @end lilypond
3264
3265 @cindex rehearsal mark format
3266 @cindex rehearsal mark style
3267 @cindex style, rehearsal mark
3268 @cindex format, rehearsal mark
3269 @cindex mark, rehearsal, style
3270 @cindex mark, rehearsal, format
3271 @cindex rehearsal mark, manual
3272 @cindex mark, rehearsal, manual
3273 @cindex custom rehearsal mark
3274 @cindex manual rehearsal mark
3275
3276 The style is defined by the property @code{markFormatter}.  It is
3277 a function taking the current mark (an integer) and the current
3278 context as argument.  It should return a markup object.  In the
3279 following example, @code{markFormatter} is set to a pre-defined
3280 procedure.  After a few measures, it is set to a procedure that
3281 produces a boxed number.
3282
3283 @lilypond[quote,verbatim]
3284 \relative c'' {
3285   \set Score.markFormatter = #format-mark-numbers
3286   c1 \mark \default
3287   c1 \mark \default
3288   \set Score.markFormatter = #format-mark-box-numbers
3289   c1 \mark \default
3290   \set Score.markFormatter = #format-mark-circle-numbers
3291   c1 \mark \default
3292   \set Score.markFormatter = #format-mark-circle-letters
3293   c1
3294 }
3295 @end lilypond
3296
3297 The file @file{scm/translation-functions.scm} contains the
3298 definitions of @code{format-mark-letters} (the default format),
3299 @code{format-mark-box-letters}, @code{format-mark-numbers} and
3300 @code{format-mark-box-numbers}.  These can be used as inspiration
3301 for other formatting functions.
3302
3303 You may use @code{format-mark-barnumbers},
3304 @code{format-mark-box-barnumbers}, and
3305 @code{format-mark-circle-barnumbers} to get bar numbers instead of
3306 incremented numbers or letters.
3307
3308 Other styles of rehearsal mark can be specified manually:
3309
3310 @example
3311 \mark "A1"
3312 @end example
3313
3314 @noindent
3315 Note that @code{Score.markFormatter} does not affect marks specified
3316 in this manner.  However, it is possible to apply a @code{\markup} to the
3317 string.
3318
3319 @example
3320 \mark \markup@{ \box A1 @}
3321 @end example
3322
3323 @cindex segno
3324 @cindex coda
3325 @cindex D.S. al Fine
3326 @cindex fermata
3327 @cindex music glyphs
3328 @cindex glyphs, music
3329
3330 @funindex \musicglyph
3331
3332 Music glyphs (such as the segno sign) may be printed inside a
3333 @code{\mark}
3334
3335 @lilypond[quote,verbatim]
3336 \relative c' {
3337   c1 \mark \markup { \musicglyph #"scripts.segno" }
3338   c1 \mark \markup { \musicglyph #"scripts.coda" }
3339   c1 \mark \markup { \musicglyph #"scripts.ufermata" }
3340   c1
3341 }
3342 @end lilypond
3343
3344 @noindent
3345 See @ref{The Feta font}, for a list of symbols which may be
3346 printed with @code{\musicglyph}.
3347
3348 For common tweaks to the positioning of rehearsal marks, see
3349 @ref{Formatting text}.  For more precise control, see
3350 @code{break-alignable-interface} in @ref{Aligning objects}.
3351
3352 The file @file{scm/translation-functions.scm} contains
3353 the definitions of @code{format-mark-numbers} and
3354 @code{format-mark-letters}.  They can be used as inspiration for
3355 other formatting functions.
3356
3357 @seealso
3358 Notation Reference:
3359 @ref{The Feta font},
3360 @ref{Formatting text},
3361 @ref{Aligning objects}.
3362
3363 Installed Files:
3364 @file{scm/translation-functions.scm}.
3365
3366 Snippets:
3367 @rlsr{Rhythms}.
3368
3369 Internals Reference:
3370 @rinternals{MarkEvent},
3371 @rinternals{Mark_engraver},
3372 @rinternals{RehearsalMark}.
3373
3374
3375 @node Special rhythmic concerns
3376 @subsection Special rhythmic concerns
3377
3378
3379 @menu
3380 * Grace notes::
3381 * Aligning to cadenzas::
3382 * Time administration::
3383 @end menu
3384
3385 @node Grace notes
3386 @unnumberedsubsubsec Grace notes
3387
3388 @cindex ornaments
3389 @cindex grace notes
3390 @cindex appoggiatura
3391 @cindex acciaccatura
3392
3393 @funindex \grace
3394 @funindex \slashedGrace
3395 @funindex \acciaccatura
3396 @funindex \appoggiatura
3397
3398 Grace notes are musical ornaments, printed in a smaller font, that take
3399 up no additional logical time in a measure.
3400
3401 @lilypond[quote,verbatim]
3402 \relative {
3403   c''4 \grace b16 a4(
3404   \grace { b16 c16 } a2)
3405 }
3406 @end lilypond
3407
3408 There are three other types of grace notes possible; the
3409 @emph{acciaccatura} -- an unmeasured grace note indicated by a slurred
3410 note with a slashed stem -- and the @emph{appoggiatura}, which takes a
3411 fixed fraction of the main note it is attached to and prints without the
3412 slash.  It is also possible to write a grace note with a slashed stem,
3413 like the @emph{acciaccatura} but without the slur, so as to place it
3414 between notes that are slurred themselves, using the
3415 @code{\slashedGrace} function.
3416
3417 @lilypond[quote,verbatim]
3418 \relative {
3419   \acciaccatura d''8 c4
3420   \appoggiatura e8 d4
3421   \acciaccatura { g16 f } e2
3422   \slashedGrace a,8 g4
3423   \slashedGrace b16 a4(
3424   \slashedGrace b8 a2)
3425 }
3426 @end lilypond
3427
3428 The placement of grace notes is synchronized between different staves.
3429 In the following example, there are two sixteenth grace notes for every
3430 eighth grace note
3431
3432 @lilypond[quote,verbatim]
3433 <<
3434   \new Staff \relative { e''2 \grace { c16 d e f } e2 }
3435   \new Staff \relative { c''2 \grace { g8 b } c2 }
3436 >>
3437 @end lilypond
3438
3439 @cindex grace notes, following
3440
3441 @funindex \afterGrace
3442
3443 If you want to end a note with a grace, use the @code{\afterGrace}
3444 command.  It takes two arguments: the main note, and the grace
3445 notes following the main note.
3446
3447 @lilypond[quote,verbatim]
3448 \relative { c''1 \afterGrace d1 { c16[ d] } c1 }
3449 @end lilypond
3450
3451 This will place the grace notes @emph{after} the start of the main
3452 note.  The point of time where the grace notes are placed is a
3453 given fraction of the main note's duration.  The default setting
3454 of
3455
3456 @example
3457 afterGraceFraction = 3/4
3458 @end example
3459
3460 @noindent
3461 may be redefined at top level.  Individual @code{\afterGrace}
3462 commands may have the fraction specified right after the command
3463 itself instead.
3464
3465 The following example shows the results from setting with the
3466 default space, setting it at @code{15/16}, and finally at
3467 @code{1/2} of the main note.
3468
3469 @lilypond[quote,verbatim]
3470 <<
3471   \new Staff \relative {
3472     c''1 \afterGrace d1 { c16[ d] } c1
3473   }
3474   \new Staff \relative {
3475     c''1 \afterGrace 15/16 d1 { c16[ d] } c1
3476   }
3477   \new Staff \relative {
3478     c''1 \afterGrace 1/2 d1 { c16[ d] } c1
3479   }
3480 >>
3481 @end lilypond
3482
3483 The effect of @code{\afterGrace} can also be achieved using
3484 spacers.  The following example places the grace note after a
3485 space lasting 7/8 of the main note.
3486
3487 @lilypond[quote,verbatim]
3488 \new Voice \relative {
3489   <<
3490     { d''1^\trill_( }
3491     { s2 s4. \grace { c16 d } }
3492   >>
3493   c1)
3494 }
3495 @end lilypond
3496
3497 @cindex tweaking grace notes
3498 @cindex grace notes, tweaking
3499 @cindex grace notes, changing layout settings
3500
3501 A @code{\grace} music expression will introduce special
3502 typesetting settings, for example, to produce smaller type, and
3503 set directions.  Hence, when introducing layout tweaks to
3504 override the special settings, they should be placed inside
3505 the grace expression.  The overrides should also be reverted
3506 inside the grace expression.  Here, the grace note's default stem
3507 direction is overridden and then reverted.
3508
3509 @lilypond[quote,verbatim]
3510 \new Voice \relative {
3511   \acciaccatura {
3512     \stemDown
3513     f''16->
3514     \stemNeutral
3515   }
3516   g4 e c2
3517 }
3518 @end lilypond
3519
3520
3521 @cindex stem, with slash
3522
3523
3524 @snippets
3525
3526 @lilypondfile[verbatim,quote,texidoc,doctitle]
3527 {using-grace-note-slashes-with-normal-heads.ly}
3528
3529 @lilypondfile[verbatim,quote,texidoc,doctitle]
3530 {tweaking-grace-layout-within-music.ly}
3531
3532 @lilypondfile[verbatim,quote,texidoc,doctitle]
3533 {redefining-grace-note-global-defaults.ly}
3534
3535 @lilypondfile[verbatim,quote,texidoc,doctitle]
3536 {positioning-grace-notes-with-floating-space.ly}
3537
3538 @seealso
3539 Music Glossary:
3540 @rglos{grace notes},
3541 @rglos{acciaccatura},
3542 @rglos{appoggiatura}.
3543
3544 Notation Reference:
3545 @ref{Scaling durations},
3546 @ref{Manual beams}.
3547
3548 Installed Files:
3549 @file{ly/grace-init.ly}.
3550
3551 Snippets:
3552 @rlsr{Rhythms}.
3553
3554 Internals Reference:
3555 @rinternals{GraceMusic},
3556 @rinternals{Grace_beam_engraver},
3557 @rinternals{Grace_auto_beam_engraver},
3558 @rinternals{Grace_engraver},
3559 @rinternals{Grace_spacing_engraver}.
3560
3561
3562 @knownissues
3563 @cindex acciaccatura, multi-note
3564 @cindex multi-note acciaccatura
3565 @cindex grace-note synchronization
3566
3567 A multi-note beamed @i{acciaccatura} is printed without a slash,
3568 and looks exactly the same as a multi-note beamed
3569 @i{appoggiatura}.
3570
3571 @c TODO Add link to LSR snippet to add slash when available
3572
3573 Grace note synchronization can also lead to surprises.  Staff
3574 notation, such as key signatures, bar lines, etc., are also
3575 synchronized.  Take care when you mix staves with grace notes and
3576 staves without, for example,
3577
3578 @lilypond[quote,verbatim]
3579 <<
3580   \new Staff \relative { e''4 \bar ".|:" \grace c16 d2. }
3581   \new Staff \relative { c''4 \bar ".|:" d2. }
3582 >>
3583 @end lilypond
3584
3585 @noindent
3586 This can be remedied by inserting grace skips of the corresponding
3587 durations in the other staves.  For the above example
3588
3589 @lilypond[quote,verbatim]
3590 <<
3591   \new Staff \relative { e''4 \bar ".|:" \grace c16 d2. }
3592   \new Staff \relative { c''4 \bar ".|:" \grace s16 d2. }
3593 >>
3594 @end lilypond
3595
3596 Please make sure that you use the @code{\grace} command for the
3597 spacer part, even if the visual part uses @code{\acciaccatura} or
3598 @code{\appoggiatura} because otherwise an ugly slur fragment will
3599 be printed, connecting the invisible grace note with the following
3600 note.
3601
3602 Grace sections should only be used within sequential music expressions.
3603 Nesting or juxtaposing grace sections is not supported, and might
3604 produce crashes or other errors.
3605
3606 Each grace note in MIDI output has a length of 1/4 of its actual
3607 duration.  If the combined length of the grace notes is greater than the
3608 length of the preceding note a @qq{@code{Going back in MIDI time}}
3609 error will be generated.  Either make the grace notes shorter in
3610 duration, for example:
3611
3612 @example
3613 c'8 \acciaccatura @{ c'8[ d' e' f' g'] @}
3614 @end example
3615
3616 becomes:
3617
3618 @example
3619 c'8 \acciaccatura @{ c'16[ d' e' f' g'] @}
3620 @end example
3621
3622 Or explicitly change the musical duration:
3623
3624 @example
3625 c'8 \acciaccatura @{ \scaleDurations 1/2 @{ c'8[ d' e' f' g'] @} @}
3626 @end example
3627
3628 See @ref{Scaling durations}.
3629
3630
3631 @node Aligning to cadenzas
3632 @unnumberedsubsubsec Aligning to cadenzas
3633
3634 @cindex cadenza
3635 @cindex cadenza, aligning to
3636 @cindex aligning to cadenza
3637
3638 In an orchestral context, cadenzas present a special problem: when
3639 constructing a score that includes a measured cadenza or other solo
3640 passage, all other instruments should skip just as many notes as the
3641 length of the cadenza, otherwise they will start too soon or too late.
3642
3643 One solution to this problem is to use the functions
3644 @code{mmrest-of-length} and @code{skip-of-length}.  These Scheme
3645 functions take a defined piece of music as an argument and generate a
3646 multi-measure rest or @code{\skip} exactly as long as the piece.
3647
3648 @lilypond[verbatim,quote]
3649 MyCadenza = \relative {
3650   c'4 d8 e f g g4
3651   f2 g4 g
3652 }
3653
3654 \new GrandStaff <<
3655   \new Staff {
3656     \MyCadenza c'1
3657     \MyCadenza c'1
3658   }
3659   \new Staff {
3660     #(mmrest-of-length MyCadenza)
3661     c'1
3662     #(skip-of-length MyCadenza)
3663     c'1
3664   }
3665 >>
3666 @end lilypond
3667
3668 @seealso
3669 Music Glossary:
3670 @rglos{cadenza}.
3671
3672 Snippets:
3673 @rlsr{Rhythms}.
3674
3675
3676 @node Time administration
3677 @unnumberedsubsubsec Time administration
3678
3679 @cindex time administration
3680 @cindex timing (within the score)
3681 @cindex music, unmetered
3682 @cindex unmetered music
3683
3684 @funindex currentBarNumber
3685 @funindex measurePosition
3686 @funindex measureLength
3687
3688 Time is administered by the @code{Timing_translator}, which by
3689 default is to be found in the @code{Score} context.  An alias,
3690 @code{Timing}, is added to the context in which the
3691 @code{Timing_translator} is placed.  To ensure that the
3692 @code{Timing} alias is available, you may need to explicitly
3693 instantiate the containing context (such as @code{Voice} or
3694 @code{Staff}).
3695
3696 The following properties of @code{Timing} are used
3697 to keep track of timing within the score.
3698
3699 @cindex bar number
3700 @cindex measure number
3701
3702 @table @code
3703 @item currentBarNumber
3704 The current measure number.  For an example showing the
3705 use of this property see @ref{Bar numbers}.
3706
3707 @item measureLength
3708 The length of the measures in the current time signature.  For a
3709 4/4 time this is@tie{}1, and for 6/8 it is 3/4.  Its value
3710 determines when bar lines are inserted and how automatic beams
3711 should be generated.
3712
3713 @item measurePosition
3714 The point within the measure where we currently are.  This
3715 quantity is reset by subtracting @code{measureLength} whenever
3716 @code{measureLength} is reached or exceeded.  When that happens,
3717 @code{currentBarNumber} is incremented.
3718
3719 @item timing
3720 If set to true, the above variables are updated for every time
3721 step.  When set to false, the engraver stays in the current
3722 measure indefinitely.
3723
3724 @end table
3725
3726 Timing can be changed by setting any of these variables
3727 explicitly.  In the next example, the default 4/4 time
3728 signature is printed, but @code{measureLength} is set to 5/4.
3729 At 4/8 through the third measure, the @code{measurePosition} is
3730 advanced by 1/8 to 5/8, shortening that bar by 1/8.
3731 The next bar line then falls at 9/8 rather than 5/4.
3732
3733 @lilypond[quote,verbatim]
3734 \new Voice \relative {
3735   \set Timing.measureLength = #(ly:make-moment 5/4)
3736   c'1 c4 |
3737   c1 c4 |
3738   c4 c
3739   \set Timing.measurePosition = #(ly:make-moment 5/8)
3740   b4 b b8 |
3741   c4 c1 |
3742 }
3743 @end lilypond
3744
3745 @noindent
3746 As the example illustrates, @code{ly:make-moment n/m} constructs a
3747 duration of n/m of a whole note.  For example,
3748 @code{ly:make-moment 1/8} is an eighth note duration and
3749 @code{ly:make-moment 7/16} is the duration of seven sixteenths
3750 notes.
3751
3752 @seealso
3753 Notation Reference:
3754 @ref{Bar numbers},
3755 @ref{Unmetered music}.
3756
3757 Snippets:
3758 @rlsr{Rhythms}.
3759
3760 Internals Reference:
3761 @rinternals{Timing_translator},
3762 @rinternals{Score}.