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