3 @c A menu is needed before every deeper *section nesting of @node's; run
4 @c M-x texinfo-all-menus-update
5 @c to automagically fill in these menus before saving changes
7 @c FIXME: singular vs. plural: Beams/Beam
16 @c .{Reference Manual}
18 @node Reference Manual
19 @chapter Reference Manual
22 <!--- @@WEB-TITLE@@=Reference Manual --->
25 This document describes GNU LilyPond and its input format. The last
26 revision of this document was made for LilyPond 1.4.1. It supposes a
27 passing familiarity with how LilyPond input works. New users are
28 encouraged to study the tutorial first.
33 * Easier music entry::
53 @c FIXME: Note entry vs Music entry at top level menu is confusing.
59 The most basic forms of music are notes. Notes on their own don't
60 form valid input, but for the sake of brevity we omit @code{\score}
61 blocks and @code{\paper} declarations.
67 * Chromatic alterations::
72 * Automatic note splitting ::
74 * Easy Notation note heads ::
82 A note is printed by specifying its pitch, and then its duration.
83 @lilypond[fragment,verbatim]
92 @cindex Note specification
94 @cindex entering notes
96 The verbose syntax for pitch specification is
100 \pitch @var{scmpitch}
103 @var{scmpitch} is a pitch scheme object.
105 In Note and Chord mode, pitches may be designated by names. The default
106 names are the Dutch note names. The notes are specified by the letters
107 @code{a} through @code{g} (where the octave is formed by notes ranging
108 from @code{c} to @code{b}). The pitch @code{c} is an octave below
109 middle C and the letters span the octave above that C.
111 @cindex note names, Dutch
113 In Dutch, a sharp is formed by adding @code{-is} to the end of a pitch
114 name and a flat is formed by adding @code{-es}. Double sharps and double
115 flats are obtained by adding @code{-isis} or @code{-eses}. @code{aes}
116 and @code{ees} are contracted to @code{as} and @code{es} in Dutch, but
117 both forms are accepted.
119 LilyPond has predefined sets of note names for various other languages.
120 To use them, simply include the language specific init file. For
121 example: @code{\include "english.ly"}. The available language files and
122 the names they define are:
125 Note Names sharp flat
126 nederlands.ly c d e f g a bes b -is -es
127 english.ly c d e f g a bf b -s/-sharp -f/-flat
128 deutsch.ly c d e f g a b h -is -es
129 norsk.ly c d e f g a b h -iss/-is -ess/-es
130 svenska.ly c d e f g a b h -iss -ess
131 italiano.ly do re mi fa sol la sib si -d -b
132 catalan.ly do re mi fa sol la sib si -d/-s -b
133 espanol.ly do re mi fa sol la sib si -s -b
142 The optional octave specification takes the form of a series of
143 single quote (`@code{'}') characters or a series of comma
144 (`@code{,}') characters. Each @code{'} raises the pitch by one
145 octave; each @code{,} lowers the pitch by an octave.
147 @lilypond[fragment,verbatim,center]
148 c' c'' es' g' as' gisis' ais'
151 @node Chromatic alterations
152 @subsection Chromatic alterations
154 Normally, accidentals are printed automatically, but you may force
155 accidentals in the following ways: A reminder accidental
156 @cindex reminder accidental
158 can be forced by adding an exclamation mark @code{!} after the pitch. A
159 cautionary accidental,
160 @cindex cautionary accidental
161 @cindex parenthesized accidental
162 i.e., an accidental within parentheses can be obtained by adding the
163 question mark `@code{?}' after the pitch.
165 The automatic production of accidentals can be tuned in many
166 ways. Refer to @ref{Accidentals} for more information.
173 A rest is entered like a note, with note name `@code{r}':
175 @lilypond[singleline,verbatim]
179 Whole bar rests centered in the bar are specified using @code{R}, see
180 @ref{Multi measure rests}. See also @seeinternals{Rest}.
182 For polyphonic music, it can be convenient to specify the rest position
183 directly. You can do that by entering a note, with the keyword
184 @code{\rest} appended, e.g. Rest collisions will leave these rests alone.
186 @lilypond[singleline,verbatim]
196 @cindex Invisible rest
199 An invisible rest, or skip, can be entered like a note with note name
200 @code{s}, or with @code{\skip @var{duration}}:
202 @lilypond[singleline,verbatim]
206 The @code{s} syntax is only available in Note mode and Chord mode.
207 In other situations, you should use the @code{\skip} command, and it is
208 only available in Note mode and Chord mode.
210 @c FIXME: in lyrics mode, we have " " and _
212 In Lyrics mode, you can use `@code{" "}' and `@code{_}':
213 @lilypond[singleline,verbatim]
215 \context Lyrics \lyrics { lah2 di4 " " dah2 _4 di }
216 \notes\relative c'' { a2 a4 a a2 a4 a }
220 The unabbreviated `@code{\skip} @var{duration}' also works outside of
223 @lilypond[singleline,verbatim]
226 { \time 4/8 \skip 2 \time 4/4 }
227 \notes\relative c'' { a2 a1 }
232 The skip command is merely a empty musical placeholder. It does not
233 produce any output, not even transparent output.
238 @subsection Durations
242 @cindex @code{\duration}
245 In Note, Chord, and Lyrics mode, durations may be designated by numbers
246 and dots: durations are entered as their reciprocal values. For notes
247 longer than a whole you must use identifiers.
251 c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64
253 r1 r2 r4 r8 r16 r32 r64 r64
259 \notes \relative c'' {
261 a1 a2 a4 a8 a16 a32 a64 a64
263 r1 r2 r4 r8 r16 r32 r64 r64
268 \remove "Clef_engraver"
269 \remove "Staff_symbol_engraver"
270 \remove "Time_signature_engraver"
271 \consists "Pitch_squash_engraver"
278 If the duration is omitted then it is set to the previous duration
279 entered. At the start of parsing a quarter note is assumed. The
280 duration can be followed by dots (`@code{.}') to obtain dotted note
284 @lilypond[fragment,verbatim,center]
290 You can alter the length of duration by a fraction @var{N/M} by
291 appending `@code{*}@var{N/M}' (or `@code{*}@var{N}' if @var{M=1}). This
292 will not affect the appearance of the notes or rests produced.
294 Durations can also be produced through GUILE extension mechanism.
295 @lilypond[verbatim,fragment]
296 c\duration #(make-duration 2 1)
307 A tie connects two adjacent note heads of the same pitch. The tie in
308 effect extends the length of a note. A tie is entered with @code{~}.
310 @lilypond[fragment,verbatim,center]
311 e' ~ e' <c' e' g'> ~ <c' e' g'>
314 When ties are used with chords, all note heads whose pitches match are
315 connected. Ties are indicated using the tilde symbol `@code{~}'. If
316 you try to tie together chords which have no common pitches then no
317 ties will be created.
319 If you want less ties created for a chord, you can set
320 @code{Voice.sparseTies} to true. In this case, a single tie is used
321 for every tied chord.
322 @lilypond[fragment,verbatim,center]
323 \property Voice.sparseTies = ##t
324 <c' e' g'> ~ <c' e' g'>
327 In its meaning a tie is just a way of extending a note duration, similar
328 to the augmentation dot: the following example are two ways of notating
329 exactly the same concept.
331 @lilypond[fragment, singleline]
332 \time 3/4 c'2. c'2 ~ c'4
334 Ties should not be confused with slurs, which indicate articulation,
335 and phrasing slurs, which indicate musical phrasing.
337 See also @seeinternals{Tie}.
342 At present, the tie is represented as a separate event, temporally
343 located in between the notes. Tieing only a subset of the note heads
344 of a chord is not supported in a simple way. It can be achieved by
345 moving the tie-engraver into the Thread context and turning on and off
348 @node Automatic note splitting
349 @subsection Automatic note splitting
350 @c FIXME: This subsection doesn't belong in @ref{Note entry}.
352 There is a facility for automatically converting long notes to tied
353 notes. This is done by replacing the @code{Note_heads_engraver} by the
354 @code{Completion_heads_engraver}.
356 @lilypond[verbatim,center]
358 \notes\relative c'{ \time 2/4
359 c2. c8 d4 e f g a b c8 c2 b4 a g16 f4 e d c8. c2
363 \remove "Note_heads_engraver"
364 \consists "Completion_heads_engraver"
368 This engraver splits all running notes at the bar line, and inserts
369 ties. One of its uses is to debug complex scores: if the measures are
370 not entirely filled, then the ties exactly show how much each measure
375 Not all durations (especially those containing tuplets) can be
376 represented exactly; the engraver will not insert tuplets.
383 @cindex @code{\times}
385 Tuplets are made out of a music expression by multiplying all duration
388 @cindex @code{\times}
390 \times @var{fraction} @var{musicexpr}
393 The duration of @var{musicexpr} will be multiplied by the fraction.
394 In print, the fraction's denominator will be printed over the notes,
395 optionally with a bracket. The most common tuplet is the triplet in
396 which 3 notes have the length of 2, so the notes are 2/3 of
397 their written length:
399 @lilypond[fragment,verbatim,center]
400 g'4 \times 2/3 {c'4 c' c'} d'4 d'4
403 The property @code{tupletSpannerDuration} specifies how long each bracket
404 should last. With this, you can make lots of tuplets while typing
405 @code{\times} only once, thus saving typing work.
407 @lilypond[fragment, relative, singleline, verbatim]
408 \property Voice.tupletSpannerDuration = #(make-moment 1 4)
409 \times 2/3 { c'8 c c c c c }
412 The format of the number is determined by the property
413 @code{tupletNumberFormatFunction}. The default prints only the
414 denominator, but if you set it to the Scheme function
415 @code{fraction-tuplet-formatter}, Lilypond will print @var{num}:@var{den}
419 @cindex @code{tupletNumberFormatFunction}
420 @cindex tuplet formatting
422 See also @seeinternals{TupletBracket}.
426 Nested tuplets are not formatted automatically. In this case, outer
427 tuplet brackets should be moved automatically.
429 @node Easy Notation note heads
430 @subsection Easy Notation note heads
432 @cindex easy notation
435 A entirely different type of note head is the "easyplay" note head: a
436 note head that includes a note name. It is used in some publications by
437 Hal-Leonard Inc. music publishers.
439 @lilypond[singleline,verbatim]
440 \include "paper23.ly"
442 \notes { c'2 e'4 f' | g'1 }
443 \paper { \translator { \EasyNotation } }
447 Note that @code{EasyNotation} overrides a @internalsref{Score} context. You
448 probably will want to print it with magnification to make it more
455 If you view the result with Xdvi, then staff lines will show through
456 the letters. Printing the postscript file obtained with ly2dvi does
457 produce the correct result.
460 @node Easier music entry
461 @section Easier music entry
467 * Skipping corrected music::
470 When entering music with LilyPond, it is easy to introduce errors. This
471 section deals with tricks and features that help you enter music, and
472 find and correct mistakes.
475 @node Relative octaves
476 @subsection Relative octaves
478 @cindex relative octave specification
480 Octaves are specified by adding @code{'} and @code{,} to pitch names.
481 When you copy existing music, it is easy to accidentally put a pitch in
482 the wrong octave and hard to find such an error. To prevent these
483 errors, LilyPond features octave entry.
485 @cindex @code{\relative}
487 \relative @var{startpitch} @var{musicexpr}
490 The octave of notes that appear in @var{musicexpr} are calculated as
491 follows: If no octave changing marks are used, the basic interval
492 between this and the last note is always taken to be a fourth or less
493 (This distance is determined without regarding alterations; a
494 @code{fisis} following a @code{ceses} will be put above the
497 The octave changing marks @code{'} and @code{,} can be added to raise or
498 lower the pitch by an extra octave. Upon entering relative mode, an
499 absolute starting pitch must be specified that will act as the
500 predecessor of the first note of @var{musicexpr}.
502 Entering music that changes octave frequently is easy in relative mode.
503 @lilypond[fragment,singleline,verbatim,center]
509 And octave changing marks are used for intervals greater than a fourth.
510 @lilypond[fragment,verbatim,center]
515 If the preceding item is a chord, the first note of the chord is used
516 to determine the first note of the next chord. However, other notes
517 within the second chord are determined by looking at the immediately
520 @lilypond[fragment,verbatim,center]
527 @cindex @code{\notes}
529 The pitch after the @code{\relative} contains a note name. To parse
530 the pitch as a note name, you have to be in note mode, so there must
531 be a surrounding @code{\notes} keyword (which is not
534 The relative conversion will not affect @code{\transpose},
535 @code{\chords} or @code{\relative} sections in its argument. If you
536 want to use relative within transposed music, you must place an
537 additional @code{\relative} inside the @code{\transpose}.
542 @subsection Bar check
546 @cindex @code{barCheckSynchronize}
550 Whenever a bar check is encountered during interpretation, a warning
551 message is issued if it doesn't fall at a measure boundary. This can
552 help you find errors in the input. Depending on the value of
553 @code{barCheckSynchronize}, the beginning of the measure will be
554 relocated, so this can also be used to shorten measures.
556 A bar check is entered using the bar symbol, @code{|}:
558 \time 3/4 c2 e4 | g2.
563 @cindex skipTypesetting
565 Failed bar checks are most often caused by entering incorrect
566 durations. Incorrect durations often completely garble up the score,
567 especially if it is polyphonic, so you should start correcting the score
568 by scanning for failed bar checks and incorrect durations. To speed up
569 this process, you can use @code{skipTypesetting} (See @ref{Skipping
572 @c . {Point and click}
573 @node Point and click
574 @subsection Point and click
576 Point and click lets you find notes in the input by clicking on them in
577 the Xdvi window. This makes it very easy to find input that causes some
578 error in the sheet music.
580 To use it, you need the following software
584 @uref{ftp://ftp.math.berkeley.edu/pub/Software/TeX/xdvi.tar.gz,plain
585 Xdvi} version 22.36 or newer.
587 Note that most @TeX{} distributions ship with xdvik, which is a
588 different and less well maintained program. To find out which xdvi you
589 are running, try @code{xdvi --version} or @code{xdvi.bin --version}.
590 @item Emacs. Emacs is an extensible text-editor It is available from
591 @uref{http://www.gnu.org/software/emacs/}. You need version 21 to use
595 Xdvi must be configured to find the @TeX{} fonts and music
596 fonts. Refer to the Xdvi documentation for more information.
598 To use point-and-click, add one of these lines to the top of your .ly
601 #(set! point-and-click line-location)
604 In the emacs startup file (usually @file{~/.emacs}), add the following
609 Make sure that the environment variable @code{XEDITOR} is set to
611 emacsclient --no-wait +%l %f
614 When viewing, Control-Mousebutton 1 will take you to the originating
615 spot in the @file{.ly} file. Control-Mousebutton 2 will show all
618 If you use Emacs version 21, then you can make emacs jump to the exact
619 spot (and not just the line) on a click, you must enable column
620 positioning. At the top of the @code{ly} file, replace the
621 @code{set!} line with the following line
623 #(set! point-and-click line-column-location)
625 Set @code{XEDITOR} to @code{emacsclient --no-wait +%l:%c %f}.
627 If you correct large files with point-and-click, be sure to start
628 correcting at the end of the file. When you start at the top, and
629 insert one line, all following locations will be off by a line.
634 When you convert the @TeX{} file to PostScript using @code{dvips}, it
635 will complain about not finding @code{src:X:Y} files. These complaints
636 are harmless, and can be ignored.
638 @node Skipping corrected music
639 @subsection Skipping corrected music
641 The property @code{Score.skipTypesetting} can be used to switch on and
642 off typesetting completely during the interpretation phase. When
643 typesetting is switched off, the music is processed much more quickly.
644 You can use this to skip over the parts of a score that you have already
647 @lilypond[fragment,singleline,verbatim]
649 \property Score.skipTypesetting = ##t
651 \property Score.skipTypesetting = ##f
659 @section Staff notation
661 This section deals with music notation that occurs on staff level,
662 such as keys, clefs and time signatures.
664 @cindex Staff notation
676 @subsection Key signature
681 Setting or changing the key signature is done with the @code{\key}
684 @code{\key} @var{pitch} @var{type}
687 @cindex @code{\minor}
688 @cindex @code{\major}
689 @cindex @code{\minor}
690 @cindex @code{\ionian}
691 @cindex @code{\locrian}
692 @cindex @code{\aeolian}
693 @cindex @code{\mixolydian}
694 @cindex @code{\lydian}
695 @cindex @code{\phrygian}
696 @cindex @code{\dorian}
698 Here, @var{type} should be @code{\major} or @code{\minor} to get
699 @var{pitch}-major or @var{pitch}-minor, respectively.
700 The standard mode names @code{\ionian},
701 @code{\locrian}, @code{\aeolian}, @code{\mixolydian}, @code{\lydian},
702 @code{\phrygian}, and @code{\dorian} are also defined.
704 This command sets the context property @code{Staff.keySignature}.
705 Non-standard key signatures can be specified by setting this property
708 The printed signature is a @internalsref{KeySignature} grob, typically
709 created in @internalsref{Staff} context.
711 @cindex @code{keySignature}
718 The clef can be set or changed with the @code{\clef} command:
719 @lilypond[fragment,verbatim]
720 \key f\major c''2 \clef alto g'2
723 Supported clef-names include
724 @c Moved standard clefs to the top /MB
726 @item treble, violin, G, G2
735 G clef on 1st line, so-called French violin clef
750 By adding @code{_8} or @code{^8} to the clef name, the clef is
751 transposed one octave down or up, respectively. Note that you have to
752 enclose @var{clefname} in quotes if you use underscores or digits in the
758 The grob for this symbol is @internalsref{Clef}.
761 This command is equivalent to setting @code{clefGlyph},
762 @code{clefPosition} (which controls the Y position of the clef),
763 @code{centralCPosition} and @code{clefOctavation}. A clef is created
764 when any of these properties are changed.
767 @c . {Time signature}
769 @subsection Time signature
770 @cindex Time signature
774 The time signature is set or changed by the @code{\time}
776 @lilypond[fragment,verbatim]
777 \time 2/4 c'2 \time 3/4 c'2.
780 The actual symbol that's printed can be customized with the @code{style}
781 property. Setting it to @code{#'()} uses fraction style for 4/4 and
785 The grob for this symbol is @internalsref{TimeSignature}. There are
786 many more options for its layout. They are selected through the
787 @code{style} grob property. See @file{input/test/time.ly} for more
790 This command sets the property @code{timeSignatureFraction},
791 @code{beatLength} and @code{measureLength}. The property
792 @code{timeSignatureFraction} determine where bar lines should be
793 inserted, and how automatic beams should be generated. Changing the
794 value of @code{timeSignatureFraction} also causes a time signature
795 symbol to be printed.
802 @cindex partial measure
803 @cindex measure, partial
804 @cindex shorten measures
805 @cindex @code{\partial}
807 Partial measures, for example in upbeats, are entered using the
808 @code{\partial} command:
809 @lilypond[fragment,verbatim]
810 \partial 4* 5/16 c'16 c4 f16 a'2. ~ a'8. a'16 | g'1
813 The syntax for this command is
815 \partial @var{duration}
817 This is internally translated into
819 \property Score.measurePosition = -@var{length of duration}
822 The property @code{measurePosition} contains a rational number
823 indicating how much of the measure has passed at this point.
826 @node Unmetered music
827 @subsection Unmetered music
829 Bar lines and bar numbers are calculated automatically. For unmetered
830 music (e.g. cadenzas), this is not desirable. The commands
831 @code{\cadenzaOn} and @code{\cadenzaOff} can be used to switch off the
834 @lilypond[fragment,relative,singleline,verbatim]
842 The property @code{Score.timing} can be used to switch off this
847 @subsection Bar lines
851 @cindex measure lines
854 Bar lines are inserted automatically, but if you need a special type
855 of barline, you can force one using the @code{\bar} command:
856 @lilypond[fragment,verbatim] c4 \bar "|:" c4
859 The following bar types are available
860 @lilypond[fragment, relative, singleline, verbatim]
872 You are encouraged to use @code{\repeat} for repetitions. See
875 In scores with many staffs, the barlines are automatically placed at
876 top level, and they are connected between different staffs of a
877 @internalsref{StaffGroup}:
878 @lilypond[fragment, verbatim]
879 < \context StaffGroup <
880 \context Staff = up { e'4 d'
883 \context Staff = down { \clef bass c4 g e g } >
884 \context Staff = pedal { \clef bass c2 c2 } >
887 The grobs that are created at @internalsref{Staff} level. The name is
888 @internalsref{BarLine}.
890 The command @code{\bar @var{bartype}} is a short cut for
891 doing @code{\property Score.whichBar = @var{bartype}}
892 Whenever @code{whichBar} is set to a string, a bar line of that type is
893 created. @code{whichBar} is usually set automatically: at the start of
894 a measure it is set to @code{defaultBarType}. The contents of
895 @code{repeatCommands} is used to override default measure bars.
897 @code{whichBar} can also be set directly, using @code{\property} or
898 @code{\bar }. These settings take precedence over the automatic
899 @code{whichBar} settings.
902 @cindex Bar_line_engraver
904 @cindex repeatCommands
905 @cindex defaultBarType
914 The easiest way to enter such fragments with more than one voice on a
915 staff is to split chords using the separator @code{\\}. You can use
916 it for small, short-lived voices (make a chord of voices) or for
919 @lilypond[verbatim,fragment]
920 \context Voice = VA \relative c'' {
921 c4 < { f d e } \\ { b c2 } > c4 < g' \\ b, \\ f \\ d >
925 The separator causes @internalsref{Voice} contexts to be instantiated,
926 bearing the names @code{"1"}, @code{"2"}, etc.
928 Sometimes, it is necessary to instantiate these contexts by hand: For
929 Instantiate a separate Voice context for each part, and use
930 @code{\voiceOne}, up to @code{\voiceFour} to assign a stem directions
931 and horizontal shift for each part.
934 @lilypond[singleline, verbatim]
936 \context Staff < \context Voice = VA { \voiceOne cis2 b }
937 \context Voice = VB { \voiceThree b4 ais ~ ais4 gis4 }
938 \context Voice = VC { \voiceTwo fis4~ fis4 f ~ f } >
941 The identifiers @code{\voiceOne} to @code{\voiceFour} set directions
942 ties, slurs and stems, and set shift directions.
944 If you want more than four voices, you can also manually set
945 horizontal shifts and stem directions, as is shown in the following example:
946 @lilypond[fragment, verbatim]
947 \context Staff \notes\relative c''<
954 \context Voice=three {
955 \shiftOnn \stemUp ais
957 \context Voice=four {
958 \shiftOnnn \stemUp fis
964 Normally, note heads with a different number of dots are not merged, but
965 if you set the grob property @code{merge-differently-dotted}, they are:
966 @lilypond[verbatim,fragment,singleline]
969 \property Staff.NoteCollision \override
970 #'merge-differently-dotted = ##t
972 } \\ { [g'8. f16] [g'8. f'16] }
976 Similarly, you can merge half note heads with eighth notes, by setting
977 @code{merge-differently-headed}:
978 @lilypond[fragment, relative=2,verbatim]
981 \property Staff.NoteCollision
982 \override #'merge-differently-headed = ##t
983 c8 c4. } \\ { c2 c2 } >
986 LilyPond also vertically shifts rests that are opposite of a stem.
988 @lilypond[singleline,fragment,verbatim]
989 \context Voice < c''4 \\ r4 >
992 See also @internalsref{NoteCollision} and @internalsref{RestCollision}
996 Resolving collisions is a very intricate subject, and LilyPond only
997 handles a few situations. When it can not cope, you are advised to use
998 @code{force-hshift} of the @internalsref{NoteColumn} grob and pitched
999 rests to override typesetting decisions.
1004 Beams are used to group short notes into chunks that are aligned with
1005 the metrum. They are inserted automatically in most cases.
1007 @lilypond[fragment,verbatim, relative=2]
1008 \time 2/4 c8 c c c \time 6/8 c c c c8. c16 c8
1011 If you're not satisfied with the automatic beaming, you can enter the
1012 beams explicitly. If you have beaming patterns that differ from the
1013 defaults, you can also set the patterns for automatic beamer.
1015 See also @internalsref{Beam}.
1018 @cindex Automatic beams
1019 @subsection Manual beams
1020 @cindex beams, manual
1024 In some cases it may be necessary to override LilyPond's automatic
1025 beaming algorithm. For example, the auto beamer will not beam over
1026 rests or bar lines, If you want that, specify the begin and end point
1027 manually using a @code{[} before the first beamed note and a @code{]}
1028 after the last note:
1030 @lilypond[fragment,relative,verbatim]
1032 r4 [r8 g' a r8] r8 [g | a] r8
1036 @cindex @code{stemLeftBeamCount}
1038 Normally, beaming patterns within a beam are determined automatically.
1039 When this mechanism fouls up, the properties
1040 @code{Voice.stemLeftBeamCount} and @code{Voice.stemRightBeamCount} can
1041 be used to control the beam subdivision on a stem. If you set either
1042 property, its value will be used only once, and then it is erased.
1044 @lilypond[fragment,relative,verbatim]
1047 [f8 r16 \property Voice.stemLeftBeamCount = #1 f g a]
1050 @cindex @code{stemRightBeamCount}
1053 The property @code{subdivideBeams} can be set in order to subdivide
1054 all 16th or shorter beams at beat positions. This accomplishes the
1055 same effect as twiddling with @code{stemLeftBeamCount} and
1056 @code{stemRightBeamCount}, but it take less typing.
1061 \property Voice.subdivideBeams = ##t
1063 [c32 c c c c c c c c c c c c c c c]
1064 \property Score.beatLength = #(make-moment 1 8)
1065 [c32 c c c c c c c c c c c c c c c]
1069 \notes \relative c' {
1071 \property Voice.subdivideBeams = ##t
1073 [c32 c c c c c c c c c c c c c c c]
1074 \property Score.beatLength = #(make-moment 1 8)
1075 [c32 c c c c c c c c c c c c c c c]
1079 @cindex subdivideBeams
1081 Kneed beams are inserted automatically, when a large gap between two
1082 adjacent beamed notes is detected. This behavior can be tuned through
1083 the grob property @code{auto-knee-gap}.
1085 @cindex beams, kneed
1087 @cindex auto-knee-gap
1091 @c TODO -> why this ref? Document?
1092 @cindex @code{neutral-direction}
1096 Auto knee beams can not be used together with hara kiri staffs.
1099 * Setting automatic beam behavior ::
1103 @no de Beam typography
1104 @sub section Beam typography
1106 One of the strong points of LilyPond is how beams are formatted. Beams
1107 are quantized, meaning that the left and right endpoints beams start
1108 exactly on staff lines. Without quantization, small wedges of white
1109 space appear between the beam and staff line, and this looks untidy.
1111 Beams are also slope-damped: melodies that go up or down should also
1112 have beams that go up or down, but the slope of the beams should be
1113 less than the slope of the notes themselves.
1115 Some beams should be horizontal. These are so-called concave beams.
1117 [TODO: some pictures.]
1120 @c . {Automatic beams}
1121 @node Setting automatic beam behavior
1122 @subsection Setting automatic beam behavior
1124 @cindex @code{autoBeamSettings}
1125 @cindex @code{(end * * * *)}
1126 @cindex @code{(begin * * * *)}
1127 @cindex automatic beams, tuning
1128 @cindex tuning automatic beaming
1130 In normal time signatures, automatic beams can start on any note but can
1131 only end in a few positions within the measure: beams can end on a beat,
1132 or at durations specified by the properties in
1133 @code{Voice.autoBeamSettings}. The defaults for @code{autoBeamSettings}
1134 are defined in @file{scm/auto-beam.scm}.
1136 The value of @code{autoBeamSettings} is changed using
1137 @code{\override} and unset using @code{\revert}:
1139 \property Voice.autoBeamSettings \override #'(@var{BE} @var{P} @var{Q} @var{N} @var{M}) = @var{dur}
1140 \property Voice.autoBeamSettings \revert #'(@var{BE} @var{P} @var{Q} @var{N} @var{M})
1142 Here, @var{BE} is the symbol @code{begin} or @code{end}. It determines
1143 whether the rule applies to begin or end-points. The quantity
1144 @var{P}/@var{Q} refers to the length of the beamed notes (and `@code{*
1145 *}' designates notes of any length), @var{N}/@var{M} refers to a time
1146 signature (wildcards, `@code{* *}' may be entered to designate all time
1149 For example, if you want automatic beams to end on every quarter note,
1150 you can use the following:
1152 \property Voice.autoBeamSettings \override
1153 #'(end * * * *) = #(make-moment 1 4)
1155 Since the duration of a quarter note is 1/4 of a whole note, it is
1156 entered as @code{(make-moment 1 4)}.
1158 The same syntax can be used to specify beam starting points. In this
1159 example, automatic beams can only end on a dotted quarter note.
1161 \property Voice.autoBeamSettings \override
1162 #'(end * * * *) = #(make-moment 3 8)
1164 In 4/4 time signature, this means that automatic beams could end only on
1165 3/8 and on the fourth beat of the measure (after 3/4, that is 2 times
1166 3/8 has passed within the measure).
1168 You can also restrict rules to specific time signatures. A rule that
1169 should only be applied in @var{N}/@var{M} time signature is formed by
1170 replacing the second asterisks by @var{N} and @var{M}. For example, a
1171 rule for 6/8 time exclusively looks like
1173 \property Voice.autoBeamSettings \override
1174 #'(begin * * 6 8) = ...
1177 If you want a rule to apply to certain types of beams, you can use the
1178 first pair of asterisks. Beams are classified according to the shortest
1179 note they contain. For a beam ending rule that only applies to beams
1180 with 32nd notes (and no shorter notes), you would use @code{(end 1
1184 @c Automatic beams can not be put on the last note in a score.
1186 If a score ends while an automatic beam has not been ended and is still
1187 accepting notes, this last beam will not be typeset at all.
1189 @cindex automatic beam generation
1191 @cindex @code{Voice.autoBeaming}
1194 For melodies that have lyrics, you may want to switch off
1195 automatic beaming. This is done by setting @code{Voice.autoBeaming} to
1201 It is not possible to specify beaming parameters for beams with mixed
1202 durations, that differ from the beaming parameters of all separate
1203 durations, i.e., you'll have to specify manual beams to get:
1204 @lilypond[fragment,singleline,relative]
1205 \property Voice.autoBeamSettings
1206 \override #'(end * * * *) = #(make-moment 3 8)
1207 \time 12/8 c'8 c c c16 c c c c c [c c c c] c8 c c4
1210 It is not possible to specify beaming parameters that act differently in
1211 different parts of a measure. This means that it is not possible to use
1212 automatic beaming in irregular meters such as @code{5/8}.
1215 @section Accidentals
1217 This section describes how to change the way that LilyPond automatically
1218 inserts accidentals before the running notes.
1221 * Using the predefined accidental macros::
1222 * Defining your own accidental typesettings::
1225 @node Using the predefined accidental macros
1226 @subsection Using the predefined accidental macros
1227 The constructs for describing the accidental typesetting rules are
1228 quite hairy, so non-experts should stick to the macros defined in
1229 @file{ly/property-init.ly}.
1230 @cindex @file{property-init.ly}
1232 The normal way of using the macros is to enter the macro name right after the
1233 creation of the context in which the accidental typesetting described
1234 by the macro is to take effect. I.e. if you want to use
1235 piano-accidentals in a pianostaff then you issue
1236 @code{\pianoAccidentals} first thing after the creation of the piano
1240 \notes \relative c'' <
1241 \context Staff = sa @{ cis4 d e2 @}
1242 \context GrandStaff <
1244 \context Staff = sb @{ cis4 d e2 @}
1245 \context Staff = sc @{ es2 c @}
1247 \context Staff = sd @{ es2 c @}
1251 @lilypond[singleline]
1253 \notes \relative c'' <
1254 \context Staff = sa { cis4 d e2 }
1255 \context GrandStaff <
1257 \context Staff = sb { cis4 d e2 }
1258 \context Staff = sc { es2 c }
1260 \context Staff = sd { es2 c }
1265 minimumVerticalExtent = #'(-4.0 . 4.0)
1273 @item \defaultAccidentals
1274 @cindex @code{\defaultAccidentals}
1275 This is the default typesetting behaviour. It should correspond
1276 to 18th century common practice: Accidentals are
1277 remembered to the end of the measure in which they occur and
1278 only on their own octave.
1280 @item \voiceAccidentals
1281 @cindex @code{\voiceAccidentals}
1282 The normal behaviour is to remember the accidentals on
1284 This macro, however, typesets accidentals individually for each
1286 Apart from that the rule is similar to
1287 @code{\defaultAccidentals}.
1289 Warning: This leads to some weird and often unwanted results
1290 because accidentals from one voice DO NOT get cancelled in other
1292 @lilypond[singleline,relative,fragment,verbatim]
1295 \context Voice=va { \voiceOne es g }
1296 \context Voice=vb { \voiceTwo c, e }
1299 Hence you should only use @code{\voiceAccidentals}
1300 if the voices are to be read solely by
1301 individual musicians. if the staff should be readable also
1302 by one musician/conductor then you should use
1303 @code{\modernVoiceAccidentals} or @code{\modernVoiceCautionaries}
1306 @item \modernAccidentals
1307 @cindex @code{\modernAccidentals}
1308 This rule should correspond to the common practice in the 20th
1310 The rule is a bit more complex than @code{\defaultAccidentals}:
1311 You get all the same accidentals, but temporary
1312 accidentals also get cancelled in other octaves. Further more,
1313 in the same octave, they also get cancelled in the following measure:
1314 @lilypond[singleline,fragment,verbatim]
1316 cis' c'' cis'2 | c'' c'
1319 @item \modernCautionaries
1320 @cindex @code{\modernCautionaries}
1321 This rule is similar to @code{\modernAccidentals}, but the
1322 ``extra'' accidentals (the ones not typeset by
1323 @code{\defaultAccidentals}) are typeset as cautionary accidentals
1324 (i.e. in reduced size):
1325 @lilypond[singleline,fragment,verbatim]
1327 cis' c'' cis'2 | c'' c'
1330 @item \modernVoiceAccidentals
1331 @cindex @code{\modernVoiceAccidentals}
1332 Multivoice accidentals to be read both by musicians playing one voice
1333 and musicians playing all voices.
1335 Accidentals are typeset for each voice, but they ARE cancelled
1336 across voices in the same @internalsref{Staff}.
1338 @item \modernVoiceCautionaries
1339 @cindex @code{\modernVoiceCautionaries}
1340 The same as @code{\modernVoiceAccidentals}, but with the
1341 extra accidentals (the ones not typeset by
1342 @code{\voiceAccidentals}) typeset as cautionaries.
1343 Notice that even though all accidentals typeset by
1344 @code{\defaultAccidentals} ARE typeset by this macro then some
1345 of them are typeset as cautionaries.
1347 @item \pianoAccidentals
1348 @cindex @code{\pianoAccidentals}
1349 20th century practice for piano notation. Very similar to
1350 @code{\modernAccidentals} but accidentals also get cancelled
1351 across the staves in the same @internalsref{GrandStaff} or
1352 @internalsref{PianoStaff}.
1354 @item \pianoCautionaries
1355 @cindex @code{\pianoCautionaries}
1356 As @code{\pianoAccidentals} but with the extra accidentals
1357 typeset as cationaries.
1360 @cindex @code{\noResetKey}
1361 Same as @code{\defaultAccidentals} but with accidentals lasting
1362 ``forever'' and not only until the next measure:
1363 @lilypond[singleline,fragment,verbatim,relative]
1368 @item \forgetAccidentals
1369 @cindex @code{\forgetAccidentals}
1370 This is sort of the opposite of @code{\noResetKey}: Accidentals
1371 are not remembered at all - and hence all accidentals are
1372 typeset relative to the key signature, regardless of what was
1373 before in the music:
1374 @lilypond[singleline,fragment,verbatim,relative]
1376 \key d\major c4 c cis cis d d dis dis
1380 @node Defining your own accidental typesettings
1381 @subsection Defining your own accidental typesettings
1383 This section must be considered gurus-only, and hence it must be
1384 sufficient with a short description of the system and a reference to
1385 the internal documentation.
1387 The idea of the algorithm is to try several different rules and then
1388 use the rule that gives the highest number of accidentals.
1389 Each rule cosists of
1392 In which context is the rule applied. I.e. if context is
1393 @internalsref{Score} then all staves share accidentals, and if
1394 context is @internalsref{Staff} then all voices in the same
1395 staff share accidentals, but staves don't - like normally.
1397 Whether the accidental changes all octaves or only the current
1400 Over how many barlines the accidental lasts.
1401 If lazyness is @code{-1} then the accidental is forget
1402 immidiately, and if lazyness is @code{#t} then the accidental
1406 As described in the internal documentation of
1407 @reng{Accidental_engraver}, the properties @code{autoAccidentals} and
1408 @code{autoCautionaries} contain lists of rule descriptions. Notice
1409 that the contexts must be listed from in to out - that is
1410 @internalsref{Thread} before @internalsref{Voice},
1411 @internalsref{Voice} before @internalsref{Staff}, etc.
1412 see the macros in @file{ly/property-init.ly} for examples of how the
1417 Currently the simultaneous notes are considered to be entered in
1418 sequential mode. This means that in a chord the accidentals are
1419 typeset as if the notes in the chord happened one at a time - in the
1420 order in which they appear in the input file.
1422 Of course this is only a problem when you have simultainous notes
1423 which accidentals should depend on each other.
1424 Notice that the problem only occurs when using non-default accidentals
1425 - as the default accidentals only depend on other accidentals on the
1426 same staff and same pitch and hence cannot depend on other
1429 This example shows two examples of the same music giving different
1430 accidentals depending on the order in which the notes occur in the
1433 @lilypond[singleline,fragment,verbatim]
1434 \property Staff.autoAccidentals = #'( Staff (any-octave . 0) )
1435 cis'4 <c'' c'> r2 | cis'4 <c' c''> r2 | <cis' c''> r | <c'' cis'> r |
1438 The only solution is to manually insert the problematic
1439 accidentals using @code{!} and @code{?}.
1441 @node Expressive marks
1442 @section Expressive marks
1457 A slur indicates that notes are to be played bound or @emph{legato}.
1458 They are entered using parentheses:
1459 @lilypond[fragment,verbatim,center]
1460 f'()g'()a' [a'8 b'(] a'4 g'2 )f'4
1463 See also @seeinternals{Slur}.
1465 Slurs avoid crossing stems, and are generally attached to note heads.
1466 However, in some situations with beams, slurs may be attached to stem
1467 ends. If you want to override this layout you can do this through the
1468 grob-property @code{attachment} of @internalsref{Slur} in
1469 @internalsref{Voice} context It's value is a pair of symbols, specifying
1470 the attachment type of the left and right end points.
1472 @lilypond[fragment,relative,verbatim]
1474 \property Voice.Stem \set #'length = #5.5
1476 \property Voice.Slur \set #'attachment = #'(stem . stem)
1480 If a slur would strike through a stem or beam, the slur will be moved
1481 away upward or downward. If this happens, attaching the slur to the
1482 stems might look better:
1484 @lilypond[fragment,relative,verbatim]
1487 \property Voice.Slur \set #'attachment = #'(stem . stem)
1492 Similarly, the curvature of a slur is adjusted to stay clear of note
1493 heads and stems. When that would increase the curvature too much, the
1494 slur is reverted to its default shape. The threshold for this
1495 decision is in @internalsref{Slur}'s grob-property @code{beautiful}.
1496 It is loosely related to the enclosed area between the slur and the
1497 notes. Usually, the default setting works well, but in some cases you
1498 may prefer a curved slur when LilyPond decides for a vertically moved
1499 one. You can indicate this preference by increasing the
1500 @code{beautiful} value:
1502 @lilyp ond[verbatim,singleline,relative]
1504 c16( a' f' a a f a, )c,
1505 c( a' f' a a f d, )c
1506 \property Voice.Slur \override #'beautiful = #5.0
1507 c( a' f' a a f d, )c
1513 Producing nice slurs is a difficult problem, and LilyPond currently
1514 uses a simple, empiric method to produce slurs. In some cases, the
1515 results of this method are ugly.
1518 This is reflected by the
1519 @code{beautiful} property, which it is an arbitrary parameter in the
1520 slur formatter. Useful values can only be determined by trial and
1524 @cindex Adjusting slurs
1526 @node Phrasing slurs
1527 @subsection Phrasing slurs
1529 @cindex phrasing slurs
1530 @cindex phrasing marks
1532 A phrasing slur (or phrasing mark) connects chords and is used to
1533 indicate a musical sentence. It is started using @code{\(} and @code{\)}
1536 @lilypond[fragment,verbatim,center,relative]
1537 \time 6/4 c' \( d () e f () e \) d
1540 Typographically, the phrasing slur behaves almost exactly like a normal
1541 slur. See also @seeinternals{PhrasingSlur}.
1545 @subsection Breath marks
1547 Breath marks are entered using @code{\breathe}. See also
1548 @seeinternals{BreathingSign}.
1550 @lilypond[fragment,relative]
1559 @cindex beats per minute
1560 @cindex metronome marking
1562 Metronome settings can be entered as follows:
1564 @cindex @code{\tempo}
1566 \tempo @var{duration} = @var{perminute}
1569 For example, @code{\tempo 4 = 76} requests output with 76 quarter notes
1574 The tempo setting is not printed, but is only used in the MIDI
1575 output. You can trick lily into producing a metronome mark,
1576 though. Details are in @ref{Text markup}.
1581 @subsection Text spanners
1582 @cindex Text spanners
1584 Some textual indications, e.g. rallentando or accelerando, often extend
1585 over many measures. This is indicated by following the text with a
1586 dotted line. You can create such texts using text spanners. The syntax
1589 \spanrequest \start "text"
1590 \spanrequest \stop "text"
1592 LilyPond will respond by creating a @internalsref{TextSpanner} grob (typically
1593 in @internalsref{Voice} context). The string to be printed, as well as the
1594 style is set through grob properties.
1596 An application---or rather, a hack---is to fake octavation indications.
1597 @lilypond[fragment,relative,verbatim]
1598 \relative c' { a''' b c a
1599 \property Voice.TextSpanner \set #'type = #'dotted-line
1600 \property Voice.TextSpanner \set #'edge-height = #'(0 . 1.5)
1601 \property Voice.TextSpanner \set #'edge-text = #'("8va " . "")
1602 \property Staff.centralCPosition = #-13
1603 a\spanrequest \start "text" b c a \spanrequest \stop "text" }
1621 @subsection Articulations
1622 @cindex Articulations
1624 @cindex articulations
1628 A variety of symbols can appear above and below notes to indicate
1629 different characteristics of the performance. They are added to a note
1630 by adding a dash and the the character signifying the
1631 articulation. They are demonstrated here.
1632 @lilypond[singleline]
1634 \notes \context Voice {
1635 \property Voice.TextScript \set #'font-family = #'typewriter
1636 \property Voice.TextScript \set #'font-shape = #'upright
1642 c''4-^_"c-\\^{ }" s4
1647 The script is automatically placed, but if you need to force
1648 directions, you can use @code{_} to force them down, or @code{^} to
1650 @lilypond[fragment, verbatim]
1655 Other symbols can be added using the syntax
1656 @var{note}@code{-\}@var{name}. Again, they can be forced up or down
1657 using @code{^} and @code{_}.
1661 \property Score.LyricText \override #'font-family =#'typewriter
1662 \property Score.LyricText \override #'font-shape = #'upright
1663 \context Staff \notes {
1664 c''-\accent c''-\marcato c''-\staccatissimo c''^\fermata
1665 c''-\stopped c''-\staccato c''-\tenuto c''-\upbow
1666 c''-\downbow c''^\lheel c''-\rheel c''^\ltoe
1667 c''-\rtoe c''-\turn c''-\open c''-\flageolet
1668 c''-\reverseturn c''-\trill c''-\prall c''-\mordent
1669 c''-\prallprall c''-\prallmordent c''-\upprall c''-\downprall
1670 c''-\upmordent c''-\downmordent c''-\pralldown c''-\prallup
1671 c''-\lineprall c''-\thumb c''-\segno c''-\coda
1673 \context Lyrics \lyrics {
1674 accent__ marcato__ staccatissimo__ fermata
1675 stopped__ staccato__ tenuto__ upbow
1676 downbow__ lheel__ rheel__ ltoe
1677 rtoe__ turn__ open__ flageolet
1678 reverseturn__ trill__ prall__ mordent
1679 prallprall__ prallmordent__ uprall__ downprall
1680 upmordent__ downmordent__ pralldown__ prallup__
1681 lineprall__ thumb__ segno__ coda
1685 linewidth = 5.875\in
1694 Fingering instructions can also be entered in this shorthand. For
1695 finger changes, use markup texts:
1697 @lilypond[verbatim, singleline, fragment]
1698 c'4-1 c'4-2 c'4-3 c'4-4
1703 @cindex @code{\script}
1708 See also @seeinternals{Script} and @seeinternals{Fingering}.
1712 All of these note ornaments appear in the printed output but have no
1713 effect on the MIDI rendering of the music.
1715 Unfortunately, there is no support for adding fingering instructions or
1716 ornaments to individual note heads. Some hacks exist, though. See
1717 @file{input/test/script-horizontal.ly}.
1722 @subsection Text scripts
1723 @cindex Text scripts
1725 In addition, it is possible to place arbitrary strings of text or markup
1726 text (see @ref{Text markup}) above or below notes by using a string:
1729 By default, these indications do not influence the note spacing, but
1730 by using the command @code{\fatText}, the widths will be taken into
1733 @lilypond[fragment,singleline,verbatim] \relative c' {
1734 c4^"longtext" \fatText c4_"longlongtext" c4 }
1737 It is possible to use @TeX{} commands in the strings, but this should be
1738 avoided because it makes it impossible for LilyPond to compute the
1739 exact length of the string, which may lead to collisions. Also, @TeX{}
1740 commands won't work with direct PostScript output (see @ref{PostScript
1743 Text scripts are created in form of @internalsref{TextScript} grobs, in
1744 @internalsref{Voice} context.
1746 @ref{Text markup} describes how to change the font or access
1747 special symbols in text scripts.
1752 @subsection Grace notes
1756 @cindex @code{\grace}
1760 Grace notes are ornaments are written out ornaments
1761 @lilypond[relative=2,verbatim,ifragment]
1762 c4 \grace c16 c4 \grace { [c16 d16] } c4
1765 In normal notation, grace notes are supposed to take up no logical
1766 time in a measure. Such an idea is practical for normal notation, but
1767 is not strict enough to put it into a program. The model that LilyPond
1768 uses for grace notes internally is that all timing is done in two
1771 Every point in musical time consists of two rational numbers: one
1772 denotes the logical time, one denotes the grace timing. The above
1773 example is shown here with timing tuples.
1776 \score { \notes \relative c''{
1777 c4^"(0,0)" \grace c16_"(1/4,-1/16)" c4^"(1/4,0)" \grace {
1778 [c16_"(2/4,-1/8)" d16^"(2/4,-1/16)" ] } c4_"(2/4,0)"
1780 \paper { linewidth = 8.\cm }
1784 The advantage of this approach is that you can use almost any lilypond
1785 construction together with grace notes, for example slurs and clef
1786 changes may appear halfway in between grace notes:
1788 @lilypond[relative=2,verbatim,fragment]
1789 c4 \grace { [ c16 c, \clef bass c, b(] } )c4
1792 The placement of these grace notes is synchronized between different
1793 staffs, using this grace timing.
1795 @lilypond[relative=2,verbatim,fragment]
1796 \context Staff = SA { e4 \grace { c16 d e f } e4 }
1797 \context Staff = SB { c4 \grace { g8 b } c4 }
1801 The syntax is as follows.
1803 \grace @var{musicexpr}
1806 Unbeamed eighth notes and shorter by default have a slash through the
1809 @lilypond[fragment,verbatim]
1810 \relative c'' \context Voice {
1811 \grace c8 c4 \grace { [c16 c16] } c4
1813 \property Voice.Stem \override #'flag-style = #'()
1815 \property Voice.Stem \revert #'flag-style
1822 Grace note synchronization can also lead to surprises. Staff notation,
1823 such as key signatures, barlines, etc. are also synchronized. Take
1824 care when you mix staffs with grace notes and staffs without.
1826 @lilypond[relative=2,fragment]
1827 < \context Staff = SA { e4 \bar "|:" \grace c16 d4 }
1828 \context Staff = SB { c4 \bar "|:" d4 } >
1831 Grace sections should only be used within sequential music
1832 expressions. Nesting, juxtaposing, or ending sequential music with a
1833 grace section is not supported, and might produce crashes or other
1845 @subsection Glissando
1848 @cindex @code{\glissando}
1850 A glissando line can be requested by attaching a @code{\glissando} to
1853 @lilypond[fragment,relative,verbatim]
1859 Printing of an additional text (such as @emph{gliss.}) must be done
1860 manually. See also @seeinternals{Glissando}.
1866 @subsection Dynamics
1879 @cindex @code{\ffff}
1889 Absolute dynamic marks are specified using an identifier after a
1890 note: @code{c4-\ff}. The available dynamic marks are: @code{\ppp},
1891 @code{\pp}, @code{\p}, @code{\mp}, @code{\mf}, @code{\f}, @code{\ff},
1892 @code{\fff}, @code{\fff}, @code{\fp}, @code{\sf}, @code{\sff},
1893 @code{\sp}, @code{\spp}, @code{\sfz}, and @code{\rfz}.
1895 @lilypond[verbatim,singleline,fragment,relative]
1896 c'\ppp c\pp c \p c\mp c\mf c\f c\ff c\fff
1902 @cindex @code{\decr}
1903 @cindex @code{\rced}
1909 A crescendo mark is started with @code{\cr} and terminated with
1910 @code{\rc} (the textual reverse of @code{cr}). A decrescendo mark is
1911 started with @code{\decr} and terminated with @code{\rced}. There are
1912 also shorthands for these marks. A crescendo can be started with
1913 @code{\<} and a decrescendo can be started with @code{\>}. Either one
1914 can be terminated with @code{\!}. Note that @code{\!} must go before
1915 the last note of the dynamic mark whereas @code{\rc} and @code{\rced} go
1916 after the last note. Because these marks are bound to notes, if you
1917 want several marks during one note, you have to use spacer notes.
1919 @lilypond[fragment,verbatim,center]
1920 c'' \< \! c'' d'' \decr e'' \rced
1921 < f''1 { s4 s4 \< \! s4 \> \! s4 } >
1924 You can also use a text saying @emph{cresc.} instead of hairpins. Here
1925 is an example how to do it:
1927 @lilypond[fragment,relative=2,verbatim]
1928 c4 \cresc c4 \endcresc c4
1935 You can also supply your own texts:
1936 @lilypond[fragment,relative,verbatim]
1938 \property Voice.crescendoText = "cresc. poco"
1939 \property Voice.crescendoSpanner = #'dashed-line
1946 Dynamics are grobs of @internalsref{DynamicText} and
1947 @internalsref{Hairpin}. Vertical positioning of these symbols is
1948 handled by the @internalsref{DynamicLineSpanner} grob. If you want to
1949 adjust padding or vertical direction of the dynamics, you must set
1950 properties for the @internalsref{DynamicLineSpanner} grob. Predefined
1951 identifiers to set the vertical direction are \dynamicUp and
1954 @cindex direction, of dynamics
1955 @cindex @code{\dynamicDown}
1956 @cindex @code{\dynamicUp}
1964 @cindex @code{\repeat}
1966 To specify repeats, use the @code{\repeat} keyword. Since repeats
1967 should work differently when played or printed, there are a few
1968 different variants of repeats.
1972 Repeated music is fully written (played) out. Useful for MIDI
1973 output, and entering repetitive music.
1976 This is the normal notation: Repeats are not written out, but
1977 alternative endings (voltas) are printed, left to right.
1980 Alternative endings are written stacked. This has limited use but may be
1981 used to typeset two lines of lyrics in songs with repeats, see
1982 @file{input/star-spangled-banner.ly}.
1988 Make beat or measure repeats. These look like percent signs.
1994 * Repeats and MIDI::
1995 * Manual repeat commands::
1997 * Tremolo subdivisions::
2002 @subsection Repeat syntax
2004 The syntax for repeats is
2007 \repeat @var{variant} @var{repeatcount} @var{repeatbody}
2010 If you have alternative endings, you may add
2011 @cindex @code{\alternative}
2013 \alternative @code{@{} @var{alternative1}
2015 @var{alternative3} @dots{} @code{@}}
2017 where each @var{alternative} is a music expression.
2019 Normal notation repeats are used like this:
2020 @lilypond[fragment,verbatim]
2022 \repeat volta 2 { c'4 d' e' f' }
2023 \repeat volta 2 { f' e' d' c' }
2026 With alternative endings:
2027 @lilypond[fragment,verbatim]
2029 \repeat volta 2 {c'4 d' e' f'}
2030 \alternative { {d'2 d'} {f' f} }
2033 Folded repeats look like this:
2036 @lilypond[fragment,verbatim]
2038 \repeat fold 2 {c'4 d' e' f'}
2039 \alternative { {d'2 d'} {f' f} }
2043 If you don't give enough alternatives for all of the repeats, then
2044 the first alternative is assumed to be repeated often enough to equal
2045 the specified number of repeats.
2047 @lilypond[fragment,verbatim]
2051 \repeat volta 4 { e | c2 d2 | e2 f2 | }
2052 \alternative { { g4 g g } { a | a a a a | b2. } }
2057 @node Repeats and MIDI
2058 @subsection Repeats and MIDI
2060 @cindex expanding repeats
2062 For instructions on how to unfoldi repeats for MIDI output, see
2063 the example file @file{input/test/unfold-all-repeats.ly}.
2068 Notice that timing information is not remembered at the start of an
2069 alternative, so you have to reset timing information after a repeat,
2070 e.g. using a bar-check (See @ref{Bar check}), setting
2071 @code{Score.measurePosition} or entering @code{\partial}. Slurs or ties
2072 are also not repeated.
2074 It is possible to nest @code{\repeat}s, although this probably is only
2075 meaningful for unfolded repeats.
2077 Folded repeats offer little more over simultaneous music.
2079 @node Manual repeat commands
2080 @subsection Manual repeat commands
2082 @cindex @code{repeatCommands}
2084 The property @code{repeatCommands} can be used to control the layout of
2085 repeats. Its value is a Scheme list of repeat commands, where each repeat
2093 @item (volta . @var{text})
2094 Print a volta bracket saying @var{text}.
2096 Stop a running volta bracket
2099 @lilypond[verbatim, fragment]
2101 \property Score.repeatCommands = #'((volta "93") end-repeat)
2103 \property Score.repeatCommands = #'((volta #f))
2108 Repeats brackets are @internalsref{VoltaBracket} grobs.
2110 @node Tremolo repeats
2111 @subsection Tremolo repeats
2112 @cindex tremolo beams
2114 To place tremolo marks between notes, use @code{\repeat} with tremolo
2116 @lilypond[verbatim,center,singleline]
2118 \context Voice \notes\relative c' {
2119 \repeat "tremolo" 8 { c16 d16 }
2120 \repeat "tremolo" 4 { c16 d16 }
2121 \repeat "tremolo" 2 { c16 d16 }
2122 \repeat "tremolo" 4 c16
2127 Tremolo beams are @internalsref{Beam} grobs. Single stem tremolos are
2128 @internalsref{StemTremolo}.
2132 Tremolo beams confuse the spacing engine.
2134 @node Tremolo subdivisions
2135 @subsection Tremolo subdivisions
2136 @cindex tremolo marks
2137 @cindex @code{tremoloFlags}
2139 Tremolo marks can be printed on a single note by adding
2140 `@code{:}[@var{length}]' after the note. The length must be at least 8.
2141 A @var{length} value of 8 gives one line across the note stem. If the
2142 length is omitted, then then the last value (stored in
2143 @code{Voice.tremoloFlags}) is used.
2145 @lilypond[verbatim,fragment,center]
2146 c'2:8 c':32 | c': c': |
2152 Tremolos in this style do not carry over into the MIDI output.
2155 @node Measure repeats
2156 @subsection Measure repeats
2158 @cindex percent repeats
2159 @cindex measure repeats
2161 In the @code{percent} style, a note pattern can be repeated. It is
2162 printed once, and then the pattern is replaced with a special sign.
2163 Patterns of a one and two measures are replaced by percent-like signs,
2164 patterns that divide the measure length are replaced by slashes.
2166 @lilypond[verbatim,singleline]
2167 \context Voice { \repeat "percent" 4 { c'4 }
2168 \repeat "percent" 2 { c'2 es'2 f'4 fis'4 g'4 c''4 }
2172 The signs are represented by these grobs: @internalsref{RepeatSlash} and
2173 @internalsref{PercentRepeat} and @internalsref{DoublePercentRepeat}.
2177 You can not nest percent repeats, e.g. by filling in the first measure
2178 with slashes, and repeating that measure with percents.
2180 @node Rhythmic music
2181 @section Rhythmic music
2183 Sometimes you might want to show only the rhythm of a melody. This can
2184 be done with the rhythmic staff. All pitches of notes on such a staff
2185 are squashed, and the staff itself looks has a single staff line:
2187 @lilypond[fragment,relative,verbatim]
2188 \context RhythmicStaff {
2190 c4 e8 f g2 | r4 g r2 | g1:32 | r1 |
2195 * Percussion staves::
2198 @node Percussion staves
2199 @subsection Percussion staves
2202 To typeset more than one piece of percussion to be played by the same
2203 musician one typically uses a multiline staff where each staff
2204 position refers to a specific piece of percussion.
2206 LilyPond is shipped with a bunch of scheme functions which allows you
2207 to do this fairly easily.
2209 The system is based on the general midi drum-pitches.
2210 In order to use the drum pitches you include
2211 @file{ly/drumpitch-init.ly}. This file defines the pitches from the scheme
2212 variable @code{drum-pitch-names} - which definition can be read in
2213 @file{scm/drums.scm}. You see that each piece of percussion has a full
2214 name and an abbreviated name - and you may freely select whether to
2215 refer to the full name or the abbreviation in your music definition.
2217 To typeset the music on a staff you apply the scheme function
2218 @code{drums->paper} to the percussion music. This function takes a
2219 list of percussion instrument names, notehead scripts and staff
2220 positions (that is: pitches relative to the C-clef) and uses this to
2221 transform the input music by moving the pitch, changing the notehead
2222 and (optionally) adding a script:
2223 @lilypond[singleline,verbatim]
2224 \include "drumpitch-init.ly"
2225 up = \notes { crashcymbal4 hihat8 halfopenhihat hh hh hh openhihat }
2226 down = \notes { bassdrum4 snare8 bd r bd sn4 }
2228 \apply #(drums->paper 'drums) \context Staff <
2230 \context Voice = up { \voiceOne \up }
2231 \context Voice = down { \voiceTwo \down }
2236 In the above example the music was transformed using the list @code{'drums}.
2237 Currently the following lists are defined in @file{scm/drums.scm}:
2240 To typeset a typical drum kit on a five line staff.
2242 \include "drumpitch-init.ly"
2243 nam = \lyrics { cymc cyms cymr hh hhc hho hhho hhp cb hc
2244 bd sn ss tomh tommh tomml toml tomfh tomfl }
2245 mus = \notes { cymc cyms cymr hh hhc hho hhho hhp cb hc
2246 bd sn ss tomh tommh tomml toml tomfh tomfl s16 }
2249 \apply #(drums->paper 'drums) \context Staff <
2253 \context Lyrics \nam
2258 \remove Bar_engraver
2259 \remove Time_signature_engraver
2260 minimumVerticalExtent = #'(-4.0 . 5.0)
2264 \remove Stem_engraver
2269 Notice that the scheme supports six different toms.
2270 If you are using fewer toms then you simply select the toms that produce
2271 the desired result - i.e. to get toms on the three middle lines you
2272 use @code{tommh}, @code{tomml} and @code{tomfh}.
2274 Because the general midi contain no rimshots we use the sidestick for
2275 this purpose instead.
2277 To typeset timbales on a two line staff.
2278 @lilypond[singleline]
2279 \include "drumpitch-init.ly"
2280 nam = \lyrics { timh ssh timl ssl cb }
2281 mus = \notes { timh ssh timl ssl cb s16 }
2284 \apply #(drums->paper 'timbales) \context Staff <
2288 \context Lyrics \nam
2293 \remove Bar_engraver
2294 \remove Time_signature_engraver
2295 StaffSymbol \override #'line-count = #2
2296 StaffSymbol \override #'staff-space = #2
2297 minimumVerticalExtent = #'(-3.0 . 4.0)
2301 \remove Stem_engraver
2308 To typeset congas on a two line staff.
2309 @lilypond[singleline]
2310 \include "drumpitch-init.ly"
2311 nam = \lyrics { cgh cgho cghm ssh cgl cglo cglm ssl }
2312 mus = \notes { cgh cgho cghm ssh cgl cglo cglm ssl s16 }
2315 \apply #(drums->paper 'congas) \context Staff <
2319 \context Lyrics \nam
2324 \remove Bar_engraver
2325 \remove Time_signature_engraver
2326 StaffSymbol \override #'line-count = #2
2327 StaffSymbol \override #'staff-space = #2
2328 minimumVerticalExtent = #'(-3.0 . 4.0)
2332 \remove Stem_engraver
2338 To typeset bongos on a two line staff.
2339 @lilypond[singleline]
2340 \include "drumpitch-init.ly"
2341 nam = \lyrics { boh boho bohm ssh bol bolo bolm ssl }
2342 mus = \notes { boh boho bohm ssh bol bolo bolm ssl s16 }
2345 \apply #(drums->paper 'bongos) \context Staff <
2349 \context Lyrics \nam
2354 \remove Bar_engraver
2355 \remove Time_signature_engraver
2356 StaffSymbol \override #'line-count = #2
2357 StaffSymbol \override #'staff-space = #2
2358 minimumVerticalExtent = #'(-3.0 . 4.0)
2362 \remove Stem_engraver
2368 To typeset all kinds of simple percussion on one line staves.
2369 @lilypond[singleline]
2370 \include "drumpitch-init.ly"
2371 nam = \lyrics { tri trio trim gui guis guil cb cl tamb cab mar hc }
2372 mus = \notes { tri trio trim gui guis guil cb cl tamb cab mar hc s16 }
2375 \apply #(drums->paper 'percussion) \context Staff <
2379 \context Lyrics \nam
2384 \remove Bar_engraver
2385 \remove Time_signature_engraver
2386 StaffSymbol \override #'line-count = #1
2387 minimumVerticalExtent = #'(-2.0 . 3.0)
2391 \remove Stem_engraver
2398 If you don't like any of the predefined lists you can define your own
2399 list at the top of your file:
2401 @lilypond[singleline, verbatim]
2403 (bassdrum default #f ,(make-pitch -1 2 0))
2404 (snare default #f ,(make-pitch 0 1 0))
2405 (hihat cross #f ,(make-pitch 0 5 0))
2406 (pedalhihat xcircle "stopped" ,(make-pitch 0 5 0))
2407 (lowtom diamond #f ,(make-pitch -1 6 0))
2409 \include "drumpitch-init.ly"
2410 up = \notes { hh8 hh hh hh hhp4 hhp }
2411 down = \notes { bd4 sn bd toml8 toml }
2413 \apply #(drums->paper 'mydrums) \context Staff <
2415 \context Voice = up { \voiceOne \up }
2416 \context Voice = down { \voiceTwo \down }
2421 To use a modified existing list instead of building your own from
2422 scratch you can append your modifications to the start of the existing
2426 #(define mydrums (append `(
2427 (bassdrum default #f ,(make-pitch -1 2 0))
2428 (lowtom diamond #f ,(make-pitch -1 6 0))
2432 @c FIXME: Too many levels of headers when using subsubsections.
2433 @c Perhaps junk subsection ``Percussion staves''
2434 @subsubsection Percussion staves with normal staves
2435 When you include @file{drumpitch-init.ly} then the default pitches
2436 are overridden so that you after the inclusion cannot use the common
2437 dutch pitch names anymore. Hence you might wan't to reinclude
2438 @file{nederlands.ly} after the drum-pattern-definitions:
2439 @lilypond[singleline,verbatim]
2440 \include "drumpitch-init.ly"
2441 up = \notes { crashcymbal4 hihat8 halfopenhihat hh hh hh openhihat }
2442 down = \notes { bassdrum4 snare8 bd r bd sn4 }
2443 \include "nederlands.ly"
2444 bass = \notes \transpose c, { a4. e8 r e g e }
2447 \apply #(drums->paper 'drums) \context Staff = drums <
2449 \context Voice = up { \voiceOne \up }
2450 \context Voice = down { \voiceTwo \down }
2452 \context Staff = bass { \clef "F_8" \bass }
2457 @subsubsection Percussion midi output
2458 In order to produce correct midi output you need to produce two score
2459 blocks - one for the paper and one for the midi.
2460 To use the percussion channel you set the property @code{instrument}
2461 to @code{'drums}. Because the drum-pitches themself are similar to the
2462 general midi pitches all you have to do is to insert the voices with
2463 none of the scheme functions to get the correct midi output:
2467 \apply #(drums->paper 'mydrums) \context Staff <
2469 \context Voice = up @{ \voiceOne \up @}
2470 \context Voice = down @{ \voiceTwo \down @}
2476 \property Staff.instrument = #'drums
2485 This scheme is to be considered a temporary implementation. Even
2486 though the scheme will probably keep on working then the future might
2487 bring some other way of typesetting drums, and probably
2488 there will be made no great efforts in keeping things downwards
2493 @section Piano music
2495 Piano music is an odd type of notation. Piano staves are two normal
2496 staves coupled with a brace. The staves are largely independent, but
2497 sometimes voices can cross between the two staves. The
2498 @internalsref{PianoStaff} is especially built to handle this cross-staffing
2499 behavior. In this section we discuss the @internalsref{PianoStaff} and some
2500 other pianistic peculiarities.
2503 * Automatic staff changes::
2504 * Manual staff switches::
2507 * Voice follower lines::
2511 @c . {Automatic staff changes}
2512 @node Automatic staff changes
2513 @subsection Automatic staff changes
2514 @cindex Automatic staff changes
2516 Voices can switch automatically between the top and the bottom
2517 staff. The syntax for this is
2519 \autochange Staff \context Voice @{ @dots{}@var{music}@dots{} @}
2521 The autochanger switches on basis of pitch (central C is the turning
2522 point), and it looks ahead skipping over rests to switch rests in
2523 advance. Here is a practical example:
2525 @lilypond[verbatim,singleline]
2526 \score { \notes \context PianoStaff <
2527 \context Staff = "up" {
2528 \autochange Staff \context Voice = VA < \relative c' {
2529 g4 a b c d r4 a g } > }
2530 \context Staff = "down" {
2535 Spacer rests are used to prevent the bottom staff from
2536 terminating too soon.
2539 @node Manual staff switches
2540 @subsection Manual staff switches
2542 @cindex manual staff switches
2543 @cindex staff switch, manual
2545 Voices can be switched between staves manually, using the following command:
2547 \translator Staff = @var{staffname} @var{music}
2549 The string @var{staffname} is the name of the staff. It switches the
2550 current voice from its current staff to the Staff called
2551 @var{staffname}. Typically @var{staffname} is @code{"up"} or
2559 Piano pedal instruction can be expressed using
2560 @code{\sustainDown}, @code{\sustainUp}, @code{\unaCorda},
2561 @code{\treCorde}, @code{\sostenutoDown} and @code{\sostenutoUp}.
2563 These identifiers are shorthands for spanner commands of the types
2564 @internalsref{Sustain}, @internalsref{UnaCorda} and @internalsref{Sostenuto}:
2566 @lilypond[fragment,verbatim]
2567 c''4 \spanrequest \start "Sustain" c''4
2568 c''4 \spanrequest \stop "Sustain"
2571 The symbols that are printed can be modified by setting
2572 @code{pedal@var{X}Strings}, where @var{X} is one of the pedal types:
2573 Sustain, Sostenuto or UnaCorda. Refer to the generated documentation of
2574 @rgrob{SustainPedal}, for example, for more information.
2576 Pedals can also be indicated by a sequence of brackets, by setting the
2577 @code{pedal-type} property of SustainPedal grobs:
2579 @lilypond[fragment,verbatim]
2580 \property Staff.SustainPedal \override #'pedal-type = #'bracket
2581 c''4 \sustainDown d''4 e''4 a'4
2582 \sustainUp \sustainDown
2583 f'4 g'4 a'4 \sustainUp
2586 A third style of pedal notation is a mixture of text and brackets,
2587 obtained by setting @code{pedal-type} to @code{mixed}:
2589 @lilypond[fragment,verbatim]
2590 \property Staff.SustainPedal \override #'pedal-type = #'mixed
2591 c''4 \sustainDown d''4 e''4 c'4
2592 \sustainUp \sustainDown
2593 f'4 g'4 a'4 \sustainUp
2596 The default '*Ped' style for sustain and damper pedals corresponds to
2597 @code{\pedal-type = #'text}. However, @code{mixed} is the default style
2598 for a sostenuto pedal:
2600 @lilypond[fragment,verbatim]
2601 c''4 \sostenutoDown d''4 e''4 c'4 f'4 g'4 a'4 \sostenutoUp
2604 For fine-tuning of the appearance of a pedal bracket, the properties
2605 @code{edge-width}, @code{edge-height}, and @code{shorten-pair} of
2606 @code{PianoPedalBracket} grobs (see the detailed documentation of
2607 @rgrob{PianoPedalBracket}) can be modified. For example, the bracket
2608 may be extended to the end of the note head.
2610 @lilypond[fragment,verbatim]
2611 \property Staff.PianoPedalBracket \override
2612 #'shorten-pair = #'(0 . -1.0)
2613 c''4 \sostenutoDown d''4 e''4 c'4
2614 f'4 g'4 a'4 \sostenutoUp
2621 @subsection Arpeggio
2624 @cindex broken arpeggio
2625 @cindex @code{\arpeggio}
2627 You can specify an arpeggio sign on a chord by attaching an
2628 @code{\arpeggio} to a note of the chord.
2631 @lilypond[fragment,relative,verbatim]
2632 \context Voice <c\arpeggio e g c>
2635 When an arpeggio crosses staves in piano music, you attach an arpeggio
2636 to the chords in both staves, and set
2637 @code{PianoStaff.connectArpeggios}.
2639 @lilypond[fragment,relative,verbatim]
2640 \context PianoStaff <
2641 \property PianoStaff.connectArpeggios = ##t
2642 \context Voice = one { <c'\arpeggio e g c> }
2643 \context Voice = other { \clef bass <c,,\arpeggio e g>}
2647 This command creates @internalsref{Arpeggio} grobs. Cross staff arpeggios
2648 are @code{PianoStaff.Arpeggio}.
2650 To add an arrow head to explicitly specify the direction of the
2651 arpeggio, you should set the arpeggio grob property
2652 @code{arpeggio-direction}.
2654 @lilypond[fragment,relative,verbatim]
2656 \property Voice.Arpeggio \set #'arpeggio-direction = #1
2658 \property Voice.Arpeggio \set #'arpeggio-direction = #-1
2663 A square bracket on the left indicates that the player should not
2664 arpeggiate the chord. To draw these brackets, set the
2665 @code{molecule-callback} property of @code{Arpeggio} or
2666 @code{PianoStaff.Arpeggio} grobs to @code{\arpeggioBracket}, and use
2667 @code{\arpeggio} statements within the chords as before.
2669 @lilypond[fragment,relative,verbatim]
2670 \context PianoStaff <
2671 \property PianoStaff.connectArpeggios = ##t
2672 \property PianoStaff.Arpeggio \override
2673 #'molecule-callback = \arpeggioBracket
2674 \context Voice = one { <c'\arpeggio e g c> }
2675 \context Voice = other { \clef bass <c,,\arpeggio e g>}
2682 It is not possible to mix connected arpeggios and unconnected
2683 arpeggios in one PianoStaff at the same time.
2687 @node Voice follower lines
2688 @subsection Voice follower lines
2690 @cindex follow voice
2691 @cindex staff switching
2694 @cindex @code{followVoice}
2696 Whenever a voice switches to another staff a line connecting the notes
2697 can be printed automatically. This is enabled if the property
2698 @code{PianoStaff.followVoice} is set to true:
2700 @lilypond[fragment,relative,verbatim]
2701 \context PianoStaff <
2702 \property PianoStaff.followVoice = ##t
2703 \context Staff \context Voice {
2705 \translator Staff=two
2708 \context Staff=two {\clef bass \skip 1*2 }
2712 The associated grob is @internalsref{VoiceFollower}.
2718 Tablature notation is used music for plucked string instruments. It
2719 notates pitches not by using note heads, but by indicating on which
2720 string and fret a note must be played. LilyPond offers limited
2721 support for tablature, by abusing the fingering system.
2724 * Tablatures basic::
2725 * Non-guitar tablatures::
2726 * Tablature in addition to normal staff::
2729 @node Tablatures basic
2730 @subsection Tablatures basic
2731 @cindex Tablatures basic
2733 Tablature can be typeset with Lilypond by using the
2734 @internalsref{TabStaff} and @internalsref{TabVoice} contexts. As
2735 tablature is a recent feature in Lilypond, most of the guitar special
2736 effects such as hammer, pull, bend are not yet supported.
2738 With the @internalsref{TabStaff}, the string number associated to a note
2739 is given though the fingering mechanism, e.g. @code{c4-3} for a C
2740 quarter on the third string. The string 1 is the lowest one, and the
2741 tuning defaults to the standard guitar tuning (with 6 strings).
2743 @lilypond[fragment,verbatim]
2746 \property Staff.Stem \override #'direction = #1
2755 @node Non-guitar tablatures
2756 @subsection Non-guitar tablatures
2757 @cindex Non-guitar tablatures
2759 There are many ways to customize Lilypond tablatures.
2761 First you can change the number of strings, by setting the number of
2762 lines in the @internalsref{TabStaff}. You can change the strings
2763 tuning. A string tuning is given as a Scheme list with one integer
2764 number for each string, the number being the pitch of an open string.
2766 Finally, it is possible to change the Scheme function to format the
2767 tablature note text. The default is @var{fret-number-tablature-format},
2768 which uses the fret number, but for some instruments that may not use
2769 this notation, just create your own tablature-format function. This
2770 function takes three argument: the string number, the string tuning and
2774 @node Tablature in addition to normal staff
2775 @subsection Tablature in addition to normal staff
2776 @cindex Tablature in addition to normal staff
2778 It is possible to typeset both tablature and a "normal" staff, as
2779 commonly done in many parts.
2781 A common trick for that is to put the notes in a variables, and to hide
2782 the fingering information (which correspond to the string number) for
2791 \context StaffGroup <
2793 % Hide fingering number (used for string number) for the "normal" staff
2794 \property Staff.Fingering \override #'transparent = ##t
2799 \property Staff.Stem \override #'direction = #1
2813 LilyPond has support for both entering and printing chords.
2814 @lilypond[verbatim,singleline]
2815 twoWays = \notes \transpose c'' {
2825 < \context ChordNames \twoWays
2826 \context Voice \twoWays > }
2829 This example also shows that the chord printing routines do not try to
2830 be intelligent. If you enter @code{f bes d}, it does not interpret
2831 this as an inversion.
2833 As you can see chords really are a set of pitches. They are internally
2834 stored as simultaneous music expressions. This means you can enter
2835 chords by name and print them as notes, enter them as notes and print
2836 them as chord names, or (the most common case) enter them by name, and
2841 * Printing named chords::
2846 @subsection Chords mode
2849 Chord mode is a mode where you can input sets of pitches using common
2850 names. It is introduced by the keyword @code{\chords}. It is similar
2851 to note mode, but words are also looked up in a chord modifier table
2852 (containing @code{maj}, @code{dim}, etc). Dashes and carets are used
2853 to indicate chord additions and subtractions, so articulation scripts
2854 can not be entered in Chord mode.
2856 Throughout these examples, chords have been shifted around the staff
2857 using @code{\transpose}.
2859 @lilypond[fragment,verbatim]
2863 c:9 c:9-.5+.7+ c:3-.5-
2873 The second type of modifier that may appear after the @code{:} is a
2874 named modifier. Named modifiers are listed in the file
2875 @file{chord-modifiers.ly}. The available modifiers are @code{m} and
2876 @code{min} which lower the 3rd half a step, `@code{aug}' which
2877 raises the 5th, `@code{dim}' which lowers the 5th,
2878 `@code{maj}' which adds a raised 7th, and `@code{sus}'
2879 which replaces the 5th with a 4th.
2881 @lilypond[fragment,verbatim]
2884 c1:m c:min7 c:maj c:aug c:dim c:sus
2890 Chord subtractions are used to eliminate notes from a chord. The
2891 notes to be subtracted are listed after a @code{^} character,
2894 @lilypond[fragment,verbatim,center]
2903 Chord inversions can be specified by appending `@code{/}' and the name
2904 of a single note to a chord. In a chord inversion, the inverted note is
2905 transposed down until it is the lowest note in the chord. If the note
2906 is not in the chord, a warning will be printed.
2908 @lilypond[fragment,verbatim,center]
2918 Bass notes can be added by `@code{/+}' and
2919 the name of a single note to a chord. This has the effect of
2920 adding the specified note to the chord, lowered by an octave,
2921 so it becomes the lowest note in the chord.
2923 @lilypond[fragment,verbatim,center]
2932 The formal syntax for named chords is as follows:
2934 @var{tonic}[@var{duration}][@code{-}@var{modifiers}][@code{^}@var{subtractions}][@code{/}@var{inversion}][@code{/+}@var{bass}].
2937 @var{tonic} should be the tonic note of the chord, and @var{duration} is
2938 the chord duration in the usual notation. There are two kinds of
2939 modifiers. One type is formed by @emph{chord additions}. Additions are
2940 obtained by listing intervals separated by dots. An interval is written
2941 by its number with an optional @code{+} or @code{-} to indicate raising
2942 or lowering by half a step. Chord additions have two effects: they adds
2943 the specified interval and all lower odd numbered intervals to the
2944 chord, and they may lower or raise the specified interval.
2949 Implementation details are gory. For example @code{c:4} not only adds
2950 a fourth, but also removes the third.
2953 @c . {Printing named chords}
2954 @node Printing named chords
2955 @subsection Printing named chords
2957 @cindex printing chord names
2961 For displaying printed chord names, use the @internalsref{ChordNames} context.
2962 The chords may be entered either using the notation described above, or
2963 directly using simultaneous music.
2965 @lilypond[verbatim,singleline]
2967 \chords {a1 b c} <d f g> <e g b>
2971 \context ChordNames \scheme
2972 \context Staff \transpose c'' \scheme
2977 You can make the chord changes stand out by setting
2978 @code{ChordNames.chordChanges} to true. This will only display chord
2979 names when there's a change in the chords scheme and at the start of a
2984 c1:m c:m \break c:m c:m d
2988 \context ChordNames {
2989 \property ChordNames.chordChanges = ##t
2991 \context Staff \transpose c'' \scheme
2993 \paper{linewidth= 9.\cm}
2997 LilyPond examines chords specified as lists of notes to determine a name
2998 to give the chord. LilyPond will not try to identify chord inversions or
2999 an added bass note, which may result in strange chord names when chords
3000 are entered as a list of pitches:
3002 @lilypond[verbatim,center,singleline]
3011 \context ChordNames \scheme
3012 \context Staff \scheme
3018 By default, a chord name system proposed by Harald Banter (See
3019 @ref{Literature}) is used. The system is very regular and predictable.
3020 Typical American style chord names may be selected by setting the
3021 @code{style} property of the @code{ChordNames.ChordName} grob to
3022 @code{'american}. Similarly @code{'jazz} selects Jazz chordnames.
3024 Routines that determine the names to be printed are written in Scheme,
3025 and may be customized by the user. The code can be found in
3026 @file{scm/chord-name.scm}. Here's an example showing the differences in
3030 @c maybe just junk verbatim option?
3031 @lilypond[verbatim,singleline]
3041 \context ChordNames = banter \scheme
3042 \context ChordNames = american {
3043 \property ChordNames.ChordName \override
3044 #'style = #'american \scheme }
3045 \context ChordNames = jazz {
3046 \property ChordNames.ChordName \override
3047 #'style = #'jazz \scheme }
3048 \context Staff \transpose c'' \scheme
3055 @section Writing parts
3057 Orchestral music involves some special notation, both in the full score,
3058 as in the individual parts. This section explains how to tackle common
3059 problems in orchestral music.
3066 * Instrument names::
3068 * Multi measure rests::
3069 * Automatic part combining::
3070 * Hara kiri staves::
3071 * Sound output for transposing instruments::
3074 @c . {Rehearsal marks}
3075 @node Rehearsal marks
3076 @subsection Rehearsal marks
3077 @cindex Rehearsal marks
3079 @cindex @code{\mark}
3081 To print a rehearsal mark, use the @code{\mark} command.
3082 @lilypond[fragment,verbatim]
3089 c1 \mark #'(music "scripts-segno")
3094 As you can see, the mark is incremented automatically if you use
3095 @code{\mark \default}. The value to use is stored in the property
3096 @code{rehearsalMark} is used and automatically incremented. The grob
3097 is @internalsref{RehearsalMark} in @internalsref{Score} context. See
3098 @code{input/test/boxed-molecule.ly} if you need boxes around the
3102 @subsection Bar numbers
3106 @cindex measure numbers
3107 @cindex currentBarNumber
3109 Bar numbers are printed by default at the start of the line. The
3110 number itself is a property that can be set by modifying the
3111 @code{currentBarNumber} property, i.e.
3113 \property Score.currentBarNumber = #217
3116 If you want boxed bar numbers, see the example file
3117 @code{input/test/boxed-molecule.ly}.
3119 See also @seeinternals{BarNumber}.
3123 Printing bar numbers at regular intervals is not implemented.
3124 Barnumbers can collide with the StaffGroup, if there is one at the
3125 top. To solve this, You have to twiddle with the
3126 @internalsref{padding} property of @internalsref{BarNumber} if your
3127 score starts with a @internalsref{StaffGroup}.
3129 @node Instrument names
3130 @subsection Instrument names
3132 In scores, the instrument name is printed before the staff. This can
3133 be done by setting @code{Staff.instrument} and
3134 @code{Staff.instr}. This will print a string before the start of the
3135 staff. For the first start, @code{instrument} is used, for the next
3136 ones @code{instr} is used.
3138 @lilypond[verbatim,singleline]
3139 \property Staff.instrument = "ploink " { c''4 }
3142 You can also use markup texts to construct more complicated instrument
3146 @lilypond[verbatim,singleline]
3148 '((font-relative-size . -2 ) (music "accidentals--1")))
3151 \property Staff.instrument = #`((kern . 0.5) (lines
3152 "2 Clarinetti" (columns " (B" ,text-flat ")")))
3160 When you put a name on a grand staff or piano staff the width of the
3161 brace is not taken into account. You must add extra spaces to the end of
3162 the name to avoid a collision.
3165 @subsection Transpose
3167 @cindex transposition of pitches
3168 @cindex @code{\transpose}
3170 A music expression can be transposed with @code{\transpose}. The syntax
3173 \transpose @var{pitch} @var{musicexpr}
3176 This means that middle C in @var{musicexpr} is transposed to
3179 @code{\transpose} distinguishes between enharmonic pitches: both
3180 @code{\transpose cis'} or @code{\transpose des'} will transpose up half
3181 a tone. The first version will print sharps and the second version
3184 @lilypond[singleline, verbatim]
3185 mus =\notes { \key e \major c d e f }
3186 \score { \notes \context Staff {
3189 \transpose des'' \mus
3190 \transpose cis'' \mus
3194 If you want to use both @code{\transpose} and @code{\relative}, then
3195 you must use @code{\transpose} first. @code{\relative} will have no
3196 effect music that appears inside a @code{\transpose}.
3198 @c . {Multi measure rests}
3199 @node Multi measure rests
3200 @subsection Multi measure rests
3201 @cindex Multi measure rests
3205 Multi measure rests are entered using `@code{R}'. It is specifically
3206 meant for full bar rests and for entering parts: the rest can expand to
3208 rests, or it can be printed as a single multimeasure rest This expansion
3209 is controlled by the property @code{Score.skipBars}. If this is set to true,
3210 Lily will not expand empty measures, and the appropriate number is added
3213 @lilypond[fragment,verbatim]
3214 \time 3/4 r2. | R2. | R2.*2
3215 \property Score.skipBars = ##t R2.*17 R2.*4
3218 Notice that the @code{R2.} is printed as a whole rest, centered in the
3221 @cindex whole rests for a full measure
3223 The grob for this object is @internalsref{MultiMeasureRest}.
3227 Currently, there is no way to automatically condense multiple rests
3228 into a single multimeasure rest. Multi measure rests do not take part
3231 @cindex condensing rests
3233 @node Automatic part combining
3234 @subsection Automatic part combining
3235 @cindex automatic part combining
3236 @cindex part combiner
3239 Automatic part combining is used to merge two parts of music onto a
3240 staff in an intelligent way. It is aimed primarily at typesetting
3241 orchestral scores. When the two parts are identical for a period of
3242 time, only one is shown. In places where the two parts differ, they
3243 are typeset as separate voices, and stem directions are set
3244 automatically. Also, solo and @emph{a due} parts can be identified
3247 The syntax for part combining is
3250 \partcombine @var{context} @var{musicexpr1} @var{musicexpr2}
3252 where the pieces of music @var{musicexpr1} and @var{musicexpr2} will be
3253 combined into one context of type @var{context}. The music expressions
3254 must be interpreted by contexts whose names should start with @code{one}
3257 The most useful function of the part combiner is to combine parts into
3258 one voice, as common for wind parts in orchestral scores:
3260 @lilypond[verbatim,singleline,fragment]
3262 \context Voice=one \partcombine Voice
3263 \context Thread=one \relative c'' {
3266 \context Thread=two \relative c'' {
3272 Notice that the first @code{g} appears only once, although it was
3273 specified twice (once in each part). Stem, slur and tie directions are
3274 set automatically, depending whether there is a solo or unisono. The
3275 first part (with context called @code{one}) always gets up stems, and
3276 `solo', while the second (called @code{two}) always gets down stems and
3279 If you just want the merging parts, and not the textual markings, you
3280 may set the property @var{soloADue} to false.
3282 @lilypond[verbatim,singleline,fragment]
3284 \property Staff.soloADue = ##f
3285 \context Voice=one \partcombine Voice
3286 \context Thread=one \relative c'' {
3289 \context Thread=two \relative c'' {
3295 There are a number of other properties that you can use to tweak the
3296 behavior of part combining, refer to the automatically generated
3297 documentation of @reng{Thread_devnull_engraver} and
3298 @reng{Voice_devnull_engraver}. Look at the documentation of the
3299 responsible engravers, @code{Thread_devnull_engraver},
3300 @code{Voice_devnull_engraver} and @code{A2_engraver}.
3304 In @code{soloADue} mode, when the two voices play the same notes on and
3305 off, the part combiner may typeset @code{a2} more than once in a
3308 @lilypond[fragment,singleline]
3310 \context Voice=one \partcombine Voice
3311 \context Thread=one \relative c'' {
3314 \context Thread=two \relative c'' {
3320 @cindex @code{Thread_devnull_engraver}
3321 @cindex @code{Voice_engraver}
3322 @cindex @code{A2_engraver}
3324 @node Hara kiri staves
3325 @subsection Hara kiri staves
3327 In orchestral scores, staff lines that only have rests are usually removed.
3328 This saves some space. LilyPond also supports this through the hara
3329 kiri@footnote{Hara kiri, also called Seppuku, is the ritual suicide of
3330 the Japanese Samourai warriors.} staff. This staff commits suicide when
3331 it finds itself to be empty after the line-breaking process. It will
3332 not disappear when it contains normal rests, you must use multi measure
3335 The hara kiri staff is specialized version of the @internalsref{Staff}
3336 context. It is available as the context identifier
3337 @code{\HaraKiriStaffContext}. Observe how the second staff in this
3338 example disappears in the second line.
3342 \notes \relative c' <
3343 \context Staff = SA { e4 f g a \break c1 }
3344 \context Staff = SB { c4 d e f \break R1 }
3348 \translator { \HaraKiriStaffContext }
3354 @node Sound output for transposing instruments
3355 @subsection Sound output for transposing instruments
3357 When you want to make a MIDI file from a score containing transposed
3358 and untransposed instruments, you have to instruct LilyPond the pitch
3359 offset (in semitones) for the transposed instruments. This is done
3360 using the @code{transposing} property. It does not affect printed
3363 @cindex @code{transposing}
3366 \property Staff.instrument = #"Cl. in B-flat"
3367 \property Staff.transposing = #-2
3373 @node Ancient notation
3374 @section Ancient notation
3377 * Ancient note heads::
3384 @node Ancient note heads
3385 @subsection Ancient note heads
3387 To get a longa note head, you have to use mensural note heads. This
3388 is accomplished by setting the @code{style} property of the
3389 NoteHead grob to @code{mensural}. There is also a note head style
3390 @code{baroque} which gives mensural note heads for @code{\longa} and
3391 @code{\breve} but standard note heads for shorter notes.
3393 @lilypond[fragment,singleline,verbatim]
3394 \property Voice.NoteHead \set #'style = #'mensural
3395 \property Voice.NoteHead \set #'font-family = #'ancient
3400 @subsection Custodes
3405 A @emph{custos} (plural: @emph{custodes}; latin word for `guard') is a
3406 staff context symbol that appears at the end of a staff line. It
3407 anticipates the pitch of the first note(s) of the following line and
3408 thus helps the player or singer to manage line breaks during
3409 performance, thus enhancing readability of a score.
3414 \property Staff.Custos \set #'style = #'mensural
3419 \consists Custos_engraver
3425 Custodes were frequently used in music notation until the 17th century.
3426 There were different appearances for different notation styles.
3427 Nowadays, they have survived only in special forms of musical notation
3428 such as via the @emph{editio vaticana} dating back to the beginning of
3431 For typesetting custodes, just put a @code{Custos_engraver} into the
3432 @internalsref{Staff} context when declaring the @code{\paper} block. In this
3433 block, you can also globally control the appearance of the custos symbol
3434 by setting the custos @code{style} property. Currently supported styles
3435 are @code{vaticana}, @code{medicaea}, @code{hufnagel} and
3442 \consists Custos_engraver
3443 Custos \override #'style = #'mensural
3448 The property can also be set locally, for example in a @code{\notes}
3453 \property Staff.Custos \override #'style = #'vaticana
3454 c'1 d' e' d' \break c' d' e' d'
3459 @subsection Ancient clefs
3461 LilyPond supports a variety of clefs, many of them ancient. These can
3462 be selected from the @code{ancient} font family, by setting
3463 @code{Staff.clefGlyph}) to one of the following values
3472 @item clefs-vaticana_do
3473 Editio Vaticana style do clef
3474 @item clefs-vaticana_fa
3475 Editio Vaticana style fa clef
3476 @item clefs-medicaea_do
3477 Editio Medicaea style do clef
3478 @item clefs-medicaea_fa
3479 Editio Medicaea style fa clef
3480 @item clefs-mensural1_c
3481 modern style mensural C clef
3482 @item clefs-mensural2_c
3483 historic style small mensural C clef
3484 @item clefs-mensural3_c
3485 historic style big mensural C clef
3486 @item clefs-mensural1_f
3487 historic style traditional mensural F clef
3488 @item clefs-mensural2_f
3489 historic style new mensural F clef
3490 @item clefs-mensural_g
3491 historic style mensural G clef
3492 @item clefs-hufnagel_do
3493 historic style hufnagel do clef
3494 @item clefs-hufnagel_fa
3495 historic style hufnagel fa clef
3496 @item clefs-hufnagel_do_fa
3497 historic style hufnagel combined do/fa clef
3498 @item clefs-percussion
3499 modern style percussion clef
3502 @emph{Modern style} means ``as is typeset in current editions.''
3503 @emph{Historic style} means ``as was typeset or written in contemporary
3504 historic editions''. @emph{Editio XXX style} means ``as is/was printed in
3507 @cindex Vaticana, Editio
3508 @cindex Medicaea, Editio
3509 @cindex hufnagel clefs
3513 @subsection Figured bass
3515 @cindex Basso continuo
3517 LilyPond has limited support for figured bass:
3519 @lilypond[verbatim,fragment]
3521 \context FiguredBass
3526 \context Voice { c4 g8 }
3530 The support for figured bass consists of two parts: there is an input
3531 mode, introduced by @code{\figures}, where you can enter bass figures
3532 as numbers, and there is a context called @internalsref{FiguredBass}
3533 that takes care of making @internalsref{BassFigure} grobs.
3535 In figures input mode, a group of bass figures is delimited by
3536 @code{<} and @code{>}. The duration is entered after the @code{>}.
3541 \context FiguredBass
3545 Accidentals are added to the numbers if you alterate them by
3546 appending @code{-}, @code{!} and @code{+}.
3552 \context FiguredBass
3553 \figures { <4- 6+ 7!> }
3556 Spaces or dashes may be inserted by using @code{_}. Brackets are
3557 introduced with @code{[} and @code{]}.
3563 \context FiguredBass
3564 \figures { < [4 6] 8 [_ 12]> }
3567 Although the support for figured bass may superficially resemble chord
3568 support, it works much simpler: in figured bass simply stores the
3569 numbers, and then prints the numbers you entered. There is no
3570 conversion to pitches, and no realizations of the bass are played in
3574 @c . {Tuning output}
3576 @section Tuning output
3578 LilyPond tries to take as much formatting as possible out of your
3579 hands. Nevertheless, there are situations where it needs some help, or
3580 where you want to override its decisions. In this section we discuss
3581 ways to do just that.
3583 Formatting is internally done by manipulating so called grobs (graphic
3584 objects). Each grob carries with it a set of properties (grob
3585 properties) specific to that object. For example, a stem grob has
3586 properties that specify its direction, length and thickness.
3588 The most direct way of tuning the output is by altering the values of
3589 these properties. There are two ways of doing that: first, you can
3590 temporarily change the definition of a certain type of grob, thus
3591 affecting a whole set of objects. Second, you can select one specific
3592 object, and set a grob property in that object.
3595 * Tuning groups of grobs ::
3596 * Tuning per grob ::
3602 @node Tuning groups of grobs
3603 @subsection Tuning groups of grobs
3605 @cindex grob description
3609 A grob definition is a Scheme association list, that is stored in a
3610 context property. By assigning to that property (using plain
3611 @code{\property}), you can change the resulting grobs.
3613 @lilypond[verbatim, fragment]
3614 c'4 \property Voice.Stem = #'()
3617 The @code{\property} assignment effectively empties the definition of
3618 the Stem object. One of the effects is that the recipe of how it should be
3619 printed is erased, with the effect of rendering it invisible. The above
3620 assignment is available as a standard identifier, for the case that you
3624 \property Voice.Stem = \turnOff
3631 This mechanism is fairly crude, since you can only set, but not modify,
3632 the definition of a grob. For this reason, there is a more advanced
3635 The definition of a grob is actually a list of default grob
3636 properties. For example, the definition of the Stem grob (available in
3637 @file{scm/grob-description.scm}), defines the following values for
3642 (beamed-lengths . (0.0 2.5 2.0 1.5))
3643 (Y-extent-callback . ,Stem::height)
3647 You can add a property on top of the existing definition, or remove a
3648 property, thus overriding the system defaults:
3650 c'4 \property Voice.Stem \override #'thickness = #4.0
3651 c'4 \property Voice.Stem \revert #'thickness
3654 You should balance @code{\override} and @code{\revert}. If that's too
3655 much work, you can use the @code{\set} shorthand. It performs a revert
3656 followed by an override. The following example gives exactly the same
3657 result as the previous one.
3659 c'4 \property Voice.Stem \set #'thickness = #4.0
3660 c'4 \property Voice.Stem \set #'thickness = #0.8
3663 If you use @code{\set}, you must explicitly restore the default.
3666 Formally the syntax for these constructions is
3668 \property @var{context}.@var{grobname} \override @var{symbol} = @var{value}
3669 \property @var{context}.@var{grobname} \set @var{symbol} = @var{value}
3670 \property @var{context}.@var{grobname} \revert @var{symbol}
3672 Here @var{symbol} is a Scheme expression of symbol type, @var{context}
3673 and @var{grobname} are strings and @var{value} is a Scheme expression.
3676 If you revert a setting which was not set in the first place, then it
3677 has no effect. However, if the setting was set as a system default, it
3678 may remove the default value, and this may give surprising results,
3679 including crashes. In other words, @code{\override} and @code{\revert},
3680 must be carefully balanced.
3682 These are examples of correct nesting of @code{\override}, @code{\set},
3685 A clumsy but correct form:
3687 \override \revert \override \revert \override \revert
3690 Shorter version of the same:
3692 \override \set \set \revert
3695 A short form, using only @code{\set}. This requires you to know the
3698 \set \set \set \set @var{to default value}
3701 If there is no default (i.e. by default, the grob property is unset),
3704 \set \set \set \revert
3707 For the digirati, the grob description is an Scheme association
3708 list. Since a Scheme list is a singly linked list, we can treat it as a
3709 stack, and @code{\override} and @code{\revert} are just push and pop
3710 operations. This pushing and popping is also used for overriding
3711 automatic beaming settings.
3715 LilyPond will hang or crash if @var{value} contains cyclic references.
3716 The backend is not very strict in type-checking grob properties. If you
3717 @code{\revert} properties that are expected to be set by default,
3721 @cindex adjusting staff symbol
3722 @cindex StaffSymbol, using \property
3723 @cindex staff lines, setting number of
3725 Some grobs are created at the moment that their context is created. An
3726 example of such a grob is the staff itself (i.e. the horizontal lines).
3727 You can not change the appearance of the staff symbol by manipulating
3728 @code{\property Staff.StaffSymbol}. At the moment that @code{\property
3729 Staff} is interpreted, a Staff context is made, and the StaffSymbol is
3730 created before any @code{\override} is effective. You can deal with this
3731 either overriding properties in a @code{\translator} definition, or by
3732 using @code{\outputproperty}.
3737 @node Tuning per grob
3738 @subsection Tuning per grob
3740 @cindex \outputproperty
3742 A second way of tuning grobs is the more arcane @code{\outputproperty}
3743 feature. The syntax is as follows:
3745 \outputproperty @var{predicate} @var{symbol} = @var{value}
3747 Here @code{predicate} is a Scheme function taking a grob argument, and
3748 returning a boolean. This statement is processed by the
3749 @code{Output_property_engraver}. It instructs the engraver to feed all
3750 grobs that it sees to @var{predicate}. Whenever the predicate returns
3751 true, the grob property @var{symbol} will be set to @var{value}.
3753 You will need to combine this statement with @code{\context} to select
3754 the appropriate context to apply this to.
3756 Here are some random examples.
3759 In the following example, all note heads occurring at current staff
3760 level, are shifted up and right by setting their @code{extra-offset}
3763 @lilypond[fragment,verbatim,singleline]
3765 \context Staff \outputproperty
3766 #(make-type-checker 'note-head-interface)
3767 #'extra-offset = #'(0.5 . 0.75)
3771 @cindex @code{extra-offset}
3773 In this example, the predicate checks the @code{text} grob property, to
3774 shift only the `m.d.' text, but not the fingering instruction "2".
3775 @lilypond[verbatim,singleline]
3776 #(define (make-text-checker text)
3777 (lambda (grob) (equal? text (ly-get-grob-property grob 'text))))
3780 \notes\relative c''' {
3781 \property Voice.Stem \set #'direction = #1
3782 \outputproperty #(make-text-checker "m.d.")
3783 #'extra-offset = #'(-3.5 . -4.5)
3791 If possible, avoid this feature: the semantics are not very clean, and
3792 the syntax and semantics are up for rewrite.
3797 @node Font selection
3798 @subsection Font selection
3800 Most graphics in LilyPond are composed of characters of fonts. You can
3801 alter the characteristics of the font by setting certain grob
3802 properties. The mechanism that is used for this resembles La@TeX{}'s New
3803 Font Selection Scheme. Within this scheme, a font is entirely
3804 characterized by its font name.
3806 For each grob that uses fonts (in other words, each grob that supports
3807 @code{font-interface}) a font-name must be selected before it can be
3808 printed. The font name is selected by looking at a number of grob
3813 A symbol indicating the general class of the typeface. Supported are
3814 @code{roman} (Computer Modern), @code{braces} (for piano staff
3815 braces), @code{music} (the standard music font), @code{ancient} (the
3816 ancient notation font) @code{dynamic} (font for dynamic signs) and
3820 A symbol indicating the shape of the font, there are typically several
3821 font shapes available for each font family. Choices are @code{italic},
3822 @code{caps} and @code{upright}
3825 A symbol indicating the series of the font. There are typically several
3826 font series for each font family and shape. Choices are @code{medium}
3829 @item font-relative-size
3830 A number indicating the size relative the standard size. For example,
3831 with 20pt staff height, relative size -1 corresponds to 16pt staff
3832 height, and relative size +1 corresponds to 23 pt staff height.
3834 @item font-design-size
3835 A number indicating the design size of the font.
3837 This is a feature of the Computer Modern Font: each point size has a
3838 slightly different design. Smaller design sizes are relatively wider,
3839 which enhances readability.
3842 The name of the font, as a string, e.g. @code{"cmr12"}. This overrides
3843 all other font-qualifiers.
3844 You may use this to use special fonts, which are not a part of the
3845 style sheet, or which have special encodings.
3850 The font is selected by taking the first font that satisfies all
3851 qualifiers specified. You can override any of these fields through
3852 @code{\override} and @code{\revert}. The special value @code{*} matches
3853 any value for that qualifier. The value @code{*} is needed to
3854 override default settings which are always present.
3857 \property Lyrics.LyricText \override #'font-series = #'bold
3858 \property Lyrics.LyricText \override #'font-shape = #'*
3861 @cindex @code{font-style}
3863 There are also pre-cooked font selection qualifiers. These are selected
3864 through the grob property @code{font-style}. For example, the style
3865 @code{finger} selects family @code{number} and relative size @code{-3}.
3866 Styles available include @code{volta}, @code{finger}, @code{tuplet},
3867 @code{timesig}, @code{mmrest}, @code{script}, @code{large}, @code{Large}
3870 The style sheets and tables for selecting fonts are located in
3871 @file{scm/font.scm}. Refer to this file for more information.
3873 The size of the font may be scaled with the grob property
3874 @code{font-magnification}. For example, @code{2.0} blows up all
3875 letters by a factor 2 in both directions.
3879 Relative size is not linked to any real size.
3881 There is no style sheet provided for other fonts besides the @TeX{}
3882 family, and the style sheet can not be modified easiyl.
3884 @cindex font selection
3885 @cindex font magnification
3886 @cindex @code{font-interface}
3890 @subsection Text markup
3894 LilyPond has an internal mechanism to typeset texts. You can
3895 form text markup expressions by composing scheme expressions
3896 in the following way.
3898 @lilypond[verbatim, singleline]
3903 c^#'(italic "italic")
3904 d_#'((bold italic) "ff")
3906 f_#'(lines "one" (bold "two"))
3907 g^#'(music "noteheads-2" ((raise . 2.4) "flags-u3"))
3911 Normally, the Scheme markup text is stored in the @code{text} property
3912 of a grob. Formally, it is defined as follows:
3915 text: string | (head? text+)
3916 head: markup | (markup+)
3917 markup-item: property | abbrev
3918 property: (@var{key} . @var{value})
3919 abbrev: @code{columns lines roman music bold italic named super sub}
3920 @code{overstrike text finger volta timesig mmrest mark script}
3921 @code{large Large dynamic}
3924 The markup is broken down and converted into a list of grob properties,
3925 which are prepended to the property list. The @var{key}-@var{value}
3926 pair is a grob property. A list of properties available is included in
3927 the generated documentation for @rint{Text_interface}.
3929 The following abbreviations are defined:
3932 horizontal mode: set all text on one line (default)
3934 vertical mode: set every text on a new line
3938 selects the Feta font (the standard font for music notation glyphs),
3939 and uses named lookup
3946 lookup by character name
3948 plain text lookup (by character value)
3954 the next text or character overstrikes this one
3956 select fingering number fontstyle
3958 select volta number fontstyle
3960 select time signature number fontstyle
3962 select multi measure rest number fontstyle
3964 select mark number fontstyle
3966 select scriptsize roman fontstyle
3968 select large roman fontstyle
3970 select Large roman fontstyle
3972 select dynamics fontstyle
3976 @cindex metronome mark
3978 One practical application of complicated markup is to fake a metronome
3982 #(define note '(columns
3983 (music "noteheads-2" ((kern . -0.1) "flags-stem"))))
3984 #(define eight-note `(columns ,note ((kern . -0.1)
3985 (music ((raise . 3.5) "flags-u3")))))
3986 #(define dotted-eight-note
3987 `(columns ,eight-note (music "dots-dot")))
3990 \notes\relative c'' {
3991 a1^#`((columns (font-relative-size . -1)) ,dotted-eight-note " = 64")
3997 TextScript \override #'font-shape = #'upright
4005 The syntax and semantics of markup texts are not clean, and both
4006 syntax and semantics are slated for a rewrite.
4013 TODO: Move this section.
4018 Generating optically pleasing spacing is black magic. LilyPond tries
4019 to deal with a number of frequent cases. Here is an example that is
4020 not handled correctly, due to the combination of chord collisions and
4025 \context PianoStaff \notes \transpose c''' <
4026 \context Staff = up { s1 }
4027 \context Staff = down { [c8 c \translator Staff=up <c d> c
4028 \translator Staff=down c c c] }
4030 \paper { linewidth = -1 }
4034 The spacing algorithm is global: it searches the entire score for the
4035 shortest notes. Pieces that have major changes in duration density
4036 (eg. due to meter changes) will be printed in a uniform density, which
4041 @section Page layout
4044 The page layout is the combined product of LilyPond formatting notation,
4045 and (La)@TeX{} putting the notation on a page, including page breaks.
4046 The part of LilyPond is documented here.
4059 @subsection Paper block
4062 The most important output definition is the @code{\paper} block, for
4063 music notation. The syntax is
4066 @code{\paper @{} [@var{paperidentifier}] @var{items} @code{@}}
4069 where each of the items is one of
4072 @item An assignment.
4074 @item A context definition. See @ref{Interpretation context} for
4075 more information on context definitions.
4078 @c . {Paper variables}
4079 @node Paper variables
4080 @subsection Paper variables
4081 @cindex Paper variables
4083 The paper block has some variables you may want to use or change:
4086 @cindex @code{indent}
4088 The indentation of the first line of music.
4089 @cindex @code{staffspace}
4091 @item @code{staffspace}
4092 The distance between two staff lines, calculated from the center
4095 @cindex @code{linewidth}
4096 @item @code{linewidth}
4097 Sets the width of the lines.
4099 If set to a negative value, a single unjustified line is produced.
4100 @c rename to singleLinePaper ?
4101 The shorthand @code{\singleLine} defines a default paper block that
4102 produces a single line.
4104 @cindex @code{textheight}
4106 @item @code{textheight}
4107 Sets the total height of the music on each page. Only used by
4110 @cindex @code{interscoreline}
4112 @item @code{interscoreline}
4113 Sets the spacing between systems. The default is 16pt.
4115 @cindex @code{interscorelinefill}
4117 @item @code{interscorelinefill}
4118 If set to a positive number, the distance between the score
4119 lines will stretch in order to fill the full page. In that
4120 case @code{interscoreline} specifies the minimum spacing.
4125 @cindex @code{stafflinethickness}
4127 @item @code{stafflinethickness}
4128 Determines the thickness of staff lines, and also acts as a scaling
4129 parameter for other line thicknesses.
4132 You may enter these dimension using units (@code{cm}, @code{in},
4133 @code{mm}, @code{pt})
4135 linewidth = 20.0 * \staffspace
4142 @subsection Font size
4143 @cindex font size, setting
4144 @cindex staff size, setting
4145 @cindex @code{paper} file
4147 The Feta font provides musical symbols at six different sizes. These
4148 fonts are 11 point, 13 point, 16 point, 20 point, 23 point, and 26
4149 point. The point size of a font is the height of the five lines in a
4150 staff when displayed in the font.
4152 Definitions for these sizes are the files @file{paperSZ.ly}, where
4153 @code{SZ} is one of 11, 13, 16, 20, 23 and 26. If you include any of
4154 these files, the identifiers @code{paperEleven}, @code{paperThirteen},
4155 @code{paperSixteen}, @code{paperTwenty}, @code{paperTwentythree}, and
4156 @code{paperTwentysix} are defined respectively. The default
4157 @code{\paper} block is also set. These files should be imported at toplevel, i.e.
4159 \include "paper26.ly"
4163 The font definitions are generated using a Scheme function. For more
4164 details, see the file @file{scm/font.scm}.
4170 @subsection Paper size
4175 @cindex @code{papersize}
4177 To change the paper size, you must first set the
4178 @code{papersize} paper variable variable. Set it to
4179 the strings @code{a4}, @code{letter}, or @code{legal}. After this
4180 specification, you must set the font as described above. If you want
4181 the default font, then use the 20 point font.
4184 \paper@{ papersize = "a4" @}
4185 \include "paper16.ly"
4188 The file @code{paper16.ly} will now include a file named @file{a4.ly}, which
4189 will set the paper variables @code{hsize} and @code{vsize} (used by
4190 Lilypond and @code{ly2dvi})
4194 @subsection Line break
4197 @cindex breaking lines
4199 Line breaks are normally computed automatically. They are chosen such
4200 that it looks neither cramped nor loose, and that consecutive lines have
4203 Occasionally you might want to override the automatic breaks; you can
4204 do this by specifying @code{\break}. This will force a line break at
4205 this point. Line breaks can only occur at places where there are bar
4206 lines. If you want to have a line break where there is no bar line,
4207 you can force an invisible bar line by entering @code{\bar
4208 ""}. Similarly, @code{\noBreak} forbids a line break at a certain
4211 If you want linebreaks at regular intervals, you can use the following:
4213 < \repeat 7 unfold @{ s1 * 4 \break @}
4217 This makes the following 28 measures (assuming 4/4 time) be broken every
4222 @subsection Page break
4225 @cindex breaking pages
4227 Page breaks are normally computed by @TeX{}, so they are not under
4228 direct control of LilyPond. However, you can insert a commands into
4229 the @file{.tex} output to instruct @TeX{} where to break pages. You
4230 can insert a @code{\newpage} from within lilypond. This is done by
4231 setting the @code{between-systems-strings} on the
4232 @internalsref{NonMusicalPaperColumn} where the system is broken.
4238 There is no mechanism to select magnification of particular fonts,
4239 meaning that you don't have access to continuously scaled fonts.
4243 @c . {Output formats}
4244 @node Output formats
4245 @section Output formats
4247 LilyPond can output processed music in different output formats.
4251 * PostScript output::
4253 * ASCIIScript output::
4258 @subsection @TeX{} output
4259 @cindex @TeX{} output
4261 LilyPond will use @TeX{} by default. Even if you want to produce
4262 PostScript output for viewing or printing, you should normally have
4263 LilyPond produce @TeX{} first. The .tex output must be processed by
4264 @TeX{} (@strong{not} La@TeX{}) to generate a .dvi. Then, @file{Dvips}
4265 is used to generate PostScript. Alternatively, @file{ly2dvi} can be
4266 used to generate the .dvi for you.
4270 Titling is not generated unless you use @file{ly2dvi}.
4273 @node PostScript output
4274 @subsection PostScript output
4275 @cindex PostScript output
4276 @cindex direct PostScript output
4278 LilyPond can produce PostScript directly, without going through @TeX{}.
4279 Currently, this is mainly useful if you cannot use TeX, because direct
4280 PostScript output has some problems; see Bugs below.
4283 $ lilypond -fps foo.ly
4284 GNU LilyPond 1.3.144
4285 Now processing: `foo.ly'
4287 Interpreting music...[3]
4288 Preprocessing elements...
4289 Calculating column positions...
4290 paper output to foo.ps...
4292 $ cat /usr/share/lilypond/pfa/feta20.pfa foo.ps | lpr
4298 Text font selection is broken.
4300 The .ps file does not contain the .pfa font files. To print a .ps
4301 created through direct postscript output, you should prepend the
4302 necessary .pfa files to LilyPond's .ps output, or upload them to the
4303 printer before printing.
4305 The line height calculation is broken, you must set @var{lineheight} in
4306 the paperblock if you have more than one staff in your score, e.g.
4311 % Set line height to 40 staff spaces
4317 @subsection Scheme output
4318 @cindex Scheme output
4320 In the typesetting stage, LilyPond builds a page description, which is
4321 then written to disk in postscript, @TeX{} or ASCII art. Before it is
4322 written, the page description is represented as Scheme expressions. You
4323 can also dump these Scheme expressions to a file, which may be
4324 convenient for debugging output routines. This is done with the Scheme
4328 $ lilypond -fscm foo.ly
4329 GNU LilyPond 1.3.144
4330 Now processing: `foo.ly'
4332 Interpreting music...[3]
4333 Preprocessing elements...
4334 Calculating column positions...
4335 paper output to foo.scm...
4338 ;;; Usage: guile -s x.scm > x.tex
4339 (primitive-load-path 'standalone.scm)
4343 $ guile -s foo.scm > foo.tex
4347 @node ASCIIScript output
4348 @subsection ASCIIScript output
4349 @cindex ASCIIScript output
4350 @cindex ascii script
4353 LilyPond can output ASCII Art. This is a two step process, LilyPond
4354 produces an ASCII description file, dubbed ASCIIScript (extension
4355 @file{.as}). ASCIIScript has a small and simple command set that
4356 includes font selection, character and string printing and line drawing
4357 commands. The program @file{as2text} is used to translate an .as file
4360 To produce ASCII Art, you must include an ASCII Art paper definition
4361 file in your .ly, one of:
4363 \include "paper-as5.ly"
4364 \include "paper-as9.ly"
4367 Here's an example use for ASCII Art output (the example file
4368 @file{as-email.ly} is included in the LilyPond distribution), the staff
4369 symbol has been made invisible:
4372 $ lilypond -fas as-email.ly
4373 GNU LilyPond 1.3.144
4374 Now processing: `as-email.ly'
4376 Interpreting music...[3]
4377 Preprocessing elements...
4378 Calculating column positions... [2]
4379 paper output to as-email.as...
4381 $ as2text as-email.as 2>/dev/null
4383 |/ |##|##| | | | | |
4384 /| | | | | |\ |\ |\ |\ |\ |
4385 / |_ 3 | | | | 5 | )| )| )| )| )|
4386 | /| \ 8 * * * | 8 * * * * * |
4396 The ASCII Art fonts are far from complete and not very well designed.
4397 It's easy to change the glyphs, though; if you think you can do better,
4398 have a look at @file{mf/*.af}.
4400 Lots of resizable symbols such as slurs, ties and tuplets are missing.
4402 The poor looks of most ASCII Art output and its limited general
4403 usefulness gives ASCII Art output a low priority; it may be
4404 dropped in future versions.
4408 @subsection Sketch output
4410 @uref{http://sketch.sourceforge.net,Sketch} is a Free vector drawing
4411 program. LilyPond includes bare bones output for Sketch version 0.7.
4414 @cindex vector drawing
4415 @cindex drawing program
4422 LilyPond can produce MIDI output. The performance lacks lots of
4423 interesting effects, such as swing, articulation, slurring, etc., but it
4424 is good enough for proof-hearing the music you have entered. Ties,
4425 dynamics and tempo changes are interpreted.
4427 Dynamic marks, crescendi and decrescendi translate into MIDI volume
4428 levels. Dynamic marks translate to a fixed fraction of the available
4429 MIDI volume range, crescendi and decrescendi make the the volume vary
4430 linearly between their two extremities. The fractions be adjusted by
4431 overriding the @code{absolute-volume-alist} defined in
4432 @file{scm/midi.scm}.
4434 For each type of musical instrument (that MIDI supports), a volume range
4435 can be defined. This gives you basic equalizer control, which can
4436 enhance the quality of the MIDI output remarkably. You can add
4437 instruments and ranges or change the default settings by overriding the
4438 @code{instrument-equalizer-alist} defined in @file{scm/midi.scm}.
4440 Both loudness controls are combined to produce the final MIDI volume.
4446 * MIDI instrument names::
4451 @subsection MIDI block
4455 The MIDI block is analogous to the paper block, but it is somewhat
4456 simpler. The @code{\midi} block can contain:
4460 @item a @code{\tempo} definition
4461 @item context definitions
4464 Assignments in the @code{\midi} block are not allowed.
4468 @cindex context definition
4470 Context definitions follow precisely the same syntax as within the
4471 \paper block. Translation modules for sound are called performers.
4472 The contexts for MIDI output are defined in @file{ly/performer-init.ly}.
4475 @node MIDI instrument names
4476 @subsection MIDI instrument names
4478 @cindex instrument names
4479 @cindex @code{Staff.midiInstrument}
4480 @cindex @code{Staff.instrument}
4482 The MIDI instrument name is set by the @code{Staff.midiInstrument}
4483 property or, if that property is not set, the @code{Staff.instrument}
4484 property. The instrument name should be chosen from the list in
4485 @ref{MIDI instruments}.
4489 If the selected string does not exactly match, then LilyPond uses the
4490 default (Grand Piano). It is not possible to select an instrument by