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