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
29 @unnumberedsubsubsec Durations
36 In Note, Chord, and Lyrics mode, durations are designated by
37 numbers and dots: durations are entered as their reciprocal
38 values. For example, a quarter note is entered using a @code{4}
39 (since it is a 1/4 note), while a half note is entered using a
40 @code{2} (since it is a 1/2 note). For notes longer than a whole
41 you must use the @code{\longa} and @code{\breve} commands
45 c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64
47 r1 r2 r4 r8 r16 r32 r64 r64
53 a\breve*1/2 \autoBeamOff
54 a1 a2 a4 a8 a16 a32 a64 a64
57 r\longa*1/4 r\breve *1/2
58 r1 r2 r4 r8 r16 r32 r64 r64
65 \remove "Bar_number_engraver"
69 \remove "Clef_engraver"
70 \override StaffSymbol #'transparent = ##t
71 \override TimeSignature #'transparent = ##t
72 \override BarLine #'transparent = ##t
73 \consists "Pitch_squash_engraver"
79 If the duration is omitted then it is set to the previously
80 entered duration. The default for the first note is a quarter
83 @lilypond[quote,ragged-right,verbatim,fragment]
84 { a a a2 a a4 a a1 a }
88 @node Augmentation dots
89 @unnumberedsubsubsec Augmentation dots
93 To obtain dotted note lengths, simply add a dot (@samp{.}) to the
94 number. Double-dotted notes are produced in a similar way.
96 @lilypond[quote,ragged-right,fragment,verbatim]
97 a'4 b' c''4. b'8 a'4. b'4.. c''8.
102 Dots are normally moved up to avoid staff lines, except in
103 polyphonic situations. The following commands may be used to
104 force a particular direction manually
110 @funindex \dotsNeutral
115 Program reference: @internalsref{Dots}, and
116 @internalsref{DotColumn}.
120 @unnumberedsubsubsec Tuplets
126 Tuplets are made out of a music expression by multiplying all
127 durations with a fraction
130 \times @var{fraction} @var{musicexpr}
134 The duration of @var{musicexpr} will be multiplied by the
135 fraction. The fraction's denominator will be printed over the
136 notes, optionally with a bracket. The most common tuplet is the
137 triplet in which 3 notes have the length of 2, so the notes are
138 2/3 of their written length
140 @lilypond[quote,ragged-right,fragment,verbatim]
141 g'4 \times 2/3 {c'4 c' c'} d'4 d'4
144 Tuplets may be nested, for example,
146 @lilypond[fragment,ragged-right,verbatim,relative=2]
147 \override TupletNumber #'text = #tuplet-number::calc-fraction-text
150 \times 3/5 { a a a a a }
158 @funindex \tupletDown
160 @funindex \tupletNeutral
161 @code{\tupletNeutral}.
166 @funindex tupletNumberFormatFunction
167 @cindex tuplet formatting
169 The property @code{tupletSpannerDuration} specifies how long each
170 bracket should last. With this, you can make lots of tuplets
171 while typing @code{\times} only once, thus saving lots of typing.
172 In the next example, there are two triplets shown, while
173 @code{\times} was only used once
175 @lilypond[quote,fragment,relative=2,ragged-right,verbatim]
176 \set tupletSpannerDuration = #(ly:make-moment 1 4)
177 \times 2/3 { c8 c c c c c }
181 For more information about @code{make-moment}, see
182 @ref{Time administration}.
184 The format of the number is determined by the property @code{text}
185 in @code{TupletNumber}. The default prints only the denominator,
186 but if it is set to the function
187 @code{tuplet-number::calc-fraction-text}, @var{num}:@var{den} will
190 To avoid printing tuplet numbers, use
192 @lilypond[quote,fragment,relative=2,ragged-right,verbatim]
193 \times 2/3 { c8 c c } \times 2/3 { c8 c c }
194 \override TupletNumber #'transparent = ##t
195 \times 2/3 { c8 c c } \times 2/3 { c8 c c }
198 Use the @code{\tweak} function to override nested tuplets
199 beginning at the same music moment. In this example,
200 @code{\tweak} specifies fraction text for the outer
201 @code{TupletNumber} and denominator text for the
202 @code{TupletNumber} of the first of the three inner tuplets.
204 @lilypond[quote,ragged-right,verbatim]
206 \tweak #'text #tuplet-number::calc-fraction-text
208 \tweak #'text #tuplet-number::calc-denominator-text
209 \times 2/3 { c'8[ c'8 c'8] }
210 \times 2/3 { c'8[ c'8 c'8] }
211 \times 2/3 { c'8[ c'8 c'8] }
216 Here @code{\tweak} and @code{\override} work together to specify
217 @code{TupletBracket} direction. The first @code{\tweak} positions
218 the @code{TupletBracket} of the outer tuplet above the staff. The
219 second @code{\tweak} positions the @code{TupletBracket} of the
220 first of the three inner tuplets below the staff. Note that this
221 pair of @code{\tweak} functions affects only the outer tuplet and
222 the first of the three inner tuplets because only those two
223 tuplets begin at the same music moment. We use @code{\override}
224 in the usual way to position the @code{TupletBrackets} of the
225 second and third of the inner tuplets below the staff.
227 @lilypond[quote,ragged-right,verbatim]
229 \tweak #'text #tuplet-number::calc-fraction-text
230 \tweak #'direction #up
232 \tweak #'direction #down
233 \times 2/3 { c'8[ c'8 c'8] }
234 \override TupletBracket #'direction = #down
235 \times 2/3 { c'8[ c'8 c'8] }
236 \times 2/3 { c'8[ c'8 c'8] }
241 Tuplet brackets can be made to run to prefatory matter or the next
244 @lilypond[ragged-right]
246 \set tupletFullLength = ##t
251 \set tupletFullLengthNote = ##t
264 Program reference: @internalsref{TupletBracket},
265 @internalsref{TupletNumber}, and @internalsref{TimeScaledMusic}.
269 @node Scaling durations
270 @unnumberedsubsubsec Scaling durations
272 You can alter the length of duration by a fraction @var{N/M}
273 appending @samp{*@var{N/M}} (or @samp{*@var{N}} if @var{M=1}).
274 This will not affect the appearance of the notes or rests
275 produced. These may be combined such as @samp{*M*N}.
277 In the following example, the first three notes take up exactly
278 two beats, but no triplet bracket is printed.
280 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
282 a4*2/3 gis4*2/3 a4*2/3
290 This manual: @ref{Tuplets}.
294 @subsection Writing rests
299 * Multi measure rests::
303 @unnumberedsubsubsec Rests
309 Rests are entered like notes with the note name @code{r}
311 @lilypond[fragment,quote,ragged-right,verbatim]
315 Whole bar rests, centered in middle of the bar, must be done with
316 multi-measure rests. They can be used for a single bar as well as
317 many bars, and are discussed in @ref{Multi measure rests}.
319 To explicitly specify a rest's vertical position, write a note
320 followed by @code{\rest}. A rest will be placed in the position
321 where the note would appear,
323 @lilypond[fragment,quote,ragged-right,verbatim]
328 This makes manual formatting of polyphonic music much easier,
329 since the automatic rest collision formatter will leave these
334 Program reference: @internalsref{Rest}.
338 @unnumberedsubsubsec Skips
341 @cindex Invisible rest
346 An invisible rest (also called a @q{skip}) can be entered like a
347 note with note name @samp{s} or with @code{\skip @var{duration}}
349 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
350 a4 a4 s4 a4 \skip 1 a4
353 The @code{s} syntax is only available in note mode and chord mode.
354 In other situations, for example, when entering lyrics, you should
355 use the @code{\skip} command
357 @lilypond[quote,ragged-right,verbatim]
360 \new Lyrics \lyricmode { \skip 2 bla2 }
364 The skip command is merely an empty musical placeholder. It does
365 not produce any output, not even transparent output.
367 The @code{s} skip command does create @internalsref{Staff} and
368 @internalsref{Voice} when necessary, similar to note and rest
369 commands. For example, the following results in an empty staff.
371 @lilypond[quote,ragged-right,verbatim]
375 The fragment @code{@{ \skip 4 @} } would produce an empty page.
379 Program reference: @internalsref{SkipMusic}.
382 @node Multi measure rests
383 @unnumberedsubsubsec Multi measure rests
385 @cindex multi measure rests
386 @cindex full measure rests
387 @cindex Rests, multi measure
388 @cindex Rests, full measure
389 @cindex whole rests for a full measure
392 Rests for one full measure (or many bars) are entered using
393 @samp{R}. It is specifically meant for full bar rests and for
394 entering parts: the rest can expand to fill a score with rests, or
395 it can be printed as a single multi-measure rest. This expansion
396 is controlled by the property @code{Score.skipBars}. If this is
397 set to true, empty measures will not be expanded, and the
398 appropriate number is added automatically
400 @lilypond[quote,ragged-right,fragment,verbatim]
401 \time 4/4 r1 | R1 | R1*2 \time 3/4 R2. \time 2/4 R2 \time 4/4
402 \set Score.skipBars = ##t R1*17 R1*4
405 The @code{1} in @code{R1} is similar to the duration notation used
406 for notes. Hence, for time signatures other than 4/4, you must
407 enter other durations. This can be done with augmentation dots or
410 @lilypond[quote,ragged-right,fragment,verbatim]
411 \set Score.skipBars = ##t
420 An @code{R} spanning a single measure is printed as either a whole
421 rest or a breve, centered in the measure regardless of the time
424 If there are only a few measures of rest, LilyPond prints
425 @q{church rests} (a series of rectangles) in the staff. To
426 replace that with a simple rest, use
427 @code{MultiMeasureRest.expand-limit}.
429 @lilypond[quote,ragged-right,fragment,verbatim]
430 \set Score.skipBars = ##t
432 \override MultiMeasureRest #'expand-limit = 1
436 @cindex text on multi-measure rest
437 @cindex script on multi-measure rest
438 @cindex fermata on multi-measure rest
440 Texts can be added to multi-measure rests by using the
441 @var{note}-@code{markup} syntax @ref{Text markup}. A variable
442 (@code{\fermataMarkup}) is provided for adding fermatas
444 @lilypond[quote,ragged-right,verbatim,fragment]
445 \set Score.skipBars = ##t
447 R2.*10^\markup { \italic "ad lib." }
451 Warning! This text is created by @code{MultiMeasureRestText}, not
454 @lilypond[quote,ragged-right,verbatim,fragment]
455 \override TextScript #'padding = #5
457 \override MultiMeasureRestText #'padding = #5
461 If you want to have text on the left end of a multi-measure rest,
462 attach the text to a zero-length skip note, i.e.,
472 Program reference: @internalsref{MultiMeasureRestMusicGroup},
473 @internalsref{MultiMeasureRest}.
475 The layout object @internalsref{MultiMeasureRestNumber} is for the
476 default number, and @internalsref{MultiMeasureRestText} for user
482 It is not possible to use fingerings (e.g., @code{R1-4}) to put
483 numbers over multi-measure rests. And the pitch of multi-measure
484 rests (or staff-centered rests) can not be influenced.
486 @cindex condensing rests
488 There is no way to automatically condense multiple rests into a
489 single multi-measure rest. Multi-measure rests do not take part
492 Be careful when entering multi-measure rests followed by whole
493 notes. The following will enter two notes lasting four measures
500 When @code{skipBars} is
501 set, the result will look OK, but the bar numbering will be off.
505 @node Displaying rhythms
506 @subsection Displaying rhythms
512 * Polymetric notation::
513 * Automatic note splitting::
517 @unnumberedsubsubsec Time signature
519 @cindex Time signature
523 Time signature indicates the metrum of a piece: a regular pattern
524 of strong and weak beats. It is denoted by a fraction at the
527 The time signature is set with the @code{\time} command
529 @lilypond[quote,ragged-right,fragment,verbatim]
530 \time 2/4 c'2 \time 3/4 c'2.
535 The symbol that is printed can be customized with the @code{style}
536 property. Setting it to @code{#'()} uses fraction style for 4/4
539 @lilypond[fragment,quote,ragged-right,verbatim]
542 \override Staff.TimeSignature #'style = #'()
547 There are many more options for its layout. See @ref{Ancient time
548 signatures}, for more examples.
550 @code{\time} sets the property @code{timeSignatureFraction},
551 @code{beatLength} and @code{measureLength} in the @code{Timing}
552 context, which is normally aliased to @internalsref{Score}. The
553 property @code{measureLength} determines where bar lines should be
554 inserted, and how automatic beams should be generated. Changing
555 the value of @code{timeSignatureFraction} also causes the symbol
558 More options are available through the Scheme function
559 @code{set-time-signature}. In combination with the
560 @internalsref{Measure_grouping_engraver}, it will create
561 @internalsref{MeasureGrouping} signs. Such signs ease reading
562 rhythmically complex modern music. In the following example, the
563 9/8 measure is subdivided in 2, 2, 2 and 3. This is passed to
564 @code{set-time-signature} as the third argument @code{(2 2 2 3)}
566 @lilypond[quote,ragged-right,verbatim]
569 #(set-time-signature 9 8 '(2 2 2 3))
570 g8[ g] d[ d] g[ g] a8[( bes g]) |
571 #(set-time-signature 5 8 '(3 2))
577 \consists "Measure_grouping_engraver"
586 Program reference: @internalsref{TimeSignature}, and
587 @internalsref{Timing_translator}.
589 Examples: @lsr{contemporary,compound-time-signature.ly}.
594 Automatic beaming does not use the measure grouping specified with
595 @code{set-time-signature}.
599 @unnumberedsubsubsec Upbeats
603 @cindex partial measure
604 @cindex measure, partial
605 @cindex shorten measures
608 Partial measures, such as an anacrusis or upbeat, are entered using the
610 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
611 \partial 16*5 c16 cis d dis e | a2. c,4 | b2
614 The syntax for this command is
617 \partial @var{duration}
620 where @code{duration} is the rhythmic length to be added before
623 This is internally translated into
626 \set Timing.measurePosition = -@var{length of duration}
629 The property @code{measurePosition} contains a rational number
630 indicating how much of the measure has passed at this point. Note
631 that this is a negative number; @code{\partial 4} is internally
632 translated to mean @qq{there is a quarter note left in the bar.}
637 This command does not take into account grace notes at the start
638 of the music. When a piece starts with graces notes in the
639 pickup, then the @code{\partial} should follow the grace notes
641 @lilypond[verbatim,quote,ragged-right,relative,fragment]
648 @code{\partial} is only intended to be used at the beginning of a
649 piece. If you use it after the beginning, some odd warnings may
653 @node Unmetered music
654 @unnumberedsubsubsec Unmetered music
658 @funindex \cadenzaOff
660 Bar lines and bar numbers are calculated automatically. For
661 unmetered music (cadenzas, for example), this is not desirable.
662 To turn off automatic bar lines and bar numbers, use the commands
663 @code{\cadenzaOn} and @code{\cadenzaOff}.
665 @lilypond[verbatim,quote,ragged-right,relative=2,fragment]
677 LilyPond will only insert line breaks and page breaks at a
678 barline. Unless the unmetered music ends before the end of the
679 staff line, you will need to insert invisible bar lines
686 to indicate where breaks can occur.
689 @node Polymetric notation
690 @unnumberedsubsubsec Polymetric notation
692 @cindex double time signatures
693 @cindex signatures, polymetric
694 @cindex polymetric signatures
695 @cindex meter, polymetric
697 Double time signatures are not supported explicitly, but they can
698 be faked. In the next example, the markup for the time signature
699 is created with a markup text. This markup text is inserted in
700 the @internalsref{TimeSignature} grob. See also
701 @lsr{contemporary,compound-time-signature}.
703 @lilypond[verbatim,ragged-right]
706 \override #'(baseline-skip . 2) \number {
709 \bracket \column { "5" "8" }
714 \override Staff.TimeSignature #'stencil = #ly:text-interface::print
715 \override Staff.TimeSignature #'text = #tsMarkup
717 c'2 \bar ":" c'4 c'4.
721 Each staff can also have its own time signature. This is done by
722 moving the @internalsref{Timing_translator} to the
723 @internalsref{Staff} context.
728 \remove "Timing_translator"
729 \remove "Default_bar_line_engraver"
733 \consists "Timing_translator"
734 \consists "Default_bar_line_engraver"
741 Now, each staff has its own time signature.
755 c4. c8 c c c4. c8 c c
760 @lilypond[quote,ragged-right]
764 \remove "Timing_translator"
765 \remove "Default_bar_line_engraver"
768 \consists "Timing_translator"
769 \consists "Default_bar_line_engraver"
784 c4. c8 c c c4. c8 c c
790 A different form of polymetric notation is where note lengths have
791 different values across staves.
793 This notation can be created by setting a common time signature
794 for each staff but replacing it manually using
795 @code{timeSignatureFraction} to the desired fraction. Then the
796 printed durations in each staff are scaled to the common time
797 signature. The latter is done with @code{\compressMusic}, which
798 is used similar to @code{\times}, but does not create a tuplet
799 bracket. The syntax is @example \compressMusic #'(@var{numerator}
800 . @var{denominator}) @var{musicexpr} @end example
804 In this example, music with the time signatures of 3/4, 9/8, and
805 10/8 are used in parallel. In the second staff, shown durations
806 are multiplied by 2/3, so that 2/3 * 9/8 = 3/4, and in the third
807 staff, shown durations are multiplied by 3/5, so that 3/5 * 10/8 =
810 @lilypond[quote,ragged-right,verbatim,fragment]
818 \set Staff.timeSignatureFraction = #'(9 . 8)
819 \compressMusic #'(2 . 3)
820 \repeat unfold 6 { c8[ c c] }
824 \set Staff.timeSignatureFraction = #'(10 . 8)
825 \compressMusic #'(3 . 5) {
826 \repeat unfold 2 { c8[ c c] }
827 \repeat unfold 2 { c8[ c] }
828 | c4. c4. \times 2/3 { c8 c c } c4
837 When using different time signatures in parallel, the spacing is
838 aligned vertically, but bar lines distort the regular spacing.
841 @node Automatic note splitting
842 @unnumberedsubsubsec Automatic note splitting
844 Long notes can be converted automatically to tied notes. This is
845 done by replacing the @internalsref{Note_heads_engraver} by the
846 @internalsref{Completion_heads_engraver}. In the following
847 examples, notes crossing the bar line are split and tied.
849 @lilypond[quote,fragment,verbatim,relative=1,line-width=12\cm]
851 \remove "Note_heads_engraver"
852 \consists "Completion_heads_engraver"
854 c2. c8 d4 e f g a b c8 c2 b4 a g16 f4 e d c8. c2
858 This engraver splits all running notes at the bar line, and
859 inserts ties. One of its uses is to debug complex scores: if the
860 measures are not entirely filled, then the ties exactly show how
861 much each measure is off.
863 If you want to allow line breaking on the bar lines where
864 @internalsref{Completion_heads_engraver} splits notes, you must
865 also remove @internalsref{Forbid_line_break_engraver}.
870 Not all durations (especially those containing tuplets) can be
871 represented exactly with normal notes and dots, but the engraver
872 will not insert tuplets.
874 @code{Completion_heads_engraver} only affects notes; it does not
880 Program reference: @internalsref{Completion_heads_engraver}.
894 @node Automatic beams
895 @unnumberedsubsubsec Automatic beams
897 LilyPond inserts beams automatically
899 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
900 \time 2/4 c8 c c c \time 6/8 c c c c8. c16 c8
903 When these automatic decisions are not good enough, beaming can be
904 entered explicitly. It is also possible to define beaming
905 patterns that differ from the defaults. See @ref{Setting
906 automatic beam behavior}, for details.
908 Individual notes may be marked with @code{\noBeam} to prevent them
911 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
912 \time 2/4 c8 c\noBeam c c
918 Program reference: @internalsref{Beam}.
922 @unnumberedsubsubsec Manual beams
924 @cindex beams, manual
928 In some cases it may be necessary to override the automatic
929 beaming algorithm. For example, the autobeamer will not put beams
930 over rests or bar lines. Such beams are specified manually by
931 marking the begin and end point with @code{[} and @code{]}
933 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
935 r4 r8[ g' a r8] r8 g[ | a] r8
942 @funindex stemLeftBeamCount
943 @funindex stemRightBeamCount
946 LilyPond can automatically determine beaming patterns within a
947 beam, but this automatic behavior can sometimes produce odd
948 results; therefore the @code{stemLeftBeamCount} and
949 @code{stemRightBeamCount} properties can be used to override the
950 defaults. If either property is set, its value will be used only
951 once, and then it is erased.
953 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
958 \set stemLeftBeamCount = #1
963 The property @code{subdivideBeams} can be set in order to
964 subdivide all 16th or shorter beams at beat positions, as defined
965 by the @code{beatLength} property.
967 @lilypond[fragment,quote,relative=2,verbatim]
969 \set subdivideBeams = ##t
971 \set Score.beatLength = #(ly:make-moment 1 8)
974 @funindex subdivideBeams
977 For more information about @code{make-moment}, see
978 @ref{Time administration}.
980 Line breaks are normally forbidden when beams cross bar lines.
981 This behavior can be changed by setting @code{breakable}.
985 @cindex beams and line breaks
988 @cindex auto-knee-gap
990 Kneed beams are inserted automatically when a large gap is
991 detected between the note heads. This behavior can be tuned
992 through the @code{auto-knee-gap} object.
997 Automatically kneed cross-staff beams cannot be used together with
998 hidden staves. See @ref{Hiding staves}.
1000 @c Is this still true with skyline spacing stuff? -J.Mandereau
1001 Beams do not avoid collisions with symbols around the notes, such
1002 as texts and accidentals.
1005 @node Feathered beams
1006 @unnumberedsubsubsec Feathered beams
1008 Feathered beams are printed by setting the @code{grow-direction}
1009 property of a @code{Beam}. The @code{\featherDurations} function
1010 can be used to adjust note durations.
1012 @lilypond[ragged-right,relative=1,fragment,verbatim,quote]
1013 \override Beam #'grow-direction = #LEFT
1014 \featherDurations #(ly:make-moment 5 4)
1022 The @code{\featherDurations} command only works with very short
1039 @unnumberedsubsubsec Bar check
1042 @funindex barCheckSynchronize
1045 Bar checks help detect errors in the durations. A bar check is
1046 entered using the bar symbol, @samp{|}. Whenever it is
1047 encountered during interpretation, it should fall on a measure
1048 boundary. If it does not, a warning is printed. In the next
1049 example, the second bar check will signal an error
1052 \time 3/4 c2 e4 | g2 |
1055 Bar checks can also be used in lyrics, for example
1060 Twin -- kle | Twin -- kle
1064 Failed bar checks are caused by entering incorrect durations.
1065 Incorrect durations often completely garble up the score,
1066 especially if the score is polyphonic, so a good place to start
1067 correcting input is by scanning for failed bar checks and
1068 incorrect durations.
1071 @funindex pipeSymbol
1073 It is also possible to redefine the meaning of @code{|}. This is
1074 done by assigning a music expression to @code{pipeSymbol},
1076 @lilypond[quote,ragged-right,verbatim]
1077 pipeSymbol = \bar "||"
1084 @unnumberedsubsubsec Bar lines
1088 @cindex measure lines
1091 Bar lines delimit measures, but are also used to indicate repeats.
1092 Normally they are inserted automatically. Line breaks may only
1093 happen on bar lines.
1095 Special types of bar lines can be forced with the @code{\bar} command
1097 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1101 The following bar types are available
1103 @lilypondfile[ragged-right,quote]{bar-lines.ly}
1105 In addition, you can specify @code{"||:"}, which is equivalent to
1106 @code{"|:"} except at line breaks, where it gives a double bar
1107 line at the end of the line and a start repeat at the beginning of
1110 To allow a line break where there is no visible bar line, use
1117 This will insert an invisible bar line and allow line breaks at
1118 this point (without increasing the bar number counter).
1120 In scores with many staves, a @code{\bar} command in one staff is
1121 automatically applied to all staves. The resulting bar lines are
1122 connected between different staves of a @code{StaffGroup},
1123 @code{PianoStaff}, or @code{GrandStaff}.
1125 @lilypond[quote,ragged-right,fragment,verbatim]
1133 \new Staff { \clef bass c4 g e g }
1135 \new Staff { \clef bass c2 c2 }
1143 @funindex repeatCommands
1144 @funindex defaultBarType
1146 The command @code{\bar }@var{bartype} is a short cut for doing
1147 @code{\set Timing.whichBar = }@var{bartype}. Whenever
1148 @code{whichBar} is set to a string, a bar line of that type is
1151 A bar line is created whenever the @code{whichBar} property is
1152 set. At the start of a measure it is set to the contents of
1153 @code{Timing.defaultBarType}. The contents of
1154 @code{repeatCommands} are used to override default measure bars.
1156 You are encouraged to use @code{\repeat} for repetitions. See
1162 In this manual: @ref{Repeats}, @ref{System start delimiters}.
1164 Program reference: @internalsref{BarLine} (created at
1165 @internalsref{Staff} level), @internalsref{SpanBar} (across
1170 @unnumberedsubsubsec Bar numbers
1173 @cindex measure numbers
1174 @funindex currentBarNumber
1176 Bar numbers are printed by default at the start of the line. The
1177 number itself is stored in the @code{currentBarNumber} property,
1178 which is normally updated automatically for every measure.
1180 @lilypond[verbatim,ragged-right,quote,fragment,relative]
1181 \repeat unfold 4 {c4 c c c} \break
1182 \set Score.currentBarNumber = #50
1183 \repeat unfold 4 {c4 c c c}
1186 Bar numbers may only be printed at bar lines; to print a bar
1187 number at the beginning of a piece, an empty bar line must be
1190 @lilypond[verbatim,ragged-right,quote,fragment,relative]
1191 \set Score.currentBarNumber = #50
1193 \repeat unfold 4 {c4 c c c} \break
1194 \repeat unfold 4 {c4 c c c}
1197 Bar numbers can be typeset at regular intervals instead of at the
1198 beginning of each line. This is illustrated in the following
1199 example, whose source is available as
1200 @lsr{staff,making-bar-numbers-appear-at-regular-intervals.ly}.
1202 @lilypondfile[ragged-right,quote]{bar-number-regular-interval.ly}
1204 Bar numbers can be removed entirely by removing the Bar number
1205 engraver from the score.
1207 @lilypond[verbatim,ragged-right,quote]
1211 \remove "Bar_number_engraver"
1223 Program reference: @internalsref{BarNumber}.
1225 Examples: @lsrdir{staff}
1230 Bar numbers can collide with the @internalsref{StaffGroup}
1231 bracket, if there is one at the top. To solve this, the
1232 @code{padding} property of @internalsref{BarNumber} can be used to
1233 position the number correctly.
1236 @node Barnumber check
1237 @unnumberedsubsubsec Barnumber check
1239 When copying large pieces of music, it can be helpful to check
1240 that the LilyPond bar number corresponds to the original that you
1241 are entering from. This can be checked with
1242 @code{\barNumberCheck}, for example,
1245 \barNumberCheck #123
1249 will print a warning if the @code{currentBarNumber} is not 123
1250 when it is processed.
1253 @node Rehearsal marks
1254 @unnumberedsubsubsec Rehearsal marks
1256 @cindex Rehearsal marks
1259 To print a rehearsal mark, use the @code{\mark} command
1261 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
1270 The letter@tie{}@q{I} is skipped in accordance with engraving
1271 traditions. If you wish to include the letter @q{I}, then use
1274 \set Score.markFormatter = #format-mark-alphabet
1277 The mark is incremented automatically if you use @code{\mark
1278 \default}, but you can also use an integer argument to set the
1279 mark manually. The value to use is stored in the property
1280 @code{rehearsalMark}.
1282 The style is defined by the property @code{markFormatter}. It is
1283 a function taking the current mark (an integer) and the current
1284 context as argument. It should return a markup object. In the
1285 following example, @code{markFormatter} is set to a canned
1286 procedure. After a few measures, it is set to function that
1287 produces a boxed number.
1289 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
1290 \set Score.markFormatter = #format-mark-numbers
1293 \set Score.markFormatter = #format-mark-box-numbers
1299 The file @file{scm/@/translation@/-functions@/.scm} contains the
1300 definitions of @code{format-mark-numbers} (the default format),
1301 @code{format-mark-box-numbers}, @code{format-mark-letters} and
1302 @code{format-mark-box-letters}. These can be used as inspiration
1303 for other formatting functions.
1305 You may use @code{format-mark-barnumbers},
1306 @code{format-mark-box-barnumbers}, and
1307 @code{format-mark-circle-barnumbers} to get bar numbers instead of
1308 incremented numbers or letters.
1310 Other styles of rehearsal mark can be specified manually
1317 @code{Score.markFormatter} does not affect marks specified in this
1318 manner. However, it is possible to apply a @code{\markup} to the
1322 \mark \markup@{ \box A1 @}
1329 Music glyphs (such as the segno sign) may be printed inside a
1332 @lilypond[fragment,quote,ragged-right,verbatim,relative]
1333 c1 \mark \markup { \musicglyph #"scripts.segno" }
1334 c1 \mark \markup { \musicglyph #"scripts.coda" }
1335 c1 \mark \markup { \musicglyph #"scripts.ufermata" }
1340 See @ref{The Feta font}, for a list of symbols which may be
1341 printed with @code{\musicglyph}.
1343 For common tweaks to the positioning of rehearsal marks, see
1348 This manual: @ref{Text marks}.
1350 Program reference: @internalsref{RehearsalMark}.
1352 Init files: @file{scm/@/translation@/-functions@/.scm} contains
1353 the definition of @code{format-mark-numbers} and
1354 @code{format-mark-letters}. They can be used as inspiration for
1355 other formatting functions.
1357 Examples: @lsr{parts,rehearsal-mark-numbers.ly}
1360 @node Special rhythmic concerns
1361 @subsection Special rhythmic concerns
1366 * Aligning to cadenzas::
1367 * Time administration::
1368 * Proportional notation (introduction)::
1372 @unnumberedsubsubsec Grace notes
1377 @cindex appoggiatura
1378 @cindex acciaccatura
1380 Grace notes are ornaments that are written out. The most common
1381 ones are acciaccatura, which should be played as very short. It
1382 is denoted by a slurred small note with a slashed stem. The
1383 appoggiatura is a grace note that takes a fixed fraction of the
1384 main note, and is denoted as a slurred note in small print without
1385 a slash. They are entered with the commands @code{\acciaccatura}
1386 and @code{\appoggiatura}, as demonstrated in the following example
1388 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
1389 b4 \acciaccatura d8 c4 \appoggiatura e8 d4
1390 \acciaccatura { g16[ f] } e4
1393 Both are special forms of the @code{\grace} command. By prefixing
1394 this keyword to a music expression, a new one is formed, which
1395 will be printed in a smaller font and takes up no logical time in
1398 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
1400 \grace { c16[ d16] } c2 c4
1404 Unlike @code{\acciaccatura} and @code{\appoggiatura}, the
1405 @code{\grace} command does not start a slur.
1407 @cindex timing, internal
1409 Internally, timing for grace notes is done using a second,
1410 @q{grace} timing. Every point in time consists of two rational
1411 numbers: one denotes the logical time, one denotes the grace
1412 timing. The above example is shown here with timing tuples
1414 @lilypond[quote,ragged-right]
1417 c4 \grace c16 c4 \grace {
1420 \new Lyrics \lyricmode {
1421 \override LyricText #'font-family = #'typewriter
1425 ( \fraction 1 4 , \fraction -1 16 ) } 16 }
1426 \markup { (\fraction 1 4 , 0 ) } 4
1428 \markup { (\fraction 2 4 , \fraction "-1" 8 ) } 16
1429 \markup { (\fraction 2 4 , \fraction "-1" 16 ) } 16
1431 \markup { ( \fraction 2 4 , 0 ) }
1436 The placement of grace notes is synchronized between different
1437 staves. In the following example, there are two sixteenth grace
1438 notes for every eighth grace note
1440 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
1441 << \new Staff { e4 \grace { c16[ d e f] } e4 }
1442 \new Staff { c4 \grace { g8[ b] } c4 } >>
1445 @funindex \afterGrace
1447 If you want to end a note with a grace, use the @code{\afterGrace}
1448 command. It takes two arguments: the main note, and the grace
1449 notes following the main note.
1451 @lilypond[ragged-right, verbatim,relative=2,fragment]
1452 c1 \afterGrace d1 { c16[ d] } c4
1455 This will put the grace notes after a @q{space} lasting 3/4 of the
1456 length of the main note. The fraction 3/4 can be changed by
1457 setting @code{afterGraceFraction}, ie.
1460 #(define afterGraceFraction (cons 7 8))
1464 will put the grace note at 7/8 of the main note.
1466 The same effect can be achieved manually by doing
1468 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
1471 { s2 \grace { c16[ d] } } >>
1477 By adjusting the duration of the skip note (here it is a
1478 half-note), the space between the main-note and the grace is
1481 A @code{\grace} music expression will introduce special
1482 typesetting settings, for example, to produce smaller type, and
1483 set directions. Hence, when introducing layout tweaks, they
1484 should be inside the grace expression, for example,
1486 @lilypond[quote,ragged-right,fragment,verbatim,relative=2]
1498 The overrides should also be reverted inside the grace expression.
1500 The layout of grace expressions can be changed throughout the
1501 music using the function @code{add-grace-property}. The following
1502 example undefines the @code{Stem} direction for this grace, so
1503 that stems do not always point up.
1507 #(add-grace-property 'Voice 'Stem 'direction '())
1513 Another option is to change the variables @code{startGraceMusic},
1514 @code{stopGraceMusic}, @code{startAcciaccaturaMusic},
1515 @code{stopAcciaccaturaMusic}, @code{startAppoggiaturaMusic},
1516 @code{stopAppoggiaturaMusic}. More information is in the file
1517 @file{ly/@/grace@/-init@/.ly}.
1520 The slash through the stem in acciaccaturas can be obtained in
1521 other situations by @code{\override Stem #'stroke-style =
1527 Grace notes may be forced to use floating spacing,
1529 @lilypond[relative=2,ragged-right]
1531 \override Score.SpacingSpanner #'strict-grace-spacing = ##t
1540 c'16[ c'16 c'16 c'16]
1541 c'16[ c'16 c'16 c'16]
1550 Program reference: @internalsref{GraceMusic}.
1555 A score that starts with a @code{\grace} expression needs an
1556 explicit @code{\new Voice} declaration, otherwise the main note
1557 and the grace note end up on different staves.
1559 Grace note synchronization can also lead to surprises. Staff
1560 notation, such as key signatures, bar lines, etc., are also
1561 synchronized. Take care when you mix staves with grace notes and
1562 staves without, for example,
1564 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
1565 << \new Staff { e4 \bar "|:" \grace c16 d4 }
1566 \new Staff { c4 \bar "|:" d4 } >>
1570 This can be remedied by inserting grace skips of the corresponding
1571 durations in the other staves. For the above example
1573 @lilypond[quote,ragged-right,relative=2,verbatim,fragment]
1574 << \new Staff { e4 \bar "|:" \grace c16 d4 }
1575 \new Staff { c4 \bar "|:" \grace s16 d4 } >>
1578 Grace sections should only be used within sequential music
1579 expressions. Nesting or juxtaposing grace sections is not
1580 supported, and might produce crashes or other errors.
1583 @node Aligning to cadenzas
1584 @unnumberedsubsubsec Aligning to cadenzas
1586 In an orchestral context, cadenzas present a special problem: when
1587 constructing a score that includes a cadenza, all other
1588 instruments should skip just as many notes as the length of the
1589 cadenza, otherwise they will start too soon or too late.
1591 A solution to this problem are the functions
1592 @code{mmrest-of-length} and @code{skip-of-length}. These Scheme
1593 functions take a piece of music as argument, and generate a
1594 @code{\skip} or multi-rest, exactly as long as the piece. The use
1595 of @code{mmrest-of-length} is demonstrated in the following
1598 @lilypond[verbatim,ragged-right,quote]
1599 cadenza = \relative c' {
1600 c4 d8 << { e f g } \\ { d4. } >>
1605 \new Staff { \cadenza c'4 }
1607 #(ly:export (mmrest-of-length cadenza))
1614 @node Time administration
1615 @unnumberedsubsubsec Time administration
1617 @cindex Time administration
1619 Time is administered by the
1620 @internalsref{Time_signature_engraver}, which usually lives in the
1621 @internalsref{Score} context. The bookkeeping deals with the
1625 @item currentBarNumber
1629 The length of the measures in the current time signature. For a
1630 4/4 time this is@tie{}1, and for 6/8 it is 3/4.
1632 @item measurePosition
1633 The point within the measure where we currently are. This
1634 quantity is reset to@tie{}0 whenever it exceeds
1635 @code{measureLength}. When that happens, @code{currentBarNumber}
1639 If set to true, the above variables are updated for every time
1640 step. When set to false, the engraver stays in the current
1641 measure indefinitely.
1645 Timing can be changed by setting any of these variables
1646 explicitly. In the next example, the 4/4 time signature is
1647 printed, but @code{measureLength} is set to 5/4. After a while,
1648 the measure is shortened by 1/8, by setting @code{measurePosition}
1649 to 7/8 at 2/4 in the measure, so the next bar line will fall at
1650 2/4 + 3/8. The 3/8 arises because 5/4 normally has 10/8, but we
1651 have manually set the measure position to be 7/8 and 10/8 - 7/8 =
1654 @lilypond[quote,ragged-right,verbatim,relative,fragment]
1655 \set Score.measureLength = #(ly:make-moment 5 4)
1659 \set Score.measurePosition = #(ly:make-moment 7 8)
1665 As the example illustrates, @code{ly:make-moment n m} constructs a
1666 duration of n/m of a whole note. For example,
1667 @code{ly:make-moment 1 8} is an eighth note duration and
1668 @code{ly:make-moment 7 16} is the duration of seven sixteenths
1672 @node Proportional notation (introduction)
1673 @unnumberedsubsubsec Proportional notation (introduction)
1674 @cindex Proportional notation
1676 See @ref{Proportional notation}.
1679 TODO: remove all this stuff?
1681 Notes can be spaced proportionally to their time-difference by
1682 assigning a duration to @code{proportionalNotationDuration}
1684 @lilypond[quote,ragged-right,verbatim,relative=2,fragment]
1686 \set Score.proportionalNotationDuration = #(ly:make-moment 1 16)
1687 \new Staff { c8[ c c c c c] c4 c2 r2 }
1688 \new Staff { c2 \times 2/3 { c8 c c } c4 c1 }
1692 Setting this property only affects the ideal spacing between
1693 consecutive notes. For true proportional notation, the following
1694 settings are also required.
1698 @item True proportional notation requires that symbols are allowed
1699 to overstrike each other. That is achieved by removing the
1700 @internalsref{Separating_line_group_engraver} from
1701 @internalsref{Staff} context.
1703 @item Spacing influence of prefatory matter (clefs, bar lines,
1704 etc.) is removed by setting the @code{strict-note-spacing}
1705 property to @code{#t} in @internalsref{SpacingSpanner} grob.
1707 @item Optical spacing tweaks are switched by setting
1708 @code{uniform-stretching} in @internalsref{SpacingSpanner} to
1715 Examples: @lsr{spacing,proportional@/-spacing@/.ly},
1716 @lsr{spacing,proportional@/-strict@/-grace@/-notes@/.ly}, and
1717 @lsr{spacing,proportional@/-strict@/-notespacing@/.ly}
1719 An example of strict proportional notation is in the
1720 example file @file{input/proportional.ly}.