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