]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/notation/rhythms.itely
9422068a219c971659a417491b0a65db84a56d60
[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.  See TRANSLATION for details.
7 @end ignore
8
9 @c \version "2.12.0"
10
11 @node Rhythms
12 @section Rhythms
13
14 @lilypondfile[quote]{rhythms-headword.ly}
15
16 This section discusses rhythms, rests, durations, beaming and bars.
17
18 @menu
19 * Writing rhythms::
20 * Writing rests::
21 * Displaying rhythms::
22 * Beams::
23 * Bars::
24 * Special rhythmic concerns::
25 @end menu
26
27
28 @node Writing rhythms
29 @subsection Writing rhythms
30
31 @menu
32 * Durations::
33 * Tuplets::
34 * Scaling durations::
35 * Ties::
36 @end menu
37
38 @node Durations
39 @unnumberedsubsubsec Durations
40
41 @cindex durations, of notes
42 @cindex note durations
43 @cindex length of notes
44 @cindex note lengths
45
46 @funindex \longa
47 @funindex longa
48 @funindex \breve
49 @funindex breve
50 @funindex \maxima
51 @funindex maxima
52
53 Durations are designated by numbers and dots.  Durations are entered
54 as their reciprocal values.  For example, a quarter note is entered
55 using a @code{4} (since it is a 1/4 note), and a half note is entered
56 using a @code{2} (since it is a 1/2 note).  For notes longer than a
57 whole you must use the @code{\longa} (a double breve) and
58 @code{\breve} commands.  Durations as short as 128th notes may be
59 specified.  Shorter values are possible, but only as beamed notes.
60
61 @c Two 64th notes are needed to obtain beams
62 @lilypond[quote,verbatim,relative=2]
63 \time 8/1
64 c\longa c\breve c1 c2
65 c4 c8 c16 c32 c64 c128 c128
66 @end lilypond
67
68 @noindent
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 @seealso
144 Music Glossary:
145 @rglos{breve},
146 @rglos{longa},
147 @rglos{maxima},
148 @rglos{note value},
149 @rglos{Duration names notes and rests}.
150
151 Notation Reference:
152 @ref{Automatic beams},
153 @ref{Ties},
154 @ref{Stems},
155 @ref{Writing rhythms},
156 @ref{Writing rests},
157 @ref{Vocal music},
158 @ref{Ancient notation},
159 @ref{Proportional notation}.
160
161 Snippets:
162 @rlsr{Rhythms}.
163
164 Internals Reference:
165 @rinternals{Dots},
166 @rinternals{DotColumn}.
167
168
169 @knownissues
170
171 @c Deliberately duplicated in Durations and Rests.  -gp
172 There is no fundamental limit to rest durations (both in terms of
173 longest and shortest), but the number of glyphs is limited:
174 rests from 128th to maxima (8 x whole) may be printed.
175
176
177 @node Tuplets
178 @unnumberedsubsubsec Tuplets
179
180 @cindex tuplets
181 @cindex triplets
182
183 @funindex \times
184 @funindex times
185
186 Tuplets are made from a music expression by multiplying all the
187 durations with a fraction:
188
189 @example
190 \times @var{fraction} @{ @var{music} @}
191 @end example
192
193 @noindent
194 The duration of @var{music} will be multiplied by the
195 fraction.  The fraction's denominator will be printed over or
196 under the notes, optionally with a bracket.  The most common
197 tuplet is the triplet in which 3 notes have the duration of 2, so
198 the notes are 2/3 of their written length.
199
200 @lilypond[quote,verbatim,relative=2]
201 a2 \times 2/3 { b4 b b }
202 c4 c \times 2/3 { b4 a g }
203 @end lilypond
204
205 @cindex tuplet bracket placement
206
207 @funindex \tupletUp
208 @funindex tupletUp
209 @funindex \tupletDown
210 @funindex tupletDown
211 @funindex \tupletNeutral
212 @funindex tupletNeutral
213
214 Tuplet brackets may be manually placed above or below the staff;
215 see @ref{Direction and placement}.
216
217 Tuplets may be nested:
218
219 @lilypond[quote,verbatim,relative=2]
220 \autoBeamOff
221 c4 \times 4/5 { f8 e f \times 2/3 { e[ f g] } } f4 |
222 @end lilypond
223
224 Modifying nested tuplets which begin at the same musical moment
225 must be done with @code{\tweak}.
226
227 To modify the duration of notes without printing a tuplet bracket,
228 see @ref{Scaling durations}.
229
230
231 @predefined
232 @code{\tupletUp},
233 @code{\tupletDown},
234 @code{\tupletNeutral}.
235 @endpredefined
236
237
238 @snippets
239
240 @cindex tuplet formatting
241 @cindex triplet formatting
242
243 @funindex tupletNumberFormatFunction
244 @funindex tupletSpannerDuration
245
246 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
247 {entering-several-tuplets-using-only-one--times-command.ly}
248
249 @cindex Tuplet number changes
250
251 @funindex TupletNumber
252
253 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
254 {changing-the-tuplet-number.ly}
255
256 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
257 {non-default-tuplet-numbers.ly}
258
259 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
260 {permitting-line-breaks-within-beamed-tuplets.ly}
261
262
263 @seealso
264 Music Glossary:
265 @rglos{triplet},
266 @rglos{tuplet},
267 @rglos{polymetric}.
268
269 Learning Manual: @rlearning{Tweaking methods}.
270
271 Notation Reference:
272 @ref{Time administration},
273 @ref{Scaling durations},
274 @ref{The tweak command},
275 @ref{Polymetric notation}.
276
277 Snippets:
278 @rlsr{Rhythms}.
279
280 Internals Reference:
281 @rinternals{TupletBracket},
282 @rinternals{TupletNumber},
283 @rinternals{TimeScaledMusic}.
284
285 @cindex grace notes within tuplet brackets
286
287 @knownissues
288 When the first note on a staff is a grace note followed by a
289 tuplet the grace note must be placed before the @code{\times}
290 command to avoid errors.  Anywhere else, grace notes may be
291 placed within tuplet brackets.
292
293
294 @node Scaling durations
295 @unnumberedsubsubsec Scaling durations
296
297 @cindex scaling durations
298 @cindex durations, scaling
299
300 You can alter the duration of single notes, rests or chords by a
301 fraction @code{N/M} by appending @code{*N/M} (or @code{*N} if @code{M}
302 is 1) to the duration.  This will not affect the appearance of the
303 notes or rests produced, but the altered duration will be used in
304 calculating the position within the measure and setting the duration
305 in the MIDI output.  Multiplying factors may be combined such as
306 @code{*L*M/N}.
307
308 In the following example, the first three notes take up exactly
309 two beats, but no triplet bracket is printed.
310
311 @lilypond[quote,relative=2,verbatim]
312 \time 2/4
313 % Alter durations to triplets
314 a4*2/3 gis4*2/3 a4*2/3
315 % Normal durations
316 a4 a4
317 % Double the duration of chord
318 <a d>4*2
319 % Duration of quarter, appears like sixteenth
320 b16*4 c4
321 @end lilypond
322
323 The duration of skip or spacing notes may also be modified by
324 a multiplier.  This is useful for skipping many measures, e.g.,
325 @code{s1*23}.
326
327 @cindex compressing music
328 @cindex expanding music
329
330 @funindex \scaleDurations
331 @funindex scaleDurations
332
333 Longer stretches of music may be compressed by a fraction in the
334 same way, as if every note, chord or rest had the fraction as a
335 multiplier.  This leaves the appearance of the music unchanged but
336 the internal duration of the notes will be multiplied by the
337 fraction @emph{num}/@emph{den}.  The spaces around the dot are
338 required.  Here is an example showing how music can be compressed
339 and expanded:
340
341 @lilypond[quote,relative=2,verbatim]
342 \time 2/4
343 % Normal durations
344 <c a>4 c8 a
345 % Scale music by *2/3
346 \scaleDurations #'(2 . 3) {
347   <c a f>4. c8 a f
348 }
349 % Scale music by *2
350 \scaleDurations #'(2 . 1) {
351   <c' a>4 c8 b
352 }
353 @end lilypond
354
355 @noindent
356 One application of this command is in polymetric
357 notation, see @ref{Polymetric notation}.
358
359
360 @seealso
361 Notation Reference:
362 @ref{Tuplets},
363 @ref{Invisible rests},
364 @ref{Polymetric notation}.
365
366 Snippets:
367 @rlsr{Rhythms}.
368
369
370 @node Ties
371 @unnumberedsubsubsec Ties
372
373 @cindex tie
374
375 @funindex ~
376
377 A tie connects two adjacent note heads of the same pitch.  The tie
378 in effect extends the duration of a note.
379
380 @warning{Ties should not be confused with @emph{slurs}, which
381 indicate articulation, or @emph{phrasing slurs}, which indicate
382 musical phrasing.  A tie is just a way of extending a note
383 duration, similar to the augmentation dot.}
384
385 A tie is entered using the tilde symbol (@code{~}).
386
387 @lilypond[quote,verbatim,relative=2]
388 a2 ~ a
389 @end lilypond
390
391
392 @noindent
393 Ties are used either when the note crosses a bar line, or when
394 dots cannot be used to denote the rhythm.  Ties should also be
395 used when note values cross larger subdivisions of the measure:
396
397 @lilypond[verbatim,quote]
398 \relative c' {
399   r8 c8 ~ c2 r4 |
400   r8^"not" c2 ~ c8 r4
401 }
402 @end lilypond
403
404 If you need to tie many notes across bar lines, it may be
405 easier to use automatic note splitting, see @ref{Automatic note
406 splitting}.  This mechanism automatically splits long notes, and
407 ties them across bar lines.
408
409 @cindex ties and chords
410 @cindex chords and ties
411
412 When a tie is applied to a chord, all note heads whose pitches
413 match are connected.  When no note heads match, no ties will be
414 created.  Chords may be partially tied by placing the tie inside
415 the chord.
416
417 @lilypond[quote,verbatim,relative=1]
418 <c e g> ~ <c e g>
419 <c~ e g~ b> <c e g b>
420 @end lilypond
421
422 @cindex repeating ties
423 @cindex ties, repeating
424 @cindex volta brackets and ties
425 @cindex ties and volta brackets
426
427 @funindex \repeatTie
428 @funindex repeatTie
429
430 When a second alternative of a repeat starts with a tied note, you
431 have to specify the repeated tie as follows:
432
433 @lilypond[quote,relative=2,verbatim]
434 \repeat volta 2 { c g <c e>2 ~ }
435 \alternative {
436   % First alternative: following note is tied normally
437   { <c e>2. r4 }
438   % Second alternative: following note has a repeated tie
439   { <c e>2\repeatTie d4 c } }
440 @end lilypond
441
442 @cindex laissez vibrer
443 @cindex ties, laissez vibrer
444
445 @funindex \laissezVibrer
446 @funindex laissezVibrer
447
448 @notation{L.v.} ties (@notation{laissez vibrer}) indicate that
449 notes must not be damped at the end.  It is used in notation for
450 piano, harp and other string and percussion instruments.  They can
451 be entered as follows:
452
453 @lilypond[quote,verbatim,relative=1]
454 <c f g>1\laissezVibrer
455 @end lilypond
456
457 @cindex ties, placement
458
459 @funindex \tieUp
460 @funindex tieUp
461 @funindex \tieDown
462 @funindex tieDown
463 @funindex \tieNeutral
464 @funindex tieNeutral
465
466 Ties may be manually placed above or below the staff; see
467 @ref{Direction and placement}.
468
469 @cindex ties, appearance
470 @cindex ties, dotted
471 @cindex ties, dashed
472 @cindex dashed ties
473 @cindex dotted ties
474
475 @funindex \tieDotted
476 @funindex tieDotted
477 @funindex \tieDashed
478 @funindex tieDashed
479 @funindex \tieSolid
480 @funindex tieSolid
481
482 Ties may be made dashed, dotted, or a combination of solid and
483 dashed.
484
485 @lilypond[quote, verbatim, relative=1]
486 \tieDotted
487 c2 ~ c
488 \tieDashed
489 c2 ~ c
490 \tieHalfDashed
491 c2 ~ c
492 \tieHalfSolid
493 c2 ~ c
494 \tieSolid
495 c2 ~ c
496 @end lilypond
497
498 Custom dash patterns can be specified:
499
500 @lilypond[quote, verbatim, relative=1]
501 \tieDashPattern #0.3 #0.75
502 c2 ~ c
503 \tieDashPattern #0.7 #1.5
504 c2 ~ c
505 \tieSolid
506 c2 ~ c
507 @end lilypond
508
509 Dash pattern definitions for ties have the same structure as 
510 dash pattern definitions for slurs.
511 For more information about complex dash patterns,
512 see the snippets under @ref{Slurs}. 
513
514 @predefined
515 @code{\tieUp},
516 @code{\tieDown},
517 @code{\tieNeutral},
518 @code{\tieDotted},
519 @code{\tieDashed},
520 @code{\tieDashPattern},
521 @code{\tieHalfDashed},
522 @code{\tieHalfSolid},
523 @code{\tieSolid}.
524 @endpredefined
525
526
527 @snippets
528
529 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
530 {using-ties-with-arpeggios.ly}
531
532 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
533 {engraving-ties-manually.ly}
534
535
536 @seealso
537 Music Glossary:
538 @rglos{tie},
539 @rglos{laissez vibrer}.
540
541 Notation Reference: 
542 @ref{Slurs},
543 @ref{Automatic note splitting}.
544
545 Snippets:
546 @rlsr{Rhythms}.
547
548 Internals Reference:
549 @rinternals{LaissezVibrerTie},
550 @rinternals{LaissezVibrerTieColumn},
551 @rinternals{TieColumn},
552 @rinternals{Tie}.
553
554
555 @knownissues
556
557 Switching staves when a tie is active will not produce a slanted
558 tie.
559
560 Changing clefs or octavations during a tie is not really
561 well-defined.  In these cases, a slur may be preferable.
562
563
564
565 @node Writing rests
566 @subsection Writing rests
567
568 Rests are entered as part of the music in music expressions.
569
570 @menu
571 * Rests::
572 * Invisible rests::
573 * Full measure rests::
574 @end menu
575
576 @node Rests
577 @unnumberedsubsubsec Rests
578
579 @cindex rest
580 @cindex rest, entering durations
581 @cindex maxima rest
582 @cindex longa rest
583 @cindex breve rest
584
585 @funindex \rest
586 @funindex rest
587 @funindex r
588 @funindex \maxima
589 @funindex maxima
590 @funindex \longa
591 @funindex longa
592 @funindex \breve
593 @funindex breve
594
595 Rests are entered like notes with the note name @code{r}.
596 Durations longer than a whole rest use the predefined
597 commands shown:
598
599 @c \time 16/1 is used to avoid spurious bar lines
600 @c and long tracts of empty measures
601 @lilypond[fragment,quote,verbatim]
602 \new Staff {
603   % These two lines are just to prettify this example
604   \time 16/1
605   \override Staff.TimeSignature #'stencil = ##f
606   % Print a maxima rest, equal to four breves
607   r\maxima
608   % Print a longa rest, equal to two breves
609   r\longa
610   % Print a breve rest
611   r\breve
612   r1 r2 r4 r8 r16 r32 r64 r128
613 }
614 @end lilypond
615
616 @cindex rest, multi-measure
617 @cindex rest, whole-measure
618
619 Whole measure rests, centered in the middle of the measure, must be
620 entered as multi-measure rests.  They can be used for a single
621 measure as well as many measures and are discussed in @ref{Full
622 measure rests}.
623
624 @cindex rest, specifying vertical position
625
626 To explicitly specify a rest's vertical position, write a note
627 followed by @code{\rest}.  A rest of the duration of the note will
628 be placed at the staff position where the note would appear.  This
629 allows for precise manual formatting of polyphonic music, since the
630 automatic rest collision formatter will not move these rests.
631
632 @lilypond[quote,verbatim,relative=2]
633 a4\rest d4\rest
634 @end lilypond
635
636 @snippets
637
638 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
639 {rest-styles.ly}
640
641
642 @seealso
643 Music Glossary:
644 @rglos{breve},
645 @rglos{longa},
646 @rglos{maxima}.
647
648 Notation Reference:
649 @ref{Full measure rests}.
650
651 Snippets:
652 @rlsr{Rhythms}.
653
654 Internals Reference:
655 @rinternals{Rest}.
656
657
658 @knownissues
659
660 @c Deliberately duplicated in Durations and Rests.  -gp
661 There is no fundamental limit to rest durations (both in terms of
662 longest and shortest), but the number of glyphs is limited: there
663 are rests from 128th to maxima (8 x whole).
664
665
666 @node Invisible rests
667 @unnumberedsubsubsec Invisible rests
668
669 @cindex skip
670 @cindex invisible rest
671 @cindex rest, invisible
672 @cindex spacer note
673 @cindex spacer rest
674
675 @funindex s
676 @funindex \skip
677 @funindex skip
678
679 An invisible rest (also called a @q{spacer rest}) can be entered
680 like a note with the note name@tie{}@code{s}:
681
682 @lilypond[verbatim,quote,relative=2]
683 c4 c s c
684 s2 c
685 @end lilypond
686
687 @cindex lyrics, skip
688
689 Spacer rests are available only in note mode and chord mode.  In
690 other situations, for example, when entering lyrics, @code{\skip}
691 is used to skip a musical moment.  @code{\skip} requires an
692 explicit duration.
693
694 @lilypond[quote,verbatim,relative=2]
695 <<
696   {
697     a2 \skip2 a2 a2
698   }
699   \new Lyrics {
700     \lyricmode {
701       foo2 \skip 1 bla2
702     }
703   }
704 >>
705 @end lilypond
706
707 A spacer rest implicitly causes @code{Staff} and @code{Voice}
708 contexts to be created if none exist, just like notes and rests
709 do:
710
711 @lilypond[quote,verbatim,fragment]
712 s1 s s
713 @end lilypond
714
715 @code{\skip} simply skips musical time; it creates no output of
716 any kind.
717
718 @lilypond[quote,verbatim,fragment]
719 % This is valid input, but does nothing
720 \skip 1 \skip1 \skip 1
721 @end lilypond
722
723
724 @seealso
725 Learning Manual:
726 @rlearning{Visibility and color of objects}.
727
728 Notation Reference:
729 @ref{Hidden notes},
730 @ref{Visibility of objects}.
731
732 Snippets:
733 @rlsr{Rhythms}.
734
735 Internals Reference: 
736 @rinternals{SkipMusic}.
737
738
739 @node Full measure rests
740 @unnumberedsubsubsec Full measure rests
741
742 @cindex multi-measure rests
743 @cindex full-measure rests
744 @cindex rest, multi-measure
745 @cindex rest, full-measure
746 @cindex whole rest for a full measure
747 @cindex rest, whole for a full measure
748
749 @funindex R
750
751 Rests for one or more full measures are entered like notes with
752 the note name uppercase @code{R}:
753
754 @lilypond[quote,verbatim,relative=2]
755 % Rest measures contracted to single measure
756 \compressFullBarRests
757 R1*4
758 R1*24
759 R1*4
760 b2^"Tutti" b4 a4
761 @end lilypond
762
763 The duration of full-measure rests is identical to the duration
764 notation used for notes.  The duration in a multi-measure rest must
765 always be an integral number of measure-lengths, so augmentation dots
766 or fractions must often be used:
767
768 @lilypond[quote,fragment,verbatim]
769 \compressFullBarRests
770 \time 2/4
771 R1 | R2 |
772 \time 3/4
773 R2. | R2.*2 |
774 \time 13/8
775 R1*13/8 | R1*13/8*12 |
776 \time 10/8
777 R4*5*4 |
778 @end lilypond
779
780 A full-measure rest is printed as either a whole or breve rest,
781 centered in the measure, depending on the time signature.
782
783 @lilypond[quote,verbatim,fragment]
784 \time 4/4
785 R1 |
786 \time 6/4
787 R1*3/2 |
788 \time 8/4
789 R1*2 |
790 @end lilypond
791
792 @cindex multi-measure rest, expanding
793 @cindex multi-measure rest, contracting
794
795 @funindex \expandFullBarRests
796 @funindex expandFullBarRests
797 @funindex \compressFullBarRests
798 @funindex compressFullBarRests
799
800 By default a multi-measure rest is expanded in the printed score to
801 show all the rest measures explicitly.  Alternatively, a multi-measure
802 rest can be shown as a single measure containing a multi-measure rest
803 symbol, with the number of measures of rest printed above the measure:
804
805 @lilypond[quote,fragment,verbatim]
806 % Default behavior
807 \time 3/4 r2. | R2.*2 |
808 \time 2/4 R2 |
809 \time 4/4
810 % Rest measures contracted to single measure
811 \compressFullBarRests
812 r1 | R1*17 | R1*4 |
813 % Rest measures expanded
814 \expandFullBarRests
815 \time 3/4
816 R2.*2 |
817 @end lilypond
818
819
820 @cindex text on multi-measure rest
821 @cindex multi-measure rest, attaching text
822 @cindex script on multi-measure rest
823 @cindex multi-measure rest, script
824 @cindex fermata on multi-measure rest
825 @cindex multi-measure rest, attaching fermata
826 @cindex markup on multi-measure rest
827 @cindex multi-measure rest with markup
828
829 @funindex \fermataMarkup
830 @funindex fermataMarkup
831 @funindex MultiMeasureRestText
832
833 Markups can be added to multi-measure rests.
834 The predefined command @code{\fermataMarkup}
835 is provided for adding fermatas.
836
837 @lilypond[quote,verbatim,fragment]
838 \compressFullBarRests
839 \time 3/4
840 R2.*10^\markup { \italic "ad lib." }
841 R2.^\fermataMarkup
842 @end lilypond
843
844 @warning{
845 Markups attached to a multi-measure rest are
846 objects of type @code{MultiMeasureRestText}, not
847 @code{TextScript}.  Overrides must be directed to the correct
848 object, or they will be ignored.  See the following example.
849 }
850
851 @lilypond[quote,verbatim,fragment]
852 % This fails, as the wrong object name is specified
853 \override TextScript #'padding = #5
854 R1^"wrong"
855 % This is correct and works
856 \override MultiMeasureRestText #'padding = #5
857 R1^"right"
858 @end lilypond
859
860 When a multi-measure rest immediately follows a @code{\partial}
861 setting, resulting bar-check warnings may not be displayed.
862
863
864 @funindex \textLengthOn
865 @funindex textLengthOn
866 @funindex \textLengthOff
867 @funindex textLenthOff
868 @funindex \fermataMarkup
869 @funindex fermataMarkup
870 @funindex \compressFullBarRests
871 @funindex compressFullBarRests
872 @funindex \expandFullBarRests
873 @funindex expandFullBarRests
874
875 @predefined
876 @code{\textLengthOn},
877 @code{\textLengthOff},
878 @code{\fermataMarkup},
879 @code{\compressFullBarRests},
880 @code{\expandFullBarRests}.
881 @endpredefined
882
883
884 @snippets
885
886 @cindex church rest
887 @cindex rest, church
888 @cindex kirchenpausen
889
890 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
891 {changing-form-of-multi-measure-rests.ly}
892
893 @cindex multi-measure rests, positioning
894 @cindex positioning multi-measure rests
895
896 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
897 {positioning-multi-measure-rests.ly}
898
899 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
900 {multi-measure-rest-markup.ly}
901
902
903 @seealso
904 Music Glossary:
905 @rglos{multi-measure rest}.
906
907 Notation Reference:
908 @ref{Durations},
909 @ref{Text},
910 @ref{Formatting text},
911 @ref{Text scripts}.
912
913 Snippets:
914 @rlsr{Rhythms}.
915
916 Internals Reference:
917 @rinternals{MultiMeasureRest},
918 @rinternals{MultiMeasureRestNumber},
919 @rinternals{MultiMeasureRestText}.
920
921
922 @cindex fingerings and multi-measure rests
923 @cindex multi-measure rests and fingerings
924
925 @knownissues
926
927 If an attempt is made to use fingerings (e.g.,
928 @code{R1*10-4}) to put numbers over multi-measure rests, the
929 fingering numeral (4) may collide with the bar counter
930 numeral (10).
931
932 @cindex condensing rests
933 @cindex rest, condensing ordinary
934
935 There is no way to automatically condense multiple ordinary rests
936 into a single multi-measure rest.
937
938 @cindex rest, collisions of
939
940 Multi-measure rests do not take part in rest collisions.
941
942 @node Displaying rhythms
943 @subsection Displaying rhythms
944
945 @menu
946 * Time signature::
947 * Upbeats::
948 * Unmetered music::
949 * Polymetric notation::
950 * Automatic note splitting::
951 * Showing melody rhythms::
952 @end menu
953
954 @node Time signature
955 @unnumberedsubsubsec Time signature
956
957 @cindex time signature
958 @cindex meter
959
960 @funindex \time
961 @funindex time
962
963 The time signature is set as follows:
964
965 @lilypond[quote,verbatim,relative=2]
966 \time 2/4 c2
967 \time 3/4 c2.
968 @end lilypond
969
970 @cindex time signature, visibility of
971
972 Time signatures are printed at the beginning of a piece
973 and whenever the time signature changes.  If a change takes place
974 at the end of a line a warning time signature sign is printed
975 there.  This default behavior may be changed, see
976 @ref{Visibility of objects}.
977
978 @lilypond[quote,verbatim,relative=2]
979 \time 2/4
980 c2 c
981 \break
982 c c
983 \break
984 \time 4/4
985 c c c c
986 @end lilypond
987
988 @cindex time signature style
989 @cindex meter style
990
991 @funindex \numericTimeSignature
992 @funindex numericTimeSignature
993 @funindex \defaultTimeSignature
994 @funindex defaultTimeSignature
995
996 The time signature symbol that is used in 2/2 and 4/4 time can be
997 changed to a numeric style:
998
999 @lilypond[quote,verbatim,relative=2]
1000 % Default style
1001 \time 4/4 c1
1002 \time 2/2 c1
1003 % Change to numeric style
1004 \numericTimeSignature
1005 \time 4/4 c1
1006 \time 2/2 c1
1007 % Revert to default style
1008 \defaultTimeSignature
1009 \time 4/4 c1
1010 \time 2/2 c1
1011 @end lilypond
1012
1013
1014 Mensural time signatures are covered in
1015 @ref{Mensural time signatures}.
1016
1017
1018 @predefined
1019 @code{\numericTimeSignature},
1020 @code{\defaultTimeSignature}.
1021 @endpredefined
1022
1023
1024 @snippets
1025
1026 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1027 {changing-the-time-signature-without-affecting-the-beaming.ly}
1028
1029 @cindex compound time signatures
1030 @cindex time signature, compound
1031
1032 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1033 {compound-time-signatures.ly}
1034
1035
1036 @seealso
1037 Music Glossary:
1038 @rglos{time signature}
1039
1040 Notation Reference:
1041 @ref{Mensural time signatures},
1042 @ref{Time administration}.
1043
1044 Snippets:
1045 @rlsr{Rhythms}.
1046
1047 Internals Reference:
1048 @rinternals{TimeSignature},
1049 @rinternals{Timing_translator}.
1050
1051
1052 @node Upbeats
1053 @unnumberedsubsubsec Upbeats
1054
1055 @cindex anacrusis
1056 @cindex upbeat
1057 @cindex partial measure
1058 @cindex measure, partial
1059 @cindex pickup measure
1060 @cindex measure, change length
1061
1062 @funindex measurePosition
1063 @funindex \partial
1064 @funindex partial
1065
1066 Partial or pick-up measures, such as an anacrusis or upbeat, are
1067 entered using the @code{\partial} command, with the syntax
1068
1069 @example
1070 \partial @var{duration}
1071 @end example
1072
1073 where @code{duration} is the rhythmic length of the interval
1074 before the start of the first complete measure:
1075
1076 @lilypond[quote,verbatim,relative=2]
1077 \partial 4 e4 |
1078 a2. c,4 |
1079 @end lilypond
1080
1081 The partial measure can be any duration less than a full measure:
1082
1083 @lilypond[quote,verbatim,relative=2]
1084 \partial 8*3 c8 d e |
1085 a2. c,4 |
1086 @end lilypond
1087
1088 Internally, this is translated into
1089
1090 @example
1091 \set Timing.measurePosition = -@var{duration}
1092 @end example
1093
1094 The property @code{measurePosition} contains a rational number
1095 indicating how much of the measure has passed at this point.  Note
1096 that this is set to a negative number by the @code{\partial}
1097 command: i.e., @code{\partial 4} is internally translated to
1098 @code{-4}, meaning @qq{there is a quarter note left in the measure.}
1099
1100
1101 @seealso
1102 Music Glossary:
1103 @rglos{anacrusis}.
1104
1105 Notation Reference:
1106 @ref{Grace notes}.
1107
1108 Snippets:
1109 @rlsr{Rhythms}.
1110
1111 Internal Reference:
1112 @rinternals{Timing_translator}.
1113
1114
1115 @knownissues
1116
1117 The @code{\partial} command is intended to be used only at the
1118 beginning of a piece.  If you use it after the beginning, some
1119 odd warnings may occur.
1120
1121 @node Unmetered music
1122 @unnumberedsubsubsec Unmetered music
1123
1124 @cindex bar lines, turning off
1125 @cindex bar numbering, turning off
1126 @cindex cadenza
1127 @cindex unmetered music
1128
1129 @funindex \cadenzaOn
1130 @funindex cadenzaOn
1131 @funindex \cadenzaOff
1132 @funindex cadenzaOff
1133
1134 Bar lines and bar numbers are calculated automatically.  For
1135 unmetered music (some cadenzas, for example), this is not desirable.
1136 To turn off automatic calculation of bar lines and bar numbers,
1137 use the command @code{\cadenzaOn}, and use @code{\cadenzaOff}
1138 to turn them on again.
1139
1140 @lilypond[verbatim,relative=2,fragment]
1141 c4 d e d
1142 \cadenzaOn
1143 c4 c d8 d d f4 g4.
1144 \cadenzaOff
1145 \bar "|"
1146 d4 e d c
1147 @end lilypond
1148
1149 Bar numbering is resumed at the end of the cadenza as if the
1150 cadenza were not there:
1151
1152 @lilypond[verbatim,relative=2,fragment]
1153 % Show all bar numbers
1154 \override Score.BarNumber #'break-visibility = #all-visible
1155 c4 d e d
1156 \cadenzaOn
1157 c4 c d8 d d f4 g4.
1158 \cadenzaOff
1159 \bar "|"
1160 d4 e d c
1161 @end lilypond
1162
1163
1164 @predefined
1165 @code{\cadenzaOn},
1166 @code{\cadenzaOff}.
1167 @endpredefined
1168
1169
1170 @seealso
1171 Music Glossary:
1172 @rglos{cadenza}.
1173
1174 Notation Reference:
1175 @ref{Visibility of objects}.
1176
1177 Snippets:
1178 @rlsr{Rhythms}.
1179
1180
1181 @cindex cadenza line breaks
1182 @cindex cadenza page breaks
1183 @cindex unmetered music, line breaks
1184 @cindex unmetered music, page breaks
1185 @cindex breaks in unmetered music
1186 @cindex line breaks in cadenzas
1187 @cindex page breaks in cadenzas
1188 @cindex line breaks in unmetered music
1189 @cindex page breaks in unmetered music
1190
1191 @knownissues
1192
1193 LilyPond will insert line breaks and page breaks only at a
1194 bar line.  Unless the unmetered music ends before the end of the
1195 staff line, you will need to insert invisible bar lines with
1196
1197 @example
1198 \bar ""
1199 @end example
1200
1201 @noindent
1202 to indicate where breaks can occur.
1203
1204
1205 @node Polymetric notation
1206 @unnumberedsubsubsec Polymetric notation
1207
1208 @c This section necessarily uses \set
1209 @c This is acceptable  -td
1210
1211 @cindex double time signatures
1212 @cindex signatures, polymetric
1213 @cindex time signatures, polymetric
1214 @cindex time signatures, double
1215 @cindex polymetric signatures
1216 @cindex meter, polymetric
1217
1218 @funindex timeSignatureFraction
1219 @funindex \scaleDurations
1220 @funindex scaleDurations
1221 @funindex \times
1222 @funindex times
1223
1224 Polymetric notation is supported, either explicitly or by modifying
1225 the visible time signature symbol and scaling the note durations.
1226
1227 @strong{@i{Staves with different time signatures, equal measure lengths}}
1228
1229 This notation can be created by setting a common time signature
1230 for each staff but replacing the symbol manually by setting
1231 @code{timeSignatureFraction} to the desired fraction and scaling
1232 the printed durations in each staff to the common time
1233 signature; see @ref{Time signature}.  The scaling is done with
1234 @code{\scaleDurations}, which is used in a similar way to
1235 @code{\times}, but does not create a tuplet bracket; see
1236 @ref{Scaling durations}.
1237
1238 @cindex beaming in polymetric music
1239 @cindex beaming in polymetric meter
1240
1241 In this example, music with the time signatures of 3/4, 9/8, and
1242 10/8 are used in parallel.  In the second staff, shown durations
1243 are multiplied by 2/3, as 2/3 * 9/8 = 3/4, and in the third
1244 staff, shown durations are multiplied by 3/5, as 3/5 * 10/8 = 3/4.
1245 It will often be necessary to insert beams manually, as the
1246 duration scaling affects the autobeaming rules.
1247
1248 @lilypond[quote,verbatim,fragment]
1249 \relative c' <<
1250   \new Staff {
1251     \time 3/4
1252     c4 c c |
1253     c c c |
1254   }
1255   \new Staff {
1256     \time 3/4
1257     \set Staff.timeSignatureFraction = #'(9 . 8)
1258     \scaleDurations #'(2 . 3)
1259     \repeat unfold 6 { c8[ c c] }
1260   }
1261   \new Staff {
1262     \time 3/4
1263     \set Staff.timeSignatureFraction = #'(10 . 8)
1264     \scaleDurations #'(3 . 5) {
1265       \repeat unfold 2 { c8[ c c] }
1266       \repeat unfold 2 { c8[ c] } |
1267       c4. c4. \times 2/3 { c8[ c c] } c4
1268     }
1269   }
1270 >>
1271 @end lilypond
1272
1273 @strong{@i{Staves with different time signatures, unequal bar lengths}}
1274
1275 Each staff can be given its own independent time signature by
1276 moving the @code{Timing_translator} and the
1277 @code{Default_bar_line_engraver} to the @code{Staff} context.
1278
1279 @lilypond[quote,verbatim]
1280 \layout {
1281   \context {
1282     \Score
1283     \remove "Timing_translator"
1284     \remove "Default_bar_line_engraver"
1285   }
1286   \context {
1287     \Staff
1288     \consists "Timing_translator"
1289     \consists "Default_bar_line_engraver"
1290   }
1291 }
1292
1293 % Now each staff has its own time signature.
1294
1295 \relative c' <<
1296   \new Staff {
1297     \time 3/4
1298     c4 c c |
1299     c c c |
1300   }
1301   \new Staff {
1302     \time 2/4
1303     c4 c |
1304     c c |
1305     c c |
1306   }
1307   \new Staff {
1308     \time 3/8
1309     c4. |
1310     c8 c c |
1311     c4. |
1312     c8 c c |
1313   }
1314 >>
1315 @end lilypond
1316
1317 @snippets
1318
1319 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1320 {compound-time-signatures.ly}
1321
1322
1323 @seealso
1324 Music Glossary:
1325 @rglos{polymetric},
1326 @rglos{polymetric time signature},
1327 @rglos{meter}.
1328
1329 Notation Reference:
1330 @ref{Time signature},
1331 @ref{Scaling durations}.
1332
1333 Snippets:
1334 @rlsr{Rhythms}.
1335
1336 Internals Reference:
1337 @rinternals{TimeSignature},
1338 @rinternals{Timing_translator},
1339 @rinternals{Default_bar_line_engraver},
1340 @rinternals{Staff}.
1341
1342
1343 @knownissues
1344
1345 When using different time signatures in parallel, notes
1346 at the same moment will be be placed at the same horizontal
1347 location.  However, the bar lines in the different staves
1348 will cause the note spacing to be less regular in each of the
1349 individual staves than would be normal without the different
1350 time signatures.
1351
1352 @node Automatic note splitting
1353 @unnumberedsubsubsec Automatic note splitting
1354
1355 @cindex notes, splitting
1356 @cindex splitting notes
1357
1358 @funindex Note_heads_engraver
1359 @funindex Completion_heads_engraver
1360
1361 Long notes which overrun bar lines can be converted automatically
1362 to tied notes.  This is done by replacing the
1363 @code{Note_heads_engraver} with the
1364 @code{Completion_heads_engraver}.  In the following
1365 example, notes crossing the bar lines are split and tied.
1366
1367 @lilypond[quote,verbatim,relative=1]
1368 \new Voice \with {
1369   \remove "Note_heads_engraver"
1370   \consists "Completion_heads_engraver"
1371 }
1372
1373 { c2. c8 d4 e f g a b c8 c2 b4 a g16 f4 e d c8. c2 }
1374 @end lilypond
1375
1376 This engraver splits all running notes at the bar line, and
1377 inserts ties.  One of its uses is to debug complex scores: if the
1378 measures are not entirely filled, then the ties show exactly how
1379 much each measure is off.
1380
1381
1382 @seealso
1383 Music Glossary: @rglos{tie}
1384
1385 Learning Manual:
1386 @rlearning{Engravers explained},
1387 @rlearning{Adding and removing engravers}.
1388
1389 Snippets:
1390 @rlsr{Rhythms}.
1391
1392 Internals Reference:
1393 @rinternals{Note_heads_engraver},
1394 @rinternals{Completion_heads_engraver},
1395 @rinternals{Forbid_line_break_engraver}.
1396
1397
1398 @knownissues
1399
1400 Not all durations (especially those containing tuplets) can be
1401 represented exactly with normal notes and dots, but the
1402 @code{Completion_heads_engraver} will not insert tuplets.
1403
1404 The @code{Completion_heads_engraver} only affects notes; it does not
1405 split rests.
1406
1407
1408 @node Showing melody rhythms
1409 @unnumberedsubsubsec Showing melody rhythms
1410
1411 @cindex melody rhythms, showing
1412 @cindex rhythms, showing melody
1413
1414 Sometimes you might want to show only the rhythm of a melody.  This
1415 can be done with the rhythmic staff.  All pitches of notes on such a
1416 staff are squashed, and the staff itself has a single line
1417
1418 @lilypond[quote,relative=1,verbatim]
1419 <<
1420   \new RhythmicStaff {
1421     \new Voice = "myRhythm" {
1422       \time 4/4
1423       c4 e8 f g2
1424       r4 g g f
1425       g1
1426     }
1427   }
1428   \new Lyrics {
1429     \lyricsto "myRhythm" {
1430       This is my song
1431       I like to sing
1432     }
1433   }
1434 >>
1435 @end lilypond
1436
1437 @cindex guitar chord charts
1438 @cindex strumming rhythms, showing
1439 @cindex guitar strumming rhythms, showing
1440
1441 @funindex Pitch_squash_engraver
1442 @funindex \improvisationOn
1443 @funindex improvisationOn
1444 @funindex \improvisationOff
1445 @funindex improvisationOff
1446
1447 Guitar chord charts often show the strumming rhythms.  This can
1448 be done with the @code{Pitch_squash_engraver} and
1449 @code{\improvisationOn}.
1450
1451
1452 @lilypond[quote,verbatim]
1453 <<
1454   \new ChordNames {
1455     \chordmode {
1456       c1 f g c
1457     }
1458   }
1459
1460   \new Voice \with {
1461     \consists Pitch_squash_engraver
1462   } \relative c'' {
1463     \improvisationOn
1464     c4 c8 c c4 c8 c
1465     f4 f8 f f4 f8 f
1466     g4 g8 g g4 g8 g
1467     c4 c8 c c4 c8 c
1468   }
1469 >>
1470 @end lilypond
1471
1472
1473 @predefined
1474 @code{\improvisationOn},
1475 @code{\improvisationOff}.
1476 @endpredefined
1477
1478
1479 @snippets
1480
1481 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1482 {guitar-strum-rhythms.ly}
1483
1484
1485 @seealso
1486 Snippets:
1487 @rlsr{Rhythms}.
1488
1489 Internals Reference:
1490 @rinternals{RhythmicStaff},
1491 @rinternals{Pitch_squash_engraver}.
1492
1493
1494 @node Beams
1495 @subsection Beams
1496
1497 @menu
1498 * Automatic beams::
1499 * Setting automatic beam behavior::
1500 * Manual beams::
1501 * Feathered beams::
1502 @end menu
1503
1504 @node Automatic beams
1505 @unnumberedsubsubsec Automatic beams
1506
1507 By default, beams are inserted automatically:
1508
1509 @cindex beams, manual
1510 @cindex manual beams
1511 @cindex beams, setting rules for
1512 @cindex beams, custom rules for
1513
1514 @funindex \autoBeamOn
1515 @funindex autoBeamOn
1516 @funindex \autoBeamOff
1517 @funindex autoBeamOff
1518
1519 @lilypond[quote,verbatim,relative=2]
1520 \time 2/4 c8 c c c
1521 \time 6/8 c c c c8. c16 c8
1522 @end lilypond
1523
1524 If these automatic decisions are not satisfactory, beaming can be
1525 entered explicitly; see @ref{Manual beams}.  Beams @emph{must} be
1526 entered manually if beams are to be extended over rests.
1527
1528 If automatic beaming is not required, it may be turned off with
1529 @code{\autoBeamOff} and on with @code{\autoBeamOn}:
1530
1531 @lilypond[quote,relative=1,verbatim]
1532 c4 c8 c8. c16 c8. c16 c8
1533 \autoBeamOff
1534 c4 c8 c8. c16 c8.
1535 \autoBeamOn
1536 c16 c8
1537 @end lilypond
1538
1539 @cindex melismata, beams
1540 @cindex beams and melismata
1541
1542 @warning{If beams are used to indicate melismata in songs, then
1543 automatic beaming should be switched off with @code{\autoBeamOff}
1544 and the beams indicated manually.}
1545
1546 Beaming patterns that differ from the automatic defaults may be
1547 created, see @ref{Setting automatic beam behavior}.
1548
1549
1550 @predefined
1551 @code{\autoBeamOff},
1552 @code{\autoBeamOn}.
1553 @endpredefined
1554
1555
1556 @snippets
1557
1558 @cindex line breaks and beams
1559 @cindex beams and line breaks
1560
1561 @funindex breakable
1562
1563 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1564 {beams-across-line-breaks.ly}
1565
1566 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1567 {changing-beam-knee-gap.ly}
1568
1569
1570 @seealso
1571 Notation Reference:
1572 @ref{Manual beams},
1573 @ref{Setting automatic beam behavior}.
1574
1575 Installed Files:
1576 @file{scm/@/auto@/-beam@/.scm}.
1577
1578 Snippets:
1579 @rlsr{Rhythms}.
1580
1581 Internals Reference: @rinternals{Beam}.
1582
1583
1584 @knownissues
1585
1586 Beams can collide with note heads and accidentals in other voices
1587
1588
1589 @node Setting automatic beam behavior
1590 @unnumberedsubsubsec Setting automatic beam behavior
1591
1592
1593 @cindex automatic beams, tuning
1594 @cindex tuning automatic beaming
1595 @cindex automatic beam generation
1596 @cindex autobeam
1597 @cindex lyrics and beaming
1598
1599 @funindex autoBeaming
1600 @funindex autoBeamSettings
1601 @funindex (end * * * *)
1602 @funindex (begin * * * *)
1603 @funindex measureLength
1604 @funindex beatLength
1605 @funindex beatGrouping
1606 @funindex \time
1607 @funindex time
1608 @funindex \set
1609 @funindex set
1610
1611 There are two types of beaming rules:  @emph{beam-grouping}
1612 rules and @emph{beam-ending} rules.  Beam-grouping rules are the
1613 simplest, but are over-ridden by any beam-ending rules which apply.
1614
1615 The placement of automatic beams is determined by applying the
1616 following rules in order:
1617
1618 @itemize
1619
1620 @item If a manual beam is specified with @code{[..]} set the beam
1621 as specified, otherwise
1622
1623 @item if @code{\autoBeamOff} is in force do not beam, otherwise
1624
1625 @item if a beam-ending rule applies use it to determine the valid
1626 places where beams may end, otherwise
1627
1628 @item if a valid (see below) beat-grouping rule applies use it to
1629 group notes with beams, otherwise
1630
1631 @item use the value of @code{beatLength} to group notes with beams
1632
1633 @end itemize
1634
1635 @i{@strong{Modifying the grouping of beats}}
1636
1637 If there are no beam-ending rules defined for the beam duration of a
1638 particular beam in the time signature in use, its beaming is
1639 controlled by three context properties: @code{measureLength},
1640 @code{beatLength} and @code{beatGrouping}.  These properties may be
1641 set in the @code{Score}, @code{Staff} or @code{Voice} contexts to
1642 delimit their scope.  The default values are set while processing
1643 @code{\time} commands, so any @code{\set} commands to modify their
1644 value must be placed after all @code{\time} commands.
1645
1646 @warning{These three properties become effective for a particular
1647 beam @strong{only} if there are no beam-ending rules predefined for
1648 that beam's duration in the time signature in use, or if these
1649 beam-ending rules have all been reverted.}
1650
1651 These determine the beaming as follows:
1652
1653 Beams may begin anywhere (unless a beam is already active).  Beams
1654 end at a time determined by the values of @code{beatGrouping} and
1655 @code{beatLength}, as follows:
1656
1657 @itemize
1658
1659 @item If @code{beatGrouping} and @code{beatLength} are consistent
1660 with @code{measureLength}, @code{beatGrouping} is used to determine
1661 the end points of beams.
1662
1663 @item If @code{beatGrouping} and @code{beatLength} are inconsistent
1664 with @code{measureLength}, @code{beatLength} is used to determine
1665 the end points of beams.
1666
1667 @end itemize
1668
1669 By default the @code{measureLength} and @code{beatLength} are
1670 derived from the time signature set by the @code{\time} command.
1671 The @code{measureLength} is set to be exactly the same length as
1672 the measure length given by the time signature, and the
1673 @code{beatLength} is set to be the same as one over the denominator
1674 of the time signature.
1675
1676 The default value of @code{beatGrouping} is taken from a table in
1677 @file{scm/@/music@/-functions@/.scm}.  To find this, see
1678 @rlearning{Other sources of information}.  It defines the beat
1679 grouping for 3/8, 4/8, 5/8, 8/8, and all the common compound time
1680 signatures.
1681
1682 Both @code{measureLength} and @code{beatLength} are @i{moments},
1683 units of musical duration.  A quantity of type @i{moment} is
1684 created by the scheme function @code{ly:make-moment}.  For more
1685 information about this function, see @ref{Time administration}.
1686
1687 @code{beatGrouping} is a list of integers giving the number of
1688 beats in each group.
1689
1690 @snippets
1691
1692 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1693 {grouping-beats.ly}
1694
1695 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1696 {specifying-context-with-beatgrouping.ly}
1697
1698 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1699 {using-beatlength-and-beatgrouping.ly}
1700
1701 @funindex subdivideBeams
1702
1703 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1704 {sub-dividing-beams.ly}
1705
1706 @cindex measure groupings
1707 @cindex beats, grouping
1708 @cindex grouping beats
1709 @cindex measure sub-grouping
1710
1711 @funindex autoBeamSettings
1712
1713 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1714 {conducting-signs,-measure-grouping-signs.ly}
1715
1716
1717 @strong{@i{Modifying the beam end points}}
1718
1719 Beam-ending rules are required when beams of different durations are
1720 to end at different points within the measure.  For example, it may
1721 be desirable for eighth-note beams in 4/4 time to end only at the
1722 end of the measure or half-way through it, but for sixteenth-note
1723 beams to end at quarter note positions to avoid overly long beamed
1724 runs.  The rules work as follows:
1725
1726 Automatic beams can start on any note but can end at only a few
1727 positions within the measure, namely at positions specified by the
1728 properties in @code{autoBeamSettings}.  These properties consist of
1729 a list of rules defining where beams can end.  The default
1730 @code{autoBeamSettings} rules are defined in
1731 @file{scm/@/auto@/-beam@/.scm}.  To find this file, see
1732 @rlearning{Other sources of information}.
1733
1734 In order to add a rule to the list, use
1735
1736 @example
1737 #(override-auto-beam-setting
1738   '(beam-limit
1739     beam-numerator  beam-denominator
1740     time-signature-numerator time-signature-denominator)
1741   moment-numerator moment-denominator [context])
1742 @end example
1743
1744 @noindent
1745 where
1746
1747 @itemize
1748
1749 @item @code{beam-limit} is the type of automatic beam limit
1750 defined.  This can be either @code{begin} or @code{end} but
1751 only @code{end} is effective.
1752
1753 @item @code{beam-numerator/beam-denominator} is the beam duration
1754 to which the rule is to apply.  A beam is considered to have the
1755 duration of its shortest note.  Set @code{beam-numerator} and
1756 @code{beam-denominator} to @code{'*'} to have this rule apply to beams
1757 of any duration.
1758
1759 @item @code{time-signature-numerator/time-signature-denominator}
1760 specifies the time signature to which this rule should apply.  If
1761 @code{time-signature-numerator} and @code{time-signature-denominator}
1762 are set to @code{'*'} this rule will apply in any time signature.
1763
1764 @item @code{moment-numerator/moment-denominator} is the position
1765 in the bar at which the beam should end.
1766
1767 @funindex score-override-auto-beam-setting
1768 @funindex override-auto-beam-setting
1769
1770 @item @code{context} is optional, and it specifies the context at which
1771 the change should be made.  The default is @code{'Voice}.
1772
1773 @code{#(score-override-auto-beam-setting '(A B C D) E F)} is equivalent to
1774 @code{#(override-auto-beam-setting '(A B C D) E F 'Score)}.
1775
1776 @end itemize
1777
1778 For example, if automatic beams should always end on the first quarter
1779 note, whatever the time signature or beam duration, use
1780
1781 @lilypond[quote,verbatim,relative=2]
1782 a8 a a a a a a a
1783 #(override-auto-beam-setting '(end * * * *) 1 4)
1784 a8 a a a a a a a
1785 @end lilypond
1786
1787 You can force the beam settings to take effect only on beams whose shortest
1788 note is a certain duration
1789
1790 @lilypond[quote,verbatim,relative=2]
1791 \time 2/4
1792 % end 1/16 beams for all time signatures at the 1/16 moment
1793 #(override-auto-beam-setting '(end 1 16 * *) 1 16)
1794 a16 a a a a a a a |
1795 a32 a a a a16 a a a a a |
1796 % end 1/32 beams for all time signatures at the 1/16 moment
1797 #(override-auto-beam-setting '(end 1 32 * *) 1 16)
1798 a32 a a a a16 a a a a a |
1799 @end lilypond
1800
1801 You can force the beam settings to take effect only in certain time
1802 signatures
1803
1804 @lilypond[quote,verbatim,relative=2]
1805 \time 5/8
1806 % end beams of all durations in 5/8 time signature at the 2/8 moment
1807 #(override-auto-beam-setting '(end * * 5 8) 2 8)
1808 c8 c d d d
1809 \time 4/4
1810 e8 e f f e e d d
1811 \time 5/8
1812 c8 c d d d
1813 @end lilypond
1814
1815 When multiple voices are used the @code{Staff} context must be
1816 specified if the beaming is to be applied to all voices in the
1817 staff:
1818
1819 @lilypond[quote,verbatim,relative=2]
1820 \time 7/8
1821 % rhythm 3-1-1-2
1822 % Context not specified - does not work correctly
1823 #(override-auto-beam-setting '(end * * 7 8) 3 8)
1824 #(override-auto-beam-setting '(end * * 7 8) 4 8)
1825 #(override-auto-beam-setting '(end * * 7 8) 5 8)
1826 << {a8 a a a16 a a a a8 a} \\ {f4. f8 f f f} >>
1827
1828 % Works correctly with context specified
1829 #(override-auto-beam-setting '(end * * 7 8) 3 8 'Staff)
1830 #(override-auto-beam-setting '(end * * 7 8) 4 8 'Staff)
1831 #(override-auto-beam-setting '(end * * 7 8) 5 8 'Staff)
1832 << {a8 a a a16 a a a a8 a} \\ {f4. f8 f f f} >>
1833 @end lilypond
1834
1835 @warning{If any unexpected beam behavior occurs, check the default
1836 automatic beam settings in @file{scm/@/auto@/-beam@/.scm} for
1837 possible interference, because the beam endings defined there will
1838 still apply in addition to your own.}
1839
1840 @funindex revert-auto-beam-setting
1841
1842 Any unwanted or conflicting default endings must be reverted for
1843 your time signature(s).  Existing default or user-defined
1844 beam-ending rules are removed by using
1845
1846 @example
1847 #(revert-auto-beam-setting
1848   '(beam-limit
1849     beam-numerator  beam-denominator
1850     time-signature-numerator time-signature-denominator)
1851   moment-numerator moment-denominator [context])
1852 @end example
1853
1854 @noindent
1855 @code{beam-limit}, @code{beam-numerator}, @code{beam-denominator},
1856 @code{time-signature-numerator}, @code{time-signature-denominator},
1857 @code{moment-numerator}, @code{moment-denominator} and @code{context}
1858 are the same as above.
1859
1860 @lilypond[quote,verbatim,relative=2]
1861 \time 4/4
1862 a16 a a a a a a a a a a a a a a a
1863 % undo a rule ending 1/16 beams in 4/4 time at 1/4 moment
1864 #(revert-auto-beam-setting '(end 1 16 4 4) 1 4)
1865 a16 a a a a a a a a a a a a a a a
1866 @end lilypond
1867
1868 The rule in a @code{revert-auto-beam-setting} statement must exactly
1869 match the original rule.  That is, no wildcard expansion is taken into
1870 account.
1871
1872 @lilypond[quote,verbatim,relative=2]
1873 \time 1/4
1874 #(override-auto-beam-setting '(end 1 16 1 4) 1 8)
1875 a16 a a a
1876 #(revert-auto-beam-setting '(end 1 16 * *) 1 8) % this won't revert it!
1877 a a a a
1878 #(revert-auto-beam-setting '(end 1 16 1 4) 1 8) % this will
1879 a a a a
1880 @end lilypond
1881
1882 @snippets
1883
1884 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1885 {beam-grouping-in-7-8-time.ly}
1886
1887 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1888 {reverting-default-beam-endings.ly}
1889
1890 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1891 {beam-endings-in-score-context.ly}
1892
1893 @funindex \autoBeamOff
1894 @funindex autoBeamOff
1895 @funindex \autoBeamOn
1896 @funindex autoBeamOn
1897
1898 @predefined
1899 @code{\autoBeamOff},
1900 @code{\autoBeamOn}.
1901 @endpredefined
1902
1903
1904 @cindex beam, last in score
1905 @cindex beam, last in polyphonic voice
1906
1907 @knownissues
1908
1909 If a score ends while an automatic beam has not been ended and is
1910 still accepting notes, this last beam will not be typeset at all.
1911 The same holds for polyphonic voices, entered with @code{<<
1912 @dots{} \\ @dots{} >>}.  If a polyphonic voice ends while an
1913 automatic beam is still accepting notes, it is not typeset.
1914
1915
1916 @seealso
1917 Snippets:
1918 @rlsr{Rhythms}.
1919
1920
1921 @node Manual beams
1922 @unnumberedsubsubsec Manual beams
1923
1924 @cindex beams, manual
1925 @cindex manual beams
1926
1927 @funindex ]
1928 @funindex [
1929
1930 In some cases it may be necessary to override the automatic
1931 beaming algorithm.  For example, the autobeamer will not put beams
1932 over rests or bar lines, and in choral scores the beaming is
1933 often set to follow the meter of the lyrics rather than the
1934 notes. Such beams can be specified manually by
1935 marking the begin and end point with @code{[} and @code{]}
1936
1937 @lilypond[quote,relative=1,verbatim]
1938 {
1939   r4 r8[ g' a r8] r8 g[ | a] r8
1940 }
1941 @end lilypond
1942
1943
1944 @funindex \noBeam
1945 @funindex noBeam
1946
1947 Individual notes may be marked with @code{\noBeam} to prevent them
1948 from being beamed:
1949
1950 @lilypond[quote,verbatim,relative=2]
1951 \time 2/4 c8 c\noBeam c c
1952 @end lilypond
1953
1954 @funindex stemLeftBeamCount
1955 @funindex stemRightBeamCount
1956
1957 Even more strict manual control with the beams can be achieved by
1958 setting the properties @code{stemLeftBeamCount} and
1959 @code{stemRightBeamCount}.  They specify the number of beams to
1960 draw on the left and right side, respectively, of the next note.
1961 If either property is set, its value will be used only once, and
1962 then it is erased.  In this example, the last @code{f} is printed
1963 with only one beam on the left side, i.e., the eighth-note beam of
1964 the group as a whole.
1965
1966 @lilypond[quote,relative=2,verbatim]
1967 a8[ r16 f g a]
1968 a8[ r16
1969 \set stemLeftBeamCount = #2
1970 \set stemRightBeamCount = #1
1971 f
1972 \set stemLeftBeamCount = #1
1973 g a]
1974 @end lilypond
1975
1976
1977 @snippets
1978
1979 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1980 {flat-flags-and-beam-nibs.ly}
1981
1982 @node Feathered beams
1983 @unnumberedsubsubsec Feathered beams
1984
1985 @cindex beams, feathered
1986 @cindex feathered beams
1987
1988 @funindex \featherDurations
1989 @funindex featherDurations
1990 @funindex grow-direction
1991
1992 Feathered beams are used to indicate that a small group of notes
1993 should be played at an increasing (or decreasing) tempo, without
1994 changing the overall tempo of the piece.  The extent of the
1995 feathered beam must be indicated manually using @code{[} and
1996 @code{]}, and the beam feathering is turned on by specifying a
1997 direction to the @code{Beam} property @code{grow-direction}.
1998
1999 If the placement of the notes and the sound in the MIDI output is to
2000 reflect the ritardando or accelerando indicated by the feathered beam
2001 the notes must be grouped as a music expression delimited by braces
2002 and preceded by a @code{featherDurations} command which specifies
2003 the ratio between the durations of the first and last notes in the
2004 group.
2005
2006 The square brackets show the extent of the beam and the braces show
2007 which notes are to have their durations modified.  Normally these
2008 would delimit the same group of notes, but this is not required: the
2009 two commands are independent.
2010
2011 In the following example the eight 16th notes occupy exactly the
2012 same time as a half note, but the first note is one half as long
2013 as the last one, with the intermediate notes gradually
2014 lengthening.  The first four 32nd notes gradually speed up, while
2015 the last four 32nd notes are at a constant tempo.
2016
2017 @lilypond[relative=1,verbatim,quote]
2018 \override Beam #'grow-direction = #LEFT
2019 \featherDurations #(ly:make-moment 2 1)
2020 { c16[ c c c c c c c] }
2021 \override Beam #'grow-direction = #RIGHT
2022 \featherDurations #(ly:make-moment 2 3)
2023 { c32[ d e f] }
2024 % revert to non-feathered beams
2025 \override Beam #'grow-direction = #'()
2026 { g32[ a b c] }
2027 @end lilypond
2028
2029 @noindent
2030 The spacing in the printed output represents the
2031 note durations only approximately, but the MIDI output is exact.
2032
2033 @knownissues
2034
2035 The @code{\featherDurations} command only works with very short
2036 music snippets, and when numbers in the fraction are small.
2037
2038
2039 @seealso
2040 Snippets:
2041 @rlsr{Rhythms}.
2042
2043
2044 @node Bars
2045 @subsection Bars
2046
2047
2048 @menu
2049 * Bar lines::
2050 * Bar numbers::
2051 * Bar and bar number checks::
2052 * Rehearsal marks::
2053 @end menu
2054
2055 @node Bar lines
2056 @unnumberedsubsubsec Bar lines
2057
2058 @cindex bar lines
2059 @cindex measure lines
2060 @cindex closing bar lines
2061 @cindex bar lines, closing
2062 @cindex double bar lines
2063 @cindex bar lines, double
2064 @cindex repeat bars
2065
2066 @funindex \bar
2067 @funindex bar
2068
2069 Bar lines delimit measures, and are also used to indicate
2070 repeats.  Normally, simple bar lines are automatically inserted
2071 into the printed output at places based on the current time
2072 signature.
2073
2074 The simple bar lines inserted automatically can be changed to
2075 other types with the @code{\bar} command.  For example, a closing
2076 double bar line is usually placed at the end of a piece:
2077
2078 @lilypond[quote,relative=1,verbatim]
2079 e4 d c2 \bar "|."
2080 @end lilypond
2081
2082 It is not invalid if the final note in a measure does not
2083 end on the automatically entered bar line: the note is assumed
2084 to carry over into the next measure.  But if a long sequence
2085 of such carry-over measures appears the music can appear compressed
2086 or even flowing off the page.  This is because automatic line
2087 breaks happen only at the end of complete measures, i.e., where
2088 all notes end before the end of a measure.
2089
2090 @warning{An incorrect duration can cause line breaks to be
2091 inhibited, leading to a line of highly compressed music or
2092 music which flows off the page.}
2093
2094 @cindex line breaks
2095 @cindex bar lines, invisible
2096 @cindex measure lines, invisible
2097
2098 Line breaks are also permitted at manually inserted bar lines
2099 even within incomplete measures.  To allow a line break without
2100 printing a bar line, use
2101
2102 @example
2103 \bar ""
2104 @end example
2105
2106 @noindent
2107 This will insert an invisible bar line and allow (but not
2108 force) a line break to occur at this point.  The bar number
2109 counter is not increased.  To force a line break see
2110 @ref{Line breaking}.
2111
2112 @cindex manual bar lines
2113 @cindex manual measure lines
2114 @cindex bar lines, manual
2115 @cindex measure lines, manual
2116
2117 This and other special bar lines may be inserted manually at any
2118 point.  When they coincide with the end of a measure they replace the
2119 simple bar line which would have been inserted there automatically.
2120 When they do not coincide with the end of a measure the specified bar
2121 line is inserted at that point in the printed output.  Such insertions
2122 do not affect the calculation and placement of subsequent automatic
2123 bar lines.
2124
2125 Two types of simple bar lines and five types of double bar lines are available
2126 for manual insertion:
2127
2128 @lilypond[quote,relative=1,verbatim]
2129 f1 \bar "|" f \bar "." g \bar "||" a \bar ".|" b \bar ".|." c \bar "|.|" d \bar "|." e
2130 @end lilypond
2131
2132 @noindent
2133 together with dotted and dashed bar lines:
2134
2135 @lilypond[quote,relative=1,verbatim]
2136 f1 \bar ":" g \bar "dashed" a
2137 @end lilypond
2138
2139 @noindent
2140 and five types of repeat bar line:
2141
2142 @lilypond[quote,relative=1,verbatim]
2143 f1 \bar "|:" g \bar ":|:" a \bar ":|.|:" b \bar ":|.:" c \bar ":|" d
2144 @end lilypond
2145
2146 Additionally, a bar line can be printed as a simple tick:
2147 @lilypond[quote,relative=1,verbatim]
2148 f1 \bar "'"
2149 @end lilypond
2150 However, as such ticks are typically used in Gregorian chant, it is preferable 
2151 to use @code{\divisioMinima} there instead, described in the section 
2152 @ref{Divisiones} in Gregorian chant.
2153
2154
2155 @cindex repeats
2156
2157 Although the bar line types signifying repeats may be inserted
2158 manually they do not in themselves cause LilyPond to recognize
2159 a repeated section.  Such repeated sections are better entered
2160 using the various repeat commands (see @ref{Repeats}), which
2161 automatically print the appropriate bar lines.
2162
2163 In addition, you can specify @code{"||:"}, which is equivalent to
2164 @code{"|:"} except at line breaks, where it gives a double bar
2165 line at the end of the line and a start repeat at the beginning of
2166 the next line.
2167
2168 @lilypond[quote,relative=2,verbatim]
2169 \override Score.RehearsalMark #'padding = #3
2170 c c c c
2171 \bar "||:"
2172 c c c c \break
2173 \bar "||:"
2174 c c c c
2175 @end lilypond
2176
2177 In scores with many staves, a @code{\bar} command in one staff is
2178 automatically applied to all staves.  The resulting bar lines are
2179 connected between different staves of a @code{StaffGroup},
2180 @code{PianoStaff}, or @code{GrandStaff}.
2181
2182 @lilypond[quote,fragment,verbatim]
2183 <<
2184   \new StaffGroup <<
2185     \new Staff {
2186       e'4 d'
2187       \bar "||"
2188       f' e'
2189     }
2190     \new Staff { \clef bass c4 g e g }
2191   >>
2192   \new Staff { \clef bass c2 c2 }
2193 >>
2194 @end lilypond
2195
2196
2197 @cindex default bar lines, changing
2198 @cindex bar lines, default, changing
2199
2200 @snippets
2201
2202 @funindex whichBar
2203 @funindex defaultBarType
2204 @funindex \bar
2205 @funindex bar
2206 @funindex bartype
2207
2208 The command @code{\bar }@var{bartype} is a shortcut for
2209 @code{\set Timing.whichBar = }@var{bartype}.  A bar line is
2210 created whenever the @code{whichBar} property is
2211 set.
2212
2213 The default bar type used for automatically inserted bar lines is
2214 @code{"|"}.  This may be changed at any time
2215 with @code{\set Timing.defaultBarType = }@var{bartype}.
2216
2217
2218 @seealso
2219 Notation Reference:
2220 @ref{Line breaking},
2221 @ref{Repeats},
2222 @ref{Grouping staves}.
2223
2224 Snippets:
2225 @rlsr{Rhythms}.
2226
2227 Internals Reference: @rinternals{BarLine} (created at
2228 @rinternals{Staff} level), @rinternals{SpanBar} (across
2229 staves), @rinternals{Timing_translator} (for Timing
2230 properties).
2231
2232
2233 @node Bar numbers
2234 @unnumberedsubsubsec Bar numbers
2235
2236 @cindex bar numbers
2237 @cindex measure numbers
2238 @cindex numbers, bar
2239 @cindex numbers, measure
2240
2241 @funindex currentBarNumber
2242
2243 Bar numbers are typeset by default at the start of every line except
2244 the first line.  The number itself is stored in the
2245 @code{currentBarNumber} property, which is normally updated
2246 automatically for every measure.  It may also be set manually:
2247
2248 @lilypond[verbatim,quote,fragment,relative=1]
2249 c1 c c c
2250 \break
2251 \set Score.currentBarNumber = #50
2252 c1 c c c
2253 @end lilypond
2254
2255 @cindex bar numbers, regular spacing
2256
2257 @funindex barNumberVisibility
2258 @funindex BarNumber
2259
2260 Bar numbers can be typeset at regular intervals instead of just at
2261 the beginning of every line.  To do this the default behavior
2262 must be overridden to permit bar numbers to be printed at places
2263 other than the start of a line.  This is controlled by the
2264 @code{break-visibility} property of @code{BarNumber}.  This takes
2265 three values which may be set to @code{#t} or @code{#f} to specify
2266 whether the corresponding bar number is visible or not.  The order
2267 of the three values is @code{end of line visible}, @code{middle of
2268 line visible}, @code{beginning of line visible}.  In the following
2269 example bar numbers are printed at all possible places:
2270
2271 @lilypond[verbatim,quote,relative=1]
2272 \override Score.BarNumber #'break-visibility = #'#(#t #t #t)
2273 \set Score.currentBarNumber = #11
2274 % Permit first bar number to be printed
2275 \bar ""
2276 c1 | c | c | c
2277 \break
2278 c1 | c | c | c
2279 @end lilypond
2280
2281
2282 @snippets
2283
2284 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
2285 {printing-the-bar-number-for-the-first-measure.ly}
2286
2287 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
2288 {printing-bar-numbers-at-regular-intervals.ly}
2289
2290 @cindex measure number, format
2291 @cindex bar number, format
2292
2293 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
2294 {printing-bar-numbers-inside-boxes-or-circles.ly}
2295
2296 @cindex bar number alignment
2297
2298 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
2299 {aligning-bar-numbers.ly}
2300
2301 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
2302 {removing-bar-numbers-from-a-score.ly}
2303
2304
2305 @seealso
2306 Snippets:
2307 @rlsr{Rhythms}.
2308
2309 Internals Reference: @rinternals{BarNumber}.
2310
2311
2312 @cindex bar number collision
2313 @cindex collision, bar number
2314
2315 @knownissues
2316
2317 Bar numbers may collide with the top of the
2318 @rinternals{StaffGroup} bracket, if there is one.  To solve
2319 this, the @code{padding} property of @rinternals{BarNumber} can
2320 be used to position the number correctly.
2321
2322
2323
2324 @node Bar and bar number checks
2325 @unnumberedsubsubsec Bar and bar number checks
2326
2327 @cindex bar check
2328 @cindex bar number check
2329 @cindex measure check
2330 @cindex measure number check
2331
2332 @funindex barCheckSynchronize
2333 @funindex |
2334
2335 Bar checks help detect errors in the entered durations.  A bar check
2336 may be entered using the bar symbol, @code{|}, at any place where a
2337 bar line is expected to fall.  If bar check lines are encountered at
2338 other places, a list of warnings is printed in the log file, showing
2339 the line numbers and lines in which the bar checks failed.  In the
2340 next example, the second bar check will signal an error.
2341
2342 @example
2343 \time 3/4 c2 e4 | g2 |
2344 @end example
2345
2346 Bar checks can also be used in lyrics, for example
2347
2348 @example
2349 \lyricmode @{
2350   \time 2/4
2351   Twin -- kle | Twin -- kle |
2352 @}
2353 @end example
2354
2355 An incorrect duration can result in a completely garbled score,
2356 especially if the score is polyphonic, so a good place to start
2357 correcting input is by scanning for failed bar checks and
2358 incorrect durations.
2359
2360 If successive bar checks are off by the same musical interval,
2361 only the first warning message is displayed.  This allows the
2362 warning to focus on the source of the timing error.
2363
2364
2365 @funindex |
2366 @funindex pipeSymbol
2367
2368 It is also possible to redefine the action taken when a bar check
2369 or pipe symbol, @code{|}, is encountered in the input, so that
2370 it does something other than a bar check.  This is done by
2371 assigning a music expression to @code{pipeSymbol}.
2372 In the following example @code{|} is set to insert a double bar
2373 line wherever it appears in the input, rather than checking
2374 for end of bar.
2375
2376 @lilypond[quote,verbatim]
2377 pipeSymbol = \bar "||"
2378 {
2379   c'2 c'2 |
2380   c'2 c'2
2381   c'2 | c'2
2382   c'2 c'2
2383 }
2384 @end lilypond
2385
2386 @funindex \barNumberCheck
2387 @funindex barNumberCheck
2388
2389 When copying large pieces of music, it can be helpful to check that
2390 the LilyPond bar number corresponds to the original that you are
2391 entering from.  This can be checked with @code{\barNumberCheck}, for
2392 example,
2393
2394 @verbatim
2395 \barNumberCheck #123
2396 @end verbatim
2397
2398 @noindent
2399 will print a warning if the @code{currentBarNumber} is not 123
2400 when it is processed.
2401
2402
2403 @seealso
2404 Snippets:
2405 @rlsr{Rhythms}.
2406
2407
2408 @node Rehearsal marks
2409 @unnumberedsubsubsec Rehearsal marks
2410
2411 @cindex rehearsal marks
2412 @cindex mark, rehearsal
2413
2414 @funindex \mark
2415 @funindex mark
2416
2417 To print a rehearsal mark, use the @code{\mark} command
2418
2419 @lilypond[quote,verbatim,relative=2]
2420 c1 \mark \default
2421 c1 \mark \default
2422 c1 \mark #8
2423 c1 \mark \default
2424 c1 \mark \default
2425 @end lilypond
2426
2427 @noindent
2428 The letter@tie{}@q{I} is skipped in accordance with engraving
2429 traditions.  If you wish to include the letter @q{I}, then use
2430
2431 @example
2432 \set Score.markFormatter = #format-mark-alphabet
2433 @end example
2434
2435 The mark is incremented automatically if you use @code{\mark
2436 \default}, but you can also use an integer argument to set the
2437 mark manually.  The value to use is stored in the property
2438 @code{rehearsalMark}.
2439
2440 @cindex rehearsal mark format
2441 @cindex rehearsal mark style
2442 @cindex style, rehearsal mark
2443 @cindex format, rehearsal mark
2444 @cindex mark, rehearsal, style
2445 @cindex mark, rehearsal, format
2446 @cindex rehearsal mark, manual
2447 @cindex mark, rehearsal, manual
2448 @cindex custom rehearsal mark
2449 @cindex manual rehearsal mark
2450
2451 The style is defined by the property @code{markFormatter}.  It is
2452 a function taking the current mark (an integer) and the current
2453 context as argument.  It should return a markup object.  In the
2454 following example, @code{markFormatter} is set to a pre-defined
2455 procedure.  After a few measures, it is set to a procedure that
2456 produces a boxed number.
2457
2458 @lilypond[quote,verbatim,relative=2]
2459 \set Score.markFormatter = #format-mark-numbers
2460 c1 \mark \default
2461 c1 \mark \default
2462 \set Score.markFormatter = #format-mark-box-numbers
2463 c1 \mark \default
2464 \set Score.markFormatter = #format-mark-circle-numbers
2465 c1 \mark \default
2466 \set Score.markFormatter = #format-mark-circle-letters
2467 c1
2468 @end lilypond
2469
2470 The file @file{scm/@/translation@/-functions@/.scm} contains the
2471 definitions of @code{format-mark-numbers} (the default format),
2472 @code{format-mark-box-numbers}, @code{format-mark-letters} and
2473 @code{format-mark-box-letters}.  These can be used as inspiration
2474 for other formatting functions.
2475
2476 You may use @code{format-mark-barnumbers},
2477 @code{format-mark-box-barnumbers}, and
2478 @code{format-mark-circle-barnumbers} to get bar numbers instead of
2479 incremented numbers or letters.
2480
2481 Other styles of rehearsal mark can be specified manually
2482
2483 @example
2484 \mark "A1"
2485 @end example
2486
2487 @noindent
2488 @code{Score.markFormatter} does not affect marks specified in this
2489 manner.  However, it is possible to apply a @code{\markup} to the
2490 string.
2491
2492 @example
2493 \mark \markup@{ \box A1 @}
2494 @end example
2495
2496 @cindex segno
2497 @cindex coda
2498 @cindex D.S. al Fine
2499 @cindex fermata
2500 @cindex music glyphs
2501 @cindex glyphs, music
2502
2503 @funindex \musicglyph
2504 @funindex musicglyph
2505
2506 Music glyphs (such as the segno sign) may be printed inside a
2507 @code{\mark}
2508
2509 @lilypond[quote,verbatim,relative=1]
2510 c1 \mark \markup { \musicglyph #"scripts.segno" }
2511 c1 \mark \markup { \musicglyph #"scripts.coda" }
2512 c1 \mark \markup { \musicglyph #"scripts.ufermata" }
2513 c1
2514 @end lilypond
2515
2516 @noindent
2517 See @ref{The Feta font}, for a list of symbols which may be
2518 printed with @code{\musicglyph}.
2519
2520 For common tweaks to the positioning of rehearsal marks, see
2521 @ref{Formatting text}.
2522
2523
2524 @seealso
2525 Notation Reference:
2526 @ref{The Feta font},
2527 @ref{Formatting text}.
2528
2529 Installed Files:
2530 @file{scm/@/translation@/-functions@/.scm} contains
2531 the definition of @code{format-mark-numbers} and
2532 @code{format-mark-letters}.  They can be used as inspiration for
2533 other formatting functions.
2534
2535 Snippets:
2536 @rlsr{Rhythms}.
2537
2538 Internals Reference: @rinternals{RehearsalMark}.
2539
2540
2541 @node Special rhythmic concerns
2542 @subsection Special rhythmic concerns
2543
2544
2545 @menu
2546 * Grace notes::
2547 * Aligning to cadenzas::
2548 * Time administration::
2549 @end menu
2550
2551 @node Grace notes
2552 @unnumberedsubsubsec Grace notes
2553
2554 @cindex ornaments
2555 @cindex grace notes
2556 @cindex appoggiatura
2557 @cindex acciaccatura
2558
2559 @funindex \grace
2560 @funindex grace
2561
2562 Grace notes are ornaments that are written out. Grace notes
2563 are printed in a smaller font and take up no logical time
2564 in a measure.
2565
2566 @lilypond[quote,relative=2,verbatim]
2567 c4 \grace c16 c4
2568 \grace { c16[ d16] } c2
2569 @end lilypond
2570
2571 LilyPond also supports two special types of grace notes, the
2572 @emph{acciaccatura}--an unmeasured grace note indicated by a slurred
2573 small note with a slashed stem--and the @emph{appoggiatura}, which
2574 takes a fixed fraction of the main note and appears in small print
2575 without a slash.
2576
2577 @lilypond[quote,relative=2,verbatim]
2578 \grace c8 b4
2579 \acciaccatura d8 c4
2580 \appoggiatura e8 d4
2581 \acciaccatura { g16[ f] } e4
2582 @end lilypond
2583
2584 The placement of grace notes is synchronized between different
2585 staves.  In the following example, there are two sixteenth grace
2586 notes for every eighth grace note
2587
2588 @lilypond[quote,relative=2,verbatim]
2589 << \new Staff { e2 \grace { c16[ d e f] } e2 }
2590    \new Staff { c2 \grace { g8[ b] } c2 } >>
2591 @end lilypond
2592
2593 @cindex grace notes, following
2594
2595 @funindex \afterGrace
2596 @funindex afterGrace
2597
2598 If you want to end a note with a grace, use the @code{\afterGrace}
2599 command.  It takes two arguments: the main note, and the grace
2600 notes following the main note.
2601
2602 @lilypond[quote,verbatim,relative=2]
2603 c1 \afterGrace d1 { c16[ d] } c1
2604 @end lilypond
2605
2606 This will put the grace notes after a space lasting 3/4 of the
2607 length of the main note.  The default fraction 3/4 can be changed by
2608 setting @code{afterGraceFraction}.  The following example shows
2609 the results from setting the space at the default,  at 15/16, and
2610 finally at 1/2 of the main note.
2611
2612 @lilypond[quote,verbatim,relative=2]
2613 <<
2614   \new Staff {
2615     c1 \afterGrace d1 { c16[ d] } c1
2616   }
2617   \new Staff {
2618     #(define afterGraceFraction (cons 15 16))
2619     c1 \afterGrace d1 { c16[ d] } c1
2620   }
2621   \new Staff {
2622     #(define afterGraceFraction (cons 1 2))
2623     c1 \afterGrace d1 { c16[ d] } c1
2624   }
2625 >>
2626 @end lilypond
2627
2628 The space between the main note and the grace note may also be
2629 specified using spacers. The following example places the grace
2630 note after a space lasting 7/8 of the main note.
2631
2632 @lilypond[quote,verbatim,relative=2]
2633 \new Voice {
2634   << { d1^\trill_( }
2635      { s2 s4. \grace { c16[ d] } } >>
2636   c1)
2637 }
2638 @end lilypond
2639
2640 @cindex tweaking grace notes
2641 @cindex grace notes, tweaking
2642 @cindex grace notes, changing layout settings
2643
2644 A @code{\grace} music expression will introduce special
2645 typesetting settings, for example, to produce smaller type, and
2646 set directions.  Hence, when introducing layout tweaks to
2647 override the special settings, they should be placed inside
2648 the grace expression. The overrides should also be reverted
2649 inside the grace expression. Here, the grace note's default stem
2650 direction is overridden and then reverted.
2651
2652 @lilypond[quote,verbatim,relative=2]
2653 \new Voice {
2654   \acciaccatura {
2655     \stemDown
2656     f16->
2657     \stemNeutral
2658   }
2659   g4 e c2
2660 }
2661 @end lilypond
2662
2663
2664 @cindex stem, with slash
2665
2666
2667 @snippets
2668
2669 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
2670 {using-grace-note-slashes-with-normal-heads.ly}
2671
2672 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
2673 {tweaking-grace-layout-within-music.ly}
2674
2675 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
2676 {redefining-grace-note-global-defaults.ly}
2677
2678 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
2679 {positioning-grace-notes-with-floating-space.ly}
2680
2681
2682 @seealso
2683 Music Glossary:
2684 @rglos{grace notes},
2685 @rglos{acciaccatura},
2686 @rglos{appoggiatura}.
2687
2688 Installed Files: @file{ly/@/grace@/-init@/.ly}.
2689
2690 Snippets: @rlsr{Rhythms}.
2691
2692 Internals Reference: @rinternals{GraceMusic}.
2693
2694
2695 @knownissues
2696
2697 @cindex acciaccatura, multi-note
2698 @cindex multi-note acciaccatura
2699 @cindex grace-note synchronization
2700
2701 A multi-note beamed @i{acciaccatura} is printed without a slash,
2702 and looks exactly the same as a multi-note beamed
2703 @i{appoggiatura}.
2704
2705 @c TODO Add link to LSR snippet to add slash when available
2706
2707 Grace note synchronization can also lead to surprises.  Staff
2708 notation, such as key signatures, bar lines, etc., are also
2709 synchronized.  Take care when you mix staves with grace notes and
2710 staves without, for example,
2711
2712 @lilypond[quote,relative=2,verbatim]
2713 <<
2714   \new Staff { e4 \bar "|:" \grace c16 d2. }
2715   \new Staff { c4 \bar "|:" d2. }
2716 >>
2717 @end lilypond
2718
2719 @noindent
2720 This can be remedied by inserting grace skips of the corresponding
2721 durations in the other staves.  For the above example
2722
2723 @lilypond[quote,relative=2,verbatim]
2724 <<
2725   \new Staff { e4 \bar "|:" \grace c16 d2. }
2726   \new Staff { c4 \bar "|:" \grace s16 d2. }
2727 >>
2728 @end lilypond
2729
2730 Grace sections should only be used within sequential music
2731 expressions.  Nesting or juxtaposing grace sections is not
2732 supported, and might produce crashes or other errors.
2733
2734 @node Aligning to cadenzas
2735 @unnumberedsubsubsec Aligning to cadenzas
2736
2737 @cindex cadenza
2738 @cindex cadenza, aligning to
2739 @cindex aligning to cadenza
2740
2741 In an orchestral context, cadenzas present a special problem: when
2742 constructing a score that includes a measured cadenza or other solo
2743 passage, all other instruments should skip just as many notes as the
2744 length of the cadenza, otherwise they will start too soon or too late.
2745
2746 One solution to this problem is to use the functions
2747 @code{mmrest-of-length} and @code{skip-of-length}.  These Scheme
2748 functions take a defined piece of music as an argument and generate a
2749 multi-measure rest or @code{\skip} exactly as long as the piece.
2750
2751 @lilypond[verbatim,quote]
2752 MyCadenza = \relative c' {
2753   c4 d8 e f g g4
2754   f2 g4 g
2755 }
2756
2757 \new GrandStaff <<
2758   \new Staff {
2759     \MyCadenza c'1
2760     \MyCadenza c'1
2761   }
2762   \new Staff {
2763     #(ly:export (mmrest-of-length MyCadenza))
2764     c'1
2765     #(ly:export (skip-of-length MyCadenza))
2766     c'1
2767   }
2768 >>
2769 @end lilypond
2770
2771
2772 @seealso
2773 Music Glossary:
2774 @rglos{cadenza}.
2775
2776 Snippets:
2777 @rlsr{Rhythms}.
2778
2779
2780 @node Time administration
2781 @unnumberedsubsubsec Time administration
2782
2783 @cindex time administration
2784 @cindex timing (within the score)
2785 @cindex music, unmetered
2786 @cindex unmetered music
2787
2788 @funindex currentBarNumber
2789 @funindex measurePosition
2790 @funindex measureLength
2791
2792 Time is administered by the @code{Timing_translator}, which by
2793 default is to be found in the @code{Score} context.  An alias,
2794 @code{Timing}, is added to the context in which the
2795 @code{Timing_translator} is placed.
2796
2797 The following properties of @code{Timing} are used
2798 to keep track of timing within the score.
2799
2800 @cindex bar number
2801 @cindex measure number
2802
2803 @table @code
2804 @item currentBarNumber
2805 The current measure number.  For an example showing the
2806 use of this property see @ref{Bar numbers}.
2807
2808 @item measureLength
2809 The length of the measures in the current time signature.  For a
2810 4/4 time this is@tie{}1, and for 6/8 it is 3/4.  Its value
2811 determines when bar lines are inserted and how automatic beams
2812 should be generated.
2813
2814 @item measurePosition
2815 The point within the measure where we currently are.  This
2816 quantity is reset by subtracting @code{measureLength} whenever
2817 @code{measureLength} is reached or exceeded.  When that happens,
2818 @code{currentBarNumber} is incremented.
2819
2820 @item timing
2821 If set to true, the above variables are updated for every time
2822 step.  When set to false, the engraver stays in the current
2823 measure indefinitely.
2824
2825 @end table
2826
2827 Timing can be changed by setting any of these variables
2828 explicitly.  In the next example, the default 4/4 time
2829 signature is printed, but @code{measureLength} is set to 5/4.
2830 At 4/8 through the third measure, the @code{measurePosition} is
2831 advanced by 1/8 to 5/8, shortening that bar by 1/8.
2832 The next bar line then falls at 9/8 rather than 5/4.
2833
2834 @lilypond[quote,verbatim,relative=1]
2835 \set Score.measureLength = #(ly:make-moment 5 4)
2836 c1 c4
2837 c1 c4
2838 c4 c4
2839 \set Score.measurePosition = #(ly:make-moment 5 8)
2840 b4 b4 b8
2841 c4 c1
2842 @end lilypond
2843
2844 @noindent
2845 As the example illustrates, @code{ly:make-moment n m} constructs a
2846 duration of n/m of a whole note.  For example,
2847 @code{ly:make-moment 1 8} is an eighth note duration and
2848 @code{ly:make-moment 7 16} is the duration of seven sixteenths
2849 notes.
2850
2851
2852 @seealso
2853 This manual: @ref{Bar numbers}, @ref{Unmetered music}
2854
2855 Snippets:
2856 @rlsr{Rhythms}.
2857
2858 Internals Reference: @rinternals{Timing_translator},
2859 @rinternals{Score}
2860