]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/rhythms.itely
Implement non-standard tuplet numbers
[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 measureLength
1442 @funindex beatLength
1443 @funindex beatGrouping
1444 @funindex \autoBeamOn
1445 @funindex autoBeamOn
1446 @funindex \autoBeamOff
1447 @funindex autoBeamOff
1448
1449 @lilypond[quote,verbatim,relative=2]
1450 \time 2/4 c8 c c c
1451 \time 6/8 c c c c8. c16 c8
1452 @end lilypond
1453
1454 If these automatic decisions are not satisfactory, beaming can be
1455 entered explicitly; see @ref{Manual beams}.  Beams must also be
1456 entered manually in the same way if beams are to be extended over
1457 rests.
1458
1459 It is possible
1460 to define beaming patterns that differ from the defaults.  The
1461 default beaming rules for most common time signatures are defined
1462 in @file{scm/@/auto@/-beam@/.scm}.  If there are no beaming rules
1463 defined for a particular beam's duration in the time signature being
1464 used, its beaming is controlled by the values of three context
1465 properties, @code{measureLength}, @code{beatLength} and
1466 @code{beatGrouping}.  Both the beaming rules and the context
1467 properties can be overridden, see @ref{Setting automatic beam behavior}.
1468
1469
1470 @warning{If beams are used to indicate melismata in songs, then automatic
1471 beaming should be switched off with @code{\autoBeamOff} and the beams
1472 indicated manually.}
1473
1474
1475 @noindent
1476 Automatic beaming may be turned off and on with
1477 @code{\autoBeamOff} and @code{\autoBeamOn} commands:
1478
1479 @lilypond[quote,relative=1,verbatim]
1480 c4 c8 c8. c16 c8. c16 c8
1481 \autoBeamOff
1482 c4 c8 c8. c16 c8.
1483 \autoBeamOn
1484 c16 c8
1485 @end lilypond
1486
1487
1488 @predefined
1489 @code{\autoBeamOff},
1490 @code{\autoBeamOn}.
1491 @endpredefined
1492
1493
1494 @snippets
1495
1496 @cindex line breaks and beams
1497 @cindex beams and line breaks
1498
1499 @funindex breakable
1500
1501 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1502 {beams-across-line-breaks.ly}
1503
1504 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1505 {changing-beam-knee-gap.ly}
1506
1507
1508 @seealso
1509 Notation Reference:
1510 @ref{Manual beams},
1511 @ref{Setting automatic beam behavior}.
1512
1513 Installed Files:
1514 @file{scm/@/auto@/-beam@/.scm}.
1515
1516 Snippets:
1517 @rlsr{Rhythms}.
1518
1519 Internals Reference: @rinternals{Beam}.
1520
1521
1522 @knownissues
1523
1524 Automatically kneed cross-staff beams cannot be used together with
1525 hidden staves.  See @ref{Hiding staves}.
1526
1527 Beams can collide with note heads and accidentals in other voices
1528
1529
1530 @node Setting automatic beam behavior
1531 @unnumberedsubsubsec Setting automatic beam behavior
1532
1533
1534 @cindex automatic beams, tuning
1535 @cindex tuning automatic beaming
1536 @cindex automatic beam generation
1537 @cindex autobeam
1538 @cindex lyrics and beaming
1539
1540 @funindex autoBeaming
1541 @funindex autoBeamSettings
1542 @funindex (end * * * *)
1543 @funindex (begin * * * *)
1544 @funindex measureLength
1545 @funindex beatLength
1546 @funindex beatGrouping
1547 @funindex \time
1548 @funindex time
1549 @funindex \set
1550 @funindex set
1551
1552 The placement of automatic beams is determined by the rules
1553 described in @ref{Automatic beams}.  There are two mutually
1554 exclusive ways in which these rules may be modified.  The
1555 first, modifying the grouping of beats, applies to uncommon time
1556 signatures, i.e. those for which there are no predefined rules
1557 defining the beam end points.  The second method, modifying the
1558 specification of the beam end points, can be used for any time
1559 signature.  This second method @strong{must} be used for those time
1560 signatures and beam durations combinations for which beam ending
1561 rules are pre-defined, unless these have all been reverted.  There
1562 are predefined rules for time signatures of 3/2, 3/4, 4/4, 2/4,
1563 4/8, 4/16, 6/8, 9/8 and 12/8.
1564
1565 @i{@strong{Modifying the grouping of beats}}
1566
1567 If there are no beam-ending rules defined for the beam duration of a
1568 particular beam in the time signature in use, its beaming is
1569 controlled by three context properties:
1570 @code{measureLength}, @code{beatLength} and @code{beatGrouping}.
1571 These properties may be set in the @code{Score}, @code{Staff} or
1572 @code{Voice} contexts to delimit their scope.  The default values
1573 are set while processing @code{\time} commands, so the @code{\set}
1574 commands must be placed after all @code{\time} commands.
1575
1576 These determine the beaming as follows:
1577
1578 Beams may begin anywhere (unless a beam is already active).  Beams
1579 end at a time determined by the values of @code{beatGrouping} and
1580 @code{beatLength}, as follows:
1581
1582 @itemize
1583
1584 @item If @code{beatGrouping} and @code{beatLength} are consistent
1585 with @code{measureLength}, @code{beatGrouping} is used to determine
1586 the end points of beams.
1587
1588 @item If @code{beatGrouping} and @code{beatLength} are inconsistent
1589 with @code{measureLength}, @code{beatLength} is used to determine
1590 the end points of beams.
1591
1592 @end itemize
1593
1594 @warning{These three properties become effective for a particular
1595 beam @strong{only} if there are no beam-ending rules predefined for
1596 that beam's duration in the time signature in use, or if these
1597 beam-ending rules have all been reverted.}
1598
1599 By default the @code{measureLength} and @code{beatLength} are
1600 derived from the time signature set by the @code{\time} command.
1601 The @code{measureLength} is set to be exactly the same length as
1602 the measure length given by the time signature, and the
1603 @code{beatLength} is set to be the same as one over the denominator
1604 of the time signature.
1605
1606 The default value of @code{beatGrouping} is taken from a table in
1607 @file{scm/@/music@/-functions@/.scm}.  To find this, see
1608 @rlearning{Other sources of information}.  It defines the beat
1609 grouping for 5/8, 6/8, 8/8, 9/8 and 12/8 time signatures.
1610
1611 Both @code{measureLength} and @code{beatLength} are @i{moments},
1612 units of musical duration.  A quantity of type @i{moment} is
1613 created by the scheme function @code{ly:make-moment}.  For more
1614 information about this function, see @ref{Time administration}.
1615
1616 @code{beatGrouping} is a list of integers giving the number of
1617 beats in each group.
1618
1619 @snippets
1620
1621 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1622 {grouping-beats.ly}
1623
1624 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1625 {specifying-context-with-beatgrouping.ly}
1626
1627 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1628 {using-beatlength-and-beatgrouping.ly}
1629
1630 @funindex subdivideBeams
1631
1632 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1633 {sub-dividing-beams.ly}
1634
1635 @cindex measure groupings
1636 @cindex beats, grouping
1637 @cindex grouping beats
1638 @cindex measure sub-grouping
1639
1640 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1641 {conducting-signs,-measure-grouping-signs.ly}
1642
1643
1644 @strong{@i{Modifying the beam end points}}
1645
1646 In common time signatures, automatic beams can start on any note
1647 but can end at only a few positions within the measure, namely at
1648 durations specified by the properties in @code{autoBeamSettings}.
1649 These properties consist of a list of rules defining where beams can
1650 end.  The default @code{autoBeamSettings} rules are defined in
1651 @file{scm/@/auto@/-beam@/.scm}.  To find this, see
1652 @rlearning{Other sources of information}.
1653
1654 This method @strong{must} be used for the time signatures for which
1655 beam-ending rules are defined by default, unless these have all
1656 been reverted.  It is also particularly suitable for many other time
1657 signatures if the time signature of the measures changes frequently,
1658 or if the beaming should be different for different beam durations.
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 auto-beam rules are removed by
1766 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 The simple bar line and five types of double bar line are available
2043 for manual insertion:
2044
2045 @lilypond[quote,relative=1,verbatim]
2046 f1 \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 @cindex repeats
2064
2065 Although the bar line types signifying repeats may be inserted
2066 manually they do not in themselves cause LilyPond to recognize
2067 a repeated section.  Such repeated sections are better entered
2068 using the various repeat commands (see @ref{Repeats}), which
2069 automatically print the appropriate bar lines.
2070
2071 In addition, you can specify @code{"||:"}, which is equivalent to
2072 @code{"|:"} except at line breaks, where it gives a double bar
2073 line at the end of the line and a start repeat at the beginning of
2074 the next line.
2075
2076 @lilypond[quote,relative=2,verbatim]
2077 \override Score.RehearsalMark #'padding = #3
2078 c c c c
2079 \bar "||:"
2080 c c c c \break
2081 \bar "||:"
2082 c c c c
2083 @end lilypond
2084
2085 In scores with many staves, a @code{\bar} command in one staff is
2086 automatically applied to all staves.  The resulting bar lines are
2087 connected between different staves of a @code{StaffGroup},
2088 @code{PianoStaff}, or @code{GrandStaff}.
2089
2090 @lilypond[quote,fragment,verbatim]
2091 <<
2092   \new StaffGroup <<
2093     \new Staff {
2094       e'4 d'
2095       \bar "||"
2096       f' e'
2097     }
2098     \new Staff { \clef bass c4 g e g }
2099   >>
2100   \new Staff { \clef bass c2 c2 }
2101 >>
2102 @end lilypond
2103
2104
2105 @snippets
2106
2107 @funindex whichBar
2108 @funindex defaultBarType
2109 @funindex \bar
2110 @funindex bar
2111 @funindex bartype
2112
2113 The command @code{\bar }@var{bartype} is a shortcut for
2114 @code{\set Timing.whichBar = }@var{bartype}.  A bar line is
2115 created whenever the @code{whichBar} property is
2116 set.
2117
2118 The default bar type used for automatically inserted bar lines is
2119 @code{"|"}.  This may be changed at any time
2120 with @code{\set Timing.defaultBarType = }@var{bartype}.
2121
2122
2123 @seealso
2124 Notation Reference:
2125 @ref{Line breaking},
2126 @ref{Repeats},
2127 @ref{Grouping staves}.
2128
2129 Snippets:
2130 @rlsr{Rhythms}.
2131
2132 Internals Reference: @rinternals{BarLine} (created at
2133 @rinternals{Staff} level), @rinternals{SpanBar} (across
2134 staves), @rinternals{Timing_translator} (for Timing
2135 properties).
2136
2137
2138 @node Bar numbers
2139 @unnumberedsubsubsec Bar numbers
2140
2141 @cindex bar numbers
2142 @cindex measure numbers
2143 @cindex numbers, bar
2144 @cindex numbers, measure
2145
2146 @funindex currentBarNumber
2147
2148 Bar numbers are typeset by default at the start of every line except
2149 the first line.  The number itself is stored in the
2150 @code{currentBarNumber} property, which is normally updated
2151 automatically for every measure.  It may also be set manually:
2152
2153 @lilypond[verbatim,quote,fragment,relative=1]
2154 c1 c c c
2155 \break
2156 \set Score.currentBarNumber = #50
2157 c1 c c c
2158 @end lilypond
2159
2160
2161 @snippets
2162
2163 @cindex bar numbers, regular spacing
2164
2165 @funindex barNumberVisibility
2166
2167 @c Uncomment this after next LSR update.
2168 @c @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
2169 @c {printing-the-bar-number-for-the-first-measure.ly}
2170
2171 Bar numbers can be typeset at regular intervals instead of just at
2172 the beginning of every line.  To do this the default behavior
2173 must be overridden to permit bar numbers to be printed at places
2174 other than the start of a line.  This is controlled by the
2175 @code{break-visibility} property of @code{BarNumber}.  This takes
2176 three values which may be set to @code{#t} or @code{#f} to specify
2177 whether the corresponding bar number is visible or not.  The order
2178 of the three values is @code{end of line visible}, @code{middle of
2179 line visible}, @code{beginning of line visible}.  In the following
2180 example bar numbers are printed at all possible places:
2181
2182 @lilypond[verbatim,quote,relative=1]
2183 \override Score.BarNumber #'break-visibility = #'#(#t #t #t)
2184 \set Score.currentBarNumber = #11
2185 \bar ""  % Permit first bar number to be printed
2186 c1 c c c
2187 \break
2188 c c c c
2189 @end lilypond
2190
2191 @c  All the rest of these examples will be added to LSR
2192 @c  and moved into the Snippets.  -gp
2193
2194 @noindent
2195 and here the bar numbers are printed every two measures
2196 except at the end of the line:
2197
2198 @lilypond[verbatim,quote,relative=1]
2199 \override Score.BarNumber #'break-visibility = #'#(#f #t #t)
2200 \set Score.currentBarNumber = #11
2201 \bar ""  % Permit first bar number to be printed
2202 % Print a bar number every second measure
2203 \set Score.barNumberVisibility = #(every-nth-bar-number-visible 2)
2204 c1 c c c c
2205 \break
2206 c c c c c
2207 @end lilypond
2208
2209 @cindex measure number, format
2210 @cindex bar number, format
2211
2212 The size of the bar number may be changed.  This is illustrated
2213 in the following example, which also shows how to enclose bar
2214 numbers in boxes and circles, and shows an alternative way
2215 of specifying @code{#(#f #t #t)} for @code{break-visibility}.
2216
2217 @lilypond[verbatim,quote,relative=1]
2218 % Prevent bar numbers at the end of a line and permit them elsewhere
2219 \override Score.BarNumber #'break-visibility
2220   = #end-of-line-invisible
2221
2222 % Increase the size of the bar number by 2
2223 \override Score.BarNumber #'font-size = #2
2224 \repeat unfold 3 { c1 } \bar "|"
2225
2226 % Draw a box round the following bar number(s)
2227 \override Score.BarNumber  #'stencil
2228   = #(make-stencil-boxer 0.1 0.25 ly:text-interface::print)
2229 \repeat unfold 3 { c1 } \bar "|"
2230
2231 % Draw a circle round the following bar number(s)
2232 \override Score.BarNumber  #'stencil
2233   = #(make-stencil-circler 0.1 0.25 ly:text-interface::print)
2234 \repeat unfold 4 { c1 } \bar "|."
2235 @end lilypond
2236
2237 @cindex bar number alignment
2238
2239 Bar numbers by default are left-aligned to their parent object.
2240 This is usually the left edge of a line or, if numbers are printed
2241 within a line, the left bar line of the measure.  The numbers may also
2242 be positioned directly on the bar line or right-aligned to the
2243 bar line:
2244
2245 @lilypond[verbatim,quote,relative=1]
2246 \set Score.currentBarNumber = #111
2247 \override Score.BarNumber #'break-visibility = #'#(#t #t #t)
2248 % Increase the size of the bar number by 2
2249 \override Score.BarNumber #'font-size = #2
2250 % Print a bar number every second measure
2251 \set Score.barNumberVisibility = #(every-nth-bar-number-visible 2)
2252 c1 c1
2253 % Center-align bar numbers
2254 \override Score.BarNumber #'self-alignment-X = #0
2255 c1 c1
2256 % Right-align bar numbers
2257 \override Score.BarNumber #'self-alignment-X = #-1
2258 c1 c1
2259 @end lilypond
2260
2261 Bar numbers can be removed entirely by removing the
2262 @code{Bar_number_engraver} from the @code{Score} context.
2263
2264 @lilypond[verbatim,quote]
2265 \layout {
2266   \context {
2267     \Score
2268     \remove "Bar_number_engraver"
2269   }
2270 }
2271 \relative c''{
2272   c4 c c c \break
2273   c4 c c c
2274 }
2275 @end lilypond
2276
2277
2278 @seealso
2279 Snippets:
2280 @rlsr{Rhythms}.
2281
2282 Internals Reference: @rinternals{BarNumber}.
2283
2284
2285 @cindex bar number collision
2286 @cindex collision, bar number
2287
2288 @knownissues
2289
2290 Bar numbers may collide with the top of the
2291 @rinternals{StaffGroup} bracket, if there is one.  To solve
2292 this, the @code{padding} property of @rinternals{BarNumber} can
2293 be used to position the number correctly.
2294
2295
2296
2297 @node Bar and bar number checks
2298 @unnumberedsubsubsec Bar and bar number checks
2299
2300 @cindex bar check
2301 @cindex bar number check
2302 @cindex measure check
2303 @cindex measure number check
2304
2305 @funindex barCheckSynchronize
2306 @funindex |
2307
2308 Bar checks help detect errors in the entered durations.  A bar check
2309 may be entered using the bar symbol, @code{|}, at any place where a
2310 bar line is expected to fall.  If bar check lines are encountered at
2311 other places, a list of warnings is printed in the log file, showing
2312 the line numbers and lines in which the bar checks failed.  In the
2313 next example, the second bar check will signal an error.
2314
2315 @example
2316 \time 3/4 c2 e4 | g2 |
2317 @end example
2318
2319 Bar checks can also be used in lyrics, for example
2320
2321 @example
2322 \lyricmode @{
2323   \time 2/4
2324   Twin -- kle | Twin -- kle |
2325 @}
2326 @end example
2327
2328 An incorrect duration can result in a completely garbled score,
2329 especially if the score is polyphonic, so a good place to start
2330 correcting input is by scanning for failed bar checks and
2331 incorrect durations.
2332
2333 If successive bar checks are off by the same musical interval,
2334 only the first warning message is displayed.  This allows the
2335 warning to focus on the source of the timing error.
2336
2337
2338 @funindex |
2339 @funindex pipeSymbol
2340
2341 It is also possible to redefine the action taken when a bar check
2342 or pipe symbol, @code{|}, is encountered in the input, so that
2343 it does something other than a bar check.  This is done by
2344 assigning a music expression to @code{pipeSymbol}.
2345 In the following example @code{|} is set to insert a double bar
2346 line wherever it appears in the input, rather than checking
2347 for end of bar.
2348
2349 @lilypond[quote,verbatim]
2350 pipeSymbol = \bar "||"
2351 {
2352   c'2 c'2 |
2353   c'2 c'2
2354   c'2 | c'2
2355   c'2 c'2
2356 }
2357 @end lilypond
2358
2359 @funindex \barNumberCheck
2360 @funindex barNumberCheck
2361
2362 When copying large pieces of music, it can be helpful to check
2363 that the LilyPond bar number corresponds to the original that you
2364 are entering from.  This can be checked with
2365 @code{\barNumberCheck}, for example,
2366
2367 @verbatim
2368 \barNumberCheck #123
2369 @end verbatim
2370
2371 @noindent
2372 will print a warning if the @code{currentBarNumber} is not 123
2373 when it is processed.
2374
2375
2376 @seealso
2377 Snippets:
2378 @rlsr{Rhythms}.
2379
2380
2381 @node Rehearsal marks
2382 @unnumberedsubsubsec Rehearsal marks
2383
2384 @cindex rehearsal marks
2385 @cindex mark, rehearsal
2386
2387 @funindex \mark
2388 @funindex mark
2389
2390 To print a rehearsal mark, use the @code{\mark} command
2391
2392 @lilypond[quote,verbatim,relative=2]
2393 c1 \mark \default
2394 c1 \mark \default
2395 c1 \mark #8
2396 c1 \mark \default
2397 c1 \mark \default
2398 @end lilypond
2399
2400 @noindent
2401 The letter@tie{}@q{I} is skipped in accordance with engraving
2402 traditions.  If you wish to include the letter @q{I}, then use
2403
2404 @example
2405 \set Score.markFormatter = #format-mark-alphabet
2406 @end example
2407
2408 The mark is incremented automatically if you use @code{\mark
2409 \default}, but you can also use an integer argument to set the
2410 mark manually.  The value to use is stored in the property
2411 @code{rehearsalMark}.
2412
2413 @cindex rehearsal mark format
2414 @cindex rehearsal mark style
2415 @cindex style, rehearsal mark
2416 @cindex format, rehearsal mark
2417 @cindex mark, rehearsal, style
2418 @cindex mark, rehearsal, format
2419 @cindex rehearsal mark, manual
2420 @cindex mark, rehearsal, manual
2421 @cindex custom rehearsal mark
2422
2423 The style is defined by the property @code{markFormatter}.  It is
2424 a function taking the current mark (an integer) and the current
2425 context as argument.  It should return a markup object.  In the
2426 following example, @code{markFormatter} is set to a pre-defined
2427 procedure.  After a few measures, it is set to a procedure that
2428 produces a boxed number.
2429
2430 @lilypond[quote,verbatim,relative=2]
2431 \set Score.markFormatter = #format-mark-numbers
2432 c1 \mark \default
2433 c1 \mark \default
2434 \set Score.markFormatter = #format-mark-box-numbers
2435 c1 \mark \default
2436 \set Score.markFormatter = #format-mark-circle-numbers
2437 c1 \mark \default
2438 \set Score.markFormatter = #format-mark-circle-letters
2439 c1
2440 @end lilypond
2441
2442 The file @file{scm/@/translation@/-functions@/.scm} contains the
2443 definitions of @code{format-mark-numbers} (the default format),
2444 @code{format-mark-box-numbers}, @code{format-mark-letters} and
2445 @code{format-mark-box-letters}.  These can be used as inspiration
2446 for other formatting functions.
2447
2448 You may use @code{format-mark-barnumbers},
2449 @code{format-mark-box-barnumbers}, and
2450 @code{format-mark-circle-barnumbers} to get bar numbers instead of
2451 incremented numbers or letters.
2452
2453 Other styles of rehearsal mark can be specified manually
2454
2455 @example
2456 \mark "A1"
2457 @end example
2458
2459 @noindent
2460 @code{Score.markFormatter} does not affect marks specified in this
2461 manner.  However, it is possible to apply a @code{\markup} to the
2462 string.
2463
2464 @example
2465 \mark \markup@{ \box A1 @}
2466 @end example
2467
2468 @cindex segno
2469 @cindex coda
2470 @cindex D.S al Fine
2471 @cindex fermata
2472 @cindex music glyphs
2473 @cindex glyphs, music
2474
2475 @funindex \musicglyph
2476 @funindex musicglyph
2477
2478 Music glyphs (such as the segno sign) may be printed inside a
2479 @code{\mark}
2480
2481 @lilypond[quote,verbatim,relative=1]
2482 c1 \mark \markup { \musicglyph #"scripts.segno" }
2483 c1 \mark \markup { \musicglyph #"scripts.coda" }
2484 c1 \mark \markup { \musicglyph #"scripts.ufermata" }
2485 c1
2486 @end lilypond
2487
2488 @noindent
2489 See @ref{The Feta font}, for a list of symbols which may be
2490 printed with @code{\musicglyph}.
2491
2492 For common tweaks to the positioning of rehearsal marks, see
2493 @ref{Formatting text}.
2494
2495
2496 @seealso
2497 Notation Reference:
2498 @ref{The Feta font},
2499 @ref{Formatting text}.
2500
2501 Installed Files:
2502 @file{scm/@/translation@/-functions@/.scm} contains
2503 the definition of @code{format-mark-numbers} and
2504 @code{format-mark-letters}.  They can be used as inspiration for
2505 other formatting functions.
2506
2507 Snippets:
2508 @rlsr{Rhythms}.
2509
2510 Internals Reference: @rinternals{RehearsalMark}.
2511
2512
2513 @node Special rhythmic concerns
2514 @subsection Special rhythmic concerns
2515
2516
2517 @menu
2518 * Grace notes::
2519 * Aligning to cadenzas::
2520 * Time administration::
2521 @end menu
2522
2523 @node Grace notes
2524 @unnumberedsubsubsec Grace notes
2525
2526 @cindex ornaments
2527 @cindex grace notes
2528 @cindex appoggiatura
2529 @cindex acciaccatura
2530
2531 @funindex \grace
2532 @funindex grace
2533
2534 Grace notes are ornaments that are written out. Grace notes
2535 are printed in a smaller font and take up no logical time
2536 in a measure.
2537
2538 @lilypond[quote,relative=2,verbatim]
2539 c4 \grace c16 c4
2540 \grace { c16[ d16] } c2
2541 @end lilypond
2542
2543 Lilypond also supports two special types of grace notes, the
2544 @emph{acciaccatura}--an unmeasured grace note indicated by a slurred
2545 small note with a slashed stem--and the @emph{appoggiatura}, which
2546 takes a fixed fraction of the main note and appears in small print
2547 without a slash.
2548
2549 @lilypond[quote,relative=2,verbatim]
2550 \grace c8 b4
2551 \acciaccatura d8 c4
2552 \appoggiatura e8 d4
2553 \acciaccatura { g16[ f] } e4
2554 @end lilypond
2555
2556 The placement of grace notes is synchronized between different
2557 staves.  In the following example, there are two sixteenth grace
2558 notes for every eighth grace note
2559
2560 @lilypond[quote,relative=2,verbatim]
2561 << \new Staff { e2 \grace { c16[ d e f] } e2 }
2562    \new Staff { c2 \grace { g8[ b] } c2 } >>
2563 @end lilypond
2564
2565 @cindex grace notes, following
2566
2567 @funindex \afterGrace
2568 @funindex afterGrace
2569
2570 If you want to end a note with a grace, use the @code{\afterGrace}
2571 command.  It takes two arguments: the main note, and the grace
2572 notes following the main note.
2573
2574 @lilypond[quote,verbatim,relative=2]
2575 c1 \afterGrace d1 { c16[ d] } c1
2576 @end lilypond
2577
2578 This will put the grace notes after a space lasting 3/4 of the
2579 length of the main note.  The default fraction 3/4 can be changed by
2580 setting @code{afterGraceFraction}.  The following example shows
2581 the results from setting the space at the default,  at 15/16, and
2582 finally at 1/2 of the main note.
2583
2584 @lilypond[quote,verbatim,relative=2]
2585 <<
2586   \new Staff {
2587     c1 \afterGrace d1 { c16[ d] } c1
2588   }
2589   \new Staff {
2590     #(define afterGraceFraction (cons 15 16))
2591     c1 \afterGrace d1 { c16[ d] } c1
2592   }
2593   \new Staff {
2594     #(define afterGraceFraction (cons 1 2))
2595     c1 \afterGrace d1 { c16[ d] } c1
2596   }
2597 >>
2598 @end lilypond
2599
2600 The space between the main note and the grace note may also be
2601 specified using spacers. The following example places the grace
2602 note after a space lasting 7/8 of the main note.
2603
2604 @lilypond[quote,verbatim,relative=2]
2605 \new Voice {
2606   << { d1^\trill_( }
2607      { s2 s4. \grace { c16[ d] } } >>
2608   c1)
2609 }
2610 @end lilypond
2611
2612 A @code{\grace} music expression will introduce special
2613 typesetting settings, for example, to produce smaller type, and
2614 set directions.  Hence, when introducing layout tweaks to
2615 override the special settings, they should be placed inside
2616 the grace expression. The overrides should also be reverted
2617 inside the grace expression. Here, the grace note's default stem
2618 direction is overriden and then reverted.
2619
2620 @lilypond[quote,verbatim,relative=2]
2621 \new Voice {
2622   \acciaccatura {
2623     \stemDown
2624     f16->
2625     \stemNeutral
2626   }
2627   g4 e c2
2628 }
2629 @end lilypond
2630
2631
2632 @cindex stem, with slash
2633
2634
2635 @snippets
2636
2637 The slash through the stem found in @emph{acciaccatura}s can be applied
2638 in other situations:
2639
2640 @lilypond[quote,verbatim,relative=2]
2641 \relative c'' {
2642   \override Stem #'stroke-style = #"grace"
2643   c8( d2) e8( f4)
2644 }
2645 @end lilypond
2646
2647 The layout of grace expressions can be changed throughout the
2648 music using the function @code{add-grace-property}.  The following
2649 example undefines the @code{Stem} direction for this grace, so
2650 that stems do not always point up.
2651
2652 @lilypond[quote,verbatim,relative=2]
2653 \relative c'' {
2654   \new Staff {
2655     #(add-grace-property 'Voice 'Stem 'direction ly:stem::calc-direction)
2656     #(remove-grace-property 'Voice 'Stem 'direction)
2657     \new Voice {
2658        \acciaccatura { f16 } g4
2659        \grace { d16[ e] } f4
2660        \appoggiatura { a,32[ b c d] } e2
2661     }
2662   }
2663 }
2664 @end lilypond
2665
2666 Another option is to change the variables @code{startGraceMusic},
2667 @code{stopGraceMusic}, @code{startAcciaccaturaMusic},
2668 @code{stopAcciaccaturaMusic}, @code{startAppoggiaturaMusic},
2669 @code{stopAppoggiaturaMusic}.  The default values of these can be
2670 seen in the file @code{ly/@/grace@/-init@/.ly}.  By redefining
2671 them other effects may be obtained.
2672
2673 Grace notes may be forced to align with regular notes
2674 in other staves:
2675
2676 @lilypond[verbatim,quote]
2677 \relative c'' {
2678   <<
2679     \override Score.SpacingSpanner #'strict-grace-spacing = ##t
2680     \new Staff {
2681       c4
2682       \afterGrace c4 { c16[ c8 c16] }
2683       c4 r
2684     }
2685     \new Staff {
2686       c16 c c c c c c c c4 r
2687     }
2688   >>
2689 }
2690 @end lilypond
2691
2692
2693 @seealso
2694 Music Glossary:
2695 @rglos{grace notes},
2696 @rglos{acciaccatura},
2697 @rglos{appoggiatura}.
2698
2699 Installed Files: @file{ly/@/grace@/-init@/.ly}.
2700
2701 Snippets: @rlsr{Rhythms}.
2702
2703 Internals Reference: @rinternals{GraceMusic}.
2704
2705
2706 @knownissues
2707
2708 A multi-note beamed @i{acciaccatura} is printed without a slash,
2709 and looks exactly the same as a multi-note beamed
2710 @i{appoggiatura}.
2711
2712 @c TODO Add link to LSR snippet to add slash when available
2713
2714 Grace note synchronization can also lead to surprises.  Staff
2715 notation, such as key signatures, bar lines, etc., are also
2716 synchronized.  Take care when you mix staves with grace notes and
2717 staves without, for example,
2718
2719 @lilypond[quote,relative=2,verbatim]
2720 << \new Staff { e4 \bar "|:" \grace c16 d2. }
2721    \new Staff { c4 \bar "|:" d2. } >>
2722 @end lilypond
2723
2724 @noindent
2725 This can be remedied by inserting grace skips of the corresponding
2726 durations in the other staves.  For the above example
2727
2728 @lilypond[quote,relative=2,verbatim]
2729 << \new Staff { e4 \bar "|:" \grace c16 d2. }
2730    \new Staff { c4 \bar "|:" \grace s16 d2. } >>
2731 @end lilypond
2732
2733 Grace sections should only be used within sequential music
2734 expressions.  Nesting or juxtaposing grace sections is not
2735 supported, and might produce crashes or other errors.
2736
2737 @node Aligning to cadenzas
2738 @unnumberedsubsubsec Aligning to cadenzas
2739
2740 @cindex cadenza
2741 @cindex cadenza, aligning to
2742 @cindex aligning to cadenza
2743
2744 In an orchestral context, cadenzas present a special problem: when
2745 constructing a score that includes a measured cadenza or other solo
2746 passage, all other instruments should skip just as many notes as the
2747 length of the cadenza, otherwise they will start too soon or too late.
2748
2749 One solution to this problem is to use the functions
2750 @code{mmrest-of-length} and @code{skip-of-length}.  These Scheme
2751 functions take a defined piece of music as an argument and generate a
2752 multi-measure rest or @code{\skip} exactly as long as the piece.
2753
2754 @lilypond[verbatim,quote]
2755 MyCadenza = \relative c' {
2756   c4 d8 e f g g4
2757   f2 g4 g
2758 }
2759
2760 \new GrandStaff <<
2761   \new Staff {
2762     \MyCadenza c'1
2763     \MyCadenza c'1
2764   }
2765   \new Staff {
2766     #(ly:export (mmrest-of-length MyCadenza))
2767     c'1
2768     #(ly:export (skip-of-length MyCadenza))
2769     c'1
2770   }
2771 >>
2772 @end lilypond
2773
2774
2775 @seealso
2776 Music Glossary:
2777 @rglos{cadenza}.
2778
2779 Snippets:
2780 @rlsr{Rhythms}.
2781
2782
2783 @node Time administration
2784 @unnumberedsubsubsec Time administration
2785
2786 @cindex time administration
2787 @cindex timing (within the score)
2788 @cindex music, unmetered
2789 @cindex unmetered music
2790
2791 @funindex currentBarNumber
2792 @funindex measurePosition
2793 @funindex measureLength
2794
2795 Time is administered by the @code{Timing_translator}, which by
2796 default is to be found in the @code{Score} context.  An alias,
2797 @code{Timing}, is added to the context in which the
2798 @code{Timing_translator} is placed.
2799
2800 The following properties of @code{Timing} are used
2801 to keep track of timing within the score.
2802
2803 @cindex bar number
2804 @cindex measure number
2805
2806 @table @code
2807 @item currentBarNumber
2808 The current measure number.  For an example showing the
2809 use of this property see @ref{Bar numbers}.
2810
2811 @item measureLength
2812 The length of the measures in the current time signature.  For a
2813 4/4 time this is@tie{}1, and for 6/8 it is 3/4.  Its value
2814 determines when bar lines are inserted and how automatic beams
2815 should be generated.
2816
2817 @item measurePosition
2818 The point within the measure where we currently are.  This
2819 quantity is reset by subtracting @code{measureLength} whenever
2820 @code{measureLength} is reached or exceeded.  When that happens,
2821 @code{currentBarNumber} is incremented.
2822
2823 @item timing
2824 If set to true, the above variables are updated for every time
2825 step.  When set to false, the engraver stays in the current
2826 measure indefinitely.
2827
2828 @end table
2829
2830 Timing can be changed by setting any of these variables
2831 explicitly.  In the next example, the default 4/4 time
2832 signature is printed, but @code{measureLength} is set to 5/4.
2833 At 4/8 through the third measure, the @code{measurePosition} is
2834 advanced by 1/8 to 5/8, shortening that bar by 1/8.
2835 The next bar line then falls at 9/8 rather than 5/4.
2836
2837 @lilypond[quote,verbatim,relative=1]
2838 \set Score.measureLength = #(ly:make-moment 5 4)
2839 c1 c4
2840 c1 c4
2841 c4 c4
2842 \set Score.measurePosition = #(ly:make-moment 5 8)
2843 b4 b4 b8
2844 c4 c1
2845 @end lilypond
2846
2847 @noindent
2848 As the example illustrates, @code{ly:make-moment n m} constructs a
2849 duration of n/m of a whole note.  For example,
2850 @code{ly:make-moment 1 8} is an eighth note duration and
2851 @code{ly:make-moment 7 16} is the duration of seven sixteenths
2852 notes.
2853
2854
2855 @seealso
2856 This manual: @ref{Bar numbers}, @ref{Unmetered music}
2857
2858 Snippets:
2859 @rlsr{Rhythms}.
2860
2861 Internals Reference: @rinternals{Timing_translator},
2862 @rinternals{Score}
2863