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