]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/rhythms.itely
91c57d4a5800c4d77f4e8becc30856cfb101b6e2
[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 Replace by snippet called "Changing the time signature without affecting the beaming"
896 @c      Submitted to LSR 2 Nov 08
897
898 The @code{\time} command sets the properties
899 @code{timeSignatureFraction}, @code{beatLength}, @code{beatGrouping}
900 and @code{measureLength} in the @code{Timing} context, which is
901 normally aliased to @code{Score}.  Changing the value of
902 @code{timeSignatureFraction} causes the new time signature symbol
903 to be printed without changing any of the other properties:
904
905 @lilypond[quote,verbatim,relative=2]
906 \time 3/4
907 a16 a a a a a a a a a a a
908 % Change time signature symbol but keep 3/4 beaming
909 % due to unchanged underlying time signature
910 \set Score.timeSignatureFraction = #'(12 . 16)
911 a16 a a a a a a a a a a a
912 \time 12/16
913 % Lose 3/4 beaming now \time has been changed
914 a16 a a a a a a a a a a a
915 @end lilypond
916
917 @cindex compound time signatures
918 @cindex time signature, compound
919
920 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
921 {compound-time-signatures.ly}
922
923
924 @seealso
925
926 Music Glossary:
927 @rglos{time signature}
928
929 Notation Reference:
930 @ref{Mensural time signatures},
931 @ref{Time administration}.
932
933 Snippets:
934 @rlsr{Rhythms}.
935
936 Internals Reference:
937 @rinternals{TimeSignature},
938 @rinternals{Timing_translator}.
939
940
941 @node Upbeats
942 @unnumberedsubsubsec Upbeats
943
944 @cindex anacrusis
945 @cindex upbeat
946 @cindex partial measure
947 @cindex measure, partial
948 @cindex pickup measure
949 @cindex measure, change length
950 @cindex measurePosition
951 @funindex \partial
952
953 Partial or pick-up measures, such as an anacrusis or upbeat, are
954 entered using the @code{\partial} command, with the syntax
955
956 @example
957 \partial @var{duration}
958 @end example
959
960 where @code{duration} is the rhythmic length of the interval
961 before the start of the first complete measure:
962
963 @lilypond[quote,verbatim,relative=2]
964 \partial 4 e4 |
965 a2. c,4 |
966 @end lilypond
967
968 The partial measure can be any duration less than a full measure:
969
970 @lilypond[quote,verbatim,relative=2]
971 \partial 8*3 c8 d e |
972 a2. c,4 |
973 @end lilypond
974
975 Internally, this is translated into
976
977 @example
978 \set Timing.measurePosition = -@var{duration}
979 @end example
980
981 The property @code{measurePosition} contains a rational number
982 indicating how much of the measure has passed at this point.  Note
983 that this is set to a negative number by the @code{\partial}
984 command: i.e., @code{\partial 4} is internally translated to
985 @code{-4}, meaning @qq{there is a quarter note left in the measure.}
986
987 @seealso
988
989 Music Glossary:
990 @rglos{anacrusis}.
991
992 Notation Reference:
993 @ref{Grace notes}.
994
995 Snippets:
996 @rlsr{Rhythms}.
997
998 Internal Reference:
999 @rinternals{Timing_translator}.
1000
1001 @knownissues
1002
1003 The @code{\partial} command is intended to be used only at the
1004 beginning of a piece.  If you use it after the beginning, some
1005 odd warnings may occur.
1006
1007 @node Unmetered music
1008 @unnumberedsubsubsec Unmetered music
1009
1010 @funindex \cadenzaOn
1011 @funindex \cadenzaOff
1012 @cindex bar lines, turning off
1013 @cindex bar numbering, turning off
1014 @cindex cadenza
1015 @cindex unmetered music
1016
1017 Bar lines and bar numbers are calculated automatically.  For
1018 unmetered music (some cadenzas, for example), this is not desirable.
1019 To turn off automatic calculation of bar lines and bar numbers,
1020 use the command @code{\cadenzaOn}, and use @code{\cadenzaOff}
1021 to turn them on again.
1022
1023 @lilypond[verbatim,relative=2,fragment]
1024 c4 d e d
1025 \cadenzaOn
1026 c4 c d8 d d f4 g4.
1027 \cadenzaOff
1028 \bar "|"
1029 d4 e d c
1030 @end lilypond
1031
1032 Bar numbering is resumed at the end of the cadenza as if the
1033 cadenza were not there:
1034
1035 @lilypond[verbatim,relative=2,fragment]
1036 % Show all bar numbers
1037 \override Score.BarNumber #'break-visibility = #all-visible
1038 c4 d e d
1039 \cadenzaOn
1040 c4 c d8 d d f4 g4.
1041 \cadenzaOff
1042 \bar "|"
1043 d4 e d c
1044 @end lilypond
1045
1046 @predefined
1047
1048 @code{\cadenzaOn},
1049 @code{\cadenzaOff}.
1050
1051 @seealso
1052
1053 Music Glossary:
1054 @rglos{cadenza}.
1055
1056 Notation Reference:
1057 @c ref{Controlling visibility of objects}.
1058
1059 Snippets:
1060 @rlsr{Rhythms}.
1061
1062 @knownissues
1063
1064 LilyPond will insert line breaks and page breaks only at a
1065 bar line.  Unless the unmetered music ends before the end of the
1066 staff line, you will need to insert invisible bar lines with
1067
1068 @example
1069 \bar ""
1070 @end example
1071
1072 @noindent
1073 to indicate where breaks can occur.
1074
1075
1076 @node Polymetric notation
1077 @unnumberedsubsubsec Polymetric notation
1078
1079 @c This section necessarily uses \set
1080 @c This is acceptable  -td
1081
1082 @cindex double time signatures
1083 @cindex signatures, polymetric
1084 @cindex polymetric signatures
1085 @cindex meter, polymetric
1086
1087 Polymetric notation is supported, either explicitly or by modifying
1088 the visible time signature symbol and scaling the note durations.
1089
1090 @strong{@i{Staves with different time signatures, equal measure lengths}}
1091
1092 This notation can be created by setting a common time signature
1093 for each staff but replacing the symbol manually by setting
1094 @code{timeSignatureFraction} to the desired fraction and scaling
1095 the printed durations in each staff to the common time
1096 signature; see @ref{Time signature}.  The scaling is done with
1097 @code{\scaleDurations}, which is used in a similar way to
1098 @code{\times}, but does not create a tuplet bracket; see
1099 @ref{Scaling durations}.
1100
1101 In this example, music with the time signatures of 3/4, 9/8, and
1102 10/8 are used in parallel.  In the second staff, shown durations
1103 are multiplied by 2/3, as 2/3 * 9/8 = 3/4, and in the third
1104 staff, shown durations are multiplied by 3/5, as 3/5 * 10/8 = 3/4.
1105 It will often be necessary to insert beams manually, as the
1106 duration scaling affects the autobeaming rules.
1107
1108 @lilypond[quote,verbatim,fragment]
1109 \relative c' <<
1110   \new Staff {
1111     \time 3/4
1112     c4 c c |
1113     c c c |
1114   }
1115   \new Staff {
1116     \time 3/4
1117     \set Staff.timeSignatureFraction = #'(9 . 8)
1118     \scaleDurations #'(2 . 3)
1119     \repeat unfold 6 { c8[ c c] }
1120   }
1121   \new Staff {
1122     \time 3/4
1123     \set Staff.timeSignatureFraction = #'(10 . 8)
1124     \scaleDurations #'(3 . 5) {
1125       \repeat unfold 2 { c8[ c c] }
1126       \repeat unfold 2 { c8[ c] } |
1127       c4. c4. \times 2/3 { c8[ c c] } c4
1128     }
1129   }
1130 >>
1131 @end lilypond
1132
1133 @strong{@i{Staves with different time signatures, unequal bar lengths}}
1134
1135 Each staff can be given its own independent time signature by
1136 moving the @code{Timing_translator} and the
1137 @code{Default_bar_line_engraver} to the @code{Staff} context.
1138
1139 @lilypond[quote,verbatim]
1140 \layout {
1141   \context {
1142     \Score
1143     \remove "Timing_translator"
1144     \remove "Default_bar_line_engraver"
1145   }
1146   \context {
1147     \Staff
1148     \consists "Timing_translator"
1149     \consists "Default_bar_line_engraver"
1150   }
1151 }
1152
1153 % Now each staff has its own time signature.
1154
1155 \relative c' <<
1156   \new Staff {
1157     \time 3/4
1158     c4 c c |
1159     c c c |
1160   }
1161   \new Staff {
1162     \time 2/4
1163     c4 c |
1164     c c |
1165     c c |
1166   }
1167   \new Staff {
1168     \time 3/8
1169     c4. |
1170     c8 c c |
1171     c4. |
1172     c8 c c |
1173   }
1174 >>
1175 @end lilypond
1176
1177 @snippets
1178
1179 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1180 {compound-time-signatures.ly}
1181
1182
1183 @seealso
1184
1185 Music Glossary:
1186 @rglos{polymetric},
1187 @rglos{polymetric time signature},
1188 @rglos{meter}.
1189
1190 Notation Reference:
1191 @ref{Time signature},
1192 @ref{Scaling durations}.
1193
1194 Snippets:
1195 @rlsr{Rhythms}.
1196
1197 Internals Reference:
1198 @rinternals{TimeSignature},
1199 @rinternals{Timing_translator},
1200 @rinternals{Default_bar_line_engraver},
1201 @rinternals{Staff}.
1202
1203 @knownissues
1204
1205 When using different time signatures in parallel, notes
1206 at the same moment will be be placed at the same horizontal
1207 location.  However, the bar lines in the different staves
1208 will cause the note spacing to be less regular in each of the
1209 individual staves than would be normal without the different
1210 time signatures.
1211
1212 @node Automatic note splitting
1213 @unnumberedsubsubsec Automatic note splitting
1214
1215 @cindex notes, splitting
1216 @cindex splitting notes
1217
1218 Long notes which overrun bar lines can be converted automatically
1219 to tied notes.  This is done by replacing the
1220 @code{Note_heads_engraver} with the
1221 @code{Completion_heads_engraver}.  In the following
1222 example, notes crossing the bar lines are split and tied.
1223
1224 @lilypond[quote,verbatim,relative=1]
1225 \new Voice \with {
1226   \remove "Note_heads_engraver"
1227   \consists "Completion_heads_engraver"
1228 }
1229
1230 { c2. c8 d4 e f g a b c8 c2 b4 a g16 f4 e d c8. c2 }
1231 @end lilypond
1232
1233 This engraver splits all running notes at the bar line, and
1234 inserts ties.  One of its uses is to debug complex scores: if the
1235 measures are not entirely filled, then the ties show exactly how
1236 much each measure is off.
1237
1238 @seealso
1239
1240 Music Glossary: @rglos{tie}
1241
1242 Learning Manual:
1243 @rlearning{Engravers explained},
1244 @rlearning{Adding and removing engravers}.
1245
1246 Snippets:
1247 @rlsr{Rhythms}.
1248
1249 Internals Reference:
1250 @rinternals{Note_heads_engraver},
1251 @rinternals{Completion_heads_engraver},
1252 @rinternals{Forbid_line_break_engraver}.
1253
1254
1255 @knownissues
1256
1257 Not all durations (especially those containing tuplets) can be
1258 represented exactly with normal notes and dots, but the
1259 @code{Completion_heads_engraver} will not insert tuplets.
1260
1261 The @code{Completion_heads_engraver} only affects notes; it does not
1262 split rests.
1263
1264
1265 @node Showing melody rhythms
1266 @unnumberedsubsubsec Showing melody rhythms
1267
1268 Sometimes you might want to show only the rhythm of a melody.  This
1269 can be done with the rhythmic staff.  All pitches of notes on such a
1270 staff are squashed, and the staff itself has a single line
1271
1272 @lilypond[quote,relative=1,verbatim]
1273 <<
1274   \new RhythmicStaff {
1275     \new Voice = "myRhythm" {
1276       \time 4/4
1277       c4 e8 f g2
1278       r4 g g f
1279       g1
1280     }
1281   }
1282   \new Lyrics {
1283     \lyricsto "myRhythm" {
1284       This is my song
1285       I like to sing
1286     }
1287   }
1288 >>
1289 @end lilypond
1290
1291 Guitar chord charts often show the strumming rhythms.  This can
1292 be done with the @code{Pitch_squash_engraver} and
1293 @code{\improvisationOn}.
1294
1295
1296 @lilypond[quote,verbatim]
1297 <<
1298   \new ChordNames {
1299     \chordmode {
1300       c1 f g c
1301     }
1302   }
1303
1304   \new Voice \with {
1305     \consists Pitch_squash_engraver
1306   } \relative c'' {
1307     \improvisationOn
1308     c4 c8 c c4 c8 c
1309     f4 f8 f f4 f8 f
1310     g4 g8 g g4 g8 g
1311     c4 c8 c c4 c8 c
1312   }
1313 >>
1314 @end lilypond
1315
1316 @predefined
1317 @code{\improvisationOn},
1318 @code{\improvisationOff}.
1319
1320 @snippets
1321
1322 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1323 {guitar-strum-rhythms.ly}
1324
1325 @seealso
1326
1327 Snippets:
1328 @rlsr{Rhythms}.
1329
1330 Internals Reference:
1331 @rinternals{RhythmicStaff},
1332 @rinternals{Pitch_squash_engraver}.
1333
1334 @node Beams
1335 @subsection Beams
1336
1337 @menu
1338 * Automatic beams::
1339 * Setting automatic beam behavior::
1340 * Manual beams::
1341 * Feathered beams::
1342 @end menu
1343
1344 @node Automatic beams
1345 @unnumberedsubsubsec Automatic beams
1346
1347 By default, beams are inserted automatically:
1348
1349 @cindex beams, manual
1350 @cindex manual beams
1351
1352 @lilypond[quote,verbatim,relative=2]
1353 \time 2/4 c8 c c c
1354 \time 6/8 c c c c8. c16 c8
1355 @end lilypond
1356
1357 If these automatic decisions are not satisfactory, beaming can be
1358 entered explicitly; see @ref{Manual beams}.  It is also possible
1359 to define beaming patterns that differ from the defaults.  The
1360 default beaming rules for most common time signatures are defined
1361 in @file{scm/@/auto@/-beam@/.scm}.  If there are no beaming rules
1362 defined for a particular beam's duration in the time signature being
1363 used, its beaming is controlled by the values of three context
1364 properties, @code{measureLength}, @code{beatLength} and
1365 @code{beatGrouping}.  Both the beaming rules and the context
1366 properties can be overridden, see @ref{Setting automatic beam behavior}.
1367
1368 @cindex autoBeamOn
1369 @cindex autoBeamOff
1370
1371 @warning{If beams are used to indicate melismata in songs, then automatic
1372 beaming should be switched off with @code{\autoBeamOff} and the beams
1373 indicated manually.}
1374
1375
1376 @noindent
1377 Automatic beaming may be turned off and on with
1378 @code{\autoBeamOff} and @code{\autoBeamOn} commands:
1379
1380 @lilypond[quote,relative=1,verbatim]
1381 c4 c8 c8. c16 c8. c16 c8
1382 \autoBeamOff
1383 c4 c8 c8. c16 c8.
1384 \autoBeamOn
1385 c16 c8
1386 @end lilypond
1387
1388 @predefined
1389 @code{\autoBeamOff},
1390 @code{\autoBeamOn}.
1391
1392 @snippets
1393
1394 @funindex breakable
1395 @cindex break, line
1396 @cindex line breaks
1397
1398 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1399 {beams-across-line-breaks.ly}
1400
1401 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1402 {changing-beam-knee-gap.ly}
1403
1404 @seealso
1405
1406 Notation Reference:
1407 @ref{Manual beams},
1408 @ref{Setting automatic beam behavior}.
1409
1410 Installed Files:
1411 @file{scm/@/auto@/-beam@/.scm}.
1412
1413 Snippets:
1414 @rlsr{Rhythms}.
1415
1416 Internals Reference: @rinternals{Beam}.
1417
1418
1419 @knownissues
1420
1421 Automatically kneed cross-staff beams cannot be used together with
1422 hidden staves.  See @ref{Hiding staves}.
1423
1424 Beams can collide with note heads and accidentals in other voices
1425
1426
1427 @node Setting automatic beam behavior
1428 @unnumberedsubsubsec Setting automatic beam behavior
1429
1430 @funindex autoBeaming
1431 @funindex autoBeamSettings
1432 @funindex (end * * * *)
1433 @funindex (begin * * * *)
1434
1435 @cindex automatic beams, tuning
1436 @cindex tuning automatic beaming
1437 @cindex automatic beam generation
1438 @cindex autobeam
1439 @cindex lyrics and beaming
1440
1441
1442 The placement of automatic beams is determined by the rules
1443 described in @ref{Automatic beams}.  There are two mutually
1444 exclusive ways in which these rules may be modified.  The
1445 first, modifying the grouping of beats, applies to uncommon time
1446 signatures, i.e. those for which there are no predefined rules
1447 defining the beam end points.  The second method, modifying the
1448 specification of the beam end points, can be used for any time
1449 signature.  This second method @strong{must} be used for those time
1450 signatures and beam durations combinations for which beam ending
1451 rules are pre-defined, unless these have all been reverted.  There
1452 are predefined rules for time signatures of 3/2, 3/4, 4/4, 2/4,
1453 4/8, 4/16, 6/8, 9/8 and 12/8.
1454
1455 @i{@strong{Modifying the grouping of beats}}
1456
1457 If there are no beam-ending rules defined for the beam duration of a
1458 particular beam in the time signature in use, its beaming is
1459 controlled by three context properties:
1460 @code{measureLength}, @code{beatLength} and @code{beatGrouping}.
1461 These properties may be set in the @code{Score}, @code{Staff} or
1462 @code{Voice} contexts to delimit their scope.
1463
1464 These determine the beaming as follows:
1465
1466 Beams may begin anywhere (unless a beam is already active).  Beams
1467 end at a time determined by the values of @code{beatGrouping} and
1468 @code{beatLength}, as follows:
1469
1470 @itemize
1471
1472 @item If @code{beatGrouping} and @code{beatLength} are consistent
1473 with @code{measureLength}, @code{beatGrouping} is used to determine
1474 the end points of beams.
1475
1476 @item If @code{beatGrouping} and @code{beatLength} are inconsistent
1477 with @code{measureLength}, @code{beatLength} is used to determine
1478 the end points of beams.
1479
1480 @end itemize
1481
1482 @warning{These three properties become effective for a particular
1483 beam @strong{only} if there are no beam-ending rules predefined for
1484 that beam's duration in the time signature in use, or if these
1485 beam-ending rules have all been reverted.}
1486
1487 By default the @code{measureLength} and @code{beatLength} are
1488 derived from the time signature set by the @code{\time} command.
1489 The @code{measureLength} is set to be exactly the same length as
1490 the measure length given by the time signature, and the
1491 @code{beatLength} is set to be the same as one over the denominator
1492 of the time signature.
1493
1494 The default value of @code{beatGrouping} is taken from a table in
1495 @file{scm/@/music@/-functions@/.scm}.  To find this, see
1496 @rlearning{Other sources of information}.  It defines the beat
1497 grouping for 5/8, 6/8, 8/8, 9/8 and 12/8 time signatures.
1498
1499 Both @code{measureLength} and @code{beatLength} are @i{moments},
1500 units of musical duration.  A quantity of type @i{moment} is
1501 created by the scheme function @code{ly:make-moment}.  For more
1502 information about this function, see @ref{Time administration}.
1503
1504 @code{beatGrouping} is a list of integers giving the number of
1505 beats in each group.
1506
1507 @snippets
1508
1509 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1510 {grouping-beats.ly}
1511
1512 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1513 {specifying-context-with-beatgrouping.ly}
1514
1515
1516 @c Added to input/new 3 Nov 08
1517 @c TODO When available, change to:
1518 @ignore
1519 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1520 {using-beatlength-and-beatgrouping.ly}
1521 @end ignore
1522
1523 @c start new snippet
1524 The property @code{measureLength} determines where bar lines
1525 should be inserted and, with @code{beatLength} and
1526 @code{beatGrouping}, how automatic beams should be generated
1527 for beam durations and time signatures for which no beam-ending
1528 rules are defined.  This example shows several ways of controlling
1529 beaming by setting these properties.  The explanations are shown
1530 as comments in the code.
1531
1532 @lilypond[quote,verbatim,relative=2]
1533 \time 3/4
1534 % The default in 3/4 time is to beam in three groups
1535 % each of a quarter note length
1536 a16 a a a a a a a a a a a
1537
1538 \time 12/16
1539 % No auto-beaming is defined for 12/16
1540 a16 a a a a a a a a a a a
1541
1542 \time 3/4
1543 a16 a a a a a a a a a a a
1544 % Change time signature symbol, but retain underlying 3/4 beaming
1545 \set Score.timeSignatureFraction = #'(12 . 16)
1546 a16 a a a a a a a a a a a
1547
1548 % The 3/4 time default grouping of (1 1 1) and beatLength of 1/8
1549 % are not consistent with a measureLength of 3/4, so the beams
1550 % are grouped at beatLength intervals
1551 \set Score.beatLength = #(ly:make-moment 1 8)
1552 a16 a a a a a a a a a a a
1553
1554 % Specify beams in groups of (3 3 2 3) 1/16th notes
1555 % 3+3+2+3=11, and 11*1/16<>3/4, so beatGrouping does not apply,
1556 % and beams are grouped at beatLength (1/16) intervals
1557 \set Score.beatLength = #(ly:make-moment 1 16)
1558 \set Score.beatGrouping = #'(3 3 2 3)
1559 a16 a a a a a a a a a a a
1560
1561 % Specify beams in groups of (3 4 2 3) 1/16th notes
1562 % 3+4+2+3=12, and 12*1/16=3/4, so beatGrouping applies
1563 \set Score.beatLength = #(ly:make-moment 1 16)
1564 \set Score.beatGrouping = #'(3 4 2 3)
1565 a16 a a a a a a a a a a a
1566 @end lilypond
1567 @c End of snippet
1568
1569 @funindex subdivideBeams
1570
1571 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1572 {sub-dividing-beams.ly}
1573
1574 @cindex measure groupings
1575 @cindex beats, grouping
1576 @cindex grouping beats
1577 @cindex measure sub-grouping
1578
1579 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1580 {conducting-signs,-measure-grouping-signs.ly}
1581
1582
1583 @strong{@i{Modifying the beam end points}}
1584
1585 In common time signatures, automatic beams can start on any note
1586 but can end at only a few positions within the measure, namely at
1587 durations specified by the properties in @code{autoBeamSettings}.
1588 These properties consist of a list of rules defining where beams can
1589 end.  The default @code{autoBeamSettings} rules are defined in
1590 @file{scm/@/auto@/-beam@/.scm}.  To find this, see
1591 @rlearning{Other sources of information}.
1592
1593 This method @strong{must} be used for the time signatures for which
1594 beam-ending rules are defined by default, unless these have all
1595 been reverted.  It is also particularly suitable for many other time
1596 signatures if the time signature of the measures changes frequently,
1597 or if the beaming should be different for different beam durations.
1598
1599 In order to add a rule to the list, use
1600
1601 @example
1602 #(override-auto-beam-setting
1603   '(beam-limit
1604     beam-numerator  beam-denominator
1605     time-signature-numerator time-signature-denominator)
1606   moment-numerator moment-denominator [context])
1607 @end example
1608
1609 @noindent
1610 where
1611
1612 @itemize
1613
1614 @item @code{beam-limit} is the type of automatic beam limit
1615 defined.  This can be either @code{begin} or @code{end} but
1616 only @code{end} is effective.
1617
1618 @item @code{beam-numerator/beam-denominator} is the beam duration
1619 to which the rule is to apply.  A beam is considered to have
1620 the duration of its shortest note.  Set @code{beam-numerator}
1621 and @code{beam-denominator} to @code{'*'} to have this rule apply
1622 to beams of any duration.
1623
1624 @item @code{time-signature-numerator/time-signature-denominator}
1625 specifies the time signature to which this rule should apply.
1626 If @code{time-signature-numerator} and
1627 @code{time-signature-denominator} are set to @code{'*'} this rule
1628 will apply in any time signature.
1629
1630 @item @code{monent-numerator/moment-denominator} is the position
1631 in the bar at which the beam should end.
1632
1633 @item @code{context} is optional, and it specifies the context at which
1634 the change should be made.  The default is @code{'Voice}.
1635
1636 @code{#(score-override-auto-beam-setting '(A B C D) E F)} is equivalent to
1637 @code{#(override-auto-beam-setting '(A B C D) E F 'Score)}.
1638
1639 @end itemize
1640
1641 For example, if automatic beams should always end on the first quarter
1642 note, whatever the time signature or beam duration, use
1643
1644 @lilypond[quote,verbatim,relative=2]
1645 a8 a a a a a a a
1646 #(override-auto-beam-setting '(end * * * *) 1 4)
1647 a8 a a a a a a a
1648 @end lilypond
1649
1650 You can force the beam settings to take effect only on beams whose shortest
1651 note is a certain duration
1652
1653 @lilypond[quote,verbatim,relative=2]
1654 \time 2/4
1655 % end 1/16 beams for all time signatures at the 1/16 moment
1656 #(override-auto-beam-setting '(end 1 16 * *) 1 16)
1657 a16 a a a a a a a |
1658 a32 a a a a16 a a a a a |
1659 % end 1/32 beams for all time signatures at the 1/16 moment
1660 #(override-auto-beam-setting '(end 1 32 * *) 1 16)
1661 a32 a a a a16 a a a a a |
1662 @end lilypond
1663
1664 You can force the beam settings to take effect only in certain time
1665 signatures
1666
1667 @lilypond[quote,verbatim,relative=2]
1668 \time 5/8
1669 % end beams of all durations in 5/8 time signature at the 2/8 moment
1670 #(override-auto-beam-setting '(end * * 5 8) 2 8)
1671 c8 c d d d
1672 \time 4/4
1673 e8 e f f e e d d
1674 \time 5/8
1675 c8 c d d d
1676 @end lilypond
1677
1678 When multiple voices are used the @code{Staff} context must be
1679 specified if the beaming is to be applied to all voices in the
1680 staff:
1681
1682 @lilypond[quote,verbatim,relative=2]
1683 \time 7/8
1684 % rhythm 3-1-1-2
1685 % Context not specified - does not work correctly
1686 #(override-auto-beam-setting '(end * * 7 8) 3 8)
1687 #(override-auto-beam-setting '(end * * 7 8) 4 8)
1688 #(override-auto-beam-setting '(end * * 7 8) 5 8)
1689 << {a8 a a a16 a a a a8 a} \\ {f4. f8 f f f} >>
1690
1691 % Works correctly with context specified
1692 #(override-auto-beam-setting '(end * * 7 8) 3 8 'Staff)
1693 #(override-auto-beam-setting '(end * * 7 8) 4 8 'Staff)
1694 #(override-auto-beam-setting '(end * * 7 8) 5 8 'Staff)
1695 << {a8 a a a16 a a a a8 a} \\ {f4. f8 f f f} >>
1696 @end lilypond
1697
1698 @warning{If any unexpected beam behavior occurs, check the default
1699 automatic beam settings in @file{scm/@/auto@/-beam@/.scm} for
1700 possible interference, because the beam endings defined there will
1701 still apply in addition to your own.}
1702
1703 Any unwanted or conflicting default endings must be reverted for
1704 your time signature(s).  Existing auto-beam rules are removed by
1705 using
1706
1707 @example
1708 #(revert-auto-beam-setting
1709   '(beam-limit
1710     beam-numerator  beam-denominator
1711     time-signature-numerator time-signature-denominator)
1712   moment-numerator moment-denominator [context])
1713 @end example
1714
1715 @noindent
1716 @code{beam-limit}, @code{beam-numerator}, @code{beam-denominator},
1717 @code{time-signature-numerator}, @code{time-signature-denominator},
1718 @code{moment-numerator}, @code{moment-denominator} and @code{context}
1719 are the same as above.
1720
1721 @lilypond[quote,verbatim,relative=2]
1722 \time 4/4
1723 a16 a a a a a a a a a a a a a a a
1724 % undo a rule ending 1/16 beams in 4/4 time at 1/4 moment
1725 #(revert-auto-beam-setting '(end 1 16 4 4) 1 4)
1726 a16 a a a a a a a a a a a a a a a
1727 @end lilypond
1728
1729 The rule in a @code{revert-auto-beam-setting} statement must exactly
1730 match the original rule.  That is, no wildcard expansion is taken into
1731 account.
1732
1733 @lilypond[quote,verbatim,relative=2]
1734 \time 1/4
1735 #(override-auto-beam-setting '(end 1 16 1 4) 1 8)
1736 a16 a a a
1737 #(revert-auto-beam-setting '(end 1 16 * *) 1 8) % this won't revert it!
1738 a a a a
1739 #(revert-auto-beam-setting '(end 1 16 1 4) 1 8) % this will
1740 a a a a
1741 @end lilypond
1742
1743 @snippets
1744
1745 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1746 {beam-grouping-in-7-8-time.ly}
1747
1748 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1749 {reverting-default-beam-endings.ly}
1750
1751 @c TODO Convert to snippet called "Beam endings in Score context"
1752 @c Submitted to LSR 3 Nov 08
1753
1754 Beam-ending rules specified in the Score context apply to all
1755 staves, but can be modified at both Staff and Voice levels:
1756
1757 @lilypond[quote,verbatim,relative=2]
1758   \time 5/4
1759   % Set default beaming for all staves
1760   #(override-auto-beam-setting '(end * * 5 4) 3 8 'Score)
1761   #(override-auto-beam-setting '(end * * 5 4) 7 8 'Score)
1762   <<
1763     \new Staff {
1764       c8 c c c c c c c c c
1765     }
1766     \new Staff {
1767       % Modify beaming for just this staff
1768       #(override-auto-beam-setting '(end * * 5 4) 6 8 'Staff)
1769       #(revert-auto-beam-setting '(end * * 5 4) 7 8 'Staff)
1770       c8 c c c c c c c c c
1771     }
1772     \new Staff {
1773       % Inherit beaming from Score context
1774       c8 c c c c c c c c c
1775     }
1776   >>
1777 @end lilypond
1778
1779
1780 @predefined
1781
1782 @funindex \autoBeamOff
1783 @code{\autoBeamOff},
1784 @funindex \autoBeamOn
1785 @code{\autoBeamOn}.
1786
1787
1788 @knownissues
1789
1790 If a score ends while an automatic beam has not been ended and is
1791 still accepting notes, this last beam will not be typeset at all.
1792 The same holds for polyphonic voices, entered with @code{<<
1793 @dots{} \\ @dots{} >>}.  If a polyphonic voice ends while an
1794 automatic beam is still accepting notes, it is not typeset.
1795
1796 @seealso
1797
1798 Snippets:
1799 @rlsr{Rhythms}.
1800
1801
1802 @node Manual beams
1803 @unnumberedsubsubsec Manual beams
1804
1805 @cindex beams, manual
1806 @funindex ]
1807 @funindex [
1808
1809 In some cases it may be necessary to override the automatic
1810 beaming algorithm.  For example, the autobeamer will not put beams
1811 over rests or bar lines, and in choral scores the beaming is
1812 often set to follow the meter of the lyrics rather than the
1813 notes. Such beams can be specified manually by
1814 marking the begin and end point with @code{[} and @code{]}
1815
1816 @lilypond[quote,relative=1,verbatim]
1817 {
1818   r4 r8[ g' a r8] r8 g[ | a] r8
1819 }
1820 @end lilypond
1821
1822
1823 Individual notes may be marked with @code{\noBeam} to prevent them
1824 from being beamed:
1825
1826 @lilypond[quote,verbatim,relative=2]
1827 \time 2/4 c8 c\noBeam c c
1828 @end lilypond
1829
1830 @funindex stemLeftBeamCount
1831 @funindex stemRightBeamCount
1832
1833 Even more strict manual control with the beams can be achieved by
1834 setting the properties @code{stemLeftBeamCount} and
1835 @code{stemRightBeamCount}.  They specify the number of beams to
1836 draw on the left and right side, respectively, of the next note.
1837 If either property is set, its value will be used only once, and
1838 then it is erased.  In this example, the last @code{f} is printed
1839 with only one beam on the left side, i.e., the eighth-note beam of
1840 the group as a whole.
1841
1842 @lilypond[quote,relative=2,verbatim]
1843 a8[ r16 f g a]
1844 a8[ r16
1845 \set stemLeftBeamCount = #2
1846 \set stemRightBeamCount = #1
1847 f
1848 \set stemLeftBeamCount = #1
1849 g a]
1850 @end lilypond
1851
1852
1853 @snippets
1854
1855 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
1856 {flat-flags-and-beam-nibs.ly}
1857
1858 @node Feathered beams
1859 @unnumberedsubsubsec Feathered beams
1860
1861 @cindex beams, feathered
1862 @funindex \featherDurations
1863
1864 Feathered beams are used to indicate that a small group of notes
1865 should be played at an increasing (or decreasing) tempo, without
1866 changing the overall tempo of the piece.  The extent of the
1867 feathered beam must be indicated manually using @code{[} and
1868 @code{]}, and the beam feathering is turned on by specifying a
1869 direction to the @code{Beam} property @code{grow-direction}.
1870
1871 If the placement of the notes and the sound in the MIDI output
1872 is to reflect the ritardando or accelerando indicated by the
1873 feathered beam the notes must be grouped as a
1874 music expression delimited by braces and preceded by a
1875 @code{featheredDurations} command which specifies the ratio
1876 between the durations of the first and last notes in the group.
1877
1878 The square brackets
1879 show the extent of the beam and the braces show
1880 which notes are to have their durations modified.  Normally
1881 these would delimit the same group of notes, but this is not
1882 required: the two commands are independent.
1883
1884 In the following example the eight 16th notes occupy exactly the
1885 same time as a half note, but the first note is one half as long
1886 as the last one, with the intermediate notes gradually
1887 lengthening.  The first four 32nd notes gradually speed up, while
1888 the last four 32nd notes are at a constant tempo.
1889
1890 @lilypond[relative=1,verbatim,quote]
1891 \override Beam #'grow-direction = #LEFT
1892 \featherDurations #(ly:make-moment 2 1)
1893 { c16[ c c c c c c c] }
1894 \override Beam #'grow-direction = #RIGHT
1895 \featherDurations #(ly:make-moment 2 3)
1896 { c32[ d e f] }
1897 % revert to non-feathered beams
1898 \override Beam #'grow-direction = #'()
1899 { g32[ a b c] }
1900 @end lilypond
1901
1902 @noindent
1903 The spacing in the printed output represents the
1904 note durations only approximately, but the MIDI output is exact.
1905
1906 @knownissues
1907
1908 The @code{\featherDurations} command only works with very short
1909 music snippets, and when numbers in the fraction are small.
1910
1911 @seealso
1912
1913 Snippets:
1914 @rlsr{Rhythms}.
1915
1916
1917
1918 @node Bars
1919 @subsection Bars
1920
1921
1922 @menu
1923 * Bar lines::
1924 * Bar numbers::
1925 * Bar and bar number checks::
1926 * Rehearsal marks::
1927 @end menu
1928
1929 @node Bar lines
1930 @unnumberedsubsubsec Bar lines
1931
1932 @cindex bar lines
1933 @funindex \bar
1934 @cindex measure lines
1935 @cindex repeat bars
1936
1937 Bar lines delimit measures, and are also used to indicate
1938 repeats.  Normally, simple bar lines are automatically inserted
1939 into the printed output at places based on the current time
1940 signature.
1941
1942 The simple bar lines inserted automatically can be changed to
1943 other types with the @code{\bar} command.  For example, a closing
1944 double bar line is usually placed at the end of a piece:
1945
1946 @lilypond[quote,relative=1,verbatim]
1947 e4 d c2 \bar "|."
1948 @end lilypond
1949
1950 It is not invalid if the final note in a measure does not
1951 end on the automatically entered bar line: the note is assumed
1952 to carry over into the next measure.  But if a long sequence
1953 of such carry-over measures appears the music can appear compressed
1954 or even flowing off the page.  This is because automatic line
1955 breaks happen only at the end of complete measures, i.e., where
1956 all notes end before the end of a measure.
1957
1958 @warning{An incorrect duration can cause line breaks to be
1959 inhibited, leading to a line of highly compressed music or
1960 music which flows off the page.}
1961
1962 @cindex line breaks
1963 @cindex bar lines, invisible
1964 @cindex measure lines, invisible
1965
1966 Line breaks are also permitted at manually inserted bar lines
1967 even within incomplete measures.  To allow a line break without
1968 printing a bar line, use
1969
1970 @example
1971 \bar ""
1972 @end example
1973
1974 @noindent
1975 This will insert an invisible bar line and allow (but not
1976 force) a line break to occur at this point.  The bar number
1977 counter is not increased.  To force a line break see
1978 @ref{Line breaking}.
1979
1980 This and other special bar lines may be inserted manually at any
1981 point.  When they coincide with the end of a measure they replace
1982 the simple bar line which would have been inserted there
1983 automatically.  When they do not coincide
1984 with the end of a measure the specified bar line is inserted at that
1985 point in the printed output.  Such insertions do not affect
1986 the calculation and placement of subsequent automatic bar lines.
1987
1988 The simple bar line and five types of double bar line are available
1989 for manual insertion:
1990
1991 @lilypond[quote,relative=1,verbatim]
1992 f1 \bar "|" g \bar "||" a \bar ".|" b \bar ".|." c \bar "|.|" d \bar "|." e
1993 @end lilypond
1994
1995 @noindent
1996 together with dotted and dashed bar lines:
1997
1998 @lilypond[quote,relative=1,verbatim]
1999 f1 \bar ":" g \bar "dashed" a
2000 @end lilypond
2001
2002 @noindent
2003 and five types of repeat bar line:
2004
2005 @lilypond[quote,relative=1,verbatim]
2006 f1 \bar "|:" g \bar ":|:" a \bar ":|.|:" b \bar ":|.:" c \bar ":|" d
2007 @end lilypond
2008
2009 @cindex repeats
2010
2011 Although the bar line types signifying repeats may be inserted
2012 manually they do not in themselves cause LilyPond to recognize
2013 a repeated section.  Such repeated sections are better entered
2014 using the various repeat commands (see @ref{Repeats}), which
2015 automatically print the appropriate bar lines.
2016
2017 In addition, you can specify @code{"||:"}, which is equivalent to
2018 @code{"|:"} except at line breaks, where it gives a double bar
2019 line at the end of the line and a start repeat at the beginning of
2020 the next line.
2021
2022 @lilypond[quote,relative=2,verbatim]
2023 \override Score.RehearsalMark #'padding = #3
2024 c c c c
2025 \bar "||:"
2026 c c c c \break
2027 \bar "||:"
2028 c c c c
2029 @end lilypond
2030
2031 In scores with many staves, a @code{\bar} command in one staff is
2032 automatically applied to all staves.  The resulting bar lines are
2033 connected between different staves of a @code{StaffGroup},
2034 @code{InnerStaffGroup}, @code{PianoStaff}, or @code{GrandStaff}.
2035
2036 @lilypond[quote,fragment,verbatim]
2037 <<
2038   \new StaffGroup <<
2039     \new Staff {
2040       e'4 d'
2041       \bar "||"
2042       f' e'
2043     }
2044     \new Staff { \clef bass c4 g e g }
2045   >>
2046   \new Staff { \clef bass c2 c2 }
2047 >>
2048 @end lilypond
2049
2050
2051 @snippets
2052
2053 @funindex whichBar
2054 @funindex defaultBarType
2055
2056 The command @code{\bar }@var{bartype} is a shortcut for
2057 @code{\set Timing.whichBar = }@var{bartype}.  A bar line is
2058 created whenever the @code{whichBar} property is
2059 set.
2060
2061 The default bar type used for automatically inserted bar lines is
2062 @code{"|"}.  This may be changed at any time
2063 with @code{\set Timing.defaultBarType = }@var{bartype}.
2064
2065 @seealso
2066
2067 Notation Reference:
2068 @ref{Line breaking},
2069 @ref{Repeats},
2070 @ref{Grouping staves}.
2071
2072 Snippets:
2073 @rlsr{Rhythms}.
2074
2075 Internals Reference: @rinternals{BarLine} (created at
2076 @rinternals{Staff} level), @rinternals{SpanBar} (across
2077 staves), @rinternals{Timing_translator} (for Timing
2078 properties).
2079
2080
2081 @node Bar numbers
2082 @unnumberedsubsubsec Bar numbers
2083
2084 @cindex bar numbers
2085 @cindex measure numbers
2086 @funindex currentBarNumber
2087
2088 Bar numbers are typeset by default at the start of every line except
2089 the first line.  The number itself is stored in the
2090 @code{currentBarNumber} property, which is normally updated
2091 automatically for every measure.  It may also be set manually:
2092
2093 @lilypond[verbatim,quote,fragment,relative=1]
2094 c1 c c c
2095 \break
2096 \set Score.currentBarNumber = #50
2097 c1 c c c
2098 @end lilypond
2099
2100
2101 @snippets
2102
2103 @funindex barNumberVisibility
2104 @cindex bar numbers, regular spacing
2105
2106 Bar numbers can be typeset at regular intervals instead of just at
2107 the beginning of every line.  To do this the default behavior
2108 must be overridden to permit bar numbers to be printed at places
2109 other than the start of a line.  This is controlled by the
2110 @code{break-visibility} property of @code{BarNumber}.  This takes
2111 three values which may be set to @code{#t} or @code{#f} to specify
2112 whether the corresponding bar number is visible or not.  The order
2113 of the three values is @code{end of line visible}, @code{middle of
2114 line visible}, @code{beginning of line visible}.  In the following
2115 example bar numbers are printed at all possible places:
2116
2117 @lilypond[verbatim,quote,relative=1]
2118 \override Score.BarNumber #'break-visibility = #'#(#t #t #t)
2119 \set Score.currentBarNumber = #11
2120 \bar ""  % Permit first bar number to be printed
2121 c1 c c c
2122 \break
2123 c c c c
2124 @end lilypond
2125
2126 @c  All the rest of these examples will be added to LSR
2127 @c  and moved into the Snippets.  -gp
2128
2129 @noindent
2130 and here the bar numbers are printed every two measures
2131 except at the end of the line:
2132
2133 @lilypond[verbatim,quote,relative=1]
2134 \override Score.BarNumber #'break-visibility = #'#(#f #t #t)
2135 \set Score.currentBarNumber = #11
2136 \bar ""  % Permit first bar number to be printed
2137 % Print a bar number every second measure
2138 \set Score.barNumberVisibility = #(every-nth-bar-number-visible 2)
2139 c1 c c c c
2140 \break
2141 c c c c c
2142 @end lilypond
2143
2144 @cindex measure number, format
2145 @cindex bar number, format
2146
2147 The size of the bar number may be changed.  This is illustrated
2148 in the following example, which also shows how to enclose bar
2149 numbers in boxes and circles, and shows an alternative way
2150 of specifying @code{#(#f #t #t)} for @code{break-visibility}.
2151
2152 @lilypond[verbatim,quote,relative=1]
2153 % Prevent bar numbers at the end of a line and permit them elsewhere
2154 \override Score.BarNumber #'break-visibility
2155   = #end-of-line-invisible
2156
2157 % Increase the size of the bar number by 2
2158 \override Score.BarNumber #'font-size = #2
2159 \repeat unfold 3 { c1 } \bar "|"
2160
2161 % Draw a box round the following bar number(s)
2162 \override Score.BarNumber  #'stencil
2163   = #(make-stencil-boxer 0.1 0.25 ly:text-interface::print)
2164 \repeat unfold 3 { c1 } \bar "|"
2165
2166 % Draw a circle round the following bar number(s)
2167 \override Score.BarNumber  #'stencil
2168   = #(make-stencil-circler 0.1 0.25 ly:text-interface::print)
2169 \repeat unfold 4 { c1 } \bar "|."
2170 @end lilypond
2171
2172 @cindex bar number alignment
2173
2174 Bar numbers by default are left-aligned to their parent object.
2175 This is usually the left edge of a line or, if numbers are printed
2176 within a line, the left bar line of the measure.  The numbers may also
2177 be positioned directly on the bar line or right-aligned to the
2178 bar line:
2179
2180 @lilypond[verbatim,quote,relative=1]
2181 \set Score.currentBarNumber = #111
2182 \override Score.BarNumber #'break-visibility = #'#(#t #t #t)
2183 % Increase the size of the bar number by 2
2184 \override Score.BarNumber #'font-size = #2
2185 % Print a bar number every second measure
2186 \set Score.barNumberVisibility = #(every-nth-bar-number-visible 2)
2187 c1 c1
2188 % Center-align bar numbers
2189 \override Score.BarNumber #'self-alignment-X = #0
2190 c1 c1
2191 % Right-align bar numbers
2192 \override Score.BarNumber #'self-alignment-X = #-1
2193 c1 c1
2194 @end lilypond
2195
2196 Bar numbers can be removed entirely by removing the
2197 @code{Bar_number_engraver} from the @code{Score} context.
2198
2199 @lilypond[verbatim,quote]
2200 \layout {
2201   \context {
2202     \Score
2203     \remove "Bar_number_engraver"
2204   }
2205 }
2206 \relative c''{
2207   c4 c c c \break
2208   c4 c c c
2209 }
2210 @end lilypond
2211
2212
2213 @seealso
2214
2215 Snippets:
2216 @rlsr{Rhythms}.
2217
2218 Internals Reference: @rinternals{BarNumber}.
2219
2220
2221 @knownissues
2222
2223 Bar numbers may collide with the top of the
2224 @rinternals{StaffGroup} bracket, if there is one.  To solve
2225 this, the @code{padding} property of @rinternals{BarNumber} can
2226 be used to position the number correctly.
2227
2228 Bar numbers may only be printed at bar lines; to print a bar
2229 number at the beginning of a piece, an empty bar line must be
2230 inserted there, and a value other than @code{1} must be placed
2231 in @code{currentBarNumber}:
2232
2233 @lilypond[verbatim,quote,relative=1]
2234 \set Score.currentBarNumber = #50
2235 \bar ""
2236 c1 c c c
2237 c1 c c c
2238 \break
2239 @end lilypond
2240
2241
2242
2243 @node Bar and bar number checks
2244 @unnumberedsubsubsec Bar and bar number checks
2245
2246 @cindex bar check
2247 @funindex barCheckSynchronize
2248 @funindex |
2249
2250 Bar checks help detect errors in the entered durations.
2251 A bar check may be entered using the bar symbol, @code{|},
2252 at any place where a bar line is expected to fall.
2253 If bar check lines are encountered at other places,
2254 a list of warnings is printed in the log file,
2255 showing the line numbers and lines
2256 in which the bar checks failed.  In the next
2257 example, the second bar check will signal an error.
2258
2259 @example
2260 \time 3/4 c2 e4 | g2 |
2261 @end example
2262
2263 Bar checks can also be used in lyrics, for example
2264
2265 @example
2266 \lyricmode @{
2267   \time 2/4
2268   Twin -- kle | Twin -- kle |
2269 @}
2270 @end example
2271
2272 An incorrect duration can result in a completely garbled score,
2273 especially if the score is polyphonic, so a good place to start
2274 correcting input is by scanning for failed bar checks and
2275 incorrect durations.
2276
2277 If successive bar checks are off by the same musical interval,
2278 only the first warning message is displayed.  This allows the
2279 warning to focus on the source of the timing error.
2280
2281
2282 @funindex |
2283 @funindex pipeSymbol
2284
2285 It is also possible to redefine the action taken when a bar check
2286 or pipe symbol, @code{|}, is encountered in the input, so that
2287 it does something other than a bar check.  This is done by
2288 assigning a music expression to @code{pipeSymbol}.
2289 In the following example @code{|} is set to insert a double bar
2290 line wherever it appears in the input, rather than checking
2291 for end of bar.
2292
2293 @lilypond[quote,verbatim]
2294 pipeSymbol = \bar "||"
2295 {
2296   c'2 c'2 |
2297   c'2 c'2
2298   c'2 | c'2
2299   c'2 c'2
2300 }
2301 @end lilypond
2302
2303 When copying large pieces of music, it can be helpful to check
2304 that the LilyPond bar number corresponds to the original that you
2305 are entering from.  This can be checked with
2306 @code{\barNumberCheck}, for example,
2307
2308 @verbatim
2309 \barNumberCheck #123
2310 @end verbatim
2311
2312 @noindent
2313 will print a warning if the @code{currentBarNumber} is not 123
2314 when it is processed.
2315
2316 @seealso
2317
2318 Snippets:
2319 @rlsr{Rhythms}.
2320
2321
2322 @node Rehearsal marks
2323 @unnumberedsubsubsec Rehearsal marks
2324
2325 @cindex rehearsal marks
2326 @cindex mark, rehearsal
2327 @funindex \mark
2328
2329 To print a rehearsal mark, use the @code{\mark} command
2330
2331 @lilypond[quote,verbatim,relative=2]
2332 c1 \mark \default
2333 c1 \mark \default
2334 c1 \mark #8
2335 c1 \mark \default
2336 c1 \mark \default
2337 @end lilypond
2338
2339 @noindent
2340 The letter@tie{}@q{I} is skipped in accordance with engraving
2341 traditions.  If you wish to include the letter @q{I}, then use
2342
2343 @example
2344 \set Score.markFormatter = #format-mark-alphabet
2345 @end example
2346
2347 The mark is incremented automatically if you use @code{\mark
2348 \default}, but you can also use an integer argument to set the
2349 mark manually.  The value to use is stored in the property
2350 @code{rehearsalMark}.
2351
2352 @cindex rehearsal mark format
2353 @cindex rehearsal mark style
2354 @cindex style, rehearsal mark
2355 @cindex format, rehearsal mark
2356 @cindex mark, rehearsal, style
2357 @cindex mark, rehearsal, format
2358
2359 The style is defined by the property @code{markFormatter}.  It is
2360 a function taking the current mark (an integer) and the current
2361 context as argument.  It should return a markup object.  In the
2362 following example, @code{markFormatter} is set to a pre-defined
2363 procedure.  After a few measures, it is set to a procedure that
2364 produces a boxed number.
2365
2366 @lilypond[quote,verbatim,relative=2]
2367 \set Score.markFormatter = #format-mark-numbers
2368 c1 \mark \default
2369 c1 \mark \default
2370 \set Score.markFormatter = #format-mark-box-numbers
2371 c1 \mark \default
2372 \set Score.markFormatter = #format-mark-circle-numbers
2373 c1 \mark \default
2374 \set Score.markFormatter = #format-mark-circle-letters
2375 c1
2376 @end lilypond
2377
2378 The file @file{scm/@/translation@/-functions@/.scm} contains the
2379 definitions of @code{format-mark-numbers} (the default format),
2380 @code{format-mark-box-numbers}, @code{format-mark-letters} and
2381 @code{format-mark-box-letters}.  These can be used as inspiration
2382 for other formatting functions.
2383
2384 You may use @code{format-mark-barnumbers},
2385 @code{format-mark-box-barnumbers}, and
2386 @code{format-mark-circle-barnumbers} to get bar numbers instead of
2387 incremented numbers or letters.
2388
2389 Other styles of rehearsal mark can be specified manually
2390
2391 @example
2392 \mark "A1"
2393 @end example
2394
2395 @noindent
2396 @code{Score.markFormatter} does not affect marks specified in this
2397 manner.  However, it is possible to apply a @code{\markup} to the
2398 string.
2399
2400 @example
2401 \mark \markup@{ \box A1 @}
2402 @end example
2403
2404 @cindex segno
2405 @cindex coda
2406 @cindex D.S al Fine
2407
2408 Music glyphs (such as the segno sign) may be printed inside a
2409 @code{\mark}
2410
2411 @lilypond[quote,verbatim,relative=1]
2412 c1 \mark \markup { \musicglyph #"scripts.segno" }
2413 c1 \mark \markup { \musicglyph #"scripts.coda" }
2414 c1 \mark \markup { \musicglyph #"scripts.ufermata" }
2415 c1
2416 @end lilypond
2417
2418 @noindent
2419 See @ref{The Feta font}, for a list of symbols which may be
2420 printed with @code{\musicglyph}.
2421
2422 For common tweaks to the positioning of rehearsal marks, see
2423 @ref{Formatting text}.
2424
2425 @seealso
2426
2427 Notation Reference:
2428 @ref{The Feta font},
2429 @ref{Formatting text}.
2430
2431 Installed Files:
2432 @file{scm/@/translation@/-functions@/.scm} contains
2433 the definition of @code{format-mark-numbers} and
2434 @code{format-mark-letters}.  They can be used as inspiration for
2435 other formatting functions.
2436
2437 Snippets:
2438 @rlsr{Rhythms}.
2439
2440 Internals Reference: @rinternals{RehearsalMark}.
2441
2442 @node Special rhythmic concerns
2443 @subsection Special rhythmic concerns
2444
2445
2446 @menu
2447 * Grace notes::
2448 * Aligning to cadenzas::
2449 * Time administration::
2450 @end menu
2451
2452 @node Grace notes
2453 @unnumberedsubsubsec Grace notes
2454
2455 @funindex \grace
2456 @cindex ornaments
2457 @cindex grace notes
2458 @cindex appoggiatura
2459 @cindex acciaccatura
2460
2461 Grace notes are ornaments that are written out. Grace notes
2462 are printed in a smaller font and take up no logical time
2463 in a measure.
2464
2465 @lilypond[quote,relative=2,verbatim]
2466 c4 \grace c16 c4
2467 \grace { c16[ d16] } c2
2468 @end lilypond
2469
2470 Lilypond also supports two special types of grace notes, the
2471 @emph{acciaccatura}--an unmeasured grace note indicated by a slurred
2472 small note with a slashed stem--and the @emph{appoggiatura}, which
2473 takes a fixed fraction of the main note and appears in small print
2474 without a slash.
2475
2476 @lilypond[quote,relative=2,verbatim]
2477 \grace c8 b4
2478 \acciaccatura d8 c4
2479 \appoggiatura e8 d4
2480 \acciaccatura { g16[ f] } e4
2481 @end lilypond
2482
2483 The placement of grace notes is synchronized between different
2484 staves.  In the following example, there are two sixteenth grace
2485 notes for every eighth grace note
2486
2487 @lilypond[quote,relative=2,verbatim]
2488 << \new Staff { e2 \grace { c16[ d e f] } e2 }
2489    \new Staff { c2 \grace { g8[ b] } c2 } >>
2490 @end lilypond
2491
2492 @funindex \afterGrace
2493
2494 @cindex grace notes, following
2495
2496 If you want to end a note with a grace, use the @code{\afterGrace}
2497 command.  It takes two arguments: the main note, and the grace
2498 notes following the main note.
2499
2500 @lilypond[quote,verbatim,relative=2]
2501 c1 \afterGrace d1 { c16[ d] } c1
2502 @end lilypond
2503
2504 This will put the grace notes after a space lasting 3/4 of the
2505 length of the main note.  The default fraction 3/4 can be changed by
2506 setting @code{afterGraceFraction}.  The following example shows
2507 the results from setting the space at the default,  at 15/16, and
2508 finally at 1/2 of the main note.
2509
2510 @lilypond[quote,verbatim,relative=2]
2511 <<
2512   \new Staff {
2513     c1 \afterGrace d1 { c16[ d] } c1
2514   }
2515   \new Staff {
2516     #(define afterGraceFraction (cons 15 16))
2517     c1 \afterGrace d1 { c16[ d] } c1
2518   }
2519   \new Staff {
2520     #(define afterGraceFraction (cons 1 2))
2521     c1 \afterGrace d1 { c16[ d] } c1
2522   }
2523 >>
2524 @end lilypond
2525
2526 The space between the main note and the grace note may also be
2527 specified using spacers. The following example places the grace
2528 note after a space lasting 7/8 of the main note.
2529
2530 @lilypond[quote,verbatim,relative=2]
2531 \new Voice {
2532   << { d1^\trill_( }
2533      { s2 s4. \grace { c16[ d] } } >>
2534   c1)
2535 }
2536 @end lilypond
2537
2538 A @code{\grace} music expression will introduce special
2539 typesetting settings, for example, to produce smaller type, and
2540 set directions.  Hence, when introducing layout tweaks to
2541 override the special settings, they should be placed inside
2542 the grace expression. The overrides should also be reverted
2543 inside the grace expression. Here, the grace note's default stem
2544 direction is overriden and then reverted.
2545
2546 @lilypond[quote,verbatim,relative=2]
2547 \new Voice {
2548   \acciaccatura {
2549     \stemDown
2550     f16->
2551     \stemNeutral
2552   }
2553   g4 e c2
2554 }
2555 @end lilypond
2556
2557
2558 @cindex stem, with slash
2559
2560
2561 @snippets
2562
2563 The slash through the stem found in @emph{acciaccatura}s can be applied
2564 in other situations:
2565
2566 @lilypond[quote,verbatim,relative=2]
2567 \relative c'' {
2568   \override Stem #'stroke-style = #"grace"
2569   c8( d2) e8( f4)
2570 }
2571 @end lilypond
2572
2573 The layout of grace expressions can be changed throughout the
2574 music using the function @code{add-grace-property}.  The following
2575 example undefines the @code{Stem} direction for this grace, so
2576 that stems do not always point up.
2577
2578 @lilypond[quote,verbatim,relative=2]
2579 \relative c'' {
2580   \new Staff {
2581     #(add-grace-property 'Voice 'Stem 'direction ly:stem::calc-direction)
2582     #(remove-grace-property 'Voice 'Stem 'direction)
2583     \new Voice {
2584        \acciaccatura { f16 } g4
2585        \grace { d16[ e] } f4
2586        \appoggiatura { a,32[ b c d] } e2
2587     }
2588   }
2589 }
2590 @end lilypond
2591
2592 Another option is to change the variables @code{startGraceMusic},
2593 @code{stopGraceMusic}, @code{startAcciaccaturaMusic},
2594 @code{stopAcciaccaturaMusic}, @code{startAppoggiaturaMusic},
2595 @code{stopAppoggiaturaMusic}.  The default values of these can be
2596 seen in the file @code{ly/@/grace@/-init@/.ly}.  By redefining
2597 them other effects may be obtained.
2598
2599 Grace notes may be forced to align with regular notes
2600 in other staves:
2601
2602 @lilypond[verbatim,quote]
2603 \relative c'' {
2604   <<
2605     \override Score.SpacingSpanner #'strict-grace-spacing = ##t
2606     \new Staff {
2607       c4
2608       \afterGrace c4 { c16[ c8 c16] }
2609       c4 r
2610     }
2611     \new Staff {
2612       c16 c c c c c c c c4 r
2613     }
2614   >>
2615 }
2616 @end lilypond
2617
2618
2619 @seealso
2620
2621 Music Glossary:
2622 @rglos{grace notes},
2623 @rglos{acciaccatura},
2624 @rglos{appoggiatura}.
2625
2626 Installed Files: @file{ly/@/grace@/-init@/.ly}.
2627
2628 Snippets: @rlsr{Rhythms}.
2629
2630 Internals Reference: @rinternals{GraceMusic}.
2631
2632
2633 @knownissues
2634
2635 A multi-note beamed @i{acciaccatura} is printed without a slash,
2636 and looks exactly the same as a multi-note beamed
2637 @i{appoggiatura}.
2638
2639 @c TODO Add link to LSR snippet to add slash when available
2640
2641 Grace note synchronization can also lead to surprises.  Staff
2642 notation, such as key signatures, bar lines, etc., are also
2643 synchronized.  Take care when you mix staves with grace notes and
2644 staves without, for example,
2645
2646 @lilypond[quote,relative=2,verbatim]
2647 << \new Staff { e4 \bar "|:" \grace c16 d2. }
2648    \new Staff { c4 \bar "|:" d2. } >>
2649 @end lilypond
2650
2651 @noindent
2652 This can be remedied by inserting grace skips of the corresponding
2653 durations in the other staves.  For the above example
2654
2655 @lilypond[quote,relative=2,verbatim]
2656 << \new Staff { e4 \bar "|:" \grace c16 d2. }
2657    \new Staff { c4 \bar "|:" \grace s16 d2. } >>
2658 @end lilypond
2659
2660 Grace sections should only be used within sequential music
2661 expressions.  Nesting or juxtaposing grace sections is not
2662 supported, and might produce crashes or other errors.
2663
2664 @node Aligning to cadenzas
2665 @unnumberedsubsubsec Aligning to cadenzas
2666
2667 @cindex cadenza
2668 @cindex cadenza, aligning to
2669 @cindex aligning to cadenza
2670
2671 In an orchestral context, cadenzas present a special problem: when
2672 constructing a score that includes a measured cadenza or other solo
2673 passage, all other instruments should skip just as many notes as the
2674 length of the cadenza, otherwise they will start too soon or too late.
2675
2676 One solution to this problem is to use the functions
2677 @code{mmrest-of-length} and @code{skip-of-length}.  These Scheme
2678 functions take a defined piece of music as an argument and generate a
2679 multi-measure rest or @code{\skip} exactly as long as the piece.
2680
2681 @lilypond[verbatim,quote]
2682 MyCadenza = \relative c' {
2683   c4 d8 e f g g4
2684   f2 g4 g
2685 }
2686
2687 \new GrandStaff <<
2688   \new Staff {
2689     \MyCadenza c'1
2690     \MyCadenza c'1
2691   }
2692   \new Staff {
2693     #(ly:export (mmrest-of-length MyCadenza))
2694     c'1
2695     #(ly:export (skip-of-length MyCadenza))
2696     c'1
2697   }
2698 >>
2699 @end lilypond
2700
2701 @seealso
2702
2703 Music Glossary:
2704 @rglos{cadenza}.
2705
2706 Snippets:
2707 @rlsr{Rhythms}.
2708
2709
2710 @node Time administration
2711 @unnumberedsubsubsec Time administration
2712
2713 @cindex time administration
2714 @cindex timing (within the score)
2715 @cindex music, unmetered
2716 @cindex unmetered music
2717
2718 @funindex currentBarNumber
2719 @funindex measurePosition
2720 @funindex measureLength
2721
2722 Time is administered by the @code{Timing_translator}, which by
2723 default is to be found in the @code{Score} context.  An alias,
2724 @code{Timing}, is added to the context in which the
2725 @code{Timing_translator} is placed.
2726
2727 The following properties of @code{Timing} are used
2728 to keep track of timing within the score.
2729
2730 @cindex bar number
2731 @cindex measure number
2732
2733 @table @code
2734 @item currentBarNumber
2735 The current measure number.  For an example showing the
2736 use of this property see @ref{Bar numbers}.
2737
2738 @item measureLength
2739 The length of the measures in the current time signature.  For a
2740 4/4 time this is@tie{}1, and for 6/8 it is 3/4.  Its value
2741 determines when bar lines are inserted and how automatic beams
2742 should be generated.
2743
2744 @item measurePosition
2745 The point within the measure where we currently are.  This
2746 quantity is reset by subtracting @code{measureLength} whenever
2747 @code{measureLength} is reached or exceeded.  When that happens,
2748 @code{currentBarNumber} is incremented.
2749
2750 @item timing
2751 If set to true, the above variables are updated for every time
2752 step.  When set to false, the engraver stays in the current
2753 measure indefinitely.
2754
2755 @end table
2756
2757 Timing can be changed by setting any of these variables
2758 explicitly.  In the next example, the default 4/4 time
2759 signature is printed, but @code{measureLength} is set to 5/4.
2760 At 4/8 through the third measure, the @code{measurePosition} is
2761 advanced by 1/8 to 5/8, shortening that bar by 1/8.
2762 The next bar line then falls at 9/8 rather than 5/4.
2763
2764 @lilypond[quote,verbatim,relative=1]
2765 \set Score.measureLength = #(ly:make-moment 5 4)
2766 c1 c4
2767 c1 c4
2768 c4 c4
2769 \set Score.measurePosition = #(ly:make-moment 5 8)
2770 b4 b4 b8
2771 c4 c1
2772 @end lilypond
2773
2774 @noindent
2775 As the example illustrates, @code{ly:make-moment n m} constructs a
2776 duration of n/m of a whole note.  For example,
2777 @code{ly:make-moment 1 8} is an eighth note duration and
2778 @code{ly:make-moment 7 16} is the duration of seven sixteenths
2779 notes.
2780
2781
2782 @seealso
2783
2784 This manual: @ref{Bar numbers}, @ref{Unmetered music}
2785
2786 Snippets:
2787 @rlsr{Rhythms}.
2788
2789 Internals Reference: @rinternals{Timing_translator},
2790 @rinternals{Score}
2791