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