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