]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/notation/rhythms.itely
Fixed errors in Catalan translation
[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.30"
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   \omit Staff.TimeSignature
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
1145 @cindex time signature properties, restoring default values
1146 @cindex restoring default properties for time signatures
1147 @funindex \revertTimeSignatureSettings
1148
1149 Changed values of default time signature properties can be restored
1150 to the original values:
1151
1152 @lilypond[quote,verbatim]
1153 \score{
1154   \relative c' {
1155     \repeat unfold 8 { c8 } |
1156     \overrideTimeSignatureSettings
1157       4/4        % timeSignatureFraction
1158       1/4        % baseMomentFraction
1159       #'(3 1)    % beatStructure
1160       #'()       % beamExceptions
1161     \time 4/4
1162     \repeat unfold 8 { c8 } |
1163     \revertTimeSignatureSettings 4/4
1164     \time 4/4
1165     \repeat unfold 8 { c8 } |
1166   }
1167 }
1168 @end lilypond
1169
1170 Different values of default time signature properties can be established
1171 for different staves by moving the @code{Timing_translator} and the
1172 @code{Default_bar_line_engraver} from the @code{Score} context to the
1173 @code{Staff} context.
1174
1175 @lilypond[quote, verbatim]
1176 \score {
1177   \new StaffGroup <<
1178      \new Staff {
1179         \overrideTimeSignatureSettings
1180           4/4        % timeSignatureFraction
1181           1/4        % baseMomentFraction
1182           #'(3 1)    % beatStructure
1183           #'()       % beamExceptions
1184         \time 4/4
1185         \repeat unfold 8 {c''8}
1186      }
1187      \new Staff {
1188         \overrideTimeSignatureSettings
1189           4/4        % timeSignatureFraction
1190           1/4        % baseMomentFraction
1191           #'(1 3)    % beatStructure
1192           #'()       % beamExceptions
1193         \time 4/4
1194         \repeat unfold 8 {c''8}
1195      }
1196   >>
1197   \layout {
1198     \context {
1199       \Score
1200       \remove "Timing_translator"
1201       \remove "Default_bar_line_engraver"
1202     }
1203     \context {
1204       \Staff
1205       \consists "Timing_translator"
1206       \consists "Default_bar_line_engraver"
1207     }
1208   }
1209 }
1210 @end lilypond
1211
1212 A further method of changing these time-signature-related variables,
1213 which avoids reprinting the time signature at the time of the change,
1214 is shown in @ref{Setting automatic beam behavior}.
1215
1216 @predefined
1217 @code{\numericTimeSignature},
1218 @code{\defaultTimeSignature}.
1219 @endpredefined
1220
1221
1222 @snippets
1223 @lilypondfile[verbatim,quote,texidoc,doctitle]
1224 {time-signature-printing-only-the-numerator-as-a-number-instead-of-the-fraction.ly}
1225
1226 @seealso
1227 Music Glossary:
1228 @rglos{time signature}
1229
1230 Notation Reference:
1231 @ref{Mensural time signatures},
1232 @ref{Setting automatic beam behavior},
1233 @ref{Time administration}.
1234
1235 Installed Files:
1236 @file{scm/time-signature-settings.scm}.
1237
1238 Snippets:
1239 @rlsr{Rhythms}.
1240
1241 Internals Reference:
1242 @rinternals{TimeSignature},
1243 @rinternals{Timing_translator}.
1244
1245
1246 @node Metronome marks
1247 @unnumberedsubsubsec Metronome marks
1248
1249 @cindex tempo
1250 @cindex beats per minute
1251 @cindex metronome mark
1252 @cindex metronome marking with text
1253
1254 @funindex \tempo
1255 @funindex tempo
1256
1257 A basic metronome mark is simple to write:
1258
1259 @lilypond[verbatim,quote,relative=1]
1260 \tempo 4 = 120
1261 c2 d
1262 e4. d8 c2
1263 @end lilypond
1264
1265 Metronome marks may also be printed as a range of two numbers:
1266
1267 @lilypond[verbatim,quote,relative=1]
1268 \tempo 4 = 40 - 46
1269 c4. e8 a4 g
1270 b,2 d4 r
1271 @end lilypond
1272
1273 Tempo indications with text can be used instead:
1274
1275 @lilypond[verbatim,quote,relative=2]
1276 \tempo "Allegretto"
1277 c4 e d c
1278 b4. a16 b c4 r4
1279 @end lilypond
1280
1281 Combining a metronome mark and text will automatically place the
1282 metronome mark within parentheses:
1283
1284 @lilypond[verbatim,quote,relative=2]
1285 \tempo "Allegro" 4 = 160
1286 g4 c d e
1287 d4 b g2
1288 @end lilypond
1289
1290 In general, the text can be any markup object:
1291
1292 @lilypond[verbatim,quote,relative=2]
1293 \tempo \markup { \italic Faster } 4 = 132
1294 a8-. r8 b-. r gis-. r a-. r
1295 @end lilypond
1296
1297 A parenthesized metronome mark with no textual indication may be
1298 written by including an empty string in the input:
1299
1300 @lilypond[verbatim,quote,relative=2]
1301 \tempo "" 8 = 96
1302 d4 g e c
1303 @end lilypond
1304
1305 @funindex \markLengthOn
1306 @funindex markLengthOn
1307 @funindex \markLengthOff
1308 @funindex markLengthOff
1309
1310 In a part for an instrument with long periods of rests,
1311 tempo indications sometimes follow each other closely.
1312 The command @code{\markLengthOn} provides extra horizontal space
1313 to prevent tempo indications from overlapping, and @code{\markLengthOff}
1314 restores the default behavior of ignoring tempo marks
1315 for horizontal spacing.
1316
1317 @lilypond[verbatim,quote,relative=0]
1318 \compressFullBarRests
1319 \markLengthOn
1320 \tempo "Molto vivace"
1321 R1*12
1322 \tempo "Meno mosso"
1323 R1*16
1324 \markLengthOff
1325 \tempo "Tranquillo"
1326 R1*20
1327 @end lilypond
1328
1329 @snippets
1330
1331 @lilypondfile[verbatim,quote,texidoc,doctitle]
1332 {printing-metronome-and-rehearsal-marks-below-the-staff.ly}
1333
1334 @c perhaps also an example of how to move it horizontally?
1335
1336 @lilypondfile[verbatim,quote,texidoc,doctitle]
1337 {changing-the-tempo-without-a-metronome-mark.ly}
1338
1339 @lilypondfile[verbatim,quote,texidoc,doctitle]
1340 {creating-metronome-marks-in-markup-mode.ly}
1341
1342 For more details, see @ref{Formatting text}.
1343
1344 @seealso
1345 Music Glossary:
1346 @rglos{metronome},
1347 @rglos{metronomic indication},
1348 @rglos{tempo indication},
1349 @rglos{metronome mark}.
1350
1351 Notation Reference:
1352 @ref{Formatting text},
1353 @ref{MIDI output}.
1354
1355 Snippets:
1356 @rlsr{Staff notation}.
1357
1358 Internals Reference:
1359 @rinternals{MetronomeMark}.
1360
1361
1362 @node Upbeats
1363 @unnumberedsubsubsec Upbeats
1364
1365 @cindex anacrusis
1366 @cindex upbeat
1367 @cindex partial measure
1368 @cindex measure, partial
1369 @cindex measure, pickup
1370 @cindex pickup measure
1371
1372 @funindex measurePosition
1373 @funindex \partial
1374 @funindex partial
1375
1376 Partial or pick-up measures, such as an @emph{anacrusis} or an
1377 @emph{upbeat}, are entered using the @code{\partial} command,
1378
1379 @example
1380 \partial @var{duration}
1381 @end example
1382
1383 @noindent
1384 where @code{@var{duration}} is the @emph{remaining} length of the
1385 partial measure @emph{before} the start of the next full measure.
1386
1387 @lilypond[quote,verbatim,relative=1]
1388 \time 3/4
1389 \partial 8
1390 e8 | a4 c8 b c4 |
1391 @end lilypond
1392
1393 The @var{duration} can be any value less than a full measure:
1394
1395 @lilypond[quote,verbatim,relative=1]
1396 \time 3/4
1397 \partial 4.
1398 r4 e8 | a4 c8 b c4 |
1399 @end lilypond
1400
1401 @code{\partial @var{duration}} can also be written as:
1402
1403 @example
1404 \set Timing.measurePosition -@var{duration}
1405 @end example
1406
1407 So the first example above could be written:
1408
1409 @lilypond[quote,verbatim,relative=1]
1410 \time 3/4
1411 \set Timing.measurePosition = #(ly:make-moment -1/8)
1412 e8 | a4 c8 b c4 |
1413 @end lilypond
1414
1415 The property @code{measurePosition} contains a rational number, which
1416 is usually positive and indicates how much of the measure has passed
1417 at this point.  The @code{\partial @var{duration}} command sets it to
1418 a negative number, when it has a different meaning: it then says that
1419 the current (first) bar will be @emph{preceded} by a bar 0 (the partial
1420 bar) with a duration given by @var{duration}.
1421
1422 @seealso
1423 Music Glossary:
1424 @rglos{anacrusis}.
1425
1426 Notation Reference:
1427 @ref{Grace notes}.
1428
1429 Snippets:
1430 @rlsr{Rhythms}.
1431
1432 Internal Reference:
1433 @rinternals{Timing_translator}.
1434
1435 @knownissues
1436 The @code{\partial} command should be used only at the beginning of a
1437 piece.  If you use it after the beginning, warnings or problems may
1438 occur, so use @code{\set Timing.measurePosition} instead.
1439
1440 @lilypond[quote,verbatim,relative=1]
1441 \time 6/8
1442 \partial 8
1443 e8 | a4 c8 b[ c b] |
1444 \set Timing.measurePosition = #(ly:make-moment -1/4)
1445 r8 e,8 | a4 c8 b[ c b] |
1446 @end lilypond
1447
1448
1449 @node Unmetered music
1450 @unnumberedsubsubsec Unmetered music
1451
1452 @cindex cadenza
1453 @cindex cadenza, beams
1454 @cindex cadenza, accidentals
1455 @cindex cadenza, bar lines
1456 @cindex cadenza, bar numbers
1457 @cindex unmetered music
1458 @cindex unmetered music, beams
1459 @cindex unmetered music, accidentals
1460 @cindex unmetered music, bar lines
1461 @cindex unmetered music, bar numbers
1462 @cindex accidentals, cadenzas
1463 @cindex accidentals, unmetered music
1464 @cindex bar lines, cadenzas
1465 @cindex bar lines, unmetered music
1466 @cindex bar numbers, cadenzas
1467 @cindex bar numbers, unmetered music
1468 @cindex beams, cadenzas
1469 @cindex beams, unmetered music
1470
1471 @funindex \cadenzaOn
1472 @funindex cadenzaOn
1473 @funindex \cadenzaOff
1474 @funindex cadenzaOff
1475
1476 In metered music bar lines are inserted and bar numbers are calculated
1477 automatically. In unmetered music (i.e. cadenzas), this is not
1478 desirable and can be @q{switched off} using the command
1479 @code{\cadenzaOn}, then @q{switched back on} at the appropriate place
1480 using @code{\cadenzaOff}.
1481
1482 @lilypond[verbatim,relative=2,quote]
1483 c4 d e d
1484 \cadenzaOn
1485 c4 c d8[ d d] f4 g4.
1486 \cadenzaOff
1487 \bar "|"
1488 d4 e d c
1489 @end lilypond
1490
1491 Bar numbering is resumed at the end of the cadenza.
1492
1493 @lilypond[verbatim,relative=2,quote]
1494 % Show all bar numbers
1495 \override Score.BarNumber.break-visibility = #all-visible
1496 c4 d e d
1497 \cadenzaOn
1498 c4 c d8[ d d] f4 g4.
1499 \cadenzaOff
1500 \bar "|"
1501 d4 e d c
1502 @end lilypond
1503
1504 Inserting a @code{\bar} command within a cadenza does not start a new
1505 measure, even if a bar line is printed.  So any accidentals -- which
1506 are usually assumed to remain in force until the end of the measure --
1507 will still be valid after the bar line printed by @code{\bar}.  If
1508 subsequent accidentals should be printed, forced accidentals or
1509 reminder accidentals need to be inserted manually, see
1510 @ref{Accidentals}.
1511
1512 @lilypond[verbatim,relative=2,quote]
1513 c4 d e d
1514 \cadenzaOn
1515 cis4 d cis d
1516 \bar "|"
1517 % First cis is printed without alteration even if it's after a \bar
1518 cis4 d cis! d
1519 \cadenzaOff
1520 \bar "|"
1521 @end lilypond
1522
1523 Automatic beaming is disabled by @code{\cadenzaOn}. Therefore, all
1524 beaming in cadenzas must be entered manually. See @ref{Manual beams}.
1525
1526 @lilypond[verbatim,relative=2,quote]
1527 \repeat unfold 8 { c8 }
1528 \cadenzaOn
1529 cis8 c c c c
1530 \bar"|"
1531 c8 c c
1532 \cadenzaOff
1533 \repeat unfold 8 { c8 }
1534 @end lilypond
1535
1536 These predefined commands affect all staves in the score, even when
1537 placed in just one @code{Voice} context.  To change this, move the
1538 @code{Timing_translator} from the @code{Score} context to the
1539 @code{Staff} context.  See @ref{Polymetric notation}.
1540
1541 @predefined
1542 @code{\cadenzaOn},
1543 @code{\cadenzaOff}.
1544 @endpredefined
1545
1546 @seealso
1547 Music Glossary:
1548 @rglos{cadenza}.
1549
1550 Notation Reference:
1551 @ref{Visibility of objects},
1552 @ref{Polymetric notation},
1553 @ref{Manual beams},
1554 @ref{Accidentals}.
1555
1556 Snippets:
1557 @rlsr{Rhythms}.
1558
1559 @cindex cadenza, line breaks
1560 @cindex cadenza, page breaks
1561 @cindex unmetered music, line breaks
1562 @cindex unmetered music, page breaks
1563 @cindex breaks in unmetered music
1564 @cindex line breaks, cadenzas
1565 @cindex page breaks, cadenzas
1566 @cindex line breaks, unmetered music
1567 @cindex page breaks, unmetered music
1568
1569 @knownissues
1570 Automatic line and page breaks are inserted only at bar lines, so
1571 @q{invisible} bar lines will need to be inserted manually in long
1572 stretches of unmetered music to permit breaking:
1573
1574 @example
1575 \bar ""
1576 @end example
1577
1578
1579 @node Polymetric notation
1580 @unnumberedsubsubsec Polymetric notation
1581
1582 @c This section necessarily uses \set
1583 @c This is acceptable  -td
1584
1585 @cindex double time signatures
1586 @cindex signatures, polymetric
1587 @cindex time signatures, polymetric
1588 @cindex time signatures, double
1589 @cindex polymetric signatures
1590 @cindex meter, polymetric
1591
1592 @funindex timeSignatureFraction
1593 @funindex \scaleDurations
1594 @funindex scaleDurations
1595 @funindex \tuplet
1596 @funindex tuplet
1597
1598 Polymetric notation is supported explicitly or by manually modifying the
1599 visible time signature symbol and/or scaling note durations.
1600
1601 @subsubsubheading Different time signatures with equal-length measures
1602
1603 Set a common time signature for each staff, and set the
1604 @code{timeSignatureFraction} to the desired fraction.  Then use the
1605 @code{\scaleDurations} function to scale the durations of the notes in
1606 each staff to the common time signature.
1607
1608 @cindex beams, with polymetric meters
1609 @cindex polymetric meters, with beams
1610
1611 In the following example, music with the time signatures of 3/4, 9/8 and
1612 10/8 are used in parallel.  In the second staff, shown durations are
1613 multiplied by 2/3 (because 2/3 * 9/8 = 3/4) and in the third staff, the
1614 shown durations are multiplied by 3/5 (because 3/5 * 10/8 = 3/4).  It
1615 may be necessary to insert beams manually, as the duration scaling will
1616 affect the autobeaming rules.
1617
1618 @lilypond[quote,verbatim]
1619 \relative c' <<
1620   \new Staff {
1621     \time 3/4
1622     c4 c c |
1623     c4 c c |
1624   }
1625   \new Staff {
1626     \time 3/4
1627     \set Staff.timeSignatureFraction = 9/8
1628     \scaleDurations 2/3
1629       \repeat unfold 6 { c8[ c c] }
1630   }
1631   \new Staff {
1632     \time 3/4
1633     \set Staff.timeSignatureFraction = 10/8
1634     \scaleDurations 3/5 {
1635       \repeat unfold 2 { c8[ c c] }
1636       \repeat unfold 2 { c8[ c] } |
1637       c4. c \tuplet 3/2 { c8[ c c] } c4
1638     }
1639   }
1640 >>
1641 @end lilypond
1642
1643 @subsubsubheading Different time signatures with unequal-length measures
1644
1645 Each staff can be given its own independent time signature by
1646 moving the @code{Timing_translator} and the
1647 @code{Default_bar_line_engraver} to the @code{Staff} context.
1648
1649 @lilypond[quote,verbatim]
1650 \layout {
1651   \context {
1652     \Score
1653     \remove "Timing_translator"
1654     \remove "Default_bar_line_engraver"
1655   }
1656   \context {
1657     \Staff
1658     \consists "Timing_translator"
1659     \consists "Default_bar_line_engraver"
1660   }
1661 }
1662
1663 % Now each staff has its own time signature.
1664
1665 \relative c' <<
1666   \new Staff {
1667     \time 3/4
1668     c4 c c |
1669     c4 c c |
1670   }
1671   \new Staff {
1672     \time 2/4
1673     c4 c |
1674     c4 c |
1675     c4 c |
1676   }
1677   \new Staff {
1678     \time 3/8
1679     c4. |
1680     c8 c c |
1681     c4. |
1682     c8 c c |
1683   }
1684 >>
1685 @end lilypond
1686
1687 @funindex \compoundMeter
1688 @cindex compound time signatures
1689 @cindex time signature, compound
1690
1691 @subsubsubheading Compound time signatures
1692
1693 These are created using the @code{\compoundMeter} function.  The syntax
1694 for this is:
1695
1696 @example
1697 \compoundMeter #'@code{(list of lists)}
1698 @end example
1699
1700 The simplest construction is a single list, where the @emph{last} number
1701 indicates the bottom number of the time signature and those that come
1702 before it, the top numbers.
1703
1704 @lilypond[quote,verbatim]
1705 \relative c' {
1706   \compoundMeter #'((2 2 2 8))
1707   \repeat unfold 6 c8 \repeat unfold 12 c16
1708 }
1709 @end lilypond
1710
1711 More complex meters can be constructed using additional lists.  Also,
1712 automatic beaming settings will be adjusted depending on the values.
1713
1714 @lilypond[quote,verbatim]
1715 \relative c' {
1716   \compoundMeter #'((1 4) (3 8))
1717   \repeat unfold 5 c8 \repeat unfold 10 c16
1718 }
1719
1720 \relative c' {
1721   \compoundMeter #'((1 2 3 8) (3 4))
1722   \repeat unfold 12 c8
1723 }
1724 @end lilypond
1725
1726 @seealso
1727 Music Glossary:
1728 @rglos{polymetric},
1729 @rglos{polymetric time signature},
1730 @rglos{meter}.
1731
1732 Notation Reference:
1733 @ref{Automatic beams},
1734 @ref{Manual beams},
1735 @ref{Time signature},
1736 @ref{Scaling durations}.
1737
1738 Snippets:
1739 @rlsr{Rhythms}.
1740
1741 Internals Reference:
1742 @rinternals{TimeSignature},
1743 @rinternals{Timing_translator},
1744 @rinternals{Default_bar_line_engraver},
1745 @rinternals{Staff}.
1746
1747 @knownissues
1748 When using different time signatures in parallel, notes at the same
1749 moment will be placed at the same horizontal location.  However, the bar
1750 lines in the different staves will cause the note spacing to be less
1751 regular in each of the individual staves than would be normal without
1752 the different time signatures.
1753
1754
1755 @node Automatic note splitting
1756 @unnumberedsubsubsec Automatic note splitting
1757
1758 @cindex notes, splitting
1759 @cindex splitting notes
1760 @cindex rests, splitting
1761 @cindex splitting rests
1762
1763 @funindex Note_heads_engraver
1764 @funindex Completion_heads_engraver
1765 @funindex Completion_rest_engraver
1766
1767 Long notes which overrun bar lines can be converted automatically to
1768 tied notes.  This is done by replacing the @code{Note_heads_engraver}
1769 with the @code{Completion_heads_engraver}.  Similarly, long rests which
1770 overrun bar lines are split automatically by replacing the
1771 @code{Rest_engraver} with the @code{Completion_rest_engraver}.  In the
1772 following example, notes and rests crossing the bar lines are split,
1773 notes are also tied.
1774
1775 @lilypond[quote,verbatim,relative=1]
1776 \new Voice \with {
1777   \remove "Note_heads_engraver"
1778   \consists "Completion_heads_engraver"
1779   \remove "Rest_engraver"
1780   \consists "Completion_rest_engraver"
1781 }
1782
1783 { c2. c8 d4 e f g a b c8 c2 b4 a g16 f4 e d c8. c2 r1*2 }
1784 @end lilypond
1785
1786 These engravers split all running notes and rests at the bar line, and
1787 inserts ties for notes.  One of its uses is to debug complex scores: if
1788 the measures are not entirely filled, then the ties show exactly how
1789 much each measure is off.
1790
1791 @seealso
1792 Music Glossary:
1793 @rglos{tie}
1794
1795 Learning Manual:
1796 @rlearning{Engravers explained},
1797 @rlearning{Adding and removing engravers}.
1798
1799 Snippets:
1800 @rlsr{Rhythms}.
1801
1802 Internals Reference:
1803 @rinternals{Note_heads_engraver},
1804 @rinternals{Completion_heads_engraver},
1805 @rinternals{Rest_engraver},
1806 @rinternals{Completion_rest_engraver},
1807 @rinternals{Forbid_line_break_engraver}.
1808
1809 @knownissues
1810 Not all durations (especially those containing tuplets) can be
1811 represented exactly with normal notes and dots, but the
1812 @code{Completion_heads_engraver} will not insert tuplets.
1813
1814 The @code{Completion_heads_engraver} only affects notes; it does not
1815 split rests.
1816
1817
1818 @node Showing melody rhythms
1819 @unnumberedsubsubsec Showing melody rhythms
1820
1821 @cindex melody rhythms, showing
1822 @cindex rhythms, showing melody
1823
1824 Sometimes you might want to show only the rhythm of a melody.  This
1825 can be done with the rhythmic staff.  All pitches of notes on such a
1826 staff are squashed, and the staff itself has a single line
1827
1828 @lilypond[quote,relative=1,verbatim]
1829 <<
1830   \new RhythmicStaff {
1831     \new Voice = "myRhythm" {
1832       \time 4/4
1833       c4 e8 f g2
1834       r4 g g f
1835       g1
1836     }
1837   }
1838   \new Lyrics {
1839     \lyricsto "myRhythm" {
1840       This is my song
1841       I like to sing
1842     }
1843   }
1844 >>
1845 @end lilypond
1846
1847 @cindex guitar chord charts
1848 @cindex strumming rhythms, showing
1849 @cindex guitar strumming rhythms, showing
1850
1851 @funindex Pitch_squash_engraver
1852 @funindex \improvisationOn
1853 @funindex improvisationOn
1854 @funindex \improvisationOff
1855 @funindex improvisationOff
1856
1857 Guitar chord charts often show the strumming rhythms.  This can
1858 be done with the @code{Pitch_squash_engraver} and
1859 @code{\improvisationOn}.
1860
1861
1862 @lilypond[quote,verbatim]
1863 <<
1864   \new ChordNames {
1865     \chordmode {
1866       c1 f g c
1867     }
1868   }
1869   \new Voice \with {
1870     \consists "Pitch_squash_engraver"
1871   } \relative c'' {
1872     \improvisationOn
1873     c4 c8 c c4 c8 c
1874     f4 f8 f f4 f8 f
1875     g4 g8 g g4 g8 g
1876     c4 c8 c c4 c8 c
1877   }
1878 >>
1879 @end lilypond
1880
1881
1882 @predefined
1883 @code{\improvisationOn},
1884 @code{\improvisationOff}.
1885 @endpredefined
1886
1887
1888 @snippets
1889
1890 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
1891 {guitar-strum-rhythms.ly}
1892
1893 @seealso
1894 Snippets:
1895 @rlsr{Rhythms}.
1896
1897 Internals Reference:
1898 @rinternals{RhythmicStaff},
1899 @rinternals{Pitch_squash_engraver}.
1900
1901
1902 @node Beams
1903 @subsection Beams
1904
1905 @menu
1906 * Automatic beams::
1907 * Setting automatic beam behavior::
1908 * Manual beams::
1909 * Feathered beams::
1910 @end menu
1911
1912 @node Automatic beams
1913 @unnumberedsubsubsec Automatic beams
1914
1915 By default, beams are inserted automatically:
1916
1917 @cindex beams, manual
1918 @cindex manual beams
1919 @cindex beams, customizing rules
1920
1921 @funindex \autoBeamOn
1922 @funindex autoBeamOn
1923 @funindex \autoBeamOff
1924 @funindex autoBeamOff
1925
1926 @lilypond[quote,verbatim,relative=2]
1927 \time 2/4 c8 c c c
1928 \time 6/8 c8 c c c8. c16 c8
1929 @end lilypond
1930
1931 If these automatic decisions are not satisfactory, beaming can be
1932 entered explicitly; see @ref{Manual beams}.  Beams @emph{must} be
1933 entered manually if beams are to be extended over rests.
1934
1935 If automatic beaming is not required, it may be turned off with
1936 @code{\autoBeamOff} and on with @code{\autoBeamOn}:
1937
1938 @lilypond[quote,relative=1,verbatim]
1939 c4 c8 c8. c16 c8. c16 c8
1940 \autoBeamOff
1941 c4 c8 c8. c16 c8.
1942 \autoBeamOn
1943 c16 c8
1944 @end lilypond
1945
1946 @cindex melismata, with beams
1947 @cindex beams, with melismata
1948
1949 @warning{If beams are used to indicate melismata in songs, then
1950 automatic beaming should be switched off with @code{@bs{}autoBeamOff}
1951 and the beams indicated manually.  Using @code{@bs{}partcombine} with
1952 @code{@bs{}autoBeamOff} can produce unintended results.  See the
1953 snippets for more information.}
1954
1955 Beaming patterns that differ from the automatic defaults can be
1956 created; see @ref{Setting automatic beam behavior}.
1957
1958 @predefined
1959 @code{\autoBeamOff},
1960 @code{\autoBeamOn}.
1961 @endpredefined
1962
1963 @cindex beams, line breaks
1964 @cindex line breaks, beams
1965 @cindex beams, with knee gap
1966 @cindex knee gap, with beams
1967 @funindex breakable
1968
1969 @snippets
1970 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
1971 {beams-across-line-breaks.ly}
1972
1973 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
1974 {changing-beam-knee-gap.ly}
1975
1976 @cindex beams, \partcombine with \autoBeamOff
1977 @cindex voices, \partcombine with \autoBeamOff
1978
1979 @lilypondfile [verbatim, quote, ragged-right, texidoc, doctitle]
1980 {partcombine-and-autobeamoff.ly}
1981
1982 @seealso
1983 Notation Reference:
1984 @ref{Manual beams},
1985 @ref{Setting automatic beam behavior}.
1986
1987 Installed Files:
1988 @file{scm/auto-beam.scm}.
1989
1990 Snippets:
1991 @rlsr{Rhythms}.
1992
1993 Internals Reference:
1994 @rinternals{Auto_beam_engraver},
1995 @rinternals{Beam_engraver},
1996 @rinternals{Beam},
1997 @rinternals{BeamEvent},
1998 @rinternals{BeamForbidEvent},
1999 @rinternals{beam-interface},
2000 @rinternals{unbreakable-spanner-interface}.
2001
2002 @knownissues
2003 The properties of a beam are determined at the @emph{start} of its
2004 construction and any additional beam-property changes that occur before
2005 the beam has been completed will not take effect until the @emph{next},
2006 new beam starts.
2007
2008
2009 @node Setting automatic beam behavior
2010 @unnumberedsubsubsec Setting automatic beam behavior
2011
2012 @cindex beams, with lyrics
2013 @cindex lyrics, with beams
2014
2015 @funindex autoBeaming
2016 @funindex baseMoment
2017 @funindex beamExceptions
2018 @funindex beatStructure
2019 @funindex measureLength
2020 @funindex \time
2021 @funindex time
2022 @funindex \set
2023 @funindex set
2024
2025 When automatic beaming is enabled, the placement of automatic beams
2026 is determined by three context properties:
2027 @code{baseMoment}, @code{beatStructure}, and @code{beamExceptions}.
2028 The default values of these variables may be overridden as described
2029 below, or alternatively the default values themselves may be changed
2030 as explained in @ref{Time signature}.
2031
2032 If a @code{beamExceptions} rule is defined for the time signature in
2033 force, that rule alone is used to determine the beam placement; the
2034 values of @code{baseMoment} and @code{beatStructure} are ignored.
2035
2036 If no @code{beamExceptions} rule is defined for the time signature
2037 in force, the beam placement is determined by the values of
2038 @code{baseMoment} and @code{beatStructure}.
2039
2040
2041 @subsubsubheading Beaming based on @code{baseMoment} and @code{beatStructure}
2042
2043 By default, @code{beamExceptions} rules are defined for most common
2044 time signatures, so the @code{beamExceptions} rules must be disabled
2045 if automatic beaming is to be based on @code{baseMoment} and
2046 @code{beatStructure}.  The @code{beamExceptions} rules are disabled
2047 by
2048
2049 @example
2050 \set Timing.beamExceptions = #'()
2051 @end example
2052
2053 When @code{beamExceptions} is set to @code{#'()}, either due to an
2054 explicit setting or because no @code{beamExceptions} rules are defined
2055 internally for the time signature in force, the ending points for
2056 beams are on beats as specified by the context properties
2057 @code{baseMoment} and @code{beatStructure}.  @code{beatStructure} is
2058 a scheme list that defines the length of each beat in the measure in
2059 units of @code{baseMoment}.  By default, @code{baseMoment} is one
2060 over the denominator of the time signature.  By default, each unit of
2061 length @code{baseMoment} is a single beat.
2062
2063 @lilypond[quote,relative=2,verbatim]
2064 \time 5/16
2065 c16^"default" c c c c |
2066 % beamExceptions are unlikely to be defined for 5/16 time,
2067 % but let's disable them anyway to be sure
2068 \set Timing.beamExceptions = #'()
2069 \set Timing.beatStructure = #'(2 3)
2070 c16^"(2+3)" c c c c |
2071 \set Timing.beatStructure = #'(3 2)
2072 c16^"(3+2)" c c c c |
2073 @end lilypond
2074
2075 @lilypond[quote,relative=2,verbatim]
2076 \time 4/4
2077 a8^"default" a a a a a a a
2078 % Disable beamExceptions because they are definitely
2079 % defined for 4/4 time
2080 \set Timing.beamExceptions = #'()
2081 \set Timing.baseMoment = #(ly:make-moment 1/4)
2082 \set Timing.beatStructure = #'(1 1 1 1)
2083 a8^"changed" a a a a a a a
2084 @end lilypond
2085
2086 Beam setting changes can be limited to specific contexts.  If no
2087 setting is included in a lower-level context, the setting of the
2088 enclosing context will apply.
2089
2090 @lilypond[quote, verbatim,relative=1]
2091 \new Staff {
2092   \time 7/8
2093   % No need to disable beamExceptions
2094   % as they are not defined for 7/8 time
2095   \set Staff.beatStructure = #'(2 3 2)
2096   <<
2097     \new Voice = one {
2098       \relative c'' {
2099         a8 a a a a a a
2100       }
2101     }
2102     \new Voice = two {
2103       \relative c' {
2104         \voiceTwo
2105         \set Voice.beatStructure = #'(1 3 3)
2106         f8 f f f f f f
2107       }
2108     }
2109   >>
2110 }
2111 @end lilypond
2112
2113 When multiple voices are used the @code{Staff} context must be
2114 specified if the beaming is to be applied to all voices in the
2115 staff:
2116
2117 @lilypond[quote,verbatim,relative=2]
2118 \time 7/8
2119 % rhythm 3-1-1-2
2120 % Change applied to Voice by default --  does not work correctly
2121 % Because of autogenerated voices, all beating will
2122 % be at baseMoment (1 . 8)
2123 \set beatStructure = #'(3 1 1 2)
2124 << {a8 a a a16 a a a a8 a} \\ {f4. f8 f f f} >>
2125
2126 % Works correctly with context Staff specified
2127 \set Staff.beatStructure = #'(3 1 1 2)
2128 << {a8 a a a16 a a a a8 a} \\ {f4. f8 f f f} >>
2129 @end lilypond
2130
2131 The value of @code{baseMoment} can be adjusted to change
2132 the beaming behavior, if desired. When this is done,
2133 the value of @code{beatStructure} must be set to be
2134 compatible with the new value of @code{baseMoment}.
2135
2136 @lilypond[quote,verbatim,relative=2]
2137 \time 5/8
2138 % No need to disable beamExceptions
2139 % as they are not defined for 5/8 time
2140 \set Timing.baseMoment = #(ly:make-moment 1/16)
2141 \set Timing.beatStructure = #'(7 3)
2142 \repeat unfold 10 { a16 }
2143 @end lilypond
2144
2145 @code{baseMoment} is a @i{moment}; a unit of musical duration.  A
2146 quantity of type @i{moment} is created by the scheme function
2147 @code{ly:make-moment}.  For more information about this function,
2148 see @ref{Time administration}.
2149
2150 By default @code{baseMoment} is set to one over the denominator of
2151 the time signature. Any exceptions to this default can be found in
2152 @file{scm/time-signature-settings.scm}.
2153
2154 @subsubsubheading Beaming based on @code{beamExceptions}
2155
2156 Special autobeaming rules (other than ending a beam on a beat)
2157 are defined in the @code{beamExceptions} property.
2158
2159 @lilypond[quote,relative=2,verbatim]
2160 \time 3/16
2161 \set Timing.beatStructure = #'(2 1)
2162 \set Timing.beamExceptions =
2163   #'(                         ;start of alist
2164      (end .                   ;entry for end of beams
2165       (                       ;start of alist of end points
2166        ((1 . 32) . (2 2 2))   ;rule for 1/32 beams -- end each 1/16
2167       )))                     %close all entries
2168 c16 c c |
2169 \repeat unfold 6 { c32 } |
2170 @end lilypond
2171
2172 @code{beamExceptions} is an alist with a key of rule-type and a value
2173 of beaming-rules.
2174
2175 At this time the only available value of rule-type is
2176 @code{'end} for beam ending.
2177
2178 Beaming-rules is a scheme alist (or list of pairs) that indicates the
2179 beam type and the grouping to be applied to beams containing notes with
2180 a shortest duration of that beam type.
2181
2182 @example
2183 #'((beam-type1 . grouping-1)
2184    (beam-type2 . grouping-2)
2185    (beam-type3 . grouping-3))
2186 @end example
2187
2188 Beam type is a scheme pair indicating the duration of the beam,
2189 e.g., @code{(1 . 16)}.
2190
2191 Grouping is a scheme list indicating the grouping to be applied to
2192 the beam.  The grouping is in units of the beam type.
2193
2194 @warning{ A @code{beamExceptions} value must be @emph{complete}
2195 exceptions list.  That is, every exception that should be applied
2196 must be included in the setting.  It is not possible to add, remove,
2197 or change only one of the exceptions. While this may seem cumbersome,
2198 it means that the current beaming settings need not be known in order
2199 to specify a new beaming pattern.}
2200
2201 When the time signature is changed, default values of
2202 @code{Timing.baseMoment}, @code{Timing.beatStructure},
2203 and @code{Timing.beamExceptions} are set.  Setting the time signature
2204 will reset the automatic beaming settings for the @code{Timing}
2205 context to the default behavior.
2206
2207 @lilypond[quote,verbatim,relative=2]
2208 \time 6/8
2209 \repeat unfold 6 { a8 }
2210 % group (4 + 2)
2211 \set Timing.beatStructure = #'(4 2)
2212 \repeat unfold 6 { a8 }
2213 % go back to default behavior
2214 \time 6/8
2215 \repeat unfold 6 { a8 }
2216 @end lilypond
2217
2218 The default automatic beaming settings for a time signature
2219 are determined in @file{scm/time-signature-settings.scm}.
2220 Changing the default automatic beaming settings
2221 for a time signature is described in @ref{Time signature}.
2222
2223 Many automatic beaming settings for a time signature contain an
2224 entry for @code{beamExceptions}.  For example, 4/4 time tries to
2225 beam the measure in two if there are only eighth notes.  The
2226 @code{beamExceptions} rule can override the @code{beatStructure} setting
2227 if @code{beamExceptions} is not reset.
2228
2229 @lilypond[quote,verbatim,relative=2]
2230 \time 4/4
2231 \set Timing.baseMoment = #(ly:make-moment 1/8)
2232 \set Timing.beatStructure = #'(3 3 2)
2233 % This won't beam (3 3 2) because of beamExceptions
2234 \repeat unfold 8 {c8} |
2235 % This will beam (3 3 2) because we clear beamExceptions
2236 \set Timing.beamExceptions = #'()
2237 \repeat unfold 8 {c8}
2238 @end lilypond
2239
2240 In a similar fashion, eighth notes in 3/4 time are beamed as a full
2241 measure by default.  To beam eighth notes in 3/4 time on the beat,
2242 reset @code{beamExceptions}.
2243
2244 @lilypond[quote,verbatim,relative=2]
2245 \time 3/4
2246 % by default we beam in (6) due to beamExceptions
2247 \repeat unfold 6 {a8} |
2248 % This will beam (1 1 1) due to default baseMoment and beatStructure
2249 \set Timing.beamExceptions = #'()
2250 \repeat unfold 6 {a8}
2251 @end lilypond
2252
2253 In engraving from the Romantic and Classical periods,
2254 beams often begin midway through the measure in 3/4 time,
2255 but modern practice is to avoid the false impression of 6/8 time
2256 (see Gould, p. 153).  Similar situations arise in 3/8 time.
2257 This behavior is controlled by the context property @code{beamHalfMeasure},
2258 which has effect only in time signatures with 3 in the numerator:
2259
2260 @lilypond[quote,verbatim,relative=2]
2261 \time 3/4
2262 r4. a8 a a |
2263 \set Timing.beamHalfMeasure = ##f
2264 r4. a8 a a |
2265 @end lilypond
2266
2267 @subsubsubheading How automatic beaming works
2268
2269 When automatic beaming is enabled, the placement of automatic beams
2270 is determined by the context properties
2271 @code{baseMoment}, @code{beatStructure}, and @code{beamExceptions}.
2272
2273 The following rules, in order of priority, apply when determining
2274 the appearance of beams:
2275
2276 @itemize
2277 @item
2278 If a manual beam is specified with @code{[@dots{}]} set the beam
2279 as specified, otherwise
2280
2281 @item
2282 if a beam-ending rule is defined in @code{beamExceptions}
2283 for the beam-type, use it to determine the valid places where
2284 beams may end, otherwise
2285
2286 @item
2287 if a beam-ending rule is defined in @code{beamExceptions}
2288 for a longer beam-type, use it to determine the valid places
2289 where beams may end, otherwise
2290
2291 @item
2292 use the values of @code{baseMoment} and @code{beatStructure} to
2293 determine the ends of the beats in the measure, and
2294 end beams at the end of beats.
2295
2296 @end itemize
2297
2298 In the rules above, the @emph{beam-type} is the duration of the
2299 shortest note in the beamed group.
2300
2301 The default beaming rules can be found in
2302 @file{scm/time-signature-settings.scm}.
2303
2304 @snippets
2305
2306 @cindex beams, subdividing
2307
2308 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
2309 {subdividing-beams.ly}
2310
2311 @cindex beamlets, orienting
2312
2313 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
2314 {strict-beat-beaming.ly}
2315
2316 @cindex measure groupings
2317 @cindex beats, grouping
2318 @cindex grouping beats
2319 @cindex measure sub-grouping
2320
2321 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
2322 {conducting-signs,-measure-grouping-signs.ly}
2323
2324 @cindex beam, endings in a score
2325 @cindex beam, endings with multiple voices
2326
2327 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
2328 {beam-endings-in-score-context.ly}
2329
2330 @seealso
2331 Notation Reference:
2332 @ref{Time signature}.
2333
2334 Installed Files:
2335 @file{scm/time-signature-settings.scm}.
2336
2337 Snippets:
2338 @rlsr{Rhythms}.
2339
2340 Internals Reference:
2341 @rinternals{Auto_beam_engraver},
2342 @rinternals{Beam},
2343 @rinternals{BeamForbidEvent},
2344 @rinternals{beam-interface}.
2345
2346 @knownissues
2347 If a score ends while an automatic beam has not been ended and is
2348 still accepting notes, this last beam will not be typeset at all.
2349 The same holds for polyphonic voices, entered with
2350 @code{<< @dots{} \\ @dots{} >>}.  If a polyphonic voice ends while an
2351 automatic beam is still accepting notes, it is not typeset.
2352 The workaround for these problems is to manually beam the last
2353 beam in the voice or score.
2354
2355 By default, the @code{Timing} translator is aliased to the
2356 @code{Score} context.  This means that setting the time signature
2357 in one staff will affect the beaming of the other staves as well.
2358 Thus, a time signature setting in a later staff will reset custom
2359 beaming that was set in an earlier staff.
2360 One way to avoid this problem is to set the time signature
2361 in only one staff.
2362
2363 @lilypond[quote,verbatim,relative=2]
2364 <<
2365   \new Staff {
2366     \time 3/4
2367     \set Timing.baseMoment = #(ly:make-moment 1/8)
2368     \set Timing.beatStructure = #'(1 5)
2369     \repeat unfold 6 { a8 }
2370   }
2371   \new Staff {
2372     \repeat unfold 6 { a8 }
2373   }
2374 >>
2375 @end lilypond
2376
2377 The default beam settings for the time signature can also be changed, so
2378 that the desired beaming will always be used.  Changes in automatic
2379 beaming settings for a time signature are described in
2380 @ref{Time signature}.
2381
2382 @lilypond[quote,verbatim,relative=2]
2383 <<
2384   \new Staff {
2385     \overrideTimeSignatureSettings
2386       3/4               % timeSignatureFraction
2387       1/8               % baseMomentFraction
2388       #'(1 5)           % beatStructure
2389       #'()              % beamExceptions
2390     \time 3/4
2391     \repeat unfold 6 { a8 }
2392   }
2393   \new Staff {
2394     \time 3/4
2395     \repeat unfold 6 { a8 }
2396   }
2397 >>
2398 @end lilypond
2399
2400
2401 @node Manual beams
2402 @unnumberedsubsubsec Manual beams
2403
2404 @cindex beams, manual
2405 @cindex manual beams
2406
2407 @funindex ]
2408 @funindex [
2409
2410 In some cases it may be necessary to override the automatic
2411 beaming algorithm.  For example, the autobeamer will not put beams
2412 over rests or bar lines, and in choral scores the beaming is
2413 often set to follow the meter of the lyrics rather than the
2414 notes.  Such beams can be specified manually by
2415 marking the begin and end point with @code{[} and @code{]}.
2416
2417 @lilypond[quote,relative=1,verbatim]
2418 r4 r8[ g' a r] r g[ | a] r
2419 @end lilypond
2420
2421 @cindex manual beams, direction shorthand for
2422 @cindex manual beams, grace notes
2423
2424 Beaming direction can be set manually using direction indicators:
2425
2426 @lilypond[quote,relative=2,verbatim]
2427 c8^[ d e] c,_[ d e f g]
2428 @end lilypond
2429
2430 @funindex \noBeam
2431 @funindex noBeam
2432
2433 Individual notes may be marked with @code{\noBeam} to prevent them
2434 from being beamed:
2435
2436 @lilypond[quote,verbatim,relative=2]
2437 \time 2/4
2438 c8 c\noBeam c c
2439 @end lilypond
2440
2441 Grace note beams and normal note beams can occur simultaneously.
2442 Unbeamed grace notes are not put into normal note beams.
2443
2444 @lilypond[quote,verbatim,relative=2]
2445 c4 d8[
2446 \grace { e32 d c d }
2447 e8] e[ e
2448 \grace { f16 }
2449 e8 e]
2450 @end lilypond
2451
2452 @funindex stemLeftBeamCount
2453 @funindex stemRightBeamCount
2454
2455 Even more strict manual control with the beams can be achieved by
2456 setting the properties @code{stemLeftBeamCount} and
2457 @code{stemRightBeamCount}.  They specify the number of beams to
2458 draw on the left and right side, respectively, of the next note.
2459 If either property is set, its value will be used only once, and
2460 then it is erased.  In this example, the last @code{f} is printed
2461 with only one beam on the left side, i.e., the eighth-note beam of
2462 the group as a whole.
2463
2464 @lilypond[quote,relative=2,verbatim]
2465 a8[ r16 f g a]
2466 a8[ r16
2467 \set stemLeftBeamCount = #2
2468 \set stemRightBeamCount = #1
2469 f16
2470 \set stemLeftBeamCount = #1
2471 g16 a]
2472 @end lilypond
2473
2474
2475 @predefined
2476 @code{\noBeam}.
2477 @endpredefined
2478
2479
2480 @snippets
2481
2482 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
2483 {flat-flags-and-beam-nibs.ly}
2484
2485 @seealso
2486 Notation Reference:
2487 @ref{Direction and placement},
2488 @ref{Grace notes}.
2489
2490 Snippets:
2491 @rlsr{Rhythms}.
2492
2493 Internals Reference:
2494 @rinternals{Beam},
2495 @rinternals{BeamEvent},
2496 @rinternals{Beam_engraver},
2497 @rinternals{beam-interface},
2498 @rinternals{Stem_engraver}.
2499
2500
2501 @node Feathered beams
2502 @unnumberedsubsubsec Feathered beams
2503
2504 @cindex beams, feathered
2505 @cindex feathered beams
2506
2507 @funindex \featherDurations
2508 @funindex featherDurations
2509 @funindex grow-direction
2510
2511 Feathered beams are used to indicate that a small group of notes
2512 should be played at an increasing (or decreasing) tempo, without
2513 changing the overall tempo of the piece.  The extent of the
2514 feathered beam must be indicated manually using @code{[} and
2515 @code{]}, and the beam feathering is turned on by specifying a
2516 direction to the @code{Beam} property @code{grow-direction}.
2517
2518 If the placement of the notes and the sound in the MIDI output is to
2519 reflect the @emph{ritardando} or @emph{accelerando} indicated by the
2520 feathered beam the notes must be grouped as a music expression delimited
2521 by braces and preceded by a @code{featherDurations} command which specifies
2522 the ratio between the durations of the first and last notes in the
2523 group.
2524
2525 The square brackets show the extent of the beam and the braces show
2526 which notes are to have their durations modified.  Normally these
2527 would delimit the same group of notes, but this is not required: the
2528 two commands are independent.
2529
2530 In the following example the eight 16th notes occupy exactly the
2531 same time as a half note, but the first note is one half as long
2532 as the last one, with the intermediate notes gradually
2533 lengthening.  The first four 32nd notes gradually speed up, while
2534 the last four 32nd notes are at a constant tempo.
2535
2536 @lilypond[relative=1,verbatim,quote]
2537 \override Beam.grow-direction = #LEFT
2538 \featherDurations #(ly:make-moment 2/1)
2539 { c16[ c c c c c c c] }
2540 \override Beam.grow-direction = #RIGHT
2541 \featherDurations #(ly:make-moment 2/3)
2542 { c32[ d e f] }
2543 % revert to non-feathered beams
2544 \override Beam.grow-direction = #'()
2545 { g32[ a b c] }
2546 @end lilypond
2547
2548 @noindent
2549 The spacing in the printed output represents the
2550 note durations only approximately, but the MIDI output is exact.
2551
2552 @predefined
2553 @code{\featherDurations}.
2554 @endpredefined
2555
2556 @seealso
2557 Snippets:
2558 @rlsr{Rhythms}.
2559
2560 @knownissues
2561 The @code{\featherDurations} command only works with very short
2562 music snippets, and when numbers in the fraction are small.
2563
2564
2565 @node Bars
2566 @subsection Bars
2567
2568 @menu
2569 * Bar lines::
2570 * Bar numbers::
2571 * Bar and bar number checks::
2572 * Rehearsal marks::
2573 @end menu
2574
2575 @node Bar lines
2576 @unnumberedsubsubsec Bar lines
2577
2578 @cindex bar lines
2579 @cindex measure lines
2580 @cindex closing bar lines
2581 @cindex bar lines, closing
2582 @cindex double bar lines
2583 @cindex bar lines, double
2584 @cindex repeat bars
2585
2586 @funindex \bar
2587 @funindex bar
2588
2589 Bar lines delimit measures, and are also used to indicate
2590 repeats.  Normally, simple bar lines are automatically inserted
2591 into the printed output at places based on the current time
2592 signature.
2593
2594 The simple bar lines inserted automatically can be changed to
2595 other types with the @code{\bar} command.  For example, a closing
2596 double bar line is usually placed at the end of a piece:
2597
2598 @lilypond[quote,relative=1,verbatim]
2599 e4 d c2 \bar "|."
2600 @end lilypond
2601
2602 It is not invalid if the final note in a measure does not
2603 end on the automatically entered bar line: the note is assumed
2604 to carry over into the next measure.  But if a long sequence
2605 of such carry-over measures appears the music can appear compressed
2606 or even flowing off the page.  This is because automatic line
2607 breaks happen only at the end of complete measures, i.e., where
2608 all notes end before the end of a measure.
2609
2610 @warning{An incorrect duration can cause line breaks to be
2611 inhibited, leading to a line of highly compressed music or
2612 music which flows off the page.}
2613
2614 @cindex line breaks
2615 @cindex bar lines, invisible
2616 @cindex measure lines, invisible
2617
2618 Line breaks are also permitted at manually inserted bar lines
2619 even within incomplete measures.  To allow a line break without
2620 printing a bar line, use the following:
2621
2622 @example
2623 \bar ""
2624 @end example
2625
2626 @noindent
2627 This will insert an invisible bar line and allow (but not
2628 force) a line break to occur at this point.  The bar number
2629 counter is not increased.  To force a line break see
2630 @ref{Line breaking}.
2631
2632 @cindex manual bar lines
2633 @cindex manual measure lines
2634 @cindex bar lines, manual
2635 @cindex measure lines, manual
2636
2637 This and other special bar lines may be inserted manually at any
2638 point.  When they coincide with the end of a measure they replace
2639 the simple bar line which would have been inserted there
2640 automatically.  When they do not coincide with the end of a measure
2641 the specified bar line is inserted at that point in the printed
2642 output.
2643
2644 Note that manual bar lines are purely visual.  They do not affect
2645 any of the properties that a normal bar line would affect, such as
2646 measure numbers, accidentals, line breaks, etc.  They do not affect
2647 the calculation and placement of subsequent automatic bar lines.
2648 When a manual bar line is placed where a normal bar line already
2649 exists, the effects of the original bar line are not altered.
2650
2651 Two types of simple bar lines and five types of double bar lines are
2652 available for manual insertion:
2653
2654 @lilypond[quote,relative=1,verbatim]
2655 f1 \bar "|"
2656 f1 \bar "."
2657 g1 \bar "||"
2658 a1 \bar ".|"
2659 b1 \bar ".."
2660 c1 \bar "|.|"
2661 d1 \bar "|."
2662 e1
2663 @end lilypond
2664
2665 @noindent
2666 together with dotted and dashed bar lines:
2667
2668 @lilypond[quote,relative=1,verbatim]
2669 f1 \bar ";"
2670 g1 \bar "!"
2671 a1
2672 @end lilypond
2673
2674 @noindent
2675 and nine types of repeat bar lines:
2676
2677 @lilypond[quote,relative=1,verbatim]
2678 f1 \bar ".|:"
2679 g1 \bar ":..:"
2680 a1 \bar ":|.|:"
2681 b1 \bar ":|.:"
2682 c1 \bar ":.|.:"
2683 d1 \bar "[|:"
2684 e1 \bar ":|][|:"
2685 f1 \bar ":|]"
2686 g1 \bar ":|."
2687 a1
2688 @end lilypond
2689
2690 Additionally, a bar line can be printed as a simple tick:
2691 @lilypond[quote,relative=1,verbatim]
2692 f1 \bar "'" g1
2693 @end lilypond
2694 However, as such ticks are typically used in Gregorian chant, it is
2695 preferable to use @code{\divisioMinima} there instead, described in
2696 the section @ref{Divisiones} in Gregorian chant.
2697
2698 Lilypond supports kievan notation and provides a special kievan
2699 bar line:
2700 @lilypond[quote,relative=1,verbatim]
2701 f1 \bar "k"
2702 @end lilypond
2703 Further details of this notation are explained in
2704 @ref{Typesetting Kievan square notation}.
2705
2706 @cindex segno
2707
2708 For in-line segno signs, there are three types of bar lines which
2709 differ in their behavior at line breaks:
2710
2711 @lilypond[quote,relative=2,verbatim]
2712 c4 c c c
2713 \bar "S"
2714 c4 c c c \break
2715 \bar "S"
2716 c4 c c c
2717 \bar "S-|"
2718 c4 c c c \break
2719 \bar "S-|"
2720 c4 c c c
2721 \bar "S-S"
2722 c4 c c c \break
2723 \bar "S-S"
2724 c1
2725 @end lilypond
2726
2727 @cindex repeats
2728
2729 Although the bar line types signifying repeats may be inserted
2730 manually they do not in themselves cause LilyPond to recognize
2731 a repeated section.  Such repeated sections are better entered
2732 using the various repeat commands (see @ref{Repeats}), which
2733 automatically print the appropriate bar lines.
2734
2735 In addition, you can specify @code{".|:-||"}, which is equivalent to
2736 @code{".|:"} except at line breaks, where it gives a double bar
2737 line at the end of the line and a start repeat at the beginning of
2738 the next line.
2739
2740 @lilypond[quote,relative=2,verbatim]
2741 c4 c c c
2742 \bar ".|:-||"
2743 c4 c c c \break
2744 \bar ".|:-||"
2745 c4 c c c
2746 @end lilypond
2747
2748 For combinations of repeats with the segno sign, there are six different
2749 variations:
2750
2751 @lilypond[quote,relative=2,verbatim]
2752 c4 c c c
2753 \bar ":|.S"
2754 c4 c c c \break
2755 \bar ":|.S"
2756 c4 c c c
2757 \bar ":|.S-S"
2758 c4 c c c \break
2759 \bar ":|.S-S"
2760 c4 c c c
2761 \bar "S.|:-S"
2762 c4 c c c \break
2763 \bar "S.|:-S"
2764 c4 c c c
2765 \bar "S.|:"
2766 c4 c c c \break
2767 \bar "S.|:"
2768 c4 c c c
2769 \bar ":|.S.|:"
2770 c4 c c c \break
2771 \bar ":|.S.|:"
2772 c4 c c c
2773 \bar ":|.S.|:-S"
2774 c4 c c c \break
2775 \bar ":|.S.|:-S"
2776 c1
2777 @end lilypond
2778
2779 Additionally there is an @code{\inStaffSegno} command which creates
2780 a segno bar line in conjunction with an appropriate repeat bar line
2781 when used with a @code{\repeat volta} command, see
2782 @ref{Normal repeats}.
2783
2784 @funindex \defineBarLine
2785 @funindex defineBarLine
2786 @cindex bar lines, defining
2787 @cindex defining bar lines
2788
2789 New bar line types can be defined with @code{\defineBarLine}:
2790
2791 @example
2792 \defineBarLine @var{bartype} #'(@var{end} @var{begin} @var{span})
2793 @end example
2794
2795 The @code{\defineBarline} variables can include the
2796 @q{empty} string @code{""}, which is equivalent to an invisible
2797 bar line being printed.  Or they can be set to @code{#f} which
2798 prints no bar line at all.
2799
2800 After the definiton, the new bar line can be used by
2801 @code{\bar} @var{bartype}.
2802
2803 There are currently ten bar line elements available:
2804
2805 @lilypond[quote,verbatim]
2806 \defineBarLine ":" #'("" ":" "")
2807 \defineBarLine "=" #'("=" "" "")
2808 \defineBarLine "[" #'("" "[" "")
2809 \defineBarLine "]" #'("]" "" "")
2810
2811 \new Staff {
2812   s1 \bar "|"
2813   s1 \bar "."
2814   s1 \bar "!"
2815   s1 \bar ";"
2816   s1 \bar ":"
2817   s1 \bar "k"
2818   s1 \bar "S"
2819   s1 \bar "="
2820   s1 \bar "["
2821   s1 \bar "]"
2822   s1 \bar ""
2823 }
2824 @end lilypond
2825
2826 The @code{"="} bar line provides the double span bar line, used
2827 in combination with the segno sign.  Do not use it as a standalone
2828 double thin bar line; here, @code{\bar} @var{"||"} is
2829 preferred.
2830
2831 The @code{"-"} sign starts annotations to bar lines which
2832 are useful to distinguish those with identical appearance
2833 but different behavior at line breaks and/or different span bars.
2834 The part following the @code{"-"} sign is not used for building up
2835 the bar line.
2836
2837 @lilypond[quote,relative=2,verbatim]
2838 \defineBarLine "||-dashedSpan" #'("||" "" "!!")
2839
2840 \new StaffGroup <<
2841   \new Staff {
2842     c1 \bar "||"
2843     c1 \bar "||-dashedSpan"
2844     c1
2845   }
2846   \new Staff {
2847     c1
2848     c1
2849     c1
2850   }
2851 >>
2852 @end lilypond
2853
2854 Furthermore, the space character @code{" "} serves as a placeholder
2855 for defining span bars correctly aligned to the main bar lines:
2856
2857 @lilypond[quote,relative=2,verbatim]
2858 \defineBarLine ":|.-wrong" #'(":|." "" "|.")
2859 \defineBarLine ":|.-right" #'(":|." "" " |.")
2860
2861 \new StaffGroup <<
2862   \new Staff {
2863     c1 \bar ":|.-wrong"
2864     c1 \bar ":|.-right"
2865     c1
2866   }
2867   \new Staff {
2868     c1
2869     c1
2870     c1
2871   }
2872 >>
2873 @end lilypond
2874
2875 If additional elements are needed, LilyPond provides a simple
2876 way to define them.  For more informations on modifying or adding
2877 bar lines, see file @file{scm/bar-line.scm}.
2878
2879 In scores with many staves, a @code{\bar} command in one staff is
2880 automatically applied to all staves.  The resulting bar lines are
2881 connected between different staves of a @code{StaffGroup},
2882 @code{PianoStaff}, or @code{GrandStaff}.
2883
2884 @lilypond[quote,relative=1,verbatim]
2885 <<
2886   \new StaffGroup <<
2887     \new Staff {
2888       e4 d
2889       \bar "||"
2890       f4 e
2891     }
2892     \new Staff { \clef bass c4 g e g }
2893   >>
2894   \new Staff { \clef bass c2 c2 }
2895 >>
2896 @end lilypond
2897
2898
2899 @cindex default bar lines, changing
2900 @cindex bar lines, default, changing
2901
2902 @funindex whichBar
2903 @funindex defaultBarType
2904 @funindex \bar
2905 @funindex bar
2906 @funindex bartype
2907
2908 The command @samp{\bar @var{bartype}} is a shortcut for
2909 @samp{\set Timing.whichBar = @var{bartype}}.  A bar line is
2910 created whenever the @code{whichBar} property is set.
2911
2912 The default bar type used for automatically inserted bar lines is
2913 @code{"|"}.  This may be changed at any time with
2914 @samp{\set Timing.defaultBarType = @var{bartype}}.
2915
2916 @seealso
2917 Notation Reference:
2918 @ref{Line breaking},
2919 @ref{Repeats},
2920 @ref{Grouping staves}.
2921
2922 Installed Files:
2923 @file{scm/bar-line.scm}.
2924
2925 Snippets:
2926 @rlsr{Rhythms}.
2927
2928 Internals Reference:
2929 @rinternals{BarLine} (created at @code{Staff} level),
2930 @rinternals{SpanBar} (across staves),
2931 @rinternals{Timing_translator} (for Timing properties).
2932
2933
2934 @node Bar numbers
2935 @unnumberedsubsubsec Bar numbers
2936
2937 @cindex bar numbers
2938 @cindex measure numbers
2939 @cindex numbers, bar
2940 @cindex numbers, measure
2941
2942 @funindex currentBarNumber
2943
2944 Bar numbers are typeset by default at the start of every line except
2945 the first line.  The number itself is stored in the
2946 @code{currentBarNumber} property, which is normally updated
2947 automatically for every measure.  It may also be set manually:
2948
2949 @lilypond[verbatim,quote,relative=1]
2950 c1 c c c
2951 \break
2952 \set Score.currentBarNumber = #50
2953 c1 c c c
2954 @end lilypond
2955
2956 @cindex bar numbers, regular spacing
2957
2958 @funindex barNumberVisibility
2959 @funindex BarNumber
2960
2961 Bar numbers can be typeset at regular intervals instead of just at
2962 the beginning of every line.  To do this the default behavior
2963 must be overridden to permit bar numbers to be printed at places
2964 other than the start of a line.  This is controlled by the
2965 @code{break-visibility} property of @code{BarNumber}.  This takes
2966 three values which may be set to @code{#t} or @code{#f} to specify
2967 whether the corresponding bar number is visible or not.  The order
2968 of the three values is @code{end of line visible}, @code{middle of
2969 line visible}, @code{beginning of line visible}.  In the following
2970 example bar numbers are printed at all possible places:
2971
2972 @lilypond[verbatim,quote,relative=1]
2973 \override Score.BarNumber.break-visibility = ##(#t #t #t)
2974 \set Score.currentBarNumber = #11
2975 % Permit first bar number to be printed
2976 \bar ""
2977 c1 | c | c | c
2978 \break
2979 c1 | c | c | c
2980 @end lilypond
2981
2982 @snippets
2983 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
2984 {printing-the-bar-number-for-the-first-measure.ly}
2985
2986 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
2987 {printing-bar-numbers-at-regular-intervals.ly}
2988
2989 @cindex measure number, format
2990 @cindex bar number, format
2991
2992 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
2993 {printing-bar-numbers-inside-boxes-or-circles.ly}
2994
2995 @cindex bar numbers, with letters
2996 @cindex bar numbers, with repeats
2997
2998 @lilypondfile[verbatim,quote,texidoc,doctitle]
2999 {alternative-bar-numbering.ly}
3000
3001 @cindex bar number alignment
3002
3003 @lilypondfile[verbatim,quote,texidoc,doctitle]
3004 {aligning-bar-numbers.ly}
3005
3006 @lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
3007 {removing-bar-numbers-from-a-score.ly}
3008
3009 @seealso
3010 Snippets:
3011 @rlsr{Rhythms}.
3012
3013 Internals Reference:
3014 @rinternals{BarNumber},
3015 @rinternals{Bar_number_engraver}.
3016
3017 @cindex bar number collision
3018 @cindex collision, bar number
3019
3020 @knownissues
3021 Bar numbers may collide with the top of the @code{StaffGroup} bracket,
3022 if there is one.  To solve this, the @code{padding} property of
3023 @code{BarNumber} can be used to position the number correctly.  See
3024 @rinternals{StaffGroup} and @rinternals{BarNumber} for more.
3025
3026
3027 @node Bar and bar number checks
3028 @unnumberedsubsubsec Bar and bar number checks
3029
3030 @cindex bar check
3031 @cindex bar number check
3032 @cindex measure check
3033 @cindex measure number check
3034
3035 @funindex barCheckSynchronize
3036 @funindex |
3037
3038 Bar checks help detect errors in the entered durations.  A bar check
3039 may be entered using the bar symbol, @code{|}, at any place where a
3040 bar line is expected to fall.  If bar check lines are encountered at
3041 other places, a list of warnings is printed in the log file, showing
3042 the line numbers and lines in which the bar checks failed.  In the
3043 next example, the second bar check will signal an error.
3044
3045 @example
3046 \time 3/4 c2 e4 | g2 |
3047 @end example
3048
3049 Bar checks can also be used in lyrics:
3050
3051 @example
3052 \lyricmode @{
3053   \time 2/4
3054   Twin -- kle | Twin -- kle |
3055 @}
3056 @end example
3057
3058 An incorrect duration can result in a completely garbled score,
3059 especially if the score is polyphonic, so a good place to start
3060 correcting input is by scanning for failed bar checks and
3061 incorrect durations.
3062
3063 If successive bar checks are off by the same musical interval,
3064 only the first warning message is displayed.  This allows the
3065 warning to focus on the source of the timing error.
3066
3067
3068 @funindex |
3069 @funindex "|"
3070
3071 It is also possible to redefine the action taken when a bar check
3072 or pipe symbol, @code{|}, is encountered in the input, so that
3073 it does something other than a bar check.  This is done by
3074 assigning a music expression to @code{"|"}.
3075 In the following example @code{|} is set to insert a double bar
3076 line wherever it appears in the input, rather than checking
3077 for end of bar.
3078
3079 @lilypond[quote,verbatim]
3080 "|" = \bar "||"
3081 {
3082   c'2 c' |
3083   c'2 c'
3084   c'2 | c'
3085   c'2 c'
3086 }
3087 @end lilypond
3088
3089 @funindex \barNumberCheck
3090 @funindex barNumberCheck
3091
3092 When copying large pieces of music, it can be helpful to check that
3093 the LilyPond bar number corresponds to the original that you are
3094 entering from.  This can be checked with @code{\barNumberCheck}, for
3095 example,
3096
3097 @verbatim
3098 \barNumberCheck #123
3099 @end verbatim
3100
3101 @noindent
3102 will print a warning if the @code{currentBarNumber} is not 123
3103 when it is processed.
3104
3105 @seealso
3106 Snippets:
3107 @rlsr{Rhythms}.
3108
3109
3110 @node Rehearsal marks
3111 @unnumberedsubsubsec Rehearsal marks
3112
3113 @cindex rehearsal marks
3114 @cindex mark, rehearsal
3115
3116 @funindex \mark
3117 @funindex mark
3118
3119 To print a rehearsal mark, use the @code{\mark} command.
3120
3121 @lilypond[quote,verbatim,relative=2]
3122 c1 \mark \default
3123 c1 \mark \default
3124 c1 \mark \default
3125 c1 \mark \default
3126 @end lilypond
3127
3128 @noindent
3129 The mark is incremented automatically if you use @code{\mark
3130 \default}, but you can also use an integer argument to set the
3131 mark manually.  The value to use is stored in the property
3132 @code{rehearsalMark}.
3133
3134 @lilypond[quote,verbatim,relative=2]
3135 c1 \mark \default
3136 c1 \mark \default
3137 c1 \mark #8
3138 c1 \mark \default
3139 c1 \mark \default
3140 @end lilypond
3141
3142 @noindent
3143 The letter@tie{}@q{I} is skipped in accordance with engraving
3144 traditions.  If you wish to include the letter @q{I}, then use one
3145 of the following commands, depending on which style of rehearsal mark
3146 you want (letters only, letters in a hollow box, or letters in a
3147 hollow circle).
3148
3149 @example
3150 \set Score.markFormatter = #format-mark-alphabet
3151 \set Score.markFormatter = #format-mark-box-alphabet
3152 \set Score.markFormatter = #format-mark-circle-alphabet
3153 @end example
3154
3155 @lilypond[quote,verbatim,relative=2]
3156 \set Score.markFormatter = #format-mark-box-alphabet
3157 c1 \mark \default
3158 c1 \mark \default
3159 c1 \mark #8
3160 c1 \mark \default
3161 c1 \mark \default
3162 @end lilypond
3163
3164 @cindex rehearsal mark format
3165 @cindex rehearsal mark style
3166 @cindex style, rehearsal mark
3167 @cindex format, rehearsal mark
3168 @cindex mark, rehearsal, style
3169 @cindex mark, rehearsal, format
3170 @cindex rehearsal mark, manual
3171 @cindex mark, rehearsal, manual
3172 @cindex custom rehearsal mark
3173 @cindex manual rehearsal mark
3174
3175 The style is defined by the property @code{markFormatter}.  It is
3176 a function taking the current mark (an integer) and the current
3177 context as argument.  It should return a markup object.  In the
3178 following example, @code{markFormatter} is set to a pre-defined
3179 procedure.  After a few measures, it is set to a procedure that
3180 produces a boxed number.
3181
3182 @lilypond[quote,verbatim,relative=2]
3183 \set Score.markFormatter = #format-mark-numbers
3184 c1 \mark \default
3185 c1 \mark \default
3186 \set Score.markFormatter = #format-mark-box-numbers
3187 c1 \mark \default
3188 \set Score.markFormatter = #format-mark-circle-numbers
3189 c1 \mark \default
3190 \set Score.markFormatter = #format-mark-circle-letters
3191 c1
3192 @end lilypond
3193
3194 The file @file{scm/translation-functions.scm} contains the
3195 definitions of @code{format-mark-numbers} (the default format),
3196 @code{format-mark-box-numbers}, @code{format-mark-letters} and
3197 @code{format-mark-box-letters}.  These can be used as inspiration
3198 for other formatting functions.
3199
3200 You may use @code{format-mark-barnumbers},
3201 @code{format-mark-box-barnumbers}, and
3202 @code{format-mark-circle-barnumbers} to get bar numbers instead of
3203 incremented numbers or letters.
3204
3205 Other styles of rehearsal mark can be specified manually:
3206
3207 @example
3208 \mark "A1"
3209 @end example
3210
3211 @noindent
3212 Note that @code{Score.markFormatter} does not affect marks specified
3213 in this manner.  However, it is possible to apply a @code{\markup} to the
3214 string.
3215
3216 @example
3217 \mark \markup@{ \box A1 @}
3218 @end example
3219
3220 @cindex segno
3221 @cindex coda
3222 @cindex D.S. al Fine
3223 @cindex fermata
3224 @cindex music glyphs
3225 @cindex glyphs, music
3226
3227 @funindex \musicglyph
3228 @funindex musicglyph
3229
3230 Music glyphs (such as the segno sign) may be printed inside a
3231 @code{\mark}
3232
3233 @lilypond[quote,verbatim,relative=1]
3234 c1 \mark \markup { \musicglyph #"scripts.segno" }
3235 c1 \mark \markup { \musicglyph #"scripts.coda" }
3236 c1 \mark \markup { \musicglyph #"scripts.ufermata" }
3237 c1
3238 @end lilypond
3239
3240 @noindent
3241 See @ref{The Feta font}, for a list of symbols which may be
3242 printed with @code{\musicglyph}.
3243
3244 For common tweaks to the positioning of rehearsal marks, see
3245 @ref{Formatting text}.  For more precise control, see
3246 @code{break-alignable-interface} in @ref{Aligning objects}.
3247
3248 The file @file{scm/translation-functions.scm} contains
3249 the definitions of @code{format-mark-numbers} and
3250 @code{format-mark-letters}.  They can be used as inspiration for
3251 other formatting functions.
3252
3253 @seealso
3254 Notation Reference:
3255 @ref{The Feta font},
3256 @ref{Formatting text},
3257 @ref{Aligning objects}.
3258
3259 Installed Files:
3260 @file{scm/translation-functions.scm}.
3261
3262 Snippets:
3263 @rlsr{Rhythms}.
3264
3265 Internals Reference:
3266 @rinternals{MarkEvent},
3267 @rinternals{Mark_engraver},
3268 @rinternals{RehearsalMark}.
3269
3270
3271 @node Special rhythmic concerns
3272 @subsection Special rhythmic concerns
3273
3274
3275 @menu
3276 * Grace notes::
3277 * Aligning to cadenzas::
3278 * Time administration::
3279 @end menu
3280
3281 @node Grace notes
3282 @unnumberedsubsubsec Grace notes
3283
3284 @cindex ornaments
3285 @cindex grace notes
3286 @cindex appoggiatura
3287 @cindex acciaccatura
3288
3289 @funindex \grace
3290 @funindex \slashedGrace
3291 @funindex \acciaccatura
3292 @funindex \appoggiatura
3293
3294 Grace notes are musical ornaments, printed in a smaller font, that take
3295 up no additional logical time in a measure.
3296
3297 @lilypond[quote,relative=2,verbatim]
3298 c4 \grace b16 a4(
3299 \grace { b16 c16 } a2)
3300 @end lilypond
3301
3302 There are three other types of grace notes possible; the
3303 @emph{acciaccatura} -- an unmeasured grace note indicated by a slurred
3304 note with a slashed stem -- and the @emph{appoggiatura}, which takes a
3305 fixed fraction of the main note it is attached to and prints without the
3306 slash.  It is also possible to write a grace note with a slashed stem,
3307 like the @emph{acciaccatura} but without the slur, so as to place it
3308 between notes that are slurred themselves, using the
3309 @code{\slashedGrace} function.
3310
3311 @lilypond[quote,relative=2,verbatim]
3312 \acciaccatura d8 c4
3313 \appoggiatura e8 d4
3314 \acciaccatura { g16 f } e2
3315 \slashedGrace a,8 g4
3316 \slashedGrace b16 a4(
3317 \slashedGrace b8 a2)
3318 @end lilypond
3319
3320 The placement of grace notes is synchronized between different staves.
3321 In the following example, there are two sixteenth grace notes for every
3322 eighth grace note
3323
3324 @lilypond[quote,relative=2,verbatim]
3325 <<
3326   \new Staff { e2 \grace { c16 d e f } e2 }
3327   \new Staff { c2 \grace { g8 b } c2 }
3328 >>
3329 @end lilypond
3330
3331 @cindex grace notes, following
3332
3333 @funindex \afterGrace
3334 @funindex afterGrace
3335
3336 If you want to end a note with a grace, use the @code{\afterGrace}
3337 command.  It takes two arguments: the main note, and the grace
3338 notes following the main note.
3339
3340 @lilypond[quote,verbatim,relative=2]
3341 c1 \afterGrace d1 { c16[ d] } c1
3342 @end lilypond
3343
3344 This will put the grace notes after a space lasting 3/4 of the
3345 length of the main note.  The default fraction 3/4 can be changed by
3346 setting @code{afterGraceFraction}.  The following example shows
3347 the results from setting the space at the default,  at 15/16, and
3348 finally at 1/2 of the main note.
3349
3350 @lilypond[quote,verbatim,relative=2]
3351 <<
3352   \new Staff {
3353     c1 \afterGrace d1 { c16[ d] } c1
3354   }
3355   \new Staff {
3356     #(define afterGraceFraction (cons 15 16))
3357     c1 \afterGrace d1 { c16[ d] } c1
3358   }
3359   \new Staff {
3360     #(define afterGraceFraction (cons 1 2))
3361     c1 \afterGrace d1 { c16[ d] } c1
3362   }
3363 >>
3364 @end lilypond
3365
3366 The space between the main note and the grace note may also be
3367 specified using spacers.  The following example places the grace
3368 note after a space lasting 7/8 of the main note.
3369
3370 @lilypond[quote,verbatim,relative=2]
3371 \new Voice {
3372   <<
3373     { d1^\trill_( }
3374     { s2 s4. \grace { c16 d } }
3375   >>
3376   c1)
3377 }
3378 @end lilypond
3379
3380 @cindex tweaking grace notes
3381 @cindex grace notes, tweaking
3382 @cindex grace notes, changing layout settings
3383
3384 A @code{\grace} music expression will introduce special
3385 typesetting settings, for example, to produce smaller type, and
3386 set directions.  Hence, when introducing layout tweaks to
3387 override the special settings, they should be placed inside
3388 the grace expression.  The overrides should also be reverted
3389 inside the grace expression.  Here, the grace note's default stem
3390 direction is overridden and then reverted.
3391
3392 @lilypond[quote,verbatim,relative=2]
3393 \new Voice {
3394   \acciaccatura {
3395     \stemDown
3396     f16->
3397     \stemNeutral
3398   }
3399   g4 e c2
3400 }
3401 @end lilypond
3402
3403
3404 @cindex stem, with slash
3405
3406
3407 @snippets
3408
3409 @lilypondfile[verbatim,quote,texidoc,doctitle]
3410 {using-grace-note-slashes-with-normal-heads.ly}
3411
3412 @lilypondfile[verbatim,quote,texidoc,doctitle]
3413 {tweaking-grace-layout-within-music.ly}
3414
3415 @lilypondfile[verbatim,quote,texidoc,doctitle]
3416 {redefining-grace-note-global-defaults.ly}
3417
3418 @lilypondfile[verbatim,quote,texidoc,doctitle]
3419 {positioning-grace-notes-with-floating-space.ly}
3420
3421 @seealso
3422 Music Glossary:
3423 @rglos{grace notes},
3424 @rglos{acciaccatura},
3425 @rglos{appoggiatura}.
3426
3427 Notation Reference:
3428 @ref{Scaling durations},
3429 @ref{Manual beams}.
3430
3431 Installed Files:
3432 @file{ly/grace-init.ly}.
3433
3434 Snippets:
3435 @rlsr{Rhythms}.
3436
3437 Internals Reference:
3438 @rinternals{GraceMusic},
3439 @rinternals{Grace_beam_engraver},
3440 @rinternals{Grace_auto_beam_engraver},
3441 @rinternals{Grace_engraver},
3442 @rinternals{Grace_spacing_engraver}.
3443
3444
3445 @knownissues
3446 @cindex acciaccatura, multi-note
3447 @cindex multi-note acciaccatura
3448 @cindex grace-note synchronization
3449
3450 A multi-note beamed @i{acciaccatura} is printed without a slash,
3451 and looks exactly the same as a multi-note beamed
3452 @i{appoggiatura}.
3453
3454 @c TODO Add link to LSR snippet to add slash when available
3455
3456 Grace note synchronization can also lead to surprises.  Staff
3457 notation, such as key signatures, bar lines, etc., are also
3458 synchronized.  Take care when you mix staves with grace notes and
3459 staves without, for example,
3460
3461 @lilypond[quote,relative=2,verbatim]
3462 <<
3463   \new Staff { e4 \bar ".|:" \grace c16 d2. }
3464   \new Staff { c4 \bar ".|:" d2. }
3465 >>
3466 @end lilypond
3467
3468 @noindent
3469 This can be remedied by inserting grace skips of the corresponding
3470 durations in the other staves.  For the above example
3471
3472 @lilypond[quote,relative=2,verbatim]
3473 <<
3474   \new Staff { e4 \bar ".|:" \grace c16 d2. }
3475   \new Staff { c4 \bar ".|:" \grace s16 d2. }
3476 >>
3477 @end lilypond
3478
3479 The use of grace notes within voice contexts confuses the way the voice
3480 is typeset. This can be overcome by inserting a rest or note between the
3481 voice command and the grace note.
3482
3483 @lilypond[quote,verbatim]
3484 accMusic = {
3485   \acciaccatura { f8 } e8 r8 \acciaccatura { f8 } e8 r4
3486 }
3487
3488 \new Staff {
3489   <<
3490     \new Voice {
3491       \relative c'' {
3492         r8 r8 \voiceOne \accMusic \oneVoice r8 |
3493         r8 \voiceOne r8 \accMusic \oneVoice r8 |
3494       }
3495     }
3496     \new Voice {
3497       \relative c' {
3498         s8 s8 \voiceTwo \accMusic \oneVoice s8 |
3499         s8 \voiceTwo r8 \accMusic \oneVoice s8 |
3500       }
3501     }
3502   >>
3503 }
3504 @end lilypond
3505
3506 Grace sections should only be used within sequential music expressions.
3507 Nesting or juxtaposing grace sections is not supported, and might
3508 produce crashes or other errors.
3509
3510 Each grace note in MIDI output has a length of 1/4 of its actual
3511 duration.  If the combined length of the grace notes is greater than the
3512 length of the preceding note a @qq{@code{Going back in MIDI time}}
3513 error will be generated.  Either make the grace notes shorter in
3514 duration, for example:
3515
3516 @example
3517 c'8 \acciaccatura @{ c'8[ d' e' f' g'] @}
3518 @end example
3519
3520 becomes:
3521
3522 @example
3523 c'8 \acciaccatura @{ c'16[ d' e' f' g'] @}
3524 @end example
3525
3526 Or explicitly change the musical duration:
3527
3528 @example
3529 c'8 \acciaccatura @{ \scaleDurations 1/2 @{ c'8[ d' e' f' g'] @} @}
3530 @end example
3531
3532 See @ref{Scaling durations}.
3533
3534
3535 @node Aligning to cadenzas
3536 @unnumberedsubsubsec Aligning to cadenzas
3537
3538 @cindex cadenza
3539 @cindex cadenza, aligning to
3540 @cindex aligning to cadenza
3541
3542 In an orchestral context, cadenzas present a special problem: when
3543 constructing a score that includes a measured cadenza or other solo
3544 passage, all other instruments should skip just as many notes as the
3545 length of the cadenza, otherwise they will start too soon or too late.
3546
3547 One solution to this problem is to use the functions
3548 @code{mmrest-of-length} and @code{skip-of-length}.  These Scheme
3549 functions take a defined piece of music as an argument and generate a
3550 multi-measure rest or @code{\skip} exactly as long as the piece.
3551
3552 @lilypond[verbatim,quote]
3553 MyCadenza = \relative c' {
3554   c4 d8 e f g g4
3555   f2 g4 g
3556 }
3557
3558 \new GrandStaff <<
3559   \new Staff {
3560     \MyCadenza c'1
3561     \MyCadenza c'1
3562   }
3563   \new Staff {
3564     #(mmrest-of-length MyCadenza)
3565     c'1
3566     #(skip-of-length MyCadenza)
3567     c'1
3568   }
3569 >>
3570 @end lilypond
3571
3572 @seealso
3573 Music Glossary:
3574 @rglos{cadenza}.
3575
3576 Snippets:
3577 @rlsr{Rhythms}.
3578
3579
3580 @node Time administration
3581 @unnumberedsubsubsec Time administration
3582
3583 @cindex time administration
3584 @cindex timing (within the score)
3585 @cindex music, unmetered
3586 @cindex unmetered music
3587
3588 @funindex currentBarNumber
3589 @funindex measurePosition
3590 @funindex measureLength
3591
3592 Time is administered by the @code{Timing_translator}, which by
3593 default is to be found in the @code{Score} context.  An alias,
3594 @code{Timing}, is added to the context in which the
3595 @code{Timing_translator} is placed.  To ensure that the
3596 @code{Timing} alias is available, you may need to explicitly
3597 instantiate the containing context (such as @code{Voice} or
3598 @code{Staff}).
3599
3600 The following properties of @code{Timing} are used
3601 to keep track of timing within the score.
3602
3603 @cindex bar number
3604 @cindex measure number
3605
3606 @table @code
3607 @item currentBarNumber
3608 The current measure number.  For an example showing the
3609 use of this property see @ref{Bar numbers}.
3610
3611 @item measureLength
3612 The length of the measures in the current time signature.  For a
3613 4/4 time this is@tie{}1, and for 6/8 it is 3/4.  Its value
3614 determines when bar lines are inserted and how automatic beams
3615 should be generated.
3616
3617 @item measurePosition
3618 The point within the measure where we currently are.  This
3619 quantity is reset by subtracting @code{measureLength} whenever
3620 @code{measureLength} is reached or exceeded.  When that happens,
3621 @code{currentBarNumber} is incremented.
3622
3623 @item timing
3624 If set to true, the above variables are updated for every time
3625 step.  When set to false, the engraver stays in the current
3626 measure indefinitely.
3627
3628 @end table
3629
3630 Timing can be changed by setting any of these variables
3631 explicitly.  In the next example, the default 4/4 time
3632 signature is printed, but @code{measureLength} is set to 5/4.
3633 At 4/8 through the third measure, the @code{measurePosition} is
3634 advanced by 1/8 to 5/8, shortening that bar by 1/8.
3635 The next bar line then falls at 9/8 rather than 5/4.
3636
3637 @lilypond[quote,verbatim]
3638 \new Voice \relative c' {
3639   \set Timing.measureLength = #(ly:make-moment 5/4)
3640   c1 c4 |
3641   c1 c4 |
3642   c4 c
3643   \set Timing.measurePosition = #(ly:make-moment 5/8)
3644   b4 b b8 |
3645   c4 c1 |
3646 }
3647 @end lilypond
3648
3649 @noindent
3650 As the example illustrates, @code{ly:make-moment n m} constructs a
3651 duration of n/m of a whole note.  For example,
3652 @code{ly:make-moment 1 8} is an eighth note duration and
3653 @code{ly:make-moment 7 16} is the duration of seven sixteenths
3654 notes.
3655
3656 @seealso
3657 Notation Reference:
3658 @ref{Bar numbers},
3659 @ref{Unmetered music}.
3660
3661 Snippets:
3662 @rlsr{Rhythms}.
3663
3664 Internals Reference:
3665 @rinternals{Timing_translator},
3666 @rinternals{Score}.