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