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