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