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