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