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