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