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