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