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