1 @c -*- coding: utf-8; mode: texinfo; -*-
6 This section discusses rhythms, durations, and bars.
11 * Displaying rhythms::
14 * Special rhythmic concerns::
19 @subsection Writing rhythms
22 @unnumberedsubsubsec Durations
29 In Note, Chord, and Lyrics mode, durations are designated by numbers and
30 dots: durations are entered as their reciprocal values. For example, a
31 quarter note is entered using a @code{4} (since it is a 1/4 note), while
32 a half note is entered using a @code{2} (since it is a 1/2 note). For
33 notes longer than a whole you must use the @code{\longa} and
34 @code{\breve} commands
38 c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64
40 r1 r2 r4 r8 r16 r32 r64 r64
46 a\breve*1/2 \autoBeamOff
47 a1 a2 a4 a8 a16 a32 a64 a64
50 r\longa*1/4 r\breve *1/2
51 r1 r2 r4 r8 r16 r32 r64 r64
58 \remove "Bar_number_engraver"
62 \remove "Clef_engraver"
63 \override StaffSymbol #'transparent = ##t
64 \override TimeSignature #'transparent = ##t
65 \override BarLine #'transparent = ##t
66 \consists "Pitch_squash_engraver"
72 If the duration is omitted then it is set to the previously entered
73 duration. The default for the first note is a quarter note.
75 @lilypond[quote,ragged-right,verbatim,fragment]
76 { a a a2 a a4 a a1 a }
80 @anchor{Augmentation dots}
81 @unnumberedsubsubsec Augmentation dots
85 To obtain dotted note lengths, simply add a dot (@samp{.}) to
86 the number. Double-dotted notes are produced in a similar way.
88 @lilypond[quote,ragged-right,fragment,verbatim]
89 a'4 b' c''4. b'8 a'4. b'4.. c''8.
94 Dots are normally moved up to avoid staff lines, except in polyphonic
95 situations. The following commands may be used to force a particular
102 @funindex \dotsNeutral
107 Program reference: @internalsref{Dots}, and @internalsref{DotColumn}.
111 @unnumberedsubsubsec Tuplets
117 Tuplets are made out of a music expression by multiplying all durations
121 \times @var{fraction} @var{musicexpr}
125 The duration of @var{musicexpr} will be multiplied by the fraction.
126 The fraction's denominator will be printed over the notes, optionally
127 with a bracket. The most common tuplet is the triplet in which 3
128 notes have the length of 2, so the notes are 2/3 of their written
131 @lilypond[quote,ragged-right,fragment,verbatim]
132 g'4 \times 2/3 {c'4 c' c'} d'4 d'4
135 Tuplets may be nested, for example,
137 @lilypond[fragment,ragged-right,verbatim,relative=2]
138 \override TupletNumber #'text = #tuplet-number::calc-fraction-text
141 \times 3/5 { a a a a a }
149 @funindex \tupletDown
151 @funindex \tupletNeutral
152 @code{\tupletNeutral}.
157 @funindex tupletNumberFormatFunction
158 @cindex tuplet formatting
160 The property @code{tupletSpannerDuration} specifies how long each
161 bracket should last. With this, you can make lots of tuplets while
162 typing @code{\times} only once, thus saving lots of typing. In the next
163 example, there are two triplets shown, while @code{\times} was only
166 @lilypond[quote,fragment,relative=2,ragged-right,verbatim]
167 \set tupletSpannerDuration = #(ly:make-moment 1 4)
168 \times 2/3 { c8 c c c c c }
172 For more information about @code{make-moment}, see
173 @ref{Time administration}.
175 The format of the number is determined by the property @code{text} in
176 @code{TupletNumber}. The default prints only the denominator, but if
177 it is set to the function @code{tuplet-number::calc-fraction-text},
178 @var{num}:@var{den} will be printed instead.
180 To avoid printing tuplet numbers, use
182 @lilypond[quote,fragment,relative=2,ragged-right,verbatim]
183 \times 2/3 { c8 c c } \times 2/3 { c8 c c }
184 \override TupletNumber #'transparent = ##t
185 \times 2/3 { c8 c c } \times 2/3 { c8 c c }
188 Use the @code{\tweak} function to override nested tuplets beginning at the
189 same music moment. In this example, @code{\tweak} specifies fraction
191 outer @code{TupletNumber} and denominator text for the @code{TupletNumber}
192 of the first of the three inner tuplets.
194 @lilypond[quote,ragged-right,verbatim]
196 \tweak #'text #tuplet-number::calc-fraction-text
198 \tweak #'text #tuplet-number::calc-denominator-text
199 \times 2/3 { c'8[ c'8 c'8] }
200 \times 2/3 { c'8[ c'8 c'8] }
201 \times 2/3 { c'8[ c'8 c'8] }
206 Here @code{\tweak} and @code{\override} work together to specify
207 @code{TupletBracket} direction. The first @code{\tweak} positions
208 the @code{TupletBracket} of the outer
209 tuplet above the staff. The second @code{\tweak} positions the
210 @code{TupletBracket} of the first of the three inner tuplets below the
211 staff. Note that this pair of @code{\tweak} functions affects only
212 the outer tuplet and the first of the three inner tuplets because only
213 those two tuplets begin at the same music moment. We use @code{\override}
214 in the usual way to position the @code{TupletBrackets} of
215 the second and third of the inner tuplets below the staff.
217 @lilypond[quote,ragged-right,verbatim]
219 \tweak #'text #tuplet-number::calc-fraction-text
220 \tweak #'direction #up
222 \tweak #'direction #down
223 \times 2/3 { c'8[ c'8 c'8] }
224 \override TupletBracket #'direction = #down
225 \times 2/3 { c'8[ c'8 c'8] }
226 \times 2/3 { c'8[ c'8 c'8] }
231 Tuplet brackets can be made to run to prefatory matter or
234 @lilypond[ragged-right]
236 \set tupletFullLength = ##t
241 \set tupletFullLengthNote = ##t
254 Program reference: @internalsref{TupletBracket},
255 @internalsref{TupletNumber}, and @internalsref{TimeScaledMusic}.
259 @anchor{Scaling durations}
260 @unnumberedsubsubsec Scaling durations
262 You can alter the length of duration by a fraction @var{N/M}
263 appending @samp{*@var{N/M}} (or @samp{*@var{N}} if @var{M=1}). This
264 will not affect the appearance of the notes or rests produced. These
265 may be combined such as @samp{*M*N}.
267 In the following example, the first three notes take up exactly two
268 beats, but no triplet bracket is printed.
270 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
272 a4*2/3 gis4*2/3 a4*2/3
280 This manual: @ref{Tuplets}.
284 @subsection Writing rests
287 @unnumberedsubsubsec Rests
293 Rests are entered like notes with the note name @code{r}
295 @lilypond[fragment,quote,ragged-right,verbatim]
299 Whole bar rests, centered in middle of the bar,
300 must be done with multi-measure rests. They can be used for a
301 single bar as well as many bars, and are discussed in
302 @ref{Multi measure rests}.
304 To explicitly specify a rest's vertical position, write a note
305 followed by @code{\rest}. A rest will be placed in the position
306 where the note would appear,
308 @lilypond[fragment,quote,ragged-right,verbatim]
313 This makes manual formatting of
314 polyphonic music much easier, since the automatic rest collision
315 formatter will leave these rests alone.
319 Program reference: @internalsref{Rest}.
323 @unnumberedsubsubsec Skips
326 @cindex Invisible rest
331 An invisible rest (also called a @q{skip}) can be entered like a note
332 with note name @samp{s} or with @code{\skip @var{duration}}
334 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
335 a4 a4 s4 a4 \skip 1 a4
338 The @code{s} syntax is only available in note mode and chord mode. In
339 other situations, for example, when entering lyrics, you should use
340 the @code{\skip} command
342 @lilypond[quote,ragged-right,verbatim]
345 \new Lyrics \lyricmode { \skip 2 bla2 }
349 The skip command is merely an empty musical placeholder. It does not
350 produce any output, not even transparent output.
352 The @code{s} skip command does create @internalsref{Staff} and
353 @internalsref{Voice} when necessary, similar to note and rest
354 commands. For example, the following results in an empty staff.
356 @lilypond[quote,ragged-right,verbatim]
360 The fragment @code{@{ \skip 4 @} } would produce an empty page.
364 Program reference: @internalsref{SkipMusic}.
367 @anchor{Multi measure rests}
368 @unnumberedsubsubsec Multi measure rests
370 @cindex multi measure rests
371 @cindex full measure rests
372 @cindex Rests, multi measure
373 @cindex Rests, full measure
374 @cindex whole rests for a full measure
377 Rests for one full measure (or many bars) are entered using @samp{R}. It
378 is specifically meant for full bar rests and for entering parts: the rest
379 can expand to fill a score with rests, or it can be printed as a single
380 multi-measure rest. This expansion is controlled by the property
381 @code{Score.skipBars}. If this is set to true, empty measures will not
382 be expanded, and the appropriate number is added automatically
384 @lilypond[quote,ragged-right,fragment,verbatim]
385 \time 4/4 r1 | R1 | R1*2 \time 3/4 R2. \time 2/4 R2 \time 4/4
386 \set Score.skipBars = ##t R1*17 R1*4
389 The @code{1} in @code{R1} is similar to the duration notation used for
390 notes. Hence, for time signatures other than 4/4, you must enter other
391 durations. This can be done with augmentation dots or fractions
393 @lilypond[quote,ragged-right,fragment,verbatim]
394 \set Score.skipBars = ##t
403 An @code{R} spanning a single measure is printed as either a whole rest
404 or a breve, centered in the measure regardless of the time signature.
406 If there are only a few measures of rest, LilyPond prints @q{church rests}
407 (a series of rectangles) in the staff. To replace that with a simple
408 rest, use @code{MultiMeasureRest.expand-limit}.
410 @lilypond[quote,ragged-right,fragment,verbatim]
411 \set Score.skipBars = ##t
413 \override MultiMeasureRest #'expand-limit = 1
417 @cindex text on multi-measure rest
418 @cindex script on multi-measure rest
419 @cindex fermata on multi-measure rest
421 Texts can be added to multi-measure rests by using the
422 @var{note}-@code{markup} syntax @ref{Text markup}.
423 A variable (@code{\fermataMarkup}) is provided for
426 @lilypond[quote,ragged-right,verbatim,fragment]
427 \set Score.skipBars = ##t
429 R2.*10^\markup { \italic "ad lib." }
433 Warning! This text is created by @code{MultiMeasureRestText}, not
436 @lilypond[quote,ragged-right,verbatim,fragment]
437 \override TextScript #'padding = #5
439 \override MultiMeasureRestText #'padding = #5
443 If you want to have text on the left end of a multi-measure rest,
444 attach the text to a zero-length skip note, i.e.,
454 Program reference: @internalsref{MultiMeasureRestMusicGroup},
455 @internalsref{MultiMeasureRest}.
457 The layout object @internalsref{MultiMeasureRestNumber} is for the
458 default number, and @internalsref{MultiMeasureRestText} for user
464 It is not possible to use fingerings (e.g., @code{R1-4}) to put numbers
465 over multi-measure rests. And the pitch of multi-measure rests (or
466 staff-centered rests) can not be influenced.
468 @cindex condensing rests
470 There is no way to automatically condense multiple rests into a single
471 multi-measure rest. Multi-measure rests do not take part in rest
474 Be careful when entering multi-measure rests followed by whole
475 notes. The following will enter two notes lasting four measures each
479 When @code{skipBars} is set, the result will look OK, but the bar
480 numbering will be off.
484 @node Displaying rhythms
485 @subsection Displaying rhythms
487 @anchor{Time signature}
488 @unnumberedsubsubsec Time signature
490 @cindex Time signature
494 Time signature indicates the metrum of a piece: a regular pattern of
495 strong and weak beats. It is denoted by a fraction at the start of the
498 The time signature is set with the @code{\time} command
500 @lilypond[quote,ragged-right,fragment,verbatim]
501 \time 2/4 c'2 \time 3/4 c'2.
506 The symbol that is printed can be customized with the @code{style}
507 property. Setting it to @code{#'()} uses fraction style for 4/4 and
510 @lilypond[fragment,quote,ragged-right,verbatim]
513 \override Staff.TimeSignature #'style = #'()
518 There are many more options for its layout. See @ref{Ancient time
519 signatures}, for more examples.
521 @code{\time} sets the property @code{timeSignatureFraction},
522 @code{beatLength} and @code{measureLength} in the @code{Timing}
523 context, which is normally aliased to @internalsref{Score}. The
524 property @code{measureLength} determines where bar lines should be
525 inserted, and how automatic beams should be generated. Changing the
526 value of @code{timeSignatureFraction} also causes the symbol to be
529 More options are available through the Scheme function
530 @code{set-time-signature}. In combination with the
531 @internalsref{Measure_grouping_engraver}, it will create
532 @internalsref{MeasureGrouping} signs. Such signs ease reading
533 rhythmically complex modern music. In the following example, the 9/8
534 measure is subdivided in 2, 2, 2 and 3. This is passed to
535 @code{set-time-signature} as the third argument @code{(2 2 2 3)}
537 @lilypond[quote,ragged-right,verbatim]
540 #(set-time-signature 9 8 '(2 2 2 3))
541 g8[ g] d[ d] g[ g] a8[( bes g]) |
542 #(set-time-signature 5 8 '(3 2))
548 \consists "Measure_grouping_engraver"
557 Program reference: @internalsref{TimeSignature}, and
558 @internalsref{Timing_translator}.
560 Examples: @lsr{contemporary,compound-time-signature.ly}.
565 Automatic beaming does not use the measure grouping specified with
566 @code{set-time-signature}.
570 @unnumberedsubsubsec Upbeats
574 @cindex partial measure
575 @cindex measure, partial
576 @cindex shorten measures
579 Partial measures, such as an anacrusis or upbeat, are entered using the
581 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
582 \partial 16*5 c16 cis d dis e | a2. c,4 | b2
585 The syntax for this command is
588 \partial @var{duration}
591 where @code{duration} is the rhythmic length to be added before
594 This is internally translated into
597 \set Timing.measurePosition = -@var{length of duration}
600 The property @code{measurePosition} contains a rational number
601 indicating how much of the measure has passed at this point. Note
602 that this is a negative number; @code{\partial 4} is internally
603 translated to mean @qq{there is a quarter note left in the bar.}
608 This command does not take into account grace notes at the start of
609 the music. When a piece starts with graces notes in the pickup, then
610 the @code{\partial} should follow the grace notes
612 @lilypond[verbatim,quote,ragged-right,relative,fragment]
619 @code{\partial} is only intended to be used at the beginning of a
620 piece. If you use it after the beginning, some odd warnings may
624 @anchor{Unmetered music}
625 @unnumberedsubsubsec Unmetered music
629 @funindex \cadenzaOff
631 Bar lines and bar numbers are calculated automatically. For unmetered
632 music (cadenzas, for example), this is not desirable. To turn off
633 automatic bar lines and bar numbers, use the commands @code{\cadenzaOn}
634 and @code{\cadenzaOff}.
636 @lilypond[verbatim,quote,ragged-right,relative=2,fragment]
648 LilyPond will only insert line breaks and page breaks at a
649 barline. Unless the unmetered music ends before the end of
650 the staff line, you will need to insert
658 to indicate where breaks can occur.
661 @anchor{Polymetric notation}
662 @unnumberedsubsubsec Polymetric notation
664 @cindex double time signatures
665 @cindex signatures, polymetric
666 @cindex polymetric signatures
667 @cindex meter, polymetric
669 Double time signatures are not supported explicitly, but they can be
670 faked. In the next example, the markup for the time signature is
671 created with a markup text. This markup text is inserted in the
672 @internalsref{TimeSignature} grob. See also
673 @lsr{contemporary,compound-time-signature}.
675 @lilypond[verbatim,ragged-right]
678 \override #'(baseline-skip . 2) \number {
681 \bracket \column { "5" "8" }
686 \override Staff.TimeSignature #'stencil = #ly:text-interface::print
687 \override Staff.TimeSignature #'text = #tsMarkup
689 c'2 \bar ":" c'4 c'4.
693 Each staff can also have its own time signature. This is done by
694 moving the @internalsref{Timing_translator} to the @internalsref{Staff}
700 \remove "Timing_translator"
701 \remove "Default_bar_line_engraver"
705 \consists "Timing_translator"
706 \consists "Default_bar_line_engraver"
713 Now, each staff has its own time signature.
726 c4. c8 c c c4. c8 c c
731 @lilypond[quote,ragged-right]
735 \remove "Timing_translator"
736 \remove "Default_bar_line_engraver"
739 \consists "Timing_translator"
740 \consists "Default_bar_line_engraver"
755 c4. c8 c c c4. c8 c c
761 A different form of polymetric notation is where note lengths have
762 different values across staves.
764 This notation can be created by setting a common time signature for
765 each staff but replacing it manually using
766 @code{timeSignatureFraction} to the desired fraction. Then the printed
767 durations in each staff are scaled to the common time signature.
768 The latter is done with @code{\compressMusic}, which is used similar
769 to @code{\times}, but does not create a tuplet bracket. The syntax is
771 \compressMusic #'(@var{numerator} . @var{denominator}) @var{musicexpr}
776 In this example, music with the time signatures of 3/4, 9/8, and 10/8 are
777 used in parallel. In the second staff, shown durations are multiplied by
778 2/3, so that 2/3 * 9/8 = 3/4, and in the third staff, shown durations are
779 multiplied by 3/5, so that 3/5 * 10/8 = 3/4.
781 @lilypond[quote,ragged-right,verbatim,fragment]
789 \set Staff.timeSignatureFraction = #'(9 . 8)
790 \compressMusic #'(2 . 3)
791 \repeat unfold 6 { c8[ c c] }
795 \set Staff.timeSignatureFraction = #'(10 . 8)
796 \compressMusic #'(3 . 5) {
797 \repeat unfold 2 { c8[ c c] }
798 \repeat unfold 2 { c8[ c] }
799 | c4. c4. \times 2/3 { c8 c c } c4
808 When using different time signatures in parallel, the spacing is
809 aligned vertically, but bar lines distort the regular spacing.
812 @anchor{Automatic note splitting}
813 @unnumberedsubsubsec Automatic note splitting
815 Long notes can be converted automatically to tied notes. This is done
816 by replacing the @internalsref{Note_heads_engraver} by the
817 @internalsref{Completion_heads_engraver}.
818 In the following examples, notes crossing the bar line are split and tied.
820 @lilypond[quote,fragment,verbatim,relative=1,line-width=12\cm]
822 \remove "Note_heads_engraver"
823 \consists "Completion_heads_engraver"
825 c2. c8 d4 e f g a b c8 c2 b4 a g16 f4 e d c8. c2
829 This engraver splits all running notes at the bar line, and inserts
830 ties. One of its uses is to debug complex scores: if the measures are
831 not entirely filled, then the ties exactly show how much each measure
834 If you want to allow line breaking on the bar lines where
835 @internalsref{Completion_heads_engraver} splits notes, you must
836 also remove @internalsref{Forbid_line_break_engraver}.
841 Not all durations (especially those containing tuplets) can be
842 represented exactly with normal notes and dots, but the engraver will
845 @code{Completion_heads_engraver} only affects notes; it does not split
851 Program reference: @internalsref{Completion_heads_engraver}.
859 @anchor{Automatic beams}
860 @unnumberedsubsubsec Automatic beams
862 LilyPond inserts beams automatically
864 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
865 \time 2/4 c8 c c c \time 6/8 c c c c8. c16 c8
868 When these automatic decisions are not good enough, beaming can be
869 entered explicitly. It is also possible to define beaming patterns
870 that differ from the defaults. See @ref{Setting automatic beam behavior},
873 Individual notes may be marked with @code{\noBeam} to prevent them
876 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
877 \time 2/4 c8 c\noBeam c c
883 Program reference: @internalsref{Beam}.
886 @anchor{Manual beams}
887 @unnumberedsubsubsec Manual beams
889 @cindex beams, manual
893 In some cases it may be necessary to override the automatic beaming
894 algorithm. For example, the autobeamer will not put beams over rests
895 or bar lines. Such beams are specified manually by marking the begin
896 and end point with @code{[} and @code{]}
898 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
900 r4 r8[ g' a r8] r8 g[ | a] r8
907 @funindex stemLeftBeamCount
908 @funindex stemRightBeamCount
911 LilyPond can automatically determine beaming patterns within a beam,
912 but this automatic behavior can sometimes produce odd results;
913 therefore the @code{stemLeftBeamCount} and @code{stemRightBeamCount} properties can
914 be used to override the defaults. If
915 either property is set, its value will be used only once, and then it
918 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
923 \set stemLeftBeamCount = #1
928 The property @code{subdivideBeams} can be set in order to subdivide
929 all 16th or shorter beams at beat positions, as defined by the
930 @code{beatLength} property.
932 @lilypond[fragment,quote,relative=2,verbatim]
934 \set subdivideBeams = ##t
936 \set Score.beatLength = #(ly:make-moment 1 8)
939 @funindex subdivideBeams
942 For more information about @code{make-moment}, see
943 @ref{Time administration}.
945 Line breaks are normally forbidden when beams cross bar lines. This
946 behavior can be changed by setting @code{breakable}.
950 @cindex beams and line breaks
953 @cindex auto-knee-gap
955 Kneed beams are inserted automatically when a large gap is detected
956 between the note heads. This behavior can be tuned through the
957 @code{auto-knee-gap} object.
962 Automatically kneed cross-staff beams cannot be used together with
963 hidden staves. See @ref{Hiding staves}.
965 @c Is this still true with skyline spacing stuff? -J.Mandereau
966 Beams do not avoid collisions with symbols around the notes, such as
967 texts and accidentals.
970 @anchor{Feathered beams}
971 @unnumberedsubsubsec Feathered beams
973 Feathered beams are printed by setting the @code{grow-direction}
974 property of a @code{Beam}. The @code{\featherDurations} function
975 can be used to adjust note durations.
977 @lilypond[ragged-right,relative=1,fragment,verbatim,quote]
978 \override Beam #'grow-direction = #LEFT
979 \featherDurations #(ly:make-moment 5 4)
987 The @code{\featherDurations} command only works with very short
996 @unnumberedsubsubsec Bar check
999 @funindex barCheckSynchronize
1002 Bar checks help detect errors in the durations. A bar check is
1003 entered using the bar symbol, @samp{|}. Whenever it is encountered
1004 during interpretation, it should fall on a measure boundary. If it
1005 does not, a warning is printed. In the next example, the second bar
1006 check will signal an error
1008 \time 3/4 c2 e4 | g2 |
1011 Bar checks can also be used in lyrics, for example
1016 Twin -- kle | Twin -- kle
1020 Failed bar checks are caused by entering incorrect
1021 durations. Incorrect durations often completely garble up the score,
1022 especially if the score is polyphonic, so a good place to start correcting
1023 input is by scanning for failed bar checks and incorrect durations.
1026 @funindex pipeSymbol
1028 It is also possible to redefine the meaning of @code{|}. This is done
1029 by assigning a music expression to @code{pipeSymbol},
1031 @lilypond[quote,ragged-right,verbatim]
1032 pipeSymbol = \bar "||"
1039 @unnumberedsubsubsec Bar lines
1043 @cindex measure lines
1046 Bar lines delimit measures, but are also used to indicate
1047 repeats. Normally they are inserted automatically. Line
1048 breaks may only happen on bar lines.
1050 Special types of bar lines can be forced with the @code{\bar} command
1052 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1056 The following bar types are available
1058 @lilypondfile[ragged-right,quote]{bar-lines.ly}
1060 In addition, you can specify @code{"||:"}, which is equivalent to
1061 @code{"|:"} except at line breaks, where it gives a double bar line at
1062 the end of the line and a start repeat at the beginning of the next
1065 To allow a line break where there is no visible bar line, use
1072 This will insert an invisible bar line and allow line breaks at this
1073 point (without increasing the bar number counter).
1075 In scores with many staves, a @code{\bar} command in one staff is
1076 automatically applied to all staves. The resulting bar lines are
1077 connected between different staves of a @code{StaffGroup},
1078 @code{PianoStaff}, or @code{GrandStaff}.
1080 @lilypond[quote,ragged-right,fragment,verbatim]
1088 \new Staff { \clef bass c4 g e g }
1090 \new Staff { \clef bass c2 c2 }
1098 @funindex repeatCommands
1099 @funindex defaultBarType
1101 The command @code{\bar }@var{bartype} is a short cut for doing
1102 @code{\set Timing.whichBar = }@var{bartype}. Whenever @code{whichBar}
1103 is set to a string, a bar line of that type is created.
1105 A bar line is created whenever the @code{whichBar} property is set.
1106 At the start of a measure it is set to the contents of
1107 @code{Timing.defaultBarType}. The contents of @code{repeatCommands} are
1109 to override default measure bars.
1111 You are encouraged to use @code{\repeat} for repetitions. See
1117 In this manual: @ref{Repeats}, @ref{System start delimiters}.
1119 Program reference: @internalsref{BarLine} (created at
1120 @internalsref{Staff} level), @internalsref{SpanBar} (across staves).
1123 @anchor{Bar numbers}
1124 @unnumberedsubsubsec Bar numbers
1127 @cindex measure numbers
1128 @funindex currentBarNumber
1130 Bar numbers are printed by default at the start of the line. The
1131 number itself is stored in the @code{currentBarNumber} property, which
1132 is normally updated automatically for every measure.
1134 @lilypond[verbatim,ragged-right,quote,fragment,relative]
1135 \repeat unfold 4 {c4 c c c} \break
1136 \set Score.currentBarNumber = #50
1137 \repeat unfold 4 {c4 c c c}
1140 Bar numbers may only be printed at bar lines; to print a bar
1141 number at the beginning of a piece, an empty bar line must
1144 @lilypond[verbatim,ragged-right,quote,fragment,relative]
1145 \set Score.currentBarNumber = #50
1147 \repeat unfold 4 {c4 c c c} \break
1148 \repeat unfold 4 {c4 c c c}
1151 Bar numbers can be typeset at regular intervals instead of at the
1152 beginning of each line. This is illustrated in the following example,
1153 whose source is available as
1154 @lsr{staff,making-bar-numbers-appear-at-regular-intervals.ly}.
1156 @lilypondfile[ragged-right,quote]{bar-number-regular-interval.ly}
1158 Bar numbers can be removed entirely by removing the Bar number
1159 engraver from the score.
1161 @lilypond[verbatim,ragged-right,quote]
1165 \remove "Bar_number_engraver"
1177 Program reference: @internalsref{BarNumber}.
1179 Examples: @lsrdir{staff}
1184 Bar numbers can collide with the @internalsref{StaffGroup} bracket, if
1185 there is one at the top. To solve this, the
1186 @code{padding} property of @internalsref{BarNumber} can be
1187 used to position the number correctly.
1190 @anchor{Barnumber check}
1191 @unnumberedsubsubsec Barnumber check
1193 When copying large pieces of music, it can be helpful to check that
1194 the LilyPond bar number corresponds to the original that you are
1195 entering from. This can be checked with @code{\barNumberCheck}, for
1199 \barNumberCheck #123
1203 will print a warning if the @code{currentBarNumber} is not 123 when it
1207 @anchor{Rehearsal marks}
1208 @unnumberedsubsubsec Rehearsal marks
1210 @cindex Rehearsal marks
1213 To print a rehearsal mark, use the @code{\mark} command
1215 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
1224 The letter@tie{}@q{I} is skipped in accordance with engraving traditions.
1225 If you wish to include the letter @q{I}, then use
1228 \set Score.markFormatter = #format-mark-alphabet
1231 The mark is incremented automatically if you use @code{\mark
1232 \default}, but you can also use an integer argument to set the mark
1233 manually. The value to use is stored in the property
1234 @code{rehearsalMark}.
1236 The style is defined by the property @code{markFormatter}. It is a
1237 function taking the current mark (an integer) and the current context
1238 as argument. It should return a markup object. In the following
1239 example, @code{markFormatter} is set to a canned procedure. After a
1240 few measures, it is set to function that produces a boxed number.
1242 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
1243 \set Score.markFormatter = #format-mark-numbers
1246 \set Score.markFormatter = #format-mark-box-numbers
1252 The file @file{scm/@/translation@/-functions@/.scm} contains the definitions
1253 of @code{format-mark-numbers} (the default format),
1254 @code{format-mark-box-numbers},
1255 @code{format-mark-letters} and @code{format-mark-box-letters}.
1256 These can be used as inspiration for other formatting functions.
1258 You may use @code{format-mark-barnumbers}, @code{format-mark-box-barnumbers},
1259 and @code{format-mark-circle-barnumbers} to get bar numbers instead of
1260 incremented numbers or letters.
1262 Other styles of rehearsal mark can be specified manually
1269 @code{Score.markFormatter} does not affect marks specified in this manner.
1270 However, it is possible to apply a @code{\markup} to the string.
1273 \mark \markup@{ \box A1 @}
1280 Music glyphs (such as the segno sign) may be printed inside
1283 @lilypond[fragment,quote,ragged-right,verbatim,relative]
1284 c1 \mark \markup { \musicglyph #"scripts.segno" }
1285 c1 \mark \markup { \musicglyph #"scripts.coda" }
1286 c1 \mark \markup { \musicglyph #"scripts.ufermata" }
1291 See @ref{The Feta font}, for a list of symbols which may be
1292 printed with @code{\musicglyph}.
1294 For common tweaks to the positioning of rehearsal marks, see @ref{Text marks}.
1298 This manual: @ref{Text marks}.
1300 Program reference: @internalsref{RehearsalMark}.
1302 Init files: @file{scm/@/translation@/-functions@/.scm} contains the
1303 definition of @code{format-mark-numbers} and
1304 @code{format-mark-letters}. They can be used as inspiration for other
1305 formatting functions.
1307 Examples: @lsr{parts,rehearsal-mark-numbers.ly}
1310 @node Special rhythmic concerns
1311 @subsection Special rhythmic concerns
1314 @anchor{Grace notes}
1315 @unnumberedsubsubsec Grace notes
1320 @cindex appoggiatura
1321 @cindex acciaccatura
1323 Grace notes are ornaments that are written out. The most common ones
1324 are acciaccatura, which should be played as very short. It is denoted
1325 by a slurred small note with a slashed stem. The appoggiatura is a
1326 grace note that takes a fixed fraction of the main note, and is
1327 denoted as a slurred note in small print without a slash. They
1328 are entered with the commands @code{\acciaccatura} and
1329 @code{\appoggiatura}, as demonstrated in the following example
1331 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
1332 b4 \acciaccatura d8 c4 \appoggiatura e8 d4
1333 \acciaccatura { g16[ f] } e4
1336 Both are special forms of the @code{\grace} command. By prefixing this
1337 keyword to a music expression, a new one is formed, which will be
1338 printed in a smaller font and takes up no logical time in a measure.
1340 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
1342 \grace { c16[ d16] } c2 c4
1346 Unlike @code{\acciaccatura} and @code{\appoggiatura}, the
1347 @code{\grace} command does not start a slur.
1349 @cindex timing, internal
1351 Internally, timing for grace notes is done using a second, @q{grace}
1352 timing. Every point in time consists of two rational numbers: one
1353 denotes the logical time, one denotes the grace timing. The above
1354 example is shown here with timing tuples
1356 @lilypond[quote,ragged-right]
1359 c4 \grace c16 c4 \grace {
1362 \new Lyrics \lyricmode {
1363 \override LyricText #'font-family = #'typewriter
1367 ( \fraction 1 4 , \fraction -1 16 ) } 16 }
1368 \markup { (\fraction 1 4 , 0 ) } 4
1370 \markup { (\fraction 2 4 , \fraction "-1" 8 ) } 16
1371 \markup { (\fraction 2 4 , \fraction "-1" 16 ) } 16
1373 \markup { ( \fraction 2 4 , 0 ) }
1378 The placement of grace notes is synchronized between different staves.
1379 In the following example, there are two sixteenth grace notes for
1380 every eighth grace note
1382 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
1383 << \new Staff { e4 \grace { c16[ d e f] } e4 }
1384 \new Staff { c4 \grace { g8[ b] } c4 } >>
1387 @funindex \afterGrace
1389 If you want to end a note with a grace, use the @code{\afterGrace}
1390 command. It takes two arguments: the main note, and the grace notes
1391 following the main note.
1393 @lilypond[ragged-right, verbatim,relative=2,fragment]
1394 c1 \afterGrace d1 { c16[ d] } c4
1397 This will put the grace notes after a @q{space} lasting 3/4 of the
1398 length of the main note. The fraction 3/4 can be changed by setting
1399 @code{afterGraceFraction}, ie.
1402 #(define afterGraceFraction (cons 7 8))
1406 will put the grace note at 7/8 of the main note.
1408 The same effect can be achieved manually by doing
1410 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
1413 { s2 \grace { c16[ d] } } >>
1419 By adjusting the duration of the skip note (here it is a half-note),
1420 the space between the main-note and the grace is adjusted.
1422 A @code{\grace} music expression will introduce special typesetting settings,
1423 for example, to produce smaller type, and set directions. Hence, when
1424 introducing layout tweaks, they should be inside the grace expression,
1427 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
1439 The overrides should also be reverted inside the grace expression.
1441 The layout of grace expressions can be changed throughout the music
1442 using the function @code{add-grace-property}. The following example
1443 undefines the @code{Stem} direction for this grace, so that stems do not
1448 #(add-grace-property 'Voice 'Stem 'direction '())
1454 Another option is to change the variables @code{startGraceMusic},
1455 @code{stopGraceMusic}, @code{startAcciaccaturaMusic},
1456 @code{stopAcciaccaturaMusic}, @code{startAppoggiaturaMusic},
1457 @code{stopAppoggiaturaMusic}. More information is in the file
1458 @file{ly/@/grace@/-init@/.ly}.
1461 The slash through the stem in acciaccaturas can be obtained
1462 in other situations by @code{\override Stem #'stroke-style = #"grace"}.
1467 Grace notes may be forced to use floating spacing,
1469 @lilypond[relative=2,ragged-right]
1471 \override Score.SpacingSpanner #'strict-grace-spacing = ##t
1480 c'16[ c'16 c'16 c'16]
1481 c'16[ c'16 c'16 c'16]
1490 Program reference: @internalsref{GraceMusic}.
1495 A score that starts with a @code{\grace} expression needs an explicit
1496 @code{\new Voice} declaration, otherwise the main note and the grace
1497 note end up on different staves.
1499 Grace note synchronization can also lead to surprises. Staff notation,
1500 such as key signatures, bar lines, etc., are also synchronized. Take
1501 care when you mix staves with grace notes and staves without, for example,
1503 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
1504 << \new Staff { e4 \bar "|:" \grace c16 d4 }
1505 \new Staff { c4 \bar "|:" d4 } >>
1509 This can be remedied by inserting grace skips of the corresponding
1510 durations in the other staves. For the above example
1512 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
1513 << \new Staff { e4 \bar "|:" \grace c16 d4 }
1514 \new Staff { c4 \bar "|:" \grace s16 d4 } >>
1517 Grace sections should only be used within sequential music
1518 expressions. Nesting or juxtaposing grace sections is not supported,
1519 and might produce crashes or other errors.
1522 @anchor{Aligning to cadenzas}
1523 @unnumberedsubsubsec Aligning to cadenzas
1525 In an orchestral context, cadenzas present a special problem:
1526 when constructing a score that includes a cadenza, all other
1527 instruments should skip just as many notes as the length of the
1528 cadenza, otherwise they will start too soon or too late.
1530 A solution to this problem are the functions @code{mmrest-of-length}
1531 and @code{skip-of-length}. These Scheme functions take a piece of music
1532 as argument, and generate a @code{\skip} or multi-rest, exactly as
1533 long as the piece. The use of @code{mmrest-of-length} is demonstrated
1534 in the following example.
1536 @lilypond[verbatim,ragged-right,quote]
1537 cadenza = \relative c' {
1538 c4 d8 << { e f g } \\ { d4. } >>
1543 \new Staff { \cadenza c'4 }
1545 #(ly:export (mmrest-of-length cadenza))
1552 @anchor{Time administration}
1553 @unnumberedsubsubsec Time administration
1555 @cindex Time administration
1557 Time is administered by the @internalsref{Time_signature_engraver},
1558 which usually lives in the @internalsref{Score} context. The
1559 bookkeeping deals with the following variables
1562 @item currentBarNumber
1566 The length of the measures in the current time signature. For a 4/4
1567 time this is@tie{}1, and for 6/8 it is 3/4.
1569 @item measurePosition
1570 The point within the measure where we currently are. This quantity
1571 is reset to@tie{}0 whenever it exceeds @code{measureLength}. When that
1572 happens, @code{currentBarNumber} is incremented.
1575 If set to true, the above variables are updated for every time
1576 step. When set to false, the engraver stays in the current measure
1580 Timing can be changed by setting any of these variables explicitly.
1581 In the next example, the 4/4 time signature is printed, but
1582 @code{measureLength} is set to 5/4. After a while, the measure is
1583 shortened by 1/8, by setting @code{measurePosition} to 7/8 at 2/4
1584 in the measure, so the next bar line will fall at 2/4 + 3/8. The
1585 3/8 arises because 5/4 normally has 10/8, but we have manually
1586 set the measure position to be 7/8 and 10/8 - 7/8 = 3/8.
1588 @lilypond[quote,ragged-right,verbatim,relative,fragment]
1589 \set Score.measureLength = #(ly:make-moment 5 4)
1593 \set Score.measurePosition = #(ly:make-moment 7 8)
1599 As the example illustrates, @code{ly:make-moment n m} constructs a
1600 duration of n/m of a whole note. For example, @code{ly:make-moment 1 8} is
1602 note duration and @code{ly:make-moment 7 16} is the duration of
1603 seven sixteenths notes.
1606 @anchor{Proportional notation (introduction)}
1607 @unnumberedsubsubsec Proportional notation (introduction)
1608 @cindex Proportional notation
1610 See @ref{Proportional notation}.
1613 TODO: remove all this stuff?
1615 Notes can be spaced proportionally to their time-difference by
1616 assigning a duration to @code{proportionalNotationDuration}
1618 @lilypond[quote,ragged-right,verbatim,relative=2,fragment]
1620 \set Score.proportionalNotationDuration = #(ly:make-moment 1 16)
1621 \new Staff { c8[ c c c c c] c4 c2 r2 }
1622 \new Staff { c2 \times 2/3 { c8 c c } c4 c1 }
1626 Setting this property only affects the ideal spacing between
1627 consecutive notes. For true proportional notation, the following
1628 settings are also required.
1632 @item True proportional notation requires that symbols are allowed to
1633 overstrike each other. That is achieved by removing the
1634 @internalsref{Separating_line_group_engraver} from
1635 @internalsref{Staff} context.
1637 @item Spacing influence of prefatory matter (clefs, bar lines, etc.)
1638 is removed by setting the @code{strict-note-spacing} property to
1639 @code{#t} in @internalsref{SpacingSpanner} grob.
1641 @item Optical spacing tweaks are switched by setting
1642 @code{uniform-stretching} in @internalsref{SpacingSpanner} to true.
1649 Examples: @lsr{spacing,proportional@/-spacing@/.ly},
1650 @lsr{spacing,proportional@/-strict@/-grace@/-notes@/.ly}, and
1651 @lsr{spacing,proportional@/-strict@/-notespacing@/.ly}
1653 An example of strict proportional notation is in the
1654 example file @file{input/proportional.ly}.