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