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