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