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