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