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