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