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