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,26pt]
441 \notes { c'2 e'4 f' | g'1 }
442 \paper { \translator { \EasyNotation } }
446 Note that @code{EasyNotation} overrides a @internalsref{Score} context. You
447 probably will want to print it with magnification or a large font size to make it more
454 If you view the result with Xdvi, then staff lines will show through
455 the letters. Printing the postscript file obtained with ly2dvi does
456 produce the correct result.
459 @node Easier music entry
460 @section Easier music entry
466 * Skipping corrected music::
469 When entering music with LilyPond, it is easy to introduce errors. This
470 section deals with tricks and features that help you enter music, and
471 find and correct mistakes.
474 @node Relative octaves
475 @subsection Relative octaves
477 @cindex relative octave specification
479 Octaves are specified by adding @code{'} and @code{,} to pitch names.
480 When you copy existing music, it is easy to accidentally put a pitch in
481 the wrong octave and hard to find such an error. To prevent these
482 errors, LilyPond features octave entry.
484 @cindex @code{\relative}
486 \relative @var{startpitch} @var{musicexpr}
489 The octave of notes that appear in @var{musicexpr} are calculated as
490 follows: If no octave changing marks are used, the basic interval
491 between this and the last note is always taken to be a fourth or less
492 (This distance is determined without regarding alterations; a
493 @code{fisis} following a @code{ceses} will be put above the
496 The octave changing marks @code{'} and @code{,} can be added to raise or
497 lower the pitch by an extra octave. Upon entering relative mode, an
498 absolute starting pitch must be specified that will act as the
499 predecessor of the first note of @var{musicexpr}.
501 Entering music that changes octave frequently is easy in relative mode.
502 @lilypond[fragment,singleline,verbatim,center]
508 And octave changing marks are used for intervals greater than a fourth.
509 @lilypond[fragment,verbatim,center]
514 If the preceding item is a chord, the first note of the chord is used
515 to determine the first note of the next chord. However, other notes
516 within the second chord are determined by looking at the immediately
519 @lilypond[fragment,verbatim,center]
526 @cindex @code{\notes}
528 The pitch after the @code{\relative} contains a note name. To parse
529 the pitch as a note name, you have to be in note mode, so there must
530 be a surrounding @code{\notes} keyword (which is not
533 The relative conversion will not affect @code{\transpose},
534 @code{\chords} or @code{\relative} sections in its argument. If you
535 want to use relative within transposed music, you must place an
536 additional @code{\relative} inside the @code{\transpose}.
541 @subsection Bar check
545 @cindex @code{barCheckSynchronize}
549 Whenever a bar check is encountered during interpretation, a warning
550 message is issued if it doesn't fall at a measure boundary. This can
551 help you find errors in the input. Depending on the value of
552 @code{barCheckSynchronize}, the beginning of the measure will be
553 relocated, so this can also be used to shorten measures.
555 A bar check is entered using the bar symbol, @code{|}:
557 \time 3/4 c2 e4 | g2.
562 @cindex skipTypesetting
564 Failed bar checks are most often caused by entering incorrect
565 durations. Incorrect durations often completely garble up the score,
566 especially if it is polyphonic, so you should start correcting the score
567 by scanning for failed bar checks and incorrect durations. To speed up
568 this process, you can use @code{skipTypesetting} (See @ref{Skipping
571 @c . {Point and click}
572 @node Point and click
573 @subsection Point and click
574 @cindex poind 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}.
591 @item An editor with a client/server interface (or a lightweight GUI editor).
593 @item Emacs. Emacs is an extensible text-editor. It is available from
594 @uref{http://www.gnu.org/software/emacs/}. You need version 21 to use
596 @item GVim. GVim is a lightweight GUI variant of VIM, the popular VI
597 clone. It is available from @uref{http://www.vim.org}.
598 @item NEdit. NEdit is a somewhat Windows like editor, that has recently
599 become Free Software. It is available from @uref{http://www.nedit.org}.
602 Xdvi must be configured to find the @TeX{} fonts and music
603 fonts. Refer to the Xdvi documentation for more information.
605 To use point-and-click, add one of these lines to the top of your .ly
608 #(set! point-and-click line-location)
610 @cindex line-location
612 When viewing, Control-Mousebutton 1 will take you to the originating
613 spot in the @file{.ly} file. Control-Mousebutton 2 will show all
618 In your emacs startup file (usually @file{~/.emacs}), add the following
623 Make sure that the environment variable @code{XEDITOR} is set to
625 emacsclient --no-wait +%l %f
629 If you use Emacs version 21, you can make emacs jump to the exact spot
630 (and not just the line) on a click. To use this feature, you must
631 enable column positioning. At the top of the @code{ly} file, replace
632 the @code{set!} line with the following line
634 #(set! point-and-click line-column-location)
636 @cindex line-colomn-location
637 Set @var{XEDITOR} to @code{emacsclient --no-wait +%l:%c %f}, or
638 use this argument with xdvi's @file{-editor} option.
640 If you correct large files with point-and-click, be sure to start
641 correcting at the end of the file. When you start at the top, and
642 insert one line, all following locations will be off by a line.
646 Set @var{XEDITOR} to @code{gvim +%l %f}, or
647 use this argument with xdvi's @code{-editor} option.
651 Set @var{XEDITOR} to @code{nc -noask +%l %f}, or
652 use this argument with xdvi's @code{-editor} option.
657 When you convert the @TeX{} file to PostScript using @code{dvips}, it
658 will complain about not finding @code{src:X:Y} files. These complaints
659 are harmless, and can be ignored.
661 @node Skipping corrected music
662 @subsection Skipping corrected music
664 The property @code{Score.skipTypesetting} can be used to switch on and
665 off typesetting completely during the interpretation phase. When
666 typesetting is switched off, the music is processed much more quickly.
667 You can use this to skip over the parts of a score that you have already
670 @lilypond[fragment,singleline,verbatim]
672 \property Score.skipTypesetting = ##t
674 \property Score.skipTypesetting = ##f
682 @section Staff notation
684 This section deals with music notation that occurs on staff level,
685 such as keys, clefs and time signatures.
687 @cindex Staff notation
699 @subsection Key signature
704 Setting or changing the key signature is done with the @code{\key}
707 @code{\key} @var{pitch} @var{type}
710 @cindex @code{\minor}
711 @cindex @code{\major}
712 @cindex @code{\minor}
713 @cindex @code{\ionian}
714 @cindex @code{\locrian}
715 @cindex @code{\aeolian}
716 @cindex @code{\mixolydian}
717 @cindex @code{\lydian}
718 @cindex @code{\phrygian}
719 @cindex @code{\dorian}
721 Here, @var{type} should be @code{\major} or @code{\minor} to get
722 @var{pitch}-major or @var{pitch}-minor, respectively.
723 The standard mode names @code{\ionian},
724 @code{\locrian}, @code{\aeolian}, @code{\mixolydian}, @code{\lydian},
725 @code{\phrygian}, and @code{\dorian} are also defined.
727 This command sets the context property @code{Staff.keySignature}.
728 Non-standard key signatures can be specified by setting this property
731 The printed signature is a @internalsref{KeySignature} grob, typically
732 created in @internalsref{Staff} context.
734 @cindex @code{keySignature}
741 The clef can be set or changed with the @code{\clef} command:
742 @lilypond[fragment,verbatim]
743 \key f\major c''2 \clef alto g'2
746 Supported clef-names include
747 @c Moved standard clefs to the top /MB
749 @item treble, violin, G, G2
758 G clef on 1st line, so-called French violin clef
773 By adding @code{_8} or @code{^8} to the clef name, the clef is
774 transposed one octave down or up, respectively. Note that you have to
775 enclose @var{clefname} in quotes if you use underscores or digits in the
781 The grob for this symbol is @internalsref{Clef}.
784 This command is equivalent to setting @code{clefGlyph},
785 @code{clefPosition} (which controls the Y position of the clef),
786 @code{centralCPosition} and @code{clefOctavation}. A clef is created
787 when any of these properties are changed.
790 @c . {Time signature}
792 @subsection Time signature
793 @cindex Time signature
797 The time signature is set or changed by the @code{\time}
799 @lilypond[fragment,verbatim]
800 \time 2/4 c'2 \time 3/4 c'2.
803 The actual symbol that's printed can be customized with the @code{style}
804 property. Setting it to @code{#'()} uses fraction style for 4/4 and
808 The grob for this symbol is @internalsref{TimeSignature}. There are
809 many more options for its layout. They are selected through the
810 @code{style} grob property. See @file{input/test/time.ly} for more
813 This command sets the property @code{timeSignatureFraction},
814 @code{beatLength} and @code{measureLength}. The property
815 @code{timeSignatureFraction} determine where bar lines should be
816 inserted, and how automatic beams should be generated. Changing the
817 value of @code{timeSignatureFraction} also causes a time signature
818 symbol to be printed.
825 @cindex partial measure
826 @cindex measure, partial
827 @cindex shorten measures
828 @cindex @code{\partial}
830 Partial measures, for example in upbeats, are entered using the
831 @code{\partial} command:
832 @lilypond[fragment,verbatim]
833 \partial 4* 5/16 c'16 c4 f16 a'2. ~ a'8. a'16 | g'1
836 The syntax for this command is
838 \partial @var{duration}
840 This is internally translated into
842 \property Score.measurePosition = -@var{length of duration}
845 The property @code{measurePosition} contains a rational number
846 indicating how much of the measure has passed at this point.
849 @node Unmetered music
850 @subsection Unmetered music
852 Bar lines and bar numbers are calculated automatically. For unmetered
853 music (e.g. cadenzas), this is not desirable. The commands
854 @code{\cadenzaOn} and @code{\cadenzaOff} can be used to switch off the
857 @lilypond[fragment,relative,singleline,verbatim]
865 The property @code{Score.timing} can be used to switch off this
870 @subsection Bar lines
874 @cindex measure lines
877 Bar lines are inserted automatically, but if you need a special type
878 of barline, you can force one using the @code{\bar} command:
879 @lilypond[fragment,verbatim] c4 \bar "|:" c4
882 The following bar types are available
883 @lilypond[fragment, relative, singleline, verbatim]
895 You are encouraged to use @code{\repeat} for repetitions. See
898 In scores with many staffs, the barlines are automatically placed at
899 top level, and they are connected between different staffs of a
900 @internalsref{StaffGroup}:
901 @lilypond[fragment, verbatim]
902 < \context StaffGroup <
903 \context Staff = up { e'4 d'
906 \context Staff = down { \clef bass c4 g e g } >
907 \context Staff = pedal { \clef bass c2 c2 } >
910 The grobs that are created at @internalsref{Staff} level. The name is
911 @internalsref{BarLine}.
913 The command @code{\bar @var{bartype}} is a short cut for
914 doing @code{\property Score.whichBar = @var{bartype}}
915 Whenever @code{whichBar} is set to a string, a bar line of that type is
916 created. @code{whichBar} is usually set automatically: at the start of
917 a measure it is set to @code{defaultBarType}. The contents of
918 @code{repeatCommands} is used to override default measure bars.
920 @code{whichBar} can also be set directly, using @code{\property} or
921 @code{\bar }. These settings take precedence over the automatic
922 @code{whichBar} settings.
925 @cindex Bar_line_engraver
927 @cindex repeatCommands
928 @cindex defaultBarType
937 The easiest way to enter such fragments with more than one voice on a
938 staff is to split chords using the separator @code{\\}. You can use
939 it for small, short-lived voices (make a chord of voices) or for
942 @lilypond[verbatim,fragment]
943 \context Voice = VA \relative c'' {
944 c4 < { f d e } \\ { b c2 } > c4 < g' \\ b, \\ f \\ d >
948 The separator causes @internalsref{Voice} contexts to be instantiated,
949 bearing the names @code{"1"}, @code{"2"}, etc.
951 Sometimes, it is necessary to instantiate these contexts by hand: For
952 Instantiate a separate Voice context for each part, and use
953 @code{\voiceOne}, up to @code{\voiceFour} to assign a stem directions
954 and horizontal shift for each part.
957 @lilypond[singleline, verbatim]
959 \context Staff < \context Voice = VA { \voiceOne cis2 b }
960 \context Voice = VB { \voiceThree b4 ais ~ ais4 gis4 }
961 \context Voice = VC { \voiceTwo fis4~ fis4 f ~ f } >
964 The identifiers @code{\voiceOne} to @code{\voiceFour} set directions
965 ties, slurs and stems, and set shift directions.
967 If you want more than four voices, you can also manually set
968 horizontal shifts and stem directions, as is shown in the following example:
969 @lilypond[fragment, verbatim]
970 \context Staff \notes\relative c''<
977 \context Voice=three {
978 \shiftOnn \stemUp ais
980 \context Voice=four {
981 \shiftOnnn \stemUp fis
987 Normally, note heads with a different number of dots are not merged, but
988 if you set the grob property @code{merge-differently-dotted}, they are:
989 @lilypond[verbatim,fragment,singleline]
992 \property Staff.NoteCollision \override
993 #'merge-differently-dotted = ##t
995 } \\ { [g'8. f16] [g'8. f'16] }
999 Similarly, you can merge half note heads with eighth notes, by setting
1000 @code{merge-differently-headed}:
1001 @lilypond[fragment, relative=2,verbatim]
1004 \property Staff.NoteCollision
1005 \override #'merge-differently-headed = ##t
1006 c8 c4. } \\ { c2 c2 } >
1009 LilyPond also vertically shifts rests that are opposite of a stem.
1011 @lilypond[singleline,fragment,verbatim]
1012 \context Voice < c''4 \\ r4 >
1015 See also @internalsref{NoteCollision} and @internalsref{RestCollision}
1019 Resolving collisions is a very intricate subject, and LilyPond only
1020 handles a few situations. When it can not cope, you are advised to use
1021 @code{force-hshift} of the @internalsref{NoteColumn} grob and pitched
1022 rests to override typesetting decisions.
1027 Beams are used to group short notes into chunks that are aligned with
1028 the metrum. They are inserted automatically in most cases.
1030 @lilypond[fragment,verbatim, relative=2]
1031 \time 2/4 c8 c c c \time 6/8 c c c c8. c16 c8
1034 If you're not satisfied with the automatic beaming, you can enter the
1035 beams explicitly. If you have beaming patterns that differ from the
1036 defaults, you can also set the patterns for automatic beamer.
1038 See also @internalsref{Beam}.
1041 @cindex Automatic beams
1042 @subsection Manual beams
1043 @cindex beams, manual
1047 In some cases it may be necessary to override LilyPond's automatic
1048 beaming algorithm. For example, the auto beamer will not beam over
1049 rests or bar lines, If you want that, specify the begin and end point
1050 manually using a @code{[} before the first beamed note and a @code{]}
1051 after the last note:
1053 @lilypond[fragment,relative,verbatim]
1055 r4 [r8 g' a r8] r8 [g | a] r8
1059 @cindex @code{stemLeftBeamCount}
1061 Normally, beaming patterns within a beam are determined automatically.
1062 When this mechanism fouls up, the properties
1063 @code{Voice.stemLeftBeamCount} and @code{Voice.stemRightBeamCount} can
1064 be used to control the beam subdivision on a stem. If you set either
1065 property, its value will be used only once, and then it is erased.
1067 @lilypond[fragment,relative,verbatim]
1070 [f8 r16 \property Voice.stemLeftBeamCount = #1 f g a]
1073 @cindex @code{stemRightBeamCount}
1076 The property @code{subdivideBeams} can be set in order to subdivide
1077 all 16th or shorter beams at beat positions. This accomplishes the
1078 same effect as twiddling with @code{stemLeftBeamCount} and
1079 @code{stemRightBeamCount}, but it take less typing.
1084 \property Voice.subdivideBeams = ##t
1086 [c32 c c c c c c c c c c c c c c c]
1087 \property Score.beatLength = #(make-moment 1 8)
1088 [c32 c c c c c c c c c c c c c c c]
1092 \notes \relative c' {
1094 \property Voice.subdivideBeams = ##t
1096 [c32 c c c c c c c c c c c c c c c]
1097 \property Score.beatLength = #(make-moment 1 8)
1098 [c32 c c c c c c c c c c c c c c c]
1102 @cindex subdivideBeams
1104 Kneed beams are inserted automatically, when a large gap between two
1105 adjacent beamed notes is detected. This behavior can be tuned through
1106 the grob property @code{auto-knee-gap}.
1108 @cindex beams, kneed
1110 @cindex auto-knee-gap
1114 @c TODO -> why this ref? Document?
1115 @cindex @code{neutral-direction}
1119 Auto knee beams can not be used together with hara kiri staffs.
1122 * Setting automatic beam behavior ::
1126 @no de Beam typography
1127 @sub section Beam typography
1129 One of the strong points of LilyPond is how beams are formatted. Beams
1130 are quantized, meaning that the left and right endpoints beams start
1131 exactly on staff lines. Without quantization, small wedges of white
1132 space appear between the beam and staff line, and this looks untidy.
1134 Beams are also slope-damped: melodies that go up or down should also
1135 have beams that go up or down, but the slope of the beams should be
1136 less than the slope of the notes themselves.
1138 Some beams should be horizontal. These are so-called concave beams.
1140 [TODO: some pictures.]
1143 @c . {Automatic beams}
1144 @node Setting automatic beam behavior
1145 @subsection Setting automatic beam behavior
1147 @cindex @code{autoBeamSettings}
1148 @cindex @code{(end * * * *)}
1149 @cindex @code{(begin * * * *)}
1150 @cindex automatic beams, tuning
1151 @cindex tuning automatic beaming
1153 In normal time signatures, automatic beams can start on any note but can
1154 only end in a few positions within the measure: beams can end on a beat,
1155 or at durations specified by the properties in
1156 @code{Voice.autoBeamSettings}. The defaults for @code{autoBeamSettings}
1157 are defined in @file{scm/auto-beam.scm}.
1159 The value of @code{autoBeamSettings} is changed using
1160 @code{\override} and unset using @code{\revert}:
1162 \property Voice.autoBeamSettings \override #'(@var{BE} @var{P} @var{Q} @var{N} @var{M}) = @var{dur}
1163 \property Voice.autoBeamSettings \revert #'(@var{BE} @var{P} @var{Q} @var{N} @var{M})
1165 Here, @var{BE} is the symbol @code{begin} or @code{end}. It determines
1166 whether the rule applies to begin or end-points. The quantity
1167 @var{P}/@var{Q} refers to the length of the beamed notes (and `@code{*
1168 *}' designates notes of any length), @var{N}/@var{M} refers to a time
1169 signature (wildcards, `@code{* *}' may be entered to designate all time
1172 For example, if you want automatic beams to end on every quarter note,
1173 you can use the following:
1175 \property Voice.autoBeamSettings \override
1176 #'(end * * * *) = #(make-moment 1 4)
1178 Since the duration of a quarter note is 1/4 of a whole note, it is
1179 entered as @code{(make-moment 1 4)}.
1181 The same syntax can be used to specify beam starting points. In this
1182 example, automatic beams can only end on a dotted quarter note.
1184 \property Voice.autoBeamSettings \override
1185 #'(end * * * *) = #(make-moment 3 8)
1187 In 4/4 time signature, this means that automatic beams could end only on
1188 3/8 and on the fourth beat of the measure (after 3/4, that is 2 times
1189 3/8 has passed within the measure).
1191 You can also restrict rules to specific time signatures. A rule that
1192 should only be applied in @var{N}/@var{M} time signature is formed by
1193 replacing the second asterisks by @var{N} and @var{M}. For example, a
1194 rule for 6/8 time exclusively looks like
1196 \property Voice.autoBeamSettings \override
1197 #'(begin * * 6 8) = ...
1200 If you want a rule to apply to certain types of beams, you can use the
1201 first pair of asterisks. Beams are classified according to the shortest
1202 note they contain. For a beam ending rule that only applies to beams
1203 with 32nd notes (and no shorter notes), you would use @code{(end 1
1207 @c Automatic beams can not be put on the last note in a score.
1209 If a score ends while an automatic beam has not been ended and is still
1210 accepting notes, this last beam will not be typeset at all.
1212 @cindex automatic beam generation
1214 @cindex @code{Voice.autoBeaming}
1217 For melodies that have lyrics, you may want to switch off
1218 automatic beaming. This is done by setting @code{Voice.autoBeaming} to
1224 It is not possible to specify beaming parameters for beams with mixed
1225 durations, that differ from the beaming parameters of all separate
1226 durations, i.e., you'll have to specify manual beams to get:
1227 @lilypond[fragment,singleline,relative]
1228 \property Voice.autoBeamSettings
1229 \override #'(end * * * *) = #(make-moment 3 8)
1230 \time 12/8 c'8 c c c16 c c c c c [c c c c] c8 c c4
1233 It is not possible to specify beaming parameters that act differently in
1234 different parts of a measure. This means that it is not possible to use
1235 automatic beaming in irregular meters such as @code{5/8}.
1238 @section Accidentals
1240 This section describes how to change the way that LilyPond automatically
1241 inserts accidentals before the running notes.
1244 * Using the predefined accidental macros::
1245 * Defining your own accidental typesettings::
1248 @node Using the predefined accidental macros
1249 @subsection Using the predefined accidental macros
1250 The constructs for describing the accidental typesetting rules are
1251 quite hairy, so non-experts should stick to the macros defined in
1252 @file{ly/property-init.ly}.
1253 @cindex @file{property-init.ly}
1255 The normal way of using the macros is to enter the macro name right after the
1256 creation of the context in which the accidental typesetting described
1257 by the macro is to take effect. I.e. if you want to use
1258 piano-accidentals in a pianostaff then you issue
1259 @code{\pianoAccidentals} first thing after the creation of the piano
1263 \notes \relative c'' <
1264 \context Staff = sa @{ cis4 d e2 @}
1265 \context GrandStaff <
1267 \context Staff = sb @{ cis4 d e2 @}
1268 \context Staff = sc @{ es2 c @}
1270 \context Staff = sd @{ es2 c @}
1274 @lilypond[singleline]
1276 \notes \relative c'' <
1277 \context Staff = sa { cis4 d e2 }
1278 \context GrandStaff <
1280 \context Staff = sb { cis4 d e2 }
1281 \context Staff = sc { es2 c }
1283 \context Staff = sd { es2 c }
1288 minimumVerticalExtent = #'(-4.0 . 4.0)
1296 @item \defaultAccidentals
1297 @cindex @code{\defaultAccidentals}
1298 This is the default typesetting behaviour. It should correspond
1299 to 18th century common practice: Accidentals are
1300 remembered to the end of the measure in which they occur and
1301 only on their own octave.
1303 @item \voiceAccidentals
1304 @cindex @code{\voiceAccidentals}
1305 The normal behaviour is to remember the accidentals on
1307 This macro, however, typesets accidentals individually for each
1309 Apart from that the rule is similar to
1310 @code{\defaultAccidentals}.
1312 Warning: This leads to some weird and often unwanted results
1313 because accidentals from one voice DO NOT get cancelled in other
1315 @lilypond[singleline,relative,fragment,verbatim]
1318 \context Voice=va { \voiceOne es g }
1319 \context Voice=vb { \voiceTwo c, e }
1322 Hence you should only use @code{\voiceAccidentals}
1323 if the voices are to be read solely by
1324 individual musicians. if the staff should be readable also
1325 by one musician/conductor then you should use
1326 @code{\modernVoiceAccidentals} or @code{\modernVoiceCautionaries}
1329 @item \modernAccidentals
1330 @cindex @code{\modernAccidentals}
1331 This rule should correspond to the common practice in the 20th
1333 The rule is a bit more complex than @code{\defaultAccidentals}:
1334 You get all the same accidentals, but temporary
1335 accidentals also get cancelled in other octaves. Further more,
1336 in the same octave, they also get cancelled in the following measure:
1337 @lilypond[singleline,fragment,verbatim]
1339 cis' c'' cis'2 | c'' c'
1342 @item \modernCautionaries
1343 @cindex @code{\modernCautionaries}
1344 This rule is similar to @code{\modernAccidentals}, but the
1345 ``extra'' accidentals (the ones not typeset by
1346 @code{\defaultAccidentals}) are typeset as cautionary accidentals
1347 (i.e. in reduced size):
1348 @lilypond[singleline,fragment,verbatim]
1350 cis' c'' cis'2 | c'' c'
1353 @item \modernVoiceAccidentals
1354 @cindex @code{\modernVoiceAccidentals}
1355 Multivoice accidentals to be read both by musicians playing one voice
1356 and musicians playing all voices.
1358 Accidentals are typeset for each voice, but they ARE cancelled
1359 across voices in the same @internalsref{Staff}.
1361 @item \modernVoiceCautionaries
1362 @cindex @code{\modernVoiceCautionaries}
1363 The same as @code{\modernVoiceAccidentals}, but with the
1364 extra accidentals (the ones not typeset by
1365 @code{\voiceAccidentals}) typeset as cautionaries.
1366 Notice that even though all accidentals typeset by
1367 @code{\defaultAccidentals} ARE typeset by this macro then some
1368 of them are typeset as cautionaries.
1370 @item \pianoAccidentals
1371 @cindex @code{\pianoAccidentals}
1372 20th century practice for piano notation. Very similar to
1373 @code{\modernAccidentals} but accidentals also get cancelled
1374 across the staves in the same @internalsref{GrandStaff} or
1375 @internalsref{PianoStaff}.
1377 @item \pianoCautionaries
1378 @cindex @code{\pianoCautionaries}
1379 As @code{\pianoAccidentals} but with the extra accidentals
1380 typeset as cationaries.
1383 @cindex @code{\noResetKey}
1384 Same as @code{\defaultAccidentals} but with accidentals lasting
1385 ``forever'' and not only until the next measure:
1386 @lilypond[singleline,fragment,verbatim,relative]
1391 @item \forgetAccidentals
1392 @cindex @code{\forgetAccidentals}
1393 This is sort of the opposite of @code{\noResetKey}: Accidentals
1394 are not remembered at all - and hence all accidentals are
1395 typeset relative to the key signature, regardless of what was
1396 before in the music:
1397 @lilypond[singleline,fragment,verbatim,relative]
1399 \key d\major c4 c cis cis d d dis dis
1403 @node Defining your own accidental typesettings
1404 @subsection Defining your own accidental typesettings
1406 This section must be considered gurus-only, and hence it must be
1407 sufficient with a short description of the system and a reference to
1408 the internal documentation.
1410 The idea of the algorithm is to try several different rules and then
1411 use the rule that gives the highest number of accidentals.
1412 Each rule cosists of
1415 In which context is the rule applied. I.e. if context is
1416 @internalsref{Score} then all staves share accidentals, and if
1417 context is @internalsref{Staff} then all voices in the same
1418 staff share accidentals, but staves don't - like normally.
1420 Whether the accidental changes all octaves or only the current
1423 Over how many barlines the accidental lasts.
1424 If lazyness is @code{-1} then the accidental is forget
1425 immidiately, and if lazyness is @code{#t} then the accidental
1429 As described in the internal documentation of
1430 @reng{Accidental_engraver}, the properties @code{autoAccidentals} and
1431 @code{autoCautionaries} contain lists of rule descriptions. Notice
1432 that the contexts must be listed from in to out - that is
1433 @internalsref{Thread} before @internalsref{Voice},
1434 @internalsref{Voice} before @internalsref{Staff}, etc.
1435 see the macros in @file{ly/property-init.ly} for examples of how the
1440 Currently the simultaneous notes are considered to be entered in
1441 sequential mode. This means that in a chord the accidentals are
1442 typeset as if the notes in the chord happened one at a time - in the
1443 order in which they appear in the input file.
1445 Of course this is only a problem when you have simultainous notes
1446 which accidentals should depend on each other.
1447 Notice that the problem only occurs when using non-default accidentals
1448 - as the default accidentals only depend on other accidentals on the
1449 same staff and same pitch and hence cannot depend on other
1452 This example shows two examples of the same music giving different
1453 accidentals depending on the order in which the notes occur in the
1456 @lilypond[singleline,fragment,verbatim]
1457 \property Staff.autoAccidentals = #'( Staff (any-octave . 0) )
1458 cis'4 <c'' c'> r2 | cis'4 <c' c''> r2 | <cis' c''> r | <c'' cis'> r |
1461 The only solution is to manually insert the problematic
1462 accidentals using @code{!} and @code{?}.
1464 @node Expressive marks
1465 @section Expressive marks
1480 A slur indicates that notes are to be played bound or @emph{legato}.
1481 They are entered using parentheses:
1482 @lilypond[fragment,verbatim,center]
1483 f'()g'()a' [a'8 b'(] a'4 g'2 )f'4
1486 See also @seeinternals{Slur}.
1488 Slurs avoid crossing stems, and are generally attached to note heads.
1489 However, in some situations with beams, slurs may be attached to stem
1490 ends. If you want to override this layout you can do this through the
1491 grob-property @code{attachment} of @internalsref{Slur} in
1492 @internalsref{Voice} context It's value is a pair of symbols, specifying
1493 the attachment type of the left and right end points.
1495 @lilypond[fragment,relative,verbatim]
1497 \property Voice.Stem \set #'length = #5.5
1499 \property Voice.Slur \set #'attachment = #'(stem . stem)
1503 If a slur would strike through a stem or beam, the slur will be moved
1504 away upward or downward. If this happens, attaching the slur to the
1505 stems might look better:
1507 @lilypond[fragment,relative,verbatim]
1510 \property Voice.Slur \set #'attachment = #'(stem . stem)
1515 Similarly, the curvature of a slur is adjusted to stay clear of note
1516 heads and stems. When that would increase the curvature too much, the
1517 slur is reverted to its default shape. The threshold for this
1518 decision is in @internalsref{Slur}'s grob-property @code{beautiful}.
1519 It is loosely related to the enclosed area between the slur and the
1520 notes. Usually, the default setting works well, but in some cases you
1521 may prefer a curved slur when LilyPond decides for a vertically moved
1522 one. You can indicate this preference by increasing the
1523 @code{beautiful} value:
1525 @lilyp ond[verbatim,singleline,relative]
1527 c16( a' f' a a f a, )c,
1528 c( a' f' a a f d, )c
1529 \property Voice.Slur \override #'beautiful = #5.0
1530 c( a' f' a a f d, )c
1536 Producing nice slurs is a difficult problem, and LilyPond currently
1537 uses a simple, empiric method to produce slurs. In some cases, the
1538 results of this method are ugly.
1541 This is reflected by the
1542 @code{beautiful} property, which it is an arbitrary parameter in the
1543 slur formatter. Useful values can only be determined by trial and
1547 @cindex Adjusting slurs
1549 @node Phrasing slurs
1550 @subsection Phrasing slurs
1552 @cindex phrasing slurs
1553 @cindex phrasing marks
1555 A phrasing slur (or phrasing mark) connects chords and is used to
1556 indicate a musical sentence. It is started using @code{\(} and @code{\)}
1559 @lilypond[fragment,verbatim,center,relative]
1560 \time 6/4 c' \( d () e f () e \) d
1563 Typographically, the phrasing slur behaves almost exactly like a normal
1564 slur. See also @seeinternals{PhrasingSlur}.
1568 @subsection Breath marks
1570 Breath marks are entered using @code{\breathe}. See also
1571 @seeinternals{BreathingSign}.
1573 @lilypond[fragment,relative]
1582 @cindex beats per minute
1583 @cindex metronome marking
1585 Metronome settings can be entered as follows:
1587 @cindex @code{\tempo}
1589 \tempo @var{duration} = @var{perminute}
1592 For example, @code{\tempo 4 = 76} requests output with 76 quarter notes
1597 The tempo setting is not printed, but is only used in the MIDI
1598 output. You can trick lily into producing a metronome mark,
1599 though. Details are in @ref{Text markup}.
1604 @subsection Text spanners
1605 @cindex Text spanners
1607 Some textual indications, e.g. rallentando or accelerando, often extend
1608 over many measures. This is indicated by following the text with a
1609 dotted line. You can create such texts using text spanners. The syntax
1612 \spanrequest \start "text"
1613 \spanrequest \stop "text"
1615 LilyPond will respond by creating a @internalsref{TextSpanner} grob (typically
1616 in @internalsref{Voice} context). The string to be printed, as well as the
1617 style is set through grob properties.
1619 An application---or rather, a hack---is to fake octavation indications.
1620 @lilypond[fragment,relative,verbatim]
1621 \relative c' { a''' b c a
1622 \property Voice.TextSpanner \set #'type = #'dotted-line
1623 \property Voice.TextSpanner \set #'edge-height = #'(0 . 1.5)
1624 \property Voice.TextSpanner \set #'edge-text = #'("8va " . "")
1625 \property Staff.centralCPosition = #-13
1626 a\spanrequest \start "text" b c a \spanrequest \stop "text" }
1644 @subsection Articulations
1645 @cindex Articulations
1647 @cindex articulations
1651 A variety of symbols can appear above and below notes to indicate
1652 different characteristics of the performance. They are added to a note
1653 by adding a dash and the the character signifying the
1654 articulation. They are demonstrated here.
1655 @lilypond[singleline]
1657 \notes \context Voice {
1658 \property Voice.TextScript \set #'font-family = #'typewriter
1659 \property Voice.TextScript \set #'font-shape = #'upright
1665 c''4-^_"c-\\^{ }" s4
1670 The script is automatically placed, but if you need to force
1671 directions, you can use @code{_} to force them down, or @code{^} to
1673 @lilypond[fragment, verbatim]
1678 Other symbols can be added using the syntax
1679 @var{note}@code{-\}@var{name}. Again, they can be forced up or down
1680 using @code{^} and @code{_}.
1684 @cindex staccatissimo
1692 @cindex organ pedal marks
1701 @cindex prallmordent
1705 @cindex thumb marking
1712 \property Score.LyricText \override #'font-family =#'typewriter
1713 \property Score.LyricText \override #'font-shape = #'upright
1714 \context Staff \notes {
1715 c''-\accent c''-\marcato c''-\staccatissimo c''^\fermata
1716 c''-\stopped c''-\staccato c''-\tenuto c''-\upbow
1717 c''-\downbow c''^\lheel c''-\rheel c''^\ltoe
1718 c''-\rtoe c''-\turn c''-\open c''-\flageolet
1719 c''-\reverseturn c''-\trill c''-\prall c''-\mordent
1720 c''-\prallprall c''-\prallmordent c''-\upprall c''-\downprall
1721 c''-\upmordent c''-\downmordent c''-\pralldown c''-\prallup
1722 c''-\lineprall c''-\thumb c''-\segno c''-\coda
1724 \context Lyrics \lyrics {
1725 accent__ marcato__ staccatissimo__ fermata
1726 stopped__ staccato__ tenuto__ upbow
1727 downbow__ lheel__ rheel__ ltoe
1728 rtoe__ turn__ open__ flageolet
1729 reverseturn__ trill__ prall__ mordent
1730 prallprall__ prallmordent__ uprall__ downprall
1731 upmordent__ downmordent__ pralldown__ prallup__
1732 lineprall__ thumb__ segno__ coda
1736 linewidth = 5.875\in
1745 Fingering instructions can also be entered in this shorthand. For
1746 finger changes, use markup texts:
1748 @lilypond[verbatim, singleline, fragment]
1749 c'4-1 c'4-2 c'4-3 c'4-4
1754 @cindex @code{\script}
1759 See also @seeinternals{Script} and @seeinternals{Fingering}.
1763 All of these note ornaments appear in the printed output but have no
1764 effect on the MIDI rendering of the music.
1766 Unfortunately, there is no support for adding fingering instructions or
1767 ornaments to individual note heads. Some hacks exist, though. See
1768 @file{input/test/script-horizontal.ly}.
1773 @subsection Text scripts
1774 @cindex Text scripts
1776 In addition, it is possible to place arbitrary strings of text or markup
1777 text (see @ref{Text markup}) above or below notes by using a string:
1780 By default, these indications do not influence the note spacing, but
1781 by using the command @code{\fatText}, the widths will be taken into
1784 @lilypond[fragment,singleline,verbatim] \relative c' {
1785 c4^"longtext" \fatText c4_"longlongtext" c4 }
1788 It is possible to use @TeX{} commands in the strings, but this should be
1789 avoided because it makes it impossible for LilyPond to compute the
1790 exact length of the string, which may lead to collisions. Also, @TeX{}
1791 commands won't work with direct PostScript output (see @ref{PostScript
1794 Text scripts are created in form of @internalsref{TextScript} grobs, in
1795 @internalsref{Voice} context.
1797 @ref{Text markup} describes how to change the font or access
1798 special symbols in text scripts.
1803 @subsection Grace notes
1807 @cindex @code{\grace}
1811 Grace notes are ornaments are written out ornaments
1812 @lilypond[relative=2,verbatim,ifragment]
1813 c4 \grace c16 c4 \grace { [c16 d16] } c4
1816 In normal notation, grace notes are supposed to take up no logical
1817 time in a measure. Such an idea is practical for normal notation, but
1818 is not strict enough to put it into a program. The model that LilyPond
1819 uses for grace notes internally is that all timing is done in two
1822 Every point in musical time consists of two rational numbers: one
1823 denotes the logical time, one denotes the grace timing. The above
1824 example is shown here with timing tuples.
1827 \score { \notes \relative c''{
1828 c4^"(0,0)" \grace c16_" "_"(1/4,-1/16)" c4^"(1/4,0)" \grace {
1829 [c16_"(2/4,-1/8)" d16^"(2/4,-1/16)" ] } c4_" "_"(2/4,0)"
1831 \paper { linewidth = 8.\cm }
1835 The advantage of this approach is that you can use almost any lilypond
1836 construction together with grace notes, for example slurs and clef
1837 changes may appear halfway in between grace notes:
1839 @lilypond[relative=2,verbatim,fragment]
1840 c4 \grace { [ c16 c, \clef bass c, b(] } )c4
1843 The placement of these grace notes is synchronized between different
1844 staffs, using this grace timing.
1846 @lilypond[relative=2,verbatim,fragment]
1847 < \context Staff = SA { e4 \grace { c16 d e f } e4 }
1848 \context Staff = SB { c4 \grace { g8 b } c4 } >
1852 Unbeamed eighth notes and shorter by default have a slash through the
1853 stem. This can be controlled with grob property @code{flag-style} of
1854 @internalsref{Stem}. The change in formatting is accomplished by
1855 inserting @code{\startGraceMusic} before handling the grace notes, and
1856 @code{\stopGraceMusic} after finishing the grace notes. You can add to
1857 these definitions to globally change grace note formatting. The
1858 standard definitions are in @file{ly/grace-init.ly}.
1861 @lilypond[fragment,verbatim]
1862 \relative c'' \context Voice {
1863 \grace c8 c4 \grace { [c16 c16] } c4
1865 \property Voice.Stem \override #'flag-style = #'()
1867 \property Voice.Stem \revert #'flag-style
1874 Grace note synchronization can also lead to surprises. Staff notation,
1875 such as key signatures, barlines, etc. are also synchronized. Take
1876 care when you mix staffs with grace notes and staffs without.
1878 @lilypond[relative=2,verbatim,fragment]
1879 < \context Staff = SA { e4 \bar "|:" \grace c16 d4 }
1880 \context Staff = SB { c4 \bar "|:" d4 } >
1883 Grace sections should only be used within sequential music
1884 expressions. Nesting, juxtaposing, or ending sequential music with a
1885 grace section is not supported, and might produce crashes or other
1897 @subsection Glissando
1900 @cindex @code{\glissando}
1902 A glissando line can be requested by attaching a @code{\glissando} to
1905 @lilypond[fragment,relative,verbatim]
1911 Printing of an additional text (such as @emph{gliss.}) must be done
1912 manually. See also @seeinternals{Glissando}.
1918 @subsection Dynamics
1931 @cindex @code{\ffff}
1941 Absolute dynamic marks are specified using an identifier after a
1942 note: @code{c4-\ff}. The available dynamic marks are: @code{\ppp},
1943 @code{\pp}, @code{\p}, @code{\mp}, @code{\mf}, @code{\f}, @code{\ff},
1944 @code{\fff}, @code{\fff}, @code{\fp}, @code{\sf}, @code{\sff},
1945 @code{\sp}, @code{\spp}, @code{\sfz}, and @code{\rfz}.
1947 @lilypond[verbatim,singleline,fragment,relative]
1948 c'\ppp c\pp c \p c\mp c\mf c\f c\ff c\fff
1954 @cindex @code{\decr}
1955 @cindex @code{\rced}
1961 A crescendo mark is started with @code{\cr} and terminated with
1962 @code{\rc} (the textual reverse of @code{cr}). A decrescendo mark is
1963 started with @code{\decr} and terminated with @code{\rced}. There are
1964 also shorthands for these marks. A crescendo can be started with
1965 @code{\<} and a decrescendo can be started with @code{\>}. Either one
1966 can be terminated with @code{\!}. Note that @code{\!} must go before
1967 the last note of the dynamic mark whereas @code{\rc} and @code{\rced} go
1968 after the last note. Because these marks are bound to notes, if you
1969 want several marks during one note, you have to use spacer notes.
1971 @lilypond[fragment,verbatim,center]
1972 c'' \< \! c'' d'' \decr e'' \rced
1973 < f''1 { s4 s4 \< \! s4 \> \! s4 } >
1976 You can also use a text saying @emph{cresc.} instead of hairpins. Here
1977 is an example how to do it:
1979 @lilypond[fragment,relative=2,verbatim]
1980 c4 \cresc c4 \endcresc c4
1987 You can also supply your own texts:
1988 @lilypond[fragment,relative,verbatim]
1990 \property Voice.crescendoText = "cresc. poco"
1991 \property Voice.crescendoSpanner = #'dashed-line
1998 Dynamics are grobs of @internalsref{DynamicText} and
1999 @internalsref{Hairpin}. Vertical positioning of these symbols is
2000 handled by the @internalsref{DynamicLineSpanner} grob. If you want to
2001 adjust padding or vertical direction of the dynamics, you must set
2002 properties for the @internalsref{DynamicLineSpanner} grob. Predefined
2003 identifiers to set the vertical direction are \dynamicUp and
2006 @cindex direction, of dynamics
2007 @cindex @code{\dynamicDown}
2008 @cindex @code{\dynamicUp}
2016 @cindex @code{\repeat}
2018 To specify repeats, use the @code{\repeat} keyword. Since repeats
2019 should work differently when played or printed, there are a few
2020 different variants of repeats.
2024 Repeated music is fully written (played) out. Useful for MIDI
2025 output, and entering repetitive music.
2028 This is the normal notation: Repeats are not written out, but
2029 alternative endings (voltas) are printed, left to right.
2032 Alternative endings are written stacked. This has limited use but may be
2033 used to typeset two lines of lyrics in songs with repeats, see
2034 @file{input/star-spangled-banner.ly}.
2040 Make beat or measure repeats. These look like percent signs.
2046 * Repeats and MIDI::
2047 * Manual repeat commands::
2049 * Tremolo subdivisions::
2054 @subsection Repeat syntax
2056 The syntax for repeats is
2059 \repeat @var{variant} @var{repeatcount} @var{repeatbody}
2062 If you have alternative endings, you may add
2063 @cindex @code{\alternative}
2065 \alternative @code{@{} @var{alternative1}
2067 @var{alternative3} @dots{} @code{@}}
2069 where each @var{alternative} is a music expression.
2071 Normal notation repeats are used like this:
2072 @lilypond[fragment,verbatim]
2074 \repeat volta 2 { c'4 d' e' f' }
2075 \repeat volta 2 { f' e' d' c' }
2078 With alternative endings:
2079 @lilypond[fragment,verbatim]
2081 \repeat volta 2 {c'4 d' e' f'}
2082 \alternative { {d'2 d'} {f' f} }
2085 Folded repeats look like this:
2088 @lilypond[fragment,verbatim]
2090 \repeat fold 2 {c'4 d' e' f'}
2091 \alternative { {d'2 d'} {f' f} }
2095 If you don't give enough alternatives for all of the repeats, then
2096 the first alternative is assumed to be repeated often enough to equal
2097 the specified number of repeats.
2099 @lilypond[fragment,verbatim]
2103 \repeat volta 4 { e | c2 d2 | e2 f2 | }
2104 \alternative { { g4 g g } { a | a a a a | b2. } }
2109 @node Repeats and MIDI
2110 @subsection Repeats and MIDI
2112 @cindex expanding repeats
2114 For instructions on how to unfoldi repeats for MIDI output, see
2115 the example file @file{input/test/unfold-all-repeats.ly}.
2120 Notice that timing information is not remembered at the start of an
2121 alternative, so you have to reset timing information after a repeat,
2122 e.g. using a bar-check (See @ref{Bar check}), setting
2123 @code{Score.measurePosition} or entering @code{\partial}. Slurs or ties
2124 are also not repeated.
2126 It is possible to nest @code{\repeat}s, although this probably is only
2127 meaningful for unfolded repeats.
2129 Folded repeats offer little more over simultaneous music.
2131 @node Manual repeat commands
2132 @subsection Manual repeat commands
2134 @cindex @code{repeatCommands}
2136 The property @code{repeatCommands} can be used to control the layout of
2137 repeats. Its value is a Scheme list of repeat commands, where each repeat
2145 @item (volta . @var{text})
2146 Print a volta bracket saying @var{text}.
2148 Stop a running volta bracket
2151 @lilypond[verbatim, fragment]
2153 \property Score.repeatCommands = #'((volta "93") end-repeat)
2155 \property Score.repeatCommands = #'((volta #f))
2160 Repeats brackets are @internalsref{VoltaBracket} grobs.
2162 @node Tremolo repeats
2163 @subsection Tremolo repeats
2164 @cindex tremolo beams
2166 To place tremolo marks between notes, use @code{\repeat} with tremolo
2168 @lilypond[verbatim,center,singleline]
2170 \context Voice \notes\relative c' {
2171 \repeat "tremolo" 8 { c16 d16 }
2172 \repeat "tremolo" 4 { c16 d16 }
2173 \repeat "tremolo" 2 { c16 d16 }
2174 \repeat "tremolo" 4 c16
2179 Tremolo beams are @internalsref{Beam} grobs. Single stem tremolos are
2180 @internalsref{StemTremolo}. The single stem tremolo @emph{must} be
2181 entered without @code{@{} and @code{@}}.
2185 Only powers of two and undotted notes are supported repeat counts.
2187 @node Tremolo subdivisions
2188 @subsection Tremolo subdivisions
2189 @cindex tremolo marks
2190 @cindex @code{tremoloFlags}
2192 Tremolo marks can be printed on a single note by adding
2193 `@code{:}[@var{length}]' after the note. The length must be at least 8.
2194 A @var{length} value of 8 gives one line across the note stem. If the
2195 length is omitted, then then the last value (stored in
2196 @code{Voice.tremoloFlags}) is used.
2198 @lilypond[verbatim,fragment,center]
2199 c'2:8 c':32 | c': c': |
2205 Tremolos in this style do not carry over into the MIDI output.
2208 @node Measure repeats
2209 @subsection Measure repeats
2211 @cindex percent repeats
2212 @cindex measure repeats
2214 In the @code{percent} style, a note pattern can be repeated. It is
2215 printed once, and then the pattern is replaced with a special sign.
2216 Patterns of a one and two measures are replaced by percent-like signs,
2217 patterns that divide the measure length are replaced by slashes.
2219 @lilypond[verbatim,singleline]
2220 \context Voice { \repeat "percent" 4 { c'4 }
2221 \repeat "percent" 2 { c'2 es'2 f'4 fis'4 g'4 c''4 }
2225 The signs are represented by these grobs: @internalsref{RepeatSlash} and
2226 @internalsref{PercentRepeat} and @internalsref{DoublePercentRepeat}.
2230 You can not nest percent repeats, e.g. by filling in the first measure
2231 with slashes, and repeating that measure with percents.
2233 @node Rhythmic music
2234 @section Rhythmic music
2236 Sometimes you might want to show only the rhythm of a melody. This can
2237 be done with the rhythmic staff. All pitches of notes on such a staff
2238 are squashed, and the staff itself looks has a single staff line:
2240 @lilypond[fragment,relative,verbatim]
2241 \context RhythmicStaff {
2243 c4 e8 f g2 | r4 g r2 | g1:32 | r1 |
2248 * Percussion staves::
2251 @node Percussion staves
2252 @subsection Percussion staves
2255 To typeset more than one piece of percussion to be played by the same
2256 musician one typically uses a multiline staff where each staff
2257 position refers to a specific piece of percussion.
2259 LilyPond is shipped with a bunch of scheme functions which allows you
2260 to do this fairly easily.
2262 The system is based on the general midi drum-pitches.
2263 In order to use the drum pitches you include
2264 @file{ly/drumpitch-init.ly}. This file defines the pitches from the scheme
2265 variable @code{drum-pitch-names} - which definition can be read in
2266 @file{scm/drums.scm}. You see that each piece of percussion has a full
2267 name and an abbreviated name - and you may freely select whether to
2268 refer to the full name or the abbreviation in your music definition.
2270 To typeset the music on a staff you apply the scheme function
2271 @code{drums->paper} to the percussion music. This function takes a
2272 list of percussion instrument names, notehead scripts and staff
2273 positions (that is: pitches relative to the C-clef) and uses this to
2274 transform the input music by moving the pitch, changing the notehead
2275 and (optionally) adding a script:
2276 @lilypond[singleline,verbatim]
2277 \include "drumpitch-init.ly"
2278 up = \notes { crashcymbal4 hihat8 halfopenhihat hh hh hh openhihat }
2279 down = \notes { bassdrum4 snare8 bd r bd sn4 }
2281 \apply #(drums->paper 'drums) \context Staff <
2283 \context Voice = up { \voiceOne \up }
2284 \context Voice = down { \voiceTwo \down }
2289 In the above example the music was transformed using the list @code{'drums}.
2290 Currently the following lists are defined in @file{scm/drums.scm}:
2293 To typeset a typical drum kit on a five line staff.
2295 \include "drumpitch-init.ly"
2296 nam = \lyrics { cymc cyms cymr hh hhc hho hhho hhp cb hc
2297 bd sn ss tomh tommh tomml toml tomfh tomfl }
2298 mus = \notes { cymc cyms cymr hh hhc hho hhho hhp cb hc
2299 bd sn ss tomh tommh tomml toml tomfh tomfl s16 }
2302 \apply #(drums->paper 'drums) \context Staff <
2306 \context Lyrics \nam
2311 \remove Bar_engraver
2312 \remove Time_signature_engraver
2313 minimumVerticalExtent = #'(-4.0 . 5.0)
2317 \remove Stem_engraver
2322 Notice that the scheme supports six different toms.
2323 If you are using fewer toms then you simply select the toms that produce
2324 the desired result - i.e. to get toms on the three middle lines you
2325 use @code{tommh}, @code{tomml} and @code{tomfh}.
2327 Because the general midi contain no rimshots we use the sidestick for
2328 this purpose instead.
2330 To typeset timbales on a two line staff.
2331 @lilypond[singleline]
2332 \include "drumpitch-init.ly"
2333 nam = \lyrics { timh ssh timl ssl cb }
2334 mus = \notes { timh ssh timl ssl cb s16 }
2337 \apply #(drums->paper 'timbales) \context Staff <
2341 \context Lyrics \nam
2346 \remove Bar_engraver
2347 \remove Time_signature_engraver
2348 StaffSymbol \override #'line-count = #2
2349 StaffSymbol \override #'staff-space = #2
2350 minimumVerticalExtent = #'(-3.0 . 4.0)
2354 \remove Stem_engraver
2361 To typeset congas on a two line staff.
2362 @lilypond[singleline]
2363 \include "drumpitch-init.ly"
2364 nam = \lyrics { cgh cgho cghm ssh cgl cglo cglm ssl }
2365 mus = \notes { cgh cgho cghm ssh cgl cglo cglm ssl s16 }
2368 \apply #(drums->paper 'congas) \context Staff <
2372 \context Lyrics \nam
2377 \remove Bar_engraver
2378 \remove Time_signature_engraver
2379 StaffSymbol \override #'line-count = #2
2380 StaffSymbol \override #'staff-space = #2
2381 minimumVerticalExtent = #'(-3.0 . 4.0)
2385 \remove Stem_engraver
2391 To typeset bongos on a two line staff.
2392 @lilypond[singleline]
2393 \include "drumpitch-init.ly"
2394 nam = \lyrics { boh boho bohm ssh bol bolo bolm ssl }
2395 mus = \notes { boh boho bohm ssh bol bolo bolm ssl s16 }
2398 \apply #(drums->paper 'bongos) \context Staff <
2402 \context Lyrics \nam
2407 \remove Bar_engraver
2408 \remove Time_signature_engraver
2409 StaffSymbol \override #'line-count = #2
2410 StaffSymbol \override #'staff-space = #2
2411 minimumVerticalExtent = #'(-3.0 . 4.0)
2415 \remove Stem_engraver
2421 To typeset all kinds of simple percussion on one line staves.
2422 @lilypond[singleline]
2423 \include "drumpitch-init.ly"
2424 nam = \lyrics { tri trio trim gui guis guil cb cl tamb cab mar hc }
2425 mus = \notes { tri trio trim gui guis guil cb cl tamb cab mar hc s16 }
2428 \apply #(drums->paper 'percussion) \context Staff <
2432 \context Lyrics \nam
2437 \remove Bar_engraver
2438 \remove Time_signature_engraver
2439 StaffSymbol \override #'line-count = #1
2440 minimumVerticalExtent = #'(-2.0 . 3.0)
2444 \remove Stem_engraver
2451 If you don't like any of the predefined lists you can define your own
2452 list at the top of your file:
2454 @lilypond[singleline, verbatim]
2456 (bassdrum default #f ,(make-pitch -1 2 0))
2457 (snare default #f ,(make-pitch 0 1 0))
2458 (hihat cross #f ,(make-pitch 0 5 0))
2459 (pedalhihat xcircle "stopped" ,(make-pitch 0 5 0))
2460 (lowtom diamond #f ,(make-pitch -1 6 0))
2462 \include "drumpitch-init.ly"
2463 up = \notes { hh8 hh hh hh hhp4 hhp }
2464 down = \notes { bd4 sn bd toml8 toml }
2466 \apply #(drums->paper 'mydrums) \context Staff <
2468 \context Voice = up { \voiceOne \up }
2469 \context Voice = down { \voiceTwo \down }
2474 To use a modified existing list instead of building your own from
2475 scratch you can append your modifications to the start of the existing
2479 #(define mydrums (append `(
2480 (bassdrum default #f ,(make-pitch -1 2 0))
2481 (lowtom diamond #f ,(make-pitch -1 6 0))
2485 @c FIXME: Too many levels of headers when using subsubsections.
2486 @c Perhaps junk subsection ``Percussion staves''
2487 @subsubsection Percussion staves with normal staves
2488 When you include @file{drumpitch-init.ly} then the default pitches
2489 are overridden so that you after the inclusion cannot use the common
2490 dutch pitch names anymore. Hence you might wan't to reinclude
2491 @file{nederlands.ly} after the drum-pattern-definitions:
2492 @lilypond[singleline,verbatim]
2493 \include "drumpitch-init.ly"
2494 up = \notes { crashcymbal4 hihat8 halfopenhihat hh hh hh openhihat }
2495 down = \notes { bassdrum4 snare8 bd r bd sn4 }
2496 \include "nederlands.ly"
2497 bass = \notes \transpose c, { a4. e8 r e g e }
2500 \apply #(drums->paper 'drums) \context Staff = drums <
2502 \context Voice = up { \voiceOne \up }
2503 \context Voice = down { \voiceTwo \down }
2505 \context Staff = bass { \clef "F_8" \bass }
2510 @subsubsection Percussion midi output
2511 In order to produce correct midi output you need to produce two score
2512 blocks - one for the paper and one for the midi.
2513 To use the percussion channel you set the property @code{instrument}
2514 to @code{'drums}. Because the drum-pitches themself are similar to the
2515 general midi pitches all you have to do is to insert the voices with
2516 none of the scheme functions to get the correct midi output:
2520 \apply #(drums->paper 'mydrums) \context Staff <
2522 \context Voice = up @{ \voiceOne \up @}
2523 \context Voice = down @{ \voiceTwo \down @}
2529 \property Staff.instrument = #'drums
2538 This scheme is to be considered a temporary implementation. Even
2539 though the scheme will probably keep on working then the future might
2540 bring some other way of typesetting drums, and probably
2541 there will be made no great efforts in keeping things downwards
2546 @section Piano music
2548 Piano music is an odd type of notation. Piano staves are two normal
2549 staves coupled with a brace. The staves are largely independent, but
2550 sometimes voices can cross between the two staves. The
2551 @internalsref{PianoStaff} is especially built to handle this cross-staffing
2552 behavior. In this section we discuss the @internalsref{PianoStaff} and some
2553 other pianistic peculiarities.
2556 * Automatic staff changes::
2557 * Manual staff switches::
2560 * Voice follower lines::
2564 @c . {Automatic staff changes}
2565 @node Automatic staff changes
2566 @subsection Automatic staff changes
2567 @cindex Automatic staff changes
2569 Voices can switch automatically between the top and the bottom
2570 staff. The syntax for this is
2572 \autochange Staff \context Voice @{ @dots{}@var{music}@dots{} @}
2574 The autochanger switches on basis of pitch (central C is the turning
2575 point), and it looks ahead skipping over rests to switch rests in
2576 advance. Here is a practical example:
2578 @lilypond[verbatim,singleline]
2579 \score { \notes \context PianoStaff <
2580 \context Staff = "up" {
2581 \autochange Staff \context Voice = VA < \relative c' {
2582 g4 a b c d r4 a g } > }
2583 \context Staff = "down" {
2588 Spacer rests are used to prevent the bottom staff from
2589 terminating too soon.
2592 @node Manual staff switches
2593 @subsection Manual staff switches
2595 @cindex manual staff switches
2596 @cindex staff switch, manual
2598 Voices can be switched between staves manually, using the following command:
2600 \translator Staff = @var{staffname} @var{music}
2602 The string @var{staffname} is the name of the staff. It switches the
2603 current voice from its current staff to the Staff called
2604 @var{staffname}. Typically @var{staffname} is @code{"up"} or
2612 Piano pedal instruction can be expressed using
2613 @code{\sustainDown}, @code{\sustainUp}, @code{\unaCorda},
2614 @code{\treCorde}, @code{\sostenutoDown} and @code{\sostenutoUp}.
2616 These identifiers are shorthands for spanner commands of the types
2617 @internalsref{Sustain}, @internalsref{UnaCorda} and @internalsref{Sostenuto}:
2619 @lilypond[fragment,verbatim]
2620 c''4 \spanrequest \start "Sustain" c''4
2621 c''4 \spanrequest \stop "Sustain"
2624 The symbols that are printed can be modified by setting
2625 @code{pedal@var{X}Strings}, where @var{X} is one of the pedal types:
2626 Sustain, Sostenuto or UnaCorda. Refer to the generated documentation of
2627 @rgrob{SustainPedal}, for example, for more information.
2629 Pedals can also be indicated by a sequence of brackets, by setting the
2630 @code{pedal-type} property of SustainPedal grobs:
2632 @lilypond[fragment,verbatim]
2633 \property Staff.SustainPedal \override #'pedal-type = #'bracket
2634 c''4 \sustainDown d''4 e''4 a'4
2635 \sustainUp \sustainDown
2636 f'4 g'4 a'4 \sustainUp
2639 A third style of pedal notation is a mixture of text and brackets,
2640 obtained by setting @code{pedal-type} to @code{mixed}:
2642 @lilypond[fragment,verbatim]
2643 \property Staff.SustainPedal \override #'pedal-type = #'mixed
2644 c''4 \sustainDown d''4 e''4 c'4
2645 \sustainUp \sustainDown
2646 f'4 g'4 a'4 \sustainUp
2649 The default '*Ped' style for sustain and damper pedals corresponds to
2650 @code{\pedal-type = #'text}. However, @code{mixed} is the default style
2651 for a sostenuto pedal:
2653 @lilypond[fragment,verbatim]
2654 c''4 \sostenutoDown d''4 e''4 c'4 f'4 g'4 a'4 \sostenutoUp
2657 For fine-tuning of the appearance of a pedal bracket, the properties
2658 @code{edge-width}, @code{edge-height}, and @code{shorten-pair} of
2659 @code{PianoPedalBracket} grobs (see the detailed documentation of
2660 @rgrob{PianoPedalBracket}) can be modified. For example, the bracket
2661 may be extended to the end of the note head.
2663 @lilypond[fragment,verbatim]
2664 \property Staff.PianoPedalBracket \override
2665 #'shorten-pair = #'(0 . -1.0)
2666 c''4 \sostenutoDown d''4 e''4 c'4
2667 f'4 g'4 a'4 \sostenutoUp
2674 @subsection Arpeggio
2677 @cindex broken arpeggio
2678 @cindex @code{\arpeggio}
2680 You can specify an arpeggio sign on a chord by attaching an
2681 @code{\arpeggio} to a note of the chord.
2684 @lilypond[fragment,relative,verbatim]
2685 \context Voice <c\arpeggio e g c>
2688 When an arpeggio crosses staves in piano music, you attach an arpeggio
2689 to the chords in both staves, and set
2690 @code{PianoStaff.connectArpeggios}.
2692 @lilypond[fragment,relative,verbatim]
2693 \context PianoStaff <
2694 \property PianoStaff.connectArpeggios = ##t
2695 \context Voice = one { <c'\arpeggio e g c> }
2696 \context Voice = other { \clef bass <c,,\arpeggio e g>}
2700 This command creates @internalsref{Arpeggio} grobs. Cross staff arpeggios
2701 are @code{PianoStaff.Arpeggio}.
2703 To add an arrow head to explicitly specify the direction of the
2704 arpeggio, you should set the arpeggio grob property
2705 @code{arpeggio-direction}.
2707 @lilypond[fragment,relative,verbatim]
2709 \property Voice.Arpeggio \set #'arpeggio-direction = #1
2711 \property Voice.Arpeggio \set #'arpeggio-direction = #-1
2716 A square bracket on the left indicates that the player should not
2717 arpeggiate the chord. To draw these brackets, set the
2718 @code{molecule-callback} property of @code{Arpeggio} or
2719 @code{PianoStaff.Arpeggio} grobs to @code{\arpeggioBracket}, and use
2720 @code{\arpeggio} statements within the chords as before.
2722 @lilypond[fragment,relative,verbatim]
2723 \context PianoStaff <
2724 \property PianoStaff.connectArpeggios = ##t
2725 \property PianoStaff.Arpeggio \override
2726 #'molecule-callback = \arpeggioBracket
2727 \context Voice = one { <c'\arpeggio e g c> }
2728 \context Voice = other { \clef bass <c,,\arpeggio e g>}
2735 It is not possible to mix connected arpeggios and unconnected
2736 arpeggios in one PianoStaff at the same time.
2740 @node Voice follower lines
2741 @subsection Voice follower lines
2743 @cindex follow voice
2744 @cindex staff switching
2747 @cindex @code{followVoice}
2749 Whenever a voice switches to another staff a line connecting the notes
2750 can be printed automatically. This is enabled if the property
2751 @code{PianoStaff.followVoice} is set to true:
2753 @lilypond[fragment,relative,verbatim]
2754 \context PianoStaff <
2755 \property PianoStaff.followVoice = ##t
2756 \context Staff \context Voice {
2758 \translator Staff=two
2761 \context Staff=two {\clef bass \skip 1*2 }
2765 The associated grob is @internalsref{VoiceFollower}.
2771 Tablature notation is used music for plucked string instruments. It
2772 notates pitches not by using note heads, but by indicating on which
2773 string and fret a note must be played. LilyPond offers limited
2774 support for tablature, by abusing the fingering system.
2777 * Tablatures basic::
2778 * Non-guitar tablatures::
2779 * Tablature in addition to normal staff::
2782 @node Tablatures basic
2783 @subsection Tablatures basic
2784 @cindex Tablatures basic
2786 Tablature can be typeset with Lilypond by using the
2787 @internalsref{TabStaff} and @internalsref{TabVoice} contexts. As
2788 tablature is a recent feature in Lilypond, most of the guitar special
2789 effects such as hammer, pull, bend are not yet supported.
2791 With the @internalsref{TabStaff}, the string number associated to a note
2792 is given though the fingering mechanism, e.g. @code{c4-3} for a C
2793 quarter on the third string. The string 1 is the lowest one, and the
2794 tuning defaults to the standard guitar tuning (with 6 strings).
2796 @lilypond[fragment,verbatim]
2799 \property Staff.Stem \override #'direction = #1
2808 @node Non-guitar tablatures
2809 @subsection Non-guitar tablatures
2810 @cindex Non-guitar tablatures
2812 There are many ways to customize Lilypond tablatures.
2814 First you can change the number of strings, by setting the number of
2815 lines in the @internalsref{TabStaff}. You can change the strings
2816 tuning. A string tuning is given as a Scheme list with one integer
2817 number for each string, the number being the pitch of an open string.
2819 Finally, it is possible to change the Scheme function to format the
2820 tablature note text. The default is @var{fret-number-tablature-format},
2821 which uses the fret number, but for some instruments that may not use
2822 this notation, just create your own tablature-format function. This
2823 function takes three argument: the string number, the string tuning and
2827 @node Tablature in addition to normal staff
2828 @subsection Tablature in addition to normal staff
2829 @cindex Tablature in addition to normal staff
2831 It is possible to typeset both tablature and a "normal" staff, as
2832 commonly done in many parts.
2834 A common trick for that is to put the notes in a variables, and to hide
2835 the fingering information (which correspond to the string number) for
2844 \context StaffGroup <
2846 % Hide fingering number
2847 \property Staff.Fingering \override #'transparent = ##t
2852 \property Staff.Stem \override #'direction = #1
2866 LilyPond has support for both entering and printing chords.
2867 @lilypond[verbatim,singleline]
2868 twoWays = \notes \transpose c'' {
2878 < \context ChordNames \twoWays
2879 \context Voice \twoWays > }
2882 This example also shows that the chord printing routines do not try to
2883 be intelligent. If you enter @code{f bes d}, it does not interpret
2884 this as an inversion.
2886 As you can see chords really are a set of pitches. They are internally
2887 stored as simultaneous music expressions. This means you can enter
2888 chords by name and print them as notes, enter them as notes and print
2889 them as chord names, or (the most common case) enter them by name, and
2894 * Printing named chords::
2899 @subsection Chords mode
2902 Chord mode is a mode where you can input sets of pitches using common
2903 names. It is introduced by the keyword @code{\chords}. It is similar
2904 to note mode, but words are also looked up in a chord modifier table
2905 (containing @code{maj}, @code{dim}, etc). Dashes and carets are used
2906 to indicate chord additions and subtractions, so articulation scripts
2907 can not be entered in Chord mode.
2909 Throughout these examples, chords have been shifted around the staff
2910 using @code{\transpose}.
2912 @lilypond[fragment,verbatim]
2916 c:9 c:9-.5+.7+ c:3-.5-
2926 The second type of modifier that may appear after the @code{:} is a
2927 named modifier. Named modifiers are listed in the file
2928 @file{chord-modifiers.ly}. The available modifiers are @code{m} and
2929 @code{min} which lower the 3rd half a step, `@code{aug}' which
2930 raises the 5th, `@code{dim}' which lowers the 5th,
2931 `@code{maj}' which adds a raised 7th, and `@code{sus}'
2932 which replaces the 5th with a 4th.
2934 @lilypond[fragment,verbatim]
2937 c1:m c:min7 c:maj c:aug c:dim c:sus
2943 Chord subtractions are used to eliminate notes from a chord. The
2944 notes to be subtracted are listed after a @code{^} character,
2947 @lilypond[fragment,verbatim,center]
2956 Chord inversions can be specified by appending `@code{/}' and the name
2957 of a single note to a chord. In a chord inversion, the inverted note is
2958 transposed down until it is the lowest note in the chord. If the note
2959 is not in the chord, a warning will be printed.
2961 @lilypond[fragment,verbatim,center]
2971 Bass notes can be added by `@code{/+}' and
2972 the name of a single note to a chord. This has the effect of
2973 adding the specified note to the chord, lowered by an octave,
2974 so it becomes the lowest note in the chord.
2976 @lilypond[fragment,verbatim,center]
2985 The formal syntax for named chords is as follows:
2987 @var{tonic}[@var{duration}][@code{-}@var{modifiers}][@code{^}@var{subtractions}][@code{/}@var{inversion}][@code{/+}@var{bass}].
2990 @var{tonic} should be the tonic note of the chord, and @var{duration} is
2991 the chord duration in the usual notation. There are two kinds of
2992 modifiers. One type is formed by @emph{chord additions}. Additions are
2993 obtained by listing intervals separated by dots. An interval is written
2994 by its number with an optional @code{+} or @code{-} to indicate raising
2995 or lowering by half a step. Chord additions have two effects: they adds
2996 the specified interval and all lower odd numbered intervals to the
2997 chord, and they may lower or raise the specified interval.
3002 Implementation details are gory. For example @code{c:4} not only adds
3003 a fourth, but also removes the third.
3006 @c . {Printing named chords}
3007 @node Printing named chords
3008 @subsection Printing named chords
3010 @cindex printing chord names
3014 For displaying printed chord names, use the @internalsref{ChordNames} context.
3015 The chords may be entered either using the notation described above, or
3016 directly using simultaneous music.
3018 @lilypond[verbatim,singleline]
3020 \chords {a1 b c} <d f g> <e g b>
3024 \context ChordNames \scheme
3025 \context Staff \transpose c'' \scheme
3030 You can make the chord changes stand out by setting
3031 @code{ChordNames.chordChanges} to true. This will only display chord
3032 names when there's a change in the chords scheme and at the start of a
3037 c1:m c:m \break c:m c:m d
3041 \context ChordNames {
3042 \property ChordNames.chordChanges = ##t
3044 \context Staff \transpose c'' \scheme
3046 \paper{linewidth= 9.\cm}
3050 LilyPond examines chords specified as lists of notes to determine a name
3051 to give the chord. LilyPond will not try to identify chord inversions or
3052 an added bass note, which may result in strange chord names when chords
3053 are entered as a list of pitches:
3055 @lilypond[verbatim,center,singleline]
3064 \context ChordNames \scheme
3065 \context Staff \scheme
3071 By default, a chord name system proposed by Harald Banter (See
3072 @ref{Literature}) is used. The system is very regular and predictable.
3073 Typical American style chord names may be selected by setting the
3074 @code{style} property of the @code{ChordNames.ChordName} grob to
3075 @code{'american}. Similarly @code{'jazz} selects Jazz chordnames.
3077 Routines that determine the names to be printed are written in Scheme,
3078 and may be customized by the user. The code can be found in
3079 @file{scm/chord-name.scm}. Here's an example showing the differences in
3083 @c maybe just junk verbatim option?
3084 @lilypond[verbatim,singleline]
3094 \context ChordNames = banter \scheme
3095 \context ChordNames = american {
3096 \property ChordNames.ChordName \override
3097 #'style = #'american \scheme }
3098 \context ChordNames = jazz {
3099 \property ChordNames.ChordName \override
3100 #'style = #'jazz \scheme }
3101 \context Staff \transpose c'' \scheme
3108 @section Writing parts
3110 Orchestral music involves some special notation, both in the full score,
3111 as in the individual parts. This section explains how to tackle common
3112 problems in orchestral music.
3119 * Instrument names::
3121 * Multi measure rests::
3122 * Automatic part combining::
3123 * Hara kiri staves::
3124 * Sound output for transposing instruments::
3127 @c . {Rehearsal marks}
3128 @node Rehearsal marks
3129 @subsection Rehearsal marks
3130 @cindex Rehearsal marks
3132 @cindex @code{\mark}
3134 To print a rehearsal mark, use the @code{\mark} command.
3135 @lilypond[fragment,verbatim]
3142 c1 \mark #'(music "scripts-segno")
3147 As you can see, the mark is incremented automatically if you use
3148 @code{\mark \default}. The value to use is stored in the property
3149 @code{rehearsalMark} is used and automatically incremented. The grob
3150 is @internalsref{RehearsalMark} in @internalsref{Score} context. See
3151 @code{input/test/boxed-molecule.ly} if you need boxes around the
3155 @subsection Bar numbers
3159 @cindex measure numbers
3160 @cindex currentBarNumber
3162 Bar numbers are printed by default at the start of the line. The
3163 number itself is a property that can be set by modifying the
3164 @code{currentBarNumber} property, i.e.
3166 \property Score.currentBarNumber = #217
3169 If you want boxed bar numbers, see the example file
3170 @code{input/test/boxed-molecule.ly}.
3172 See also @seeinternals{BarNumber}.
3176 Printing bar numbers at regular intervals is not implemented.
3177 Barnumbers can collide with the StaffGroup, if there is one at the
3178 top. To solve this, You have to twiddle with the
3179 @internalsref{padding} property of @internalsref{BarNumber} if your
3180 score starts with a @internalsref{StaffGroup}.
3182 @node Instrument names
3183 @subsection Instrument names
3185 In scores, the instrument name is printed before the staff. This can
3186 be done by setting @code{Staff.instrument} and
3187 @code{Staff.instr}. This will print a string before the start of the
3188 staff. For the first start, @code{instrument} is used, for the next
3189 ones @code{instr} is used.
3191 @lilypond[verbatim,singleline]
3192 \property Staff.instrument = "ploink " { c''4 }
3195 You can also use markup texts to construct more complicated instrument
3199 @lilypond[verbatim,singleline]
3201 '((font-relative-size . -2 ) (music "accidentals--1")))
3204 \property Staff.instrument = #`((kern . 0.5) (lines
3205 "2 Clarinetti" (columns " (B" ,text-flat ")")))
3213 When you put a name on a grand staff or piano staff the width of the
3214 brace is not taken into account. You must add extra spaces to the end of
3215 the name to avoid a collision.
3218 @subsection Transpose
3220 @cindex transposition of pitches
3221 @cindex @code{\transpose}
3223 A music expression can be transposed with @code{\transpose}. The syntax
3226 \transpose @var{pitch} @var{musicexpr}
3229 This means that middle C in @var{musicexpr} is transposed to
3232 @code{\transpose} distinguishes between enharmonic pitches: both
3233 @code{\transpose cis'} or @code{\transpose des'} will transpose up half
3234 a tone. The first version will print sharps and the second version
3237 @lilypond[singleline, verbatim]
3238 mus =\notes { \key d \major cis d fis g }
3239 \score { \notes \context Staff {
3247 If you want to use both @code{\transpose} and @code{\relative}, then
3248 you must use @code{\transpose} first. @code{\relative} will have no
3249 effect music that appears inside a @code{\transpose}.
3251 @c . {Multi measure rests}
3252 @node Multi measure rests
3253 @subsection Multi measure rests
3254 @cindex Multi measure rests
3258 Multi measure rests are entered using `@code{R}'. It is specifically
3259 meant for full bar rests and for entering parts: the rest can expand to
3261 rests, or it can be printed as a single multimeasure rest This expansion
3262 is controlled by the property @code{Score.skipBars}. If this is set to true,
3263 Lily will not expand empty measures, and the appropriate number is added
3266 @lilypond[fragment,verbatim]
3267 \time 3/4 r2. | R2. | R2.*2
3268 \property Score.skipBars = ##t R2.*17 R2.*4
3271 Notice that the @code{R2.} is printed as a whole rest, centered in the
3274 @cindex whole rests for a full measure
3276 The grob for this object is @internalsref{MultiMeasureRest}.
3280 Currently, there is no way to automatically condense multiple rests
3281 into a single multimeasure rest. Multi measure rests do not take part
3284 @cindex condensing rests
3286 @node Automatic part combining
3287 @subsection Automatic part combining
3288 @cindex automatic part combining
3289 @cindex part combiner
3292 Automatic part combining is used to merge two parts of music onto a
3293 staff in an intelligent way. It is aimed primarily at typesetting
3294 orchestral scores. When the two parts are identical for a period of
3295 time, only one is shown. In places where the two parts differ, they
3296 are typeset as separate voices, and stem directions are set
3297 automatically. Also, solo and @emph{a due} parts can be identified
3300 The syntax for part combining is
3303 \partcombine @var{context} @var{musicexpr1} @var{musicexpr2}
3305 where the pieces of music @var{musicexpr1} and @var{musicexpr2} will be
3306 combined into one context of type @var{context}. The music expressions
3307 must be interpreted by contexts whose names should start with @code{one}
3310 The most useful function of the part combiner is to combine parts into
3311 one voice, as common for wind parts in orchestral scores:
3313 @lilypond[verbatim,singleline,fragment]
3315 \context Voice=one \partcombine Voice
3316 \context Thread=one \relative c'' {
3319 \context Thread=two \relative c'' {
3325 Notice that the first @code{g} appears only once, although it was
3326 specified twice (once in each part). Stem, slur and tie directions are
3327 set automatically, depending whether there is a solo or unisono. The
3328 first part (with context called @code{one}) always gets up stems, and
3329 `solo', while the second (called @code{two}) always gets down stems and
3332 If you just want the merging parts, and not the textual markings, you
3333 may set the property @var{soloADue} to false.
3335 @lilypond[verbatim,singleline,fragment]
3337 \property Staff.soloADue = ##f
3338 \context Voice=one \partcombine Voice
3339 \context Thread=one \relative c'' {
3342 \context Thread=two \relative c'' {
3348 There are a number of other properties that you can use to tweak the
3349 behavior of part combining, refer to the automatically generated
3350 documentation of @reng{Thread_devnull_engraver} and
3351 @reng{Voice_devnull_engraver}. Look at the documentation of the
3352 responsible engravers, @code{Thread_devnull_engraver},
3353 @code{Voice_devnull_engraver} and @code{A2_engraver}.
3357 In @code{soloADue} mode, when the two voices play the same notes on and
3358 off, the part combiner may typeset @code{a2} more than once in a
3361 @lilypond[fragment,singleline]
3363 \context Voice=one \partcombine Voice
3364 \context Thread=one \relative c'' {
3367 \context Thread=two \relative c'' {
3373 @cindex @code{Thread_devnull_engraver}
3374 @cindex @code{Voice_engraver}
3375 @cindex @code{A2_engraver}
3377 @node Hara kiri staves
3378 @subsection Hara kiri staves
3380 In orchestral scores, staff lines that only have rests are usually removed.
3381 This saves some space. LilyPond also supports this through the hara
3382 kiri@footnote{Hara kiri, also called Seppuku, is the ritual suicide of
3383 the Japanese Samourai warriors.} staff. This staff commits suicide when
3384 it finds itself to be empty after the line-breaking process. It will
3385 not disappear when it contains normal rests, you must use multi measure
3388 The hara kiri staff is specialized version of the @internalsref{Staff}
3389 context. It is available as the context identifier
3390 @code{\HaraKiriStaffContext}. Observe how the second staff in this
3391 example disappears in the second line.
3395 \notes \relative c' <
3396 \context Staff = SA { e4 f g a \break c1 }
3397 \context Staff = SB { c4 d e f \break R1 }
3401 \translator { \HaraKiriStaffContext }
3407 @node Sound output for transposing instruments
3408 @subsection Sound output for transposing instruments
3410 When you want to make a MIDI file from a score containing transposed
3411 and untransposed instruments, you have to instruct LilyPond the pitch
3412 offset (in semitones) for the transposed instruments. This is done
3413 using the @code{transposing} property. It does not affect printed
3416 @cindex @code{transposing}
3419 \property Staff.instrument = #"Cl. in B-flat"
3420 \property Staff.transposing = #-2
3426 @node Ancient notation
3427 @section Ancient notation
3430 * Ancient note heads::
3437 @node Ancient note heads
3438 @subsection Ancient note heads
3440 To get a longa note head, you have to use mensural note heads. This
3441 is accomplished by setting the @code{style} property of the
3442 NoteHead grob to @code{mensural}. There is also a note head style
3443 @code{baroque} which gives mensural note heads for @code{\longa} and
3444 @code{\breve} but standard note heads for shorter notes.
3446 @lilypond[fragment,singleline,verbatim]
3447 \property Voice.NoteHead \set #'style = #'mensural
3448 \property Voice.NoteHead \set #'font-family = #'ancient
3453 @subsection Custodes
3458 A @emph{custos} (plural: @emph{custodes}; latin word for `guard') is a
3459 staff context symbol that appears at the end of a staff line. It
3460 anticipates the pitch of the first note(s) of the following line and
3461 thus helps the player or singer to manage line breaks during
3462 performance, thus enhancing readability of a score.
3467 \property Staff.Custos \set #'style = #'mensural
3472 \consists Custos_engraver
3478 Custodes were frequently used in music notation until the 17th century.
3479 There were different appearances for different notation styles.
3480 Nowadays, they have survived only in special forms of musical notation
3481 such as via the @emph{editio vaticana} dating back to the beginning of
3484 For typesetting custodes, just put a @code{Custos_engraver} into the
3485 @internalsref{Staff} context when declaring the @code{\paper} block. In this
3486 block, you can also globally control the appearance of the custos symbol
3487 by setting the custos @code{style} property. Currently supported styles
3488 are @code{vaticana}, @code{medicaea}, @code{hufnagel} and
3495 \consists Custos_engraver
3496 Custos \override #'style = #'mensural
3501 The property can also be set locally, for example in a @code{\notes}
3506 \property Staff.Custos \override #'style = #'vaticana
3507 c'1 d' e' d' \break c' d' e' d'
3512 @subsection Ancient clefs
3514 LilyPond supports a variety of clefs, many of them ancient. These can
3515 be selected from the @code{ancient} font family, by setting
3516 @code{Staff.clefGlyph}) to one of the following values
3525 @item clefs-vaticana_do
3526 Editio Vaticana style do clef
3527 @item clefs-vaticana_fa
3528 Editio Vaticana style fa clef
3529 @item clefs-medicaea_do
3530 Editio Medicaea style do clef
3531 @item clefs-medicaea_fa
3532 Editio Medicaea style fa clef
3533 @item clefs-mensural1_c
3534 modern style mensural C clef
3535 @item clefs-mensural2_c
3536 historic style small mensural C clef
3537 @item clefs-mensural3_c
3538 historic style big mensural C clef
3539 @item clefs-mensural1_f
3540 historic style traditional mensural F clef
3541 @item clefs-mensural2_f
3542 historic style new mensural F clef
3543 @item clefs-mensural_g
3544 historic style mensural G clef
3545 @item clefs-hufnagel_do
3546 historic style hufnagel do clef
3547 @item clefs-hufnagel_fa
3548 historic style hufnagel fa clef
3549 @item clefs-hufnagel_do_fa
3550 historic style hufnagel combined do/fa clef
3551 @item clefs-percussion
3552 modern style percussion clef
3555 @emph{Modern style} means ``as is typeset in current editions.''
3556 @emph{Historic style} means ``as was typeset or written in contemporary
3557 historic editions''. @emph{Editio XXX style} means ``as is/was printed in
3560 @cindex Vaticana, Editio
3561 @cindex Medicaea, Editio
3562 @cindex hufnagel clefs
3566 @subsection Figured bass
3568 @cindex Basso continuo
3570 LilyPond has limited support for figured bass:
3572 @lilypond[verbatim,fragment]
3574 \context FiguredBass
3579 \context Voice { c4 g8 }
3583 The support for figured bass consists of two parts: there is an input
3584 mode, introduced by @code{\figures}, where you can enter bass figures
3585 as numbers, and there is a context called @internalsref{FiguredBass}
3586 that takes care of making @internalsref{BassFigure} grobs.
3588 In figures input mode, a group of bass figures is delimited by
3589 @code{<} and @code{>}. The duration is entered after the @code{>}.
3594 \context FiguredBass
3598 Accidentals are added to the numbers if you alterate them by
3599 appending @code{-}, @code{!} and @code{+}.
3605 \context FiguredBass
3606 \figures { <4- 6+ 7!> }
3609 Spaces or dashes may be inserted by using @code{_}. Brackets are
3610 introduced with @code{[} and @code{]}.
3616 \context FiguredBass
3617 \figures { < [4 6] 8 [_ 12]> }
3620 Although the support for figured bass may superficially resemble chord
3621 support, it works much simpler: in figured bass simply stores the
3622 numbers, and then prints the numbers you entered. There is no
3623 conversion to pitches, and no realizations of the bass are played in
3627 @c . {Tuning output}
3629 @section Tuning output
3631 LilyPond tries to take as much formatting as possible out of your
3632 hands. Nevertheless, there are situations where it needs some help, or
3633 where you want to override its decisions. In this section we discuss
3634 ways to do just that.
3636 Formatting is internally done by manipulating so called grobs (graphic
3637 objects). Each grob carries with it a set of properties (grob
3638 properties) specific to that object. For example, a stem grob has
3639 properties that specify its direction, length and thickness.
3641 The most direct way of tuning the output is by altering the values of
3642 these properties. There are two ways of doing that: first, you can
3643 temporarily change the definition of a certain type of grob, thus
3644 affecting a whole set of objects. Second, you can select one specific
3645 object, and set a grob property in that object.
3648 * Tuning groups of grobs ::
3649 * Tuning per grob ::
3654 @node Tuning groups of grobs
3655 @subsection Tuning groups of grobs
3657 @cindex grob description
3661 A grob definition is a Scheme association list, that is stored in a
3662 context property. By assigning to that property (using plain
3663 @code{\property}), you can change the resulting grobs.
3665 @lilypond[verbatim, fragment]
3666 c'4 \property Voice.Stem = #'()
3669 The @code{\property} assignment effectively empties the definition of
3670 the Stem object. One of the effects is that the recipe of how it should be
3671 printed is erased, with the effect of rendering it invisible. The above
3672 assignment is available as a standard identifier, for the case that you
3676 \property Voice.Stem = \turnOff
3683 This mechanism is fairly crude, since you can only set, but not modify,
3684 the definition of a grob. For this reason, there is a more advanced
3687 The definition of a grob is actually a list of default grob
3688 properties. For example, the definition of the Stem grob (available in
3689 @file{scm/grob-description.scm}), defines the following values for
3694 (beamed-lengths . (0.0 2.5 2.0 1.5))
3695 (Y-extent-callback . ,Stem::height)
3699 You can add a property on top of the existing definition, or remove a
3700 property, thus overriding the system defaults:
3702 c'4 \property Voice.Stem \override #'thickness = #4.0
3703 c'4 \property Voice.Stem \revert #'thickness
3706 You should balance @code{\override} and @code{\revert}. If that's too
3707 much work, you can use the @code{\set} shorthand. It performs a revert
3708 followed by an override. The following example gives exactly the same
3709 result as the previous one.
3711 c'4 \property Voice.Stem \set #'thickness = #4.0
3712 c'4 \property Voice.Stem \set #'thickness = #0.8
3715 If you use @code{\set}, you must explicitly restore the default.
3718 Formally the syntax for these constructions is
3720 \property @var{context}.@var{grobname} \override @var{symbol} = @var{value}
3721 \property @var{context}.@var{grobname} \set @var{symbol} = @var{value}
3722 \property @var{context}.@var{grobname} \revert @var{symbol}
3724 Here @var{symbol} is a Scheme expression of symbol type, @var{context}
3725 and @var{grobname} are strings and @var{value} is a Scheme expression.
3728 If you revert a setting which was not set in the first place, then it
3729 has no effect. However, if the setting was set as a system default, it
3730 may remove the default value, and this may give surprising results,
3731 including crashes. In other words, @code{\override} and @code{\revert},
3732 must be carefully balanced.
3734 These are examples of correct nesting of @code{\override}, @code{\set},
3737 A clumsy but correct form:
3739 \override \revert \override \revert \override \revert
3742 Shorter version of the same:
3744 \override \set \set \revert
3747 A short form, using only @code{\set}. This requires you to know the
3750 \set \set \set \set @var{to default value}
3753 If there is no default (i.e. by default, the grob property is unset),
3756 \set \set \set \revert
3759 For the digirati, the grob description is an Scheme association
3760 list. Since a Scheme list is a singly linked list, we can treat it as a
3761 stack, and @code{\override} and @code{\revert} are just push and pop
3762 operations. This pushing and popping is also used for overriding
3763 automatic beaming settings.
3767 LilyPond will hang or crash if @var{value} contains cyclic references.
3768 The backend is not very strict in type-checking grob properties. If you
3769 @code{\revert} properties that are expected to be set by default,
3773 @cindex adjusting staff symbol
3774 @cindex StaffSymbol, using \property
3775 @cindex staff lines, setting number of
3777 Some grobs are created at the moment that their context is created. An
3778 example of such a grob is the staff itself (i.e. the horizontal lines).
3779 You can not change the appearance of the staff symbol by manipulating
3780 @code{\property Staff.StaffSymbol}. At the moment that @code{\property
3781 Staff} is interpreted, a Staff context is made, and the StaffSymbol is
3782 created before any @code{\override} is effective. You can deal with this
3783 either overriding properties in a @code{\translator} definition, or by
3784 using @code{\outputproperty}.
3789 @node Tuning per grob
3790 @subsection Tuning per grob
3792 @cindex \outputproperty
3794 A second way of tuning grobs is the more arcane @code{\outputproperty}
3795 feature. The syntax is as follows:
3797 \outputproperty @var{predicate} @var{symbol} = @var{value}
3799 Here @code{predicate} is a Scheme function taking a grob argument, and
3800 returning a boolean. This statement is processed by the
3801 @code{Output_property_engraver}. It instructs the engraver to feed all
3802 grobs that it sees to @var{predicate}. Whenever the predicate returns
3803 true, the grob property @var{symbol} will be set to @var{value}.
3805 You will need to combine this statement with @code{\context} to select
3806 the appropriate context to apply this to.
3808 Here are some random examples.
3811 In the following example, all note heads occurring at current staff
3812 level, are shifted up and right by setting their @code{extra-offset}
3815 @lilypond[fragment,verbatim,singleline]
3817 \context Staff \outputproperty
3818 #(make-type-checker 'note-head-interface)
3819 #'extra-offset = #'(0.5 . 0.75)
3823 @cindex @code{extra-offset}
3825 In this example, the predicate checks the @code{text} grob property, to
3826 shift only the `m.d.' text, but not the fingering instruction "2".
3827 @lilypond[verbatim,singleline]
3828 #(define (make-text-checker text)
3829 (lambda (grob) (equal? text (ly-get-grob-property grob 'text))))
3832 \notes\relative c''' {
3833 \property Voice.Stem \set #'direction = #1
3834 \outputproperty #(make-text-checker "m.d.")
3835 #'extra-offset = #'(-3.5 . -4.5)
3843 If possible, avoid this feature: the semantics are not very clean, and
3844 the syntax and semantics are up for rewrite.
3849 @node Font selection
3850 @subsection Font selection
3852 The most common thing to change about the appearance of fonts is
3853 their size. The font size of a @internalsref{Voice},
3854 @internalsref{Staff} or @internalsref{Thread} context, can be easily
3855 changed by setting the @code{fontSize} property for that context:
3856 @lilypond[fragment,relative=1]
3857 c4 c4 \property Voice.fontSize = #-1
3860 This command will not change the size of variable symbols, such as
3861 beams or slurs. You can use this command to get smaller symbol for
3862 cue notes, but that involves some more subtleties. An elaborate
3863 example of those is in @file{input/test/cue-notes.ly}.
3869 The font used for printing a grob can be selected by setting
3870 @code{font-name}, e.g.
3872 \property Staff.TimeSignature
3873 \set #'font-name = #"cmr17"
3875 You may use any font which is available to @TeX{}, such as foreign
3876 fonts or fonts that do not belong to the Computer Modern font family.
3877 Font selection for the standard fonts, @TeX{}'s Computer Modern fonts,
3878 can also be adjusted with a more fine-grained mechanism. By setting
3879 the grob properties described below, you can select a different font.
3880 All three mechanisms work for every grob that supports
3881 @code{font-interface}.
3885 A symbol indicating the general class of the typeface. Supported are
3886 @code{roman} (Computer Modern), @code{braces} (for piano staff
3887 braces), @code{music} (the standard music font), @code{ancient} (the
3888 ancient notation font) @code{dynamic} (font for dynamic signs) and
3892 A symbol indicating the shape of the font, there are typically several
3893 font shapes available for each font family. Choices are @code{italic},
3894 @code{caps} and @code{upright}
3897 A symbol indicating the series of the font. There are typically several
3898 font series for each font family and shape. Choices are @code{medium}
3901 @item font-relative-size
3902 A number indicating the size relative the standard size. For example,
3903 with 20pt staff height, relative size -1 corresponds to 16pt staff
3904 height, and relative size +1 corresponds to 23 pt staff height.
3906 @item font-design-size
3907 A number indicating the design size of the font.
3909 This is a feature of the Computer Modern Font: each point size has a
3910 slightly different design. Smaller design sizes are relatively wider,
3911 which enhances readability.
3914 For any of these properties, the value @code{*} (i.e. the @emph{symbol},
3915 @code{*}, entered as @code{#'*}), acts as a wildcard. This can be used
3916 to override default setting, which are always present. For example:
3918 \property Lyrics . LyricText \override #'font-series = #'bold
3919 \property Lyrics . LyricText \override #'font-family = #'typewriter
3920 \property Lyrics . LyricText \override #'font-shape = #'*
3923 @cindex @code{font-style}
3925 There are also pre-cooked font selection qualifiers. These are
3926 selected through the grob property @code{font-style}. For example,
3927 the style @code{finger} selects family @code{number} and relative size
3928 @code{-3}. Styles available include @code{volta}, @code{finger},
3929 @code{tuplet}, @code{timesig}, @code{mmrest}, @code{script},
3930 @code{large}, @code{Large} and @code{dynamic}. The style sheets and
3931 tables for selecting fonts are located in @file{scm/font.scm}. Refer
3932 to this file for more information.
3934 @cindex magnification
3936 The size of the font may be scaled with the grob property
3937 @code{font-magnification}. For example, @code{2.0} blows up all
3938 letters by a factor 2 in both directions.
3942 Relative size is not linked to any real size.
3944 There is no style sheet provided for other fonts besides the @TeX{}
3945 family, and the style sheet can not be modified easiyl.
3947 @cindex font selection
3948 @cindex font magnification
3949 @cindex @code{font-interface}
3953 @subsection Text markup
3957 LilyPond has an internal mechanism to typeset texts. You can
3958 form text markup expressions by composing scheme expressions
3959 in the following way.
3961 @lilypond[verbatim, singleline]
3966 c^#'(italic "italic")
3967 d_#'((bold italic) "ff")
3969 f_#'(lines "one" (bold "two"))
3970 g^#'(music "noteheads-2" ((raise . 2.4) "flags-u3"))
3974 Normally, the Scheme markup text is stored in the @code{text} property
3975 of a grob. Formally, it is defined as follows:
3978 text: string | (head? text+)
3979 head: markup | (markup+)
3980 markup-item: property | abbrev
3981 property: (@var{key} . @var{value})
3982 abbrev: @code{columns lines roman music bold italic named super sub}
3983 @code{overstrike text finger volta timesig mmrest mark script}
3984 @code{large Large dynamic}
3987 The markup is broken down and converted into a list of grob properties,
3988 which are prepended to the property list. The @var{key}-@var{value}
3989 pair is a grob property. A list of properties available is included in
3990 the generated documentation for @rint{Text_interface}.
3992 The following abbreviations are defined:
3995 horizontal mode: set all text on one line (default)
3997 vertical mode: set every text on a new line
4001 selects the Feta font (the standard font for music notation glyphs),
4002 and uses named lookup
4009 lookup by character name
4011 plain text lookup (by character value)
4017 the next text or character overstrikes this one
4019 select fingering number fontstyle
4021 select volta number fontstyle
4023 select time signature number fontstyle
4025 select multi measure rest number fontstyle
4027 select mark number fontstyle
4029 select scriptsize roman fontstyle
4031 select large roman fontstyle
4033 select Large roman fontstyle
4035 select dynamics fontstyle
4039 @cindex metronome mark
4041 One practical application of complicated markup is to fake a metronome
4045 #(define note '(columns
4046 (music "noteheads-2" ((kern . -0.1) "flags-stem"))))
4047 #(define eight-note `(columns ,note ((kern . -0.1)
4048 (music ((raise . 3.5) "flags-u3")))))
4049 #(define dotted-eight-note
4050 `(columns ,eight-note (music "dots-dot")))
4053 \notes\relative c'' {
4054 a1^#`((columns (font-relative-size . -1)) ,dotted-eight-note " = 64")
4060 TextScript \override #'font-shape = #'upright
4068 The syntax and semantics of markup texts are not clean, and both
4069 syntax and semantics are slated for a rewrite.
4072 @section Global layout
4074 The global layout determined by three factors: the page layout, the
4075 line breaks and the spacing. These all influence each other: The
4076 choice of spacing determines how densely each system of music is set,
4077 whree line breaks breaks are chosen, and thus ultimately how many
4078 pages a piece of music takes. In this section we will explain how the
4079 lilypond spacing engine works, and how you can tune its results.
4081 Globally spoken, this procedure happens in three steps: first,
4082 flexible distances (``springs'') are chosen, based on durations. All
4083 possible line breaking combination are tried, and the one with the
4084 best results---a layout that has uniform density and requires as
4085 little stretching or cramping as possible---is chosen. When the score
4086 is processed by @TeX{}, page are filled with systems, and page breaks
4087 are chosen whenever the page gets full.
4099 The spacing engine translates differences in durations into
4100 stretchable distances (``springs'') of differing lengths. Longer
4101 durations get more space, shorter durations get less. The basis for
4102 assigning spaces to durations, is that the shortest durations get a
4103 fixed amount of space, and the longer durations get more: doubling a
4104 duration adds a fixed amount of space to the note.
4106 For example, the following piece contains lots of half, quarter and
4107 8th notes, the eighth note is followed by 1 note head width. The The
4108 quarter note is followed by 2 NHW, the half by 3 NHW, etc.
4109 @lilypond[fragment, verbatim, relative=1]
4110 c2 c4. c8 c4. c8 c4. c8 c8 c8 c4 c4 c4
4113 These two amounts of space are @code{shortest-duration-space}
4114 @code{spacing-increment}, grob properties of
4115 @internalsref{SpacingSpanner}. Normally @code{spacing-increment} is
4116 set to 1.2, which is the width of a note head, and
4117 @code{shortest-duration-space} is set to 2.0, meaning that the
4118 shortest note gets 2 noteheads of space. For normal notes, this space
4119 is always counted from the left edge of the symbol, so the short notes
4120 in a score is generally followed by one note head width of space.
4122 If one would follow the above procedure exactly, then adding a single
4123 32th note to a score that uses 8th and 16th notes, would widen up the
4124 entire score a lot. The shortest note is no longer a 16th, but a 64th,
4125 thus adding 2 noteheads of space to every note. To prevent this, the
4126 shortest duration for spacing is not the shortest note in the score,
4127 but the most commonly found shortest note. Notes that are even
4128 shorter this are followed by a space that is proportonial to their
4129 duration relative to the common shortest note. So if we were to add
4130 only a few 16th notes to the example above, they would be followed by
4133 @lilypond[fragment, verbatim, relative=1]
4134 c2 c4. c8 c4. [c16 c] c4. c8 c8 c8 c4 c4 c4
4137 The most common shortest duration is determined as follows: in every
4138 measure, the shortest duration is determined. The most common short
4139 duration, is taken as the basis for the spacing, with the stipulation
4140 that this shortest duration should always be equal to or shorter than
4141 1/8th note. The shortest duration is printed when you run lilypond
4142 with @code{--verbose}. These durations may also be customized. If you
4143 set the @code{common-shortest-duration} in
4144 @internalsref{SpacingSpanner}, then this sets the base duration for
4145 spacing. The maximum duration for this base (normally 1/8th), is set
4146 through @code{base-shortest-duration}.
4148 @cindex @code{common-shortest-duration}
4149 @cindex @code{base-shortest-duration}
4150 @cindex @code{stem-spacing-correction}
4151 @cindex @code{spacing}
4153 In the introduction it was explained that stem directions influence
4154 spacing. This is controlled with @code{stem-spacing-correction} in
4155 @internalsref{NoteSpacing}. The @code{StaffSpacing} grob contains the
4156 same property for controlling the stem/barline spacing. In the
4157 following example shows these corrections, once with default settings,
4158 and once with exaggerated corrections.
4164 \property Staff.NoteSpacing \override #'stem-spacing-correction
4166 \property Staff.StaffSpacing \override #'stem-spacing-correction
4171 \paper { linewidth = -1. } }
4178 Spacing is determined on a score wide basis. If you have a score that
4179 changes its character (measured in durations) half way during the
4180 score, the part containing the longer durations will be spaced too
4183 Generating optically pleasing spacing is black magic. LilyPond tries
4184 to deal with a number of frequent cases. Here is an example that is
4185 not handled correctly, due to the combination of chord collisions and
4190 \context PianoStaff \notes \transpose c''' <
4191 \context Staff = up { s1 }
4192 \context Staff = down { [c8 c \translator Staff=up <c d> c
4193 \translator Staff=down c c c] }
4195 \paper { linewidth = -1 }
4202 @subsection Font size
4203 @cindex font size, setting
4204 @cindex staff size, setting
4205 @cindex @code{paper} file
4207 The Feta font provides musical symbols at seven different sizes.
4208 These fonts are 11 point, 13 point, 16 point, 19 pt, 20 point, 23
4209 point, and 26 point. The point size of a font is the height of the
4210 five lines in a staff when displayed in the font.
4212 Definitions for these sizes are the files @file{paperSZ.ly}, where
4213 @code{SZ} is one of 11, 13, 16, 19, 20, 23 and 26. If you include any
4214 of these files, the identifiers @code{paperEleven},
4215 @code{paperThirteen}, @code{paperSixteen}, @code{paperNineteen},
4216 @code{paperTwenty}, @code{paperTwentythree}, and @code{paperTwentysix}
4217 are defined respectively. The default @code{\paper} block is also
4218 set. These files should be imported at toplevel, i.e.
4220 \include "paper26.ly"
4224 The font definitions are generated using a Scheme function. For more
4225 details, see the file @file{scm/font.scm}.
4230 @subsection Line breaking
4233 @cindex breaking lines
4235 Line breaks are normally computed automatically. They are chosen such
4236 that it looks neither cramped nor loose, and that consecutive lines have
4239 Occasionally you might want to override the automatic breaks; you can
4240 do this by specifying @code{\break}. This will force a line break at
4241 this point. Line breaks can only occur at places where there are bar
4242 lines. If you want to have a line break where there is no bar line,
4243 you can force an invisible bar line by entering @code{\bar
4244 ""}. Similarly, @code{\noBreak} forbids a line break at a certain
4247 If you want linebreaks at regular intervals, you can use the following:
4249 < \repeat 7 unfold @{ s1 * 4 \break @}
4253 This makes the following 28 measures (assuming 4/4 time) be broken every
4257 @subsection Page layout
4260 @cindex breaking pages
4262 @cindex @code{indent}
4263 @cindex @code{linewidth}
4265 The most basic settings influencing the spacing are @code{linewidth}
4266 and @code{indent}, both set in the @code{\paper} block. They control
4267 the indentation of the first line of music, and the lengths of the
4268 lines. If @code{linewidth} set to a negative value, a single
4269 unjustified line is produced. A similar effect for scores that are
4270 longer than one line, can be produced by setting @code{raggedright} to
4271 true in the @code{\paper} block.
4275 The page layout process happens outside lilypond. Ly2dvi sets page
4276 layout instructions. Ly2dvi responds to the following variables in the
4277 @code{\paper} block. The variable @code{textheight} sets the total
4278 height of the music on each page. The spacing between systems is
4279 controlled with @code{interscoreline}, its default is 16pt.
4280 The distance between the score lines will stretch in order to fill the
4281 full page @code{interscorelinefill} is set to a positive number. In
4282 that case @code{interscoreline} specifies the minimum spacing.
4284 @cindex @code{textheight}
4285 @cindex @code{interscoreline}
4286 @cindex @code{interscorelinefill}
4288 Page breaks are normally computed by @TeX{}, so they are not under
4289 direct control of LilyPond. However, you can insert a commands into
4290 the @file{.tex} output to instruct @TeX{} where to break pages. You
4291 can insert a @code{\newpage} from within lilypond. This is done by
4292 setting the @code{between-systems-strings} on the
4293 @internalsref{NonMusicalPaperColumn} where the system is broken.
4297 @cindex @code{papersize}
4299 To change the paper size, you must first set the
4300 @code{papersize} paper variable variable. Set it to
4301 the strings @code{a4}, @code{letter}, or @code{legal}. After this
4302 specification, you must set the font as described above. If you want
4303 the default font, then use the 20 point font.
4306 \paper@{ papersize = "a4" @}
4307 \include "paper16.ly"
4310 The file @code{paper16.ly} will now include a file named @file{a4.ly}, which
4311 will set the paper variables @code{hsize} and @code{vsize} (used by
4312 Lilypond and @code{ly2dvi})
4322 LilyPond can produce MIDI output. The performance lacks lots of
4323 interesting effects, such as swing, articulation, slurring, etc., but it
4324 is good enough for proof-hearing the music you have entered. Ties,
4325 dynamics and tempo changes are interpreted.
4327 Dynamic marks, crescendi and decrescendi translate into MIDI volume
4328 levels. Dynamic marks translate to a fixed fraction of the available
4329 MIDI volume range, crescendi and decrescendi make the the volume vary
4330 linearly between their two extremities. The fractions be adjusted by
4331 overriding the @code{absolute-volume-alist} defined in
4332 @file{scm/midi.scm}.
4334 For each type of musical instrument (that MIDI supports), a volume range
4335 can be defined. This gives you basic equalizer control, which can
4336 enhance the quality of the MIDI output remarkably. You can add
4337 instruments and ranges or change the default settings by overriding the
4338 @code{instrument-equalizer-alist} defined in @file{scm/midi.scm}.
4340 Both loudness controls are combined to produce the final MIDI volume.
4346 * MIDI instrument names::
4351 @subsection MIDI block
4355 The MIDI block is analogous to the paper block, but it is somewhat
4356 simpler. The @code{\midi} block can contain:
4360 @item a @code{\tempo} definition
4361 @item context definitions
4364 Assignments in the @code{\midi} block are not allowed.
4368 @cindex context definition
4370 Context definitions follow precisely the same syntax as within the
4371 \paper block. Translation modules for sound are called performers.
4372 The contexts for MIDI output are defined in @file{ly/performer-init.ly}.
4375 @node MIDI instrument names
4376 @subsection MIDI instrument names
4378 @cindex instrument names
4379 @cindex @code{Staff.midiInstrument}
4380 @cindex @code{Staff.instrument}
4382 The MIDI instrument name is set by the @code{Staff.midiInstrument}
4383 property or, if that property is not set, the @code{Staff.instrument}
4384 property. The instrument name should be chosen from the list in
4385 @ref{MIDI instruments}.
4389 If the selected string does not exactly match, then LilyPond uses the
4390 default (Grand Piano). It is not possible to select an instrument by