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