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