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