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