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