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