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