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