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