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