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