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