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