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