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