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