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::
52 @c FIXME: Note entry vs Music entry at top level menu is confusing.
58 The most basic forms of music are notes. Notes on their own don't
59 form valid input, but for the sake of brevity we omit @code{\score}
60 blocks and @code{\paper} declarations.
66 * Chromatic alterations::
71 * Automatic note splitting ::
73 * Easy Notation note heads ::
81 A note is printed by specifying its pitch, and then its duration.
82 @lilypond[fragment,verbatim]
91 @cindex Note specification
93 @cindex entering notes
95 The verbose syntax for pitch specification is
102 @var{scmpitch} is a pitch scheme object.
104 In Note and Chord mode, pitches may be designated by names. The default
105 names are the Dutch note names. The notes are specified by the letters
106 @code{a} through @code{g} (where the octave is formed by notes ranging
107 from @code{c} to @code{b}). The pitch @code{c} is an octave below
108 middle C and the letters span the octave above that C.
110 @cindex note names, Dutch
112 In Dutch, a sharp is formed by adding @code{-is} to the end of a pitch
113 name and a flat is formed by adding @code{-es}. Double sharps and double
114 flats are obtained by adding @code{-isis} or @code{-eses}. @code{aes}
115 and @code{ees} are contracted to @code{as} and @code{es} in Dutch, but
116 both forms are accepted.
118 LilyPond has predefined sets of note names for various other languages.
119 To use them, simply include the language specific init file. For
120 example: @code{\include "english.ly"}. The available language files and
121 the names they define are:
124 Note Names sharp flat
125 nederlands.ly c d e f g a bes b -is -es
126 english.ly c d e f g a bf b -s/-sharp -f/-flat
127 deutsch.ly c d e f g a b h -is -es
128 norsk.ly c d e f g a b h -iss/-is -ess/-es
129 svenska.ly c d e f g a b h -iss -ess
130 italiano.ly do re mi fa sol la sib si -d -b
131 catalan.ly do re mi fa sol la sib si -d/-s -b
132 espanol.ly do re mi fa sol la sib si -s -b
141 The optional octave specification takes the form of a series of
142 single quote (`@code{'}') characters or a series of comma
143 (`@code{,}') characters. Each @code{'} raises the pitch by one
144 octave; each @code{,} lowers the pitch by an octave.
146 @lilypond[fragment,verbatim,center]
147 c' c'' es' g' as' gisis' ais'
150 @node Chromatic alterations
151 @subsection Chromatic alterations
153 Normally, accidentals are printed automatically, but you may force
154 accidentals in the following ways: A reminder accidental
155 @cindex reminder accidental
157 can be forced by adding an exclamation mark @code{!} after the pitch. A
158 cautionary accidental,
159 @cindex cautionary accidental
160 @cindex parenthesized accidental
161 i.e., an accidental within parentheses can be obtained by adding the
162 question mark `@code{?}' after the pitch.
164 The automatic production of accidentals can be tuned in many
165 ways. Refer to @ref{Accidentals} for more information.
172 A rest is entered like a note, with note name `@code{r}':
174 @lilypond[singleline,verbatim]
178 Whole bar rests centered in the bar are specified using @code{R}, see
179 @ref{Multi measure rests}. See also @seeinternals{Rest}.
181 For polyphonic music, it can be convenient to specify the rest position
182 directly. You can do that by entering a note, with the keyword
183 @code{\rest} appended, e.g. Rest collisions will leave these rests alone.
185 @lilypond[singleline,verbatim]
195 @cindex Invisible rest
198 An invisible rest, or skip, can be entered like a note with note name
199 @code{s}, or with @code{\skip @var{duration}}:
201 @lilypond[singleline,verbatim]
205 The @code{s} syntax is only available in Note mode and Chord mode.
206 In other situations, you should use the @code{\skip} command, and it is
207 only available in Note mode and Chord mode.
209 @c FIXME: in lyrics mode, we have " " and _
211 In Lyrics mode, you can use `@code{" "}' and `@code{_}':
212 @lilypond[singleline,verbatim]
214 \context Lyrics \lyrics { lah2 di4 " " dah2 _4 di }
215 \notes\relative c'' { a2 a4 a a2 a4 a }
219 The unabbreviated `@code{\skip} @var{duration}' also works outside of
222 @lilypond[singleline,verbatim]
225 { \time 4/8 \skip 2 \time 4/4 }
226 \notes\relative c'' { a2 a1 }
231 The skip command is merely a empty musical placeholder. It does not
232 produce any output, not even transparent output.
237 @subsection Durations
241 @cindex @code{\duration}
244 In Note, Chord, and Lyrics mode, durations may be designated by numbers
245 and dots: durations are entered as their reciprocal values. For notes
246 longer than a whole you must use identifiers.
250 c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64
252 r1 r2 r4 r8 r16 r32 r64 r64
258 \notes \relative c'' {
260 a1 a2 a4 a8 a16 a32 a64 a64
262 r1 r2 r4 r8 r16 r32 r64 r64
267 \remove "Clef_engraver"
268 \remove "Staff_symbol_engraver"
269 \remove "Time_signature_engraver"
270 \consists "Pitch_squash_engraver"
277 If the duration is omitted then it is set to the previous duration
278 entered. At the start of parsing a quarter note is assumed. The
279 duration can be followed by dots (`@code{.}') to obtain dotted note
283 @lilypond[fragment,verbatim,center]
289 You can alter the length of duration by a fraction @var{N/M} by
290 appending `@code{*}@var{N/M}' (or `@code{*}@var{N}' if @var{M=1}). This
291 will not affect the appearance of the notes or rests produced.
293 Durations can also be produced through GUILE extension mechanism.
294 @lilypond[verbatim,fragment]
295 c\duration #(make-duration 2 1)
301 Dot placement for chords is not perfect. In some cases, dots overlap:
303 \context Voice { <f,4. c'' d e f> }
314 A tie connects two adjacent note heads of the same pitch. The tie in
315 effect extends the length of a note. A tie is entered with @code{~}.
317 @lilypond[fragment,verbatim,center]
318 e' ~ e' <c' e' g'> ~ <c' e' g'>
321 When ties are used with chords, all note heads whose pitches match are
322 connected. Ties are indicated using the tilde symbol `@code{~}'. If
323 you try to tie together chords which have no common pitches then no
324 ties will be created.
326 If you want less ties created for a chord, you can set
327 @code{Voice.sparseTies} to true. In this case, a single tie is used
328 for every tied chord.
329 @lilypond[fragment,verbatim,center]
330 \property Voice.sparseTies = ##t
331 <c' e' g'> ~ <c' e' g'>
334 In its meaning a tie is just a way of extending a note duration, similar
335 to the augmentation dot: the following example are two ways of notating
336 exactly the same concept.
338 @lilypond[fragment, singleline]
339 \time 3/4 c'2. c'2 ~ c'4
341 Ties should not be confused with slurs, which indicate articulation,
342 and phrasing slurs, which indicate musical phrasing.
344 See also @seeinternals{Tie}.
349 At present, the tie is represented as a separate event, temporally
350 located in between the notes. Tieing only a subset of the note heads
351 of a chord is not supported in a simple way. It can be achieved by
352 moving the tie-engraver into the Thread context and turning on and off
355 Switching staffs when a tie is active will not work.
357 @node Automatic note splitting
358 @subsection Automatic note splitting
359 @c FIXME: This subsection doesn't belong in @ref{Note entry}.
361 There is a facility for automatically converting long notes to tied
362 notes. This is done by replacing the @code{Note_heads_engraver} by the
363 @code{Completion_heads_engraver}.
365 @lilypond[verbatim,center]
367 \notes\relative c'{ \time 2/4
368 c2. c8 d4 e f g a b c8 c2 b4 a g16 f4 e d c8. c2
372 \remove "Note_heads_engraver"
373 \consists "Completion_heads_engraver"
377 This engraver splits all running notes at the bar line, and inserts
378 ties. One of its uses is to debug complex scores: if the measures are
379 not entirely filled, then the ties exactly show how much each measure
384 Not all durations (especially those containing tuplets) can be
385 represented exactly; the engraver will not insert tuplets.
392 @cindex @code{\times}
394 Tuplets are made out of a music expression by multiplying all duration
397 @cindex @code{\times}
399 \times @var{fraction} @var{musicexpr}
402 The duration of @var{musicexpr} will be multiplied by the fraction.
403 In print, the fraction's denominator will be printed over the notes,
404 optionally with a bracket. The most common tuplet is the triplet in
405 which 3 notes have the length of 2, so the notes are 2/3 of
406 their written length:
408 @lilypond[fragment,verbatim,center]
409 g'4 \times 2/3 {c'4 c' c'} d'4 d'4
412 The property @code{tupletSpannerDuration} specifies how long each bracket
413 should last. With this, you can make lots of tuplets while typing
414 @code{\times} only once, thus saving typing work.
416 @lilypond[fragment, relative, singleline, verbatim]
417 \property Voice.tupletSpannerDuration = #(make-moment 1 4)
418 \times 2/3 { c'8 c c c c c }
421 The format of the number is determined by the property
422 @code{tupletNumberFormatFunction}. The default prints only the
423 denominator, but if you set it to the Scheme function
424 @code{fraction-tuplet-formatter}, Lilypond will print @var{num}:@var{den}
428 @cindex @code{tupletNumberFormatFunction}
429 @cindex tuplet formatting
431 See also @seeinternals{TupletBracket}.
435 Nested tuplets are not formatted automatically. In this case, outer
436 tuplet brackets should be moved automatically.
438 @node Easy Notation note heads
439 @subsection Easy Notation note heads
441 @cindex easy notation
444 A entirely different type of note head is the "easyplay" note head: a
445 note head that includes a note name. It is used in some publications by
446 Hal-Leonard Inc. music publishers.
448 @lilypond[singleline,verbatim,26pt]
450 \notes { c'2 e'4 f' | g'1 }
451 \paper { \translator { \EasyNotation } }
455 Note that @code{EasyNotation} overrides a @internalsref{Score} context. You
456 probably will want to print it with magnification or a large font size to make it more
463 If you view the result with Xdvi, then staff lines will show through
464 the letters. Printing the PostScript file obtained with ly2dvi does
465 produce the correct result.
468 @node Easier music entry
469 @section Easier music entry
472 * Graphical interfaces::
476 * Skipping corrected music::
479 When entering music with LilyPond, it is easy to introduce errors. This
480 section deals with tricks and features that help you enter music, and
481 find and correct mistakes.
483 @node Graphical interfaces
484 @subsection Graphical interfaces
487 @cindex graphical interface
494 One way to avoid entering notes using the keyboard is to use a
495 graphical user interface. The following programs are known to have
496 a lilypond export option:
500 @uref{http://denemo.sourceforge.net/, Denemo} was once intended as
501 a LilyPond graphical user interface. It run on Gnome/GTK.
503 @uref{http://rnvs.informatik.tu-chemnitz.de/~jan/noteedit/noteedit.html, Noteedit}
504 is a graphical score editor that runs under KDE/Qt.
506 @uref{http://rosegarden.sf.net/, RoseGarden}
507 was the inspiration for naming LilyPond. Nowadays it has been
508 rewritten from scratch and supports LilyPond export as of version
512 Another option is to enter the music using your favorite MIDI
513 sequencer, and then import it using midi2ly. midi2ly is described in
514 @ref{Invoking midi2ly}.
518 @node Relative octaves
519 @subsection Relative octaves
521 @cindex relative octave specification
523 Octaves are specified by adding @code{'} and @code{,} to pitch names.
524 When you copy existing music, it is easy to accidentally put a pitch in
525 the wrong octave and hard to find such an error. To prevent these
526 errors, LilyPond features octave entry.
528 @cindex @code{\relative}
530 \relative @var{startpitch} @var{musicexpr}
533 The octave of notes that appear in @var{musicexpr} are calculated as
534 follows: If no octave changing marks are used, the basic interval
535 between this and the last note is always taken to be a fourth or less
536 (This distance is determined without regarding alterations; a
537 @code{fisis} following a @code{ceses} will be put above the
540 The octave changing marks @code{'} and @code{,} can be added to raise or
541 lower the pitch by an extra octave. Upon entering relative mode, an
542 absolute starting pitch must be specified that will act as the
543 predecessor of the first note of @var{musicexpr}.
545 Entering music that changes octave frequently is easy in relative mode.
546 @lilypond[fragment,singleline,verbatim,center]
552 And octave changing marks are used for intervals greater than a fourth.
553 @lilypond[fragment,verbatim,center]
558 If the preceding item is a chord, the first note of the chord is used
559 to determine the first note of the next chord. However, other notes
560 within the second chord are determined by looking at the immediately
563 @lilypond[fragment,verbatim,center]
570 @cindex @code{\notes}
572 The pitch after the @code{\relative} contains a note name. To parse
573 the pitch as a note name, you have to be in note mode, so there must
574 be a surrounding @code{\notes} keyword (which is not
577 The relative conversion will not affect @code{\transpose},
578 @code{\chords} or @code{\relative} sections in its argument. If you
579 want to use relative within transposed music, you must place an
580 additional @code{\relative} inside the @code{\transpose}.
585 @subsection Bar check
589 @cindex @code{barCheckSynchronize}
593 Whenever a bar check is encountered during interpretation, a warning
594 message is issued if it doesn't fall at a measure boundary. This can
595 help you find errors in the input. Depending on the value of
596 @code{barCheckSynchronize}, the beginning of the measure will be
597 relocated, so this can also be used to shorten measures.
599 A bar check is entered using the bar symbol, @code{|}:
601 \time 3/4 c2 e4 | g2.
606 @cindex skipTypesetting
608 Failed bar checks are most often caused by entering incorrect
609 durations. Incorrect durations often completely garble up the score,
610 especially if it is polyphonic, so you should start correcting the score
611 by scanning for failed bar checks and incorrect durations. To speed up
612 this process, you can use @code{skipTypesetting} (See @ref{Skipping
615 @c . {Point and click}
616 @node Point and click
617 @subsection Point and click
618 @cindex poind and click
620 Point and click lets you find notes in the input by clicking on them in
621 the Xdvi window. This makes it very easy to find input that causes some
622 error in the sheet music.
624 To use it, you need the following software
626 @item A dvi viewer that supports src specials.
628 @item Xdvi, version 22.36 or newer. Available from
629 @uref{ftp://ftp.math.berkeley.edu/pub/Software/TeX/xdvi.tar.gz,ftp.math.berkeley.edu}.
631 Note that most @TeX{} distributions ship with xdvik, which is always
632 a few versions behind the official Xdvi. To find out which xdvi you
633 are running, try @code{xdvi -version} or @code{xdvi.bin -version}.
634 @item KDVI. A dvi viewer for KDE. You need KDVI from KDE 3.0 or
635 newer. Enable option @emph{Inverse search} in the menu @emph{Settings}.
644 @item An editor with a client/server interface (or a lightweight GUI
650 @item Emacs. Emacs is an extensible text-editor. It is available from
651 @uref{http://www.gnu.org/software/emacs/}. You need version 21 to use
654 @c move this elsewhere?
656 LilyPond also comes with support files for emacs: lilypond-mode for
657 emacs provides indentation, syntax coloring and handy compile
658 short-cuts. If lilypond-mode is not installed on your platform, then
659 refer to the installation instructions for more information
663 @cindex lilypond-mode for emacs
664 @cindex syntax coloring
666 @item XEmacs. Xemacs is very similar to emacs.
670 @item NEdit. NEdit runs under Windows, and Unix.
671 It is available from @uref{http://www.nedit.org}.
675 @item GVim. GVim is a GUI variant of VIM, the popular VI
676 clone. It is available from @uref{http://www.vim.org}.
685 Xdvi must be configured to find the @TeX{} fonts and music
686 fonts. Refer to the Xdvi documentation for more information.
688 To use point-and-click, add one of these lines to the top of your .ly
691 #(set-point-and-click! 'line)
693 @cindex line-location
695 When viewing, Control-Mousebutton 1 will take you to the originating
696 spot in the @file{.ly} file. Control-Mousebutton 2 will show all
699 If you correct large files with point-and-click, be sure to start
700 correcting at the end of the file. When you start at the top, and
701 insert one line, all following locations will be off by a line.
704 For using point-and-click with emacs, add the following
705 In your emacs startup file (usually @file{~/.emacs}),
710 Make sure that the environment variable @var{XEDITOR} is set to
712 emacsclient --no-wait +%l %f
714 @cindex @var{XEDITOR}
715 If you use xemacs instead of emacs, you use @code{(gnuserve-start)} in
716 your @file{.emacs}, and set @code{XEDITOR} to @code{gnuclient -q +%l %f}
718 For using Vim, set @code{XEDITOR} to @code{gvim --remote +%l %f}, or use this
719 argument with xdvi's @code{-editor} option.
721 For using NEdit, set @code{XEDITOR} to @code{nc -noask +%l %f}, or
722 use this argument with xdvi's @code{-editor} option.
724 If can also make your editor jump to the exact location of the note
725 you clicked. This is only supported on Emacs. Users of version 20 must
726 apply the patch @file{emacsclient.patch}. Users of version 21 must
727 apply @file{server.el.patch} (version 21.2 and earlier). At the top
728 of the @code{ly} file, replace the @code{set!} line with the following
731 #(set-point-and-click! 'line-column)
733 @cindex line-colomn-location
734 and set @code{XEDITOR} to @code{emacsclient --no-wait +%l:%c %f}.
738 When you convert the @TeX{} file to PostScript using @code{dvips}, it
739 will complain about not finding @code{src:X:Y} files. These complaints
740 are harmless, and can be ignored.
742 @node Skipping corrected music
743 @subsection Skipping corrected music
745 The property @code{Score.skipTypesetting} can be used to switch on and
746 off typesetting completely during the interpretation phase. When
747 typesetting is switched off, the music is processed much more quickly.
748 You can use this to skip over the parts of a score that you have already
751 @lilypond[fragment,singleline,verbatim]
753 \property Score.skipTypesetting = ##t
755 \property Score.skipTypesetting = ##f
763 @section Staff notation
765 This section deals with music notation that occurs on staff level,
766 such as keys, clefs and time signatures.
768 @cindex Staff notation
780 @subsection Staff symbol
783 @cindex adjusting staff symbol
784 @cindex StaffSymbol, using \property
785 @cindex staff lines, setting number of
788 The lines of the staff symbol are formed by the
789 @internalsref{StaffSymbol} grob. This grob is created at the moment
790 that their context is created. You can not change the appearance of
791 the staff symbol by using @code{\override} or @code{\set}. At the
792 moment that @code{\property Staff} is interpreted, a Staff context is
793 made, and the StaffSymbol is created before any @code{\override} is
794 effective. You can deal with this either overriding properties in a
795 @code{\translator} definition, or by using @code{\outputproperty}.
800 If you end a staff half way a piece, the staff symbol may not end
801 exactly on the barline.
806 @subsection Key signature
811 Setting or changing the key signature is done with the @code{\key}
814 @code{\key} @var{pitch} @var{type}
817 @cindex @code{\minor}
818 @cindex @code{\major}
819 @cindex @code{\minor}
820 @cindex @code{\ionian}
821 @cindex @code{\locrian}
822 @cindex @code{\aeolian}
823 @cindex @code{\mixolydian}
824 @cindex @code{\lydian}
825 @cindex @code{\phrygian}
826 @cindex @code{\dorian}
828 Here, @var{type} should be @code{\major} or @code{\minor} to get
829 @var{pitch}-major or @var{pitch}-minor, respectively.
830 The standard mode names @code{\ionian},
831 @code{\locrian}, @code{\aeolian}, @code{\mixolydian}, @code{\lydian},
832 @code{\phrygian}, and @code{\dorian} are also defined.
834 This command sets the context property @code{Staff.keySignature}.
835 Non-standard key signatures can be specified by setting this property
838 The printed signature is a @internalsref{KeySignature} grob, typically
839 created in @internalsref{Staff} context.
841 @cindex @code{keySignature}
848 The clef can be set or changed with the @code{\clef} command:
849 @lilypond[fragment,verbatim]
850 \key f\major c''2 \clef alto g'2
853 Supported clef-names include
854 @c Moved standard clefs to the top /MB
856 @item treble, violin, G, G2
865 G clef on 1st line, so-called French violin clef
880 By adding @code{_8} or @code{^8} to the clef name, the clef is
881 transposed one octave down or up, respectively. Note that you have to
882 enclose @var{clefname} in quotes if you use underscores or digits in the
888 The grob for this symbol is @internalsref{Clef}.
891 This command is equivalent to setting @code{clefGlyph},
892 @code{clefPosition} (which controls the Y position of the clef),
893 @code{centralCPosition} and @code{clefOctavation}. A clef is created
894 when any of these properties are changed.
897 @c . {Time signature}
899 @subsection Time signature
900 @cindex Time signature
904 The time signature is set or changed by the @code{\time}
906 @lilypond[fragment,verbatim]
907 \time 2/4 c'2 \time 3/4 c'2.
910 The actual symbol that's printed can be customized with the @code{style}
911 property. Setting it to @code{#'()} uses fraction style for 4/4 and
915 The grob for this symbol is @internalsref{TimeSignature}. There are
916 many more options for its layout. They are selected through the
917 @code{style} grob property. See @file{input/test/time.ly} for more
920 This command sets the property @code{timeSignatureFraction},
921 @code{beatLength} and @code{measureLength}. The property
922 @code{timeSignatureFraction} determine where bar lines should be
923 inserted, and how automatic beams should be generated. Changing the
924 value of @code{timeSignatureFraction} also causes a time signature
925 symbol to be printed.
932 @cindex partial measure
933 @cindex measure, partial
934 @cindex shorten measures
935 @cindex @code{\partial}
937 Partial measures, for example in upbeats, are entered using the
938 @code{\partial} command:
939 @lilypond[fragment,verbatim]
940 \partial 4* 5/16 c'16 c4 f16 a'2. ~ a'8. a'16 | g'1
943 The syntax for this command is
945 \partial @var{duration}
947 This is internally translated into
949 \property Score.measurePosition = -@var{length of duration}
952 The property @code{measurePosition} contains a rational number
953 indicating how much of the measure has passed at this point.
956 @node Unmetered music
957 @subsection Unmetered music
959 Bar lines and bar numbers are calculated automatically. For unmetered
960 music (e.g. cadenzas), this is not desirable. The commands
961 @code{\cadenzaOn} and @code{\cadenzaOff} can be used to switch off the
964 @lilypond[fragment,relative,singleline,verbatim]
972 The property @code{Score.timing} can be used to switch off this
977 @subsection Bar lines
981 @cindex measure lines
984 Bar lines are inserted automatically, but if you need a special type
985 of barline, you can force one using the @code{\bar} command:
986 @lilypond[fragment,verbatim] c4 \bar "|:" c4
989 The following bar types are available
990 @lilypond[fragment, relative, singleline, verbatim]
1002 You are encouraged to use @code{\repeat} for repetitions. See
1005 In scores with many staffs, the barlines are automatically placed at
1006 top level, and they are connected between different staffs of a
1007 @internalsref{StaffGroup}:
1008 @lilypond[fragment, verbatim]
1009 < \context StaffGroup <
1010 \context Staff = up { e'4 d'
1013 \context Staff = down { \clef bass c4 g e g } >
1014 \context Staff = pedal { \clef bass c2 c2 } >
1017 The grobs that are created at @internalsref{Staff} level. The name is
1018 @internalsref{BarLine}.
1020 The command @code{\bar @var{bartype}} is a short cut for
1021 doing @code{\property Score.whichBar = @var{bartype}}
1022 Whenever @code{whichBar} is set to a string, a bar line of that type is
1023 created. @code{whichBar} is usually set automatically: at the start of
1024 a measure it is set to @code{defaultBarType}. The contents of
1025 @code{repeatCommands} is used to override default measure bars.
1027 @code{whichBar} can also be set directly, using @code{\property} or
1028 @code{\bar }. These settings take precedence over the automatic
1029 @code{whichBar} settings.
1032 @cindex Bar_line_engraver
1034 @cindex repeatCommands
1035 @cindex defaultBarType
1044 The easiest way to enter such fragments with more than one voice on a
1045 staff is to split chords using the separator @code{\\}. You can use
1046 it for small, short-lived voices (make a chord of voices) or for
1049 @lilypond[verbatim,fragment]
1050 \context Voice = VA \relative c'' {
1051 c4 < { f d e } \\ { b c2 } > c4 < g' \\ b, \\ f \\ d >
1055 The separator causes @internalsref{Voice} contexts to be instantiated,
1056 bearing the names @code{"1"}, @code{"2"}, etc.
1058 Sometimes, it is necessary to instantiate these contexts by hand: For
1059 Instantiate a separate Voice context for each part, and use
1060 @code{\voiceOne}, up to @code{\voiceFour} to assign a stem directions
1061 and horizontal shift for each part.
1064 @lilypond[singleline, verbatim]
1066 \context Staff < \context Voice = VA { \voiceOne cis2 b }
1067 \context Voice = VB { \voiceThree b4 ais ~ ais4 gis4 }
1068 \context Voice = VC { \voiceTwo fis4~ fis4 f ~ f } >
1071 The identifiers @code{\voiceOne} to @code{\voiceFour} set directions
1072 ties, slurs and stems, and set shift directions.
1074 If you want more than four voices, you can also manually set
1075 horizontal shifts and stem directions, as is shown in the following example:
1076 @lilypond[fragment, verbatim]
1077 \context Staff \notes\relative c''<
1078 \context Voice=one {
1079 \shiftOff \stemUp e4
1081 \context Voice=two {
1082 \shiftOn \stemUp cis
1084 \context Voice=three {
1085 \shiftOnn \stemUp ais
1087 \context Voice=four {
1088 \shiftOnnn \stemUp fis
1094 Normally, note heads with a different number of dots are not merged, but
1095 if you set the grob property @code{merge-differently-dotted}, they are:
1096 @lilypond[verbatim,fragment,singleline]
1099 \property Staff.NoteCollision \override
1100 #'merge-differently-dotted = ##t
1102 } \\ { [g'8. f16] [g'8. f'16] }
1106 Similarly, you can merge half note heads with eighth notes, by setting
1107 @code{merge-differently-headed}:
1108 @lilypond[fragment, relative=2,verbatim]
1111 \property Staff.NoteCollision
1112 \override #'merge-differently-headed = ##t
1113 c8 c4. } \\ { c2 c2 } >
1116 LilyPond also vertically shifts rests that are opposite of a stem.
1118 @lilypond[singleline,fragment,verbatim]
1119 \context Voice < c''4 \\ r4 >
1122 See also @internalsref{NoteCollision} and @internalsref{RestCollision}
1126 Resolving collisions is a very intricate subject, and LilyPond only
1127 handles a few situations. When it can not cope, you are advised to use
1128 @code{force-hshift} of the @internalsref{NoteColumn} grob and pitched
1129 rests to override typesetting decisions.
1134 Beams are used to group short notes into chunks that are aligned with
1135 the metrum. They are inserted automatically in most cases.
1137 @lilypond[fragment,verbatim, relative=2]
1138 \time 2/4 c8 c c c \time 6/8 c c c c8. c16 c8
1141 If you're not satisfied with the automatic beaming, you can enter the
1142 beams explicitly. If you have beaming patterns that differ from the
1143 defaults, you can also set the patterns for automatic beamer.
1145 See also @internalsref{Beam}.
1148 @cindex Automatic beams
1149 @subsection Manual beams
1150 @cindex beams, manual
1154 In some cases it may be necessary to override LilyPond's automatic
1155 beaming algorithm. For example, the auto beamer will not beam over
1156 rests or bar lines, If you want that, specify the begin and end point
1157 manually using a @code{[} before the first beamed note and a @code{]}
1158 after the last note:
1160 @lilypond[fragment,relative,verbatim]
1162 r4 [r8 g' a r8] r8 [g | a] r8
1166 @cindex @code{stemLeftBeamCount}
1168 Normally, beaming patterns within a beam are determined automatically.
1169 When this mechanism fouls up, the properties
1170 @code{Voice.stemLeftBeamCount} and @code{Voice.stemRightBeamCount} can
1171 be used to control the beam subdivision on a stem. If you set either
1172 property, its value will be used only once, and then it is erased.
1174 @lilypond[fragment,relative,verbatim]
1177 [f8 r16 \property Voice.stemLeftBeamCount = #1 f g a]
1180 @cindex @code{stemRightBeamCount}
1183 The property @code{subdivideBeams} can be set in order to subdivide
1184 all 16th or shorter beams at beat positions. This accomplishes the
1185 same effect as twiddling with @code{stemLeftBeamCount} and
1186 @code{stemRightBeamCount}, but it take less typing.
1191 \property Voice.subdivideBeams = ##t
1193 [c32 c c c c c c c c c c c c c c c]
1194 \property Score.beatLength = #(make-moment 1 8)
1195 [c32 c c c c c c c c c c c c c c c]
1199 \notes \relative c' {
1201 \property Voice.subdivideBeams = ##t
1203 [c32 c c c c c c c c c c c c c c c]
1204 \property Score.beatLength = #(make-moment 1 8)
1205 [c32 c c c c c c c c c c c c c c c]
1209 @cindex subdivideBeams
1211 Kneed beams are inserted automatically, when a large gap between two
1212 adjacent beamed notes is detected. This behavior can be tuned through
1213 the grob property @code{auto-knee-gap}.
1215 @cindex beams, kneed
1217 @cindex auto-knee-gap
1221 @c TODO -> why this ref? Document?
1222 @cindex @code{neutral-direction}
1226 Auto knee beams can not be used together with hara kiri staffs.
1230 The Automatic beamer does not put @strong{unfinished} beams on the
1231 last notes of a score.
1233 Formatting of ties is a difficult subject. LilyPond often does not
1234 give optimal results.
1237 * Setting automatic beam behavior ::
1241 @no de Beam typography
1242 @sub section Beam typography
1244 One of the strong points of LilyPond is how beams are formatted. Beams
1245 are quantized, meaning that the left and right endpoints beams start
1246 exactly on staff lines. Without quantization, small wedges of white
1247 space appear between the beam and staff line, and this looks untidy.
1249 Beams are also slope-damped: melodies that go up or down should also
1250 have beams that go up or down, but the slope of the beams should be
1251 less than the slope of the notes themselves.
1253 Some beams should be horizontal. These are so-called concave beams.
1255 [TODO: some pictures.]
1258 @c . {Automatic beams}
1259 @node Setting automatic beam behavior
1260 @subsection Setting automatic beam behavior
1262 @cindex @code{autoBeamSettings}
1263 @cindex @code{(end * * * *)}
1264 @cindex @code{(begin * * * *)}
1265 @cindex automatic beams, tuning
1266 @cindex tuning automatic beaming
1268 In normal time signatures, automatic beams can start on any note but can
1269 only end in a few positions within the measure: beams can end on a beat,
1270 or at durations specified by the properties in
1271 @code{Voice.autoBeamSettings}. The defaults for @code{autoBeamSettings}
1272 are defined in @file{scm/auto-beam.scm}.
1274 The value of @code{autoBeamSettings} is changed using
1275 @code{\override} and unset using @code{\revert}:
1277 \property Voice.autoBeamSettings \override #'(@var{BE} @var{P} @var{Q} @var{N} @var{M}) = @var{dur}
1278 \property Voice.autoBeamSettings \revert #'(@var{BE} @var{P} @var{Q} @var{N} @var{M})
1280 Here, @var{BE} is the symbol @code{begin} or @code{end}. It determines
1281 whether the rule applies to begin or end-points. The quantity
1282 @var{P}/@var{Q} refers to the length of the beamed notes (and `@code{*
1283 *}' designates notes of any length), @var{N}/@var{M} refers to a time
1284 signature (wildcards, `@code{* *}' may be entered to designate all time
1287 For example, if you want automatic beams to end on every quarter note,
1288 you can use the following:
1290 \property Voice.autoBeamSettings \override
1291 #'(end * * * *) = #(make-moment 1 4)
1293 Since the duration of a quarter note is 1/4 of a whole note, it is
1294 entered as @code{(make-moment 1 4)}.
1296 The same syntax can be used to specify beam starting points. In this
1297 example, automatic beams can only end on a dotted quarter note.
1299 \property Voice.autoBeamSettings \override
1300 #'(end * * * *) = #(make-moment 3 8)
1302 In 4/4 time signature, this means that automatic beams could end only on
1303 3/8 and on the fourth beat of the measure (after 3/4, that is 2 times
1304 3/8 has passed within the measure).
1306 You can also restrict rules to specific time signatures. A rule that
1307 should only be applied in @var{N}/@var{M} time signature is formed by
1308 replacing the second asterisks by @var{N} and @var{M}. For example, a
1309 rule for 6/8 time exclusively looks like
1311 \property Voice.autoBeamSettings \override
1312 #'(begin * * 6 8) = ...
1315 If you want a rule to apply to certain types of beams, you can use the
1316 first pair of asterisks. Beams are classified according to the shortest
1317 note they contain. For a beam ending rule that only applies to beams
1318 with 32nd notes (and no shorter notes), you would use @code{(end 1
1322 @c Automatic beams can not be put on the last note in a score.
1324 If a score ends while an automatic beam has not been ended and is still
1325 accepting notes, this last beam will not be typeset at all.
1327 @cindex automatic beam generation
1329 @cindex @code{Voice.autoBeaming}
1332 For melodies that have lyrics, you may want to switch off
1333 automatic beaming. This is done by setting @code{Voice.autoBeaming} to
1339 It is not possible to specify beaming parameters for beams with mixed
1340 durations, that differ from the beaming parameters of all separate
1341 durations, i.e., you'll have to specify manual beams to get:
1343 @lilypond[singleline,fragment,relative,noverbatim]
1344 \property Voice.autoBeamSettings
1345 \override #'(end * * * *) = #(make-moment 3 8)
1346 \time 12/8 c'8 c c c16 c c c c c [c c c c] c8 c c4
1348 It is not possible to specify beaming parameters that act differently in
1349 different parts of a measure. This means that it is not possible to use
1350 automatic beaming in irregular meters such as @code{5/8}.
1353 @section Accidentals
1355 This section describes how to change the way that LilyPond automatically
1356 inserts accidentals before the running notes.
1359 * Using the predefined accidental macros::
1360 * Defining your own accidental typesettings::
1363 @node Using the predefined accidental macros
1364 @subsection Using the predefined accidental macros
1365 The constructs for describing the accidental typesetting rules are
1366 quite hairy, so non-experts should stick to the macros defined in
1367 @file{ly/property-init.ly}.
1368 @cindex @file{property-init.ly}
1370 The macros operate on the ``Current'' context (see @ref{Context properties}). This
1371 means that the macros shuold normally be invoked right after the
1372 creation of the context in which the accidental typesetting described
1373 by the macro is to take effect. I.e. if you want to use
1374 piano-accidentals in a pianostaff then you issue
1375 @code{\pianoAccidentals} first thing after the creation of the piano
1379 \notes \relative c'' <
1380 \context Staff = sa @{ cis4 d e2 @}
1381 \context GrandStaff <
1383 \context Staff = sb @{ cis4 d e2 @}
1384 \context Staff = sc @{ es2 c @}
1386 \context Staff = sd @{ es2 c @}
1390 @lilypond[singleline]
1392 \notes \relative c'' <
1393 \context Staff = sa { cis4 d e2 }
1394 \context GrandStaff <
1396 \context Staff = sb { cis4 d e2 }
1397 \context Staff = sc { es2 c }
1399 \context Staff = sd { es2 c }
1404 minimumVerticalExtent = #'(-4.0 . 4.0)
1412 @item \defaultAccidentals
1413 @cindex @code{\defaultAccidentals}
1414 This is the default typesetting behaviour. It should correspond
1415 to 18th century common practice: Accidentals are
1416 remembered to the end of the measure in which they occur and
1417 only on their own octave.
1419 @item \voiceAccidentals
1420 @cindex @code{\voiceAccidentals}
1421 The normal behaviour is to remember the accidentals on
1423 This macro, however, typesets accidentals individually for each
1425 Apart from that the rule is similar to
1426 @code{\defaultAccidentals}.
1428 Warning: This leads to some weird and often unwanted results
1429 because accidentals from one voice DO NOT get cancelled in other
1431 @lilypond[singleline,relative,fragment,verbatim]
1434 \context Voice=va { \voiceOne es g }
1435 \context Voice=vb { \voiceTwo c, e }
1438 Hence you should only use @code{\voiceAccidentals}
1439 if the voices are to be read solely by
1440 individual musicians. if the staff should be readable also
1441 by one musician/conductor then you should use
1442 @code{\modernVoiceAccidentals} or @code{\modernVoiceCautionaries}
1445 @item \modernAccidentals
1446 @cindex @code{\modernAccidentals}
1447 This rule should correspond to the common practice in the 20th
1449 The rule is a bit more complex than @code{\defaultAccidentals}:
1450 You get all the same accidentals, but temporary
1451 accidentals also get cancelled in other octaves. Further more,
1452 in the same octave, they also get cancelled in the following measure:
1453 @lilypond[singleline,fragment,verbatim]
1455 cis' c'' cis'2 | c'' c'
1458 @item \modernCautionaries
1459 @cindex @code{\modernCautionaries}
1460 This rule is similar to @code{\modernAccidentals}, but the
1461 ``extra'' accidentals (the ones not typeset by
1462 @code{\defaultAccidentals}) are typeset as cautionary accidentals
1463 (i.e. in reduced size):
1464 @lilypond[singleline,fragment,verbatim]
1466 cis' c'' cis'2 | c'' c'
1469 @item \modernVoiceAccidentals
1470 @cindex @code{\modernVoiceAccidentals}
1471 Multivoice accidentals to be read both by musicians playing one voice
1472 and musicians playing all voices.
1474 Accidentals are typeset for each voice, but they ARE cancelled
1475 across voices in the same @internalsref{Staff}.
1477 @item \modernVoiceCautionaries
1478 @cindex @code{\modernVoiceCautionaries}
1479 The same as @code{\modernVoiceAccidentals}, but with the
1480 extra accidentals (the ones not typeset by
1481 @code{\voiceAccidentals}) typeset as cautionaries.
1482 Notice that even though all accidentals typeset by
1483 @code{\defaultAccidentals} ARE typeset by this macro then some
1484 of them are typeset as cautionaries.
1486 @item \pianoAccidentals
1487 @cindex @code{\pianoAccidentals}
1488 20th century practice for piano notation. Very similar to
1489 @code{\modernAccidentals} but accidentals also get cancelled
1490 across the staves in the same @internalsref{GrandStaff} or
1491 @internalsref{PianoStaff}.
1493 @item \pianoCautionaries
1494 @cindex @code{\pianoCautionaries}
1495 As @code{\pianoAccidentals} but with the extra accidentals
1496 typeset as cationaries.
1499 @cindex @code{\noResetKey}
1500 Same as @code{\defaultAccidentals} but with accidentals lasting
1501 ``forever'' and not only until the next measure:
1502 @lilypond[singleline,fragment,verbatim,relative]
1507 @item \forgetAccidentals
1508 @cindex @code{\forgetAccidentals}
1509 This is sort of the opposite of @code{\noResetKey}: Accidentals
1510 are not remembered at all - and hence all accidentals are
1511 typeset relative to the key signature, regardless of what was
1512 before in the music:
1513 @lilypond[singleline,fragment,verbatim,relative]
1515 \key d\major c4 c cis cis d d dis dis
1519 @node Defining your own accidental typesettings
1520 @subsection Defining your own accidental typesettings
1522 This section must be considered gurus-only, and hence it must be
1523 sufficient with a short description of the system and a reference to
1524 the internal documentation.
1526 The idea of the algorithm is to try several different rules and then
1527 use the rule that gives the highest number of accidentals.
1528 Each rule cosists of
1531 In which context is the rule applied. I.e. if context is
1532 @internalsref{Score} then all staves share accidentals, and if
1533 context is @internalsref{Staff} then all voices in the same
1534 staff share accidentals, but staves don't - like normally.
1536 Whether the accidental changes all octaves or only the current
1539 Over how many barlines the accidental lasts.
1540 If lazyness is @code{-1} then the accidental is forget
1541 immidiately, and if lazyness is @code{#t} then the accidental
1545 As described in the internal documentation of
1546 @reng{Accidental_engraver}, the properties @code{autoAccidentals} and
1547 @code{autoCautionaries} contain lists of rule descriptions. Notice
1548 that the contexts must be listed from in to out - that is
1549 @internalsref{Thread} before @internalsref{Voice},
1550 @internalsref{Voice} before @internalsref{Staff}, etc.
1551 see the macros in @file{ly/property-init.ly} for examples of how the
1556 Currently the simultaneous notes are considered to be entered in
1557 sequential mode. This means that in a chord the accidentals are
1558 typeset as if the notes in the chord happened one at a time - in the
1559 order in which they appear in the input file.
1561 Of course this is only a problem when you have simultainous notes
1562 which accidentals should depend on each other.
1563 Notice that the problem only occurs when using non-default accidentals
1564 - as the default accidentals only depend on other accidentals on the
1565 same staff and same pitch and hence cannot depend on other
1568 This example shows two examples of the same music giving different
1569 accidentals depending on the order in which the notes occur in the
1572 @lilypond[singleline,fragment,verbatim]
1573 \property Staff.autoAccidentals = #'( Staff (any-octave . 0) )
1574 cis'4 <c'' c'> r2 | cis'4 <c' c''> r2 | <cis' c''> r | <c'' cis'> r |
1577 The only solution is to manually insert the problematic
1578 accidentals using @code{!} and @code{?}.
1580 @node Expressive marks
1581 @section Expressive marks
1596 A slur indicates that notes are to be played bound or @emph{legato}.
1597 They are entered using parentheses:
1598 @lilypond[fragment,verbatim,center]
1599 f'()g'()a' [a'8 b'(] a'4 g'2 )f'4
1602 See also @seeinternals{Slur}.
1604 Slurs avoid crossing stems, and are generally attached to note heads.
1605 However, in some situations with beams, slurs may be attached to stem
1606 ends. If you want to override this layout you can do this through the
1607 grob-property @code{attachment} of @internalsref{Slur} in
1608 @internalsref{Voice} context It's value is a pair of symbols, specifying
1609 the attachment type of the left and right end points.
1611 @lilypond[fragment,relative,verbatim]
1613 \property Voice.Stem \set #'length = #5.5
1615 \property Voice.Slur \set #'attachment = #'(stem . stem)
1619 If a slur would strike through a stem or beam, the slur will be moved
1620 away upward or downward. If this happens, attaching the slur to the
1621 stems might look better:
1623 @lilypond[fragment,relative,verbatim]
1626 \property Voice.Slur \set #'attachment = #'(stem . stem)
1631 Similarly, the curvature of a slur is adjusted to stay clear of note
1632 heads and stems. When that would increase the curvature too much, the
1633 slur is reverted to its default shape. The threshold for this
1634 decision is in @internalsref{Slur}'s grob-property @code{beautiful}.
1635 It is loosely related to the enclosed area between the slur and the
1636 notes. Usually, the default setting works well, but in some cases you
1637 may prefer a curved slur when LilyPond decides for a vertically moved
1638 one. You can indicate this preference by increasing the
1639 @code{beautiful} value:
1641 @lilyp ond[verbatim,singleline,relative]
1643 c16( a' f' a a f a, )c,
1644 c( a' f' a a f d, )c
1645 \property Voice.Slur \override #'beautiful = #5.0
1646 c( a' f' a a f d, )c
1652 Producing nice slurs is a difficult problem, and LilyPond currently
1653 uses a simple, empiric method to produce slurs. In some cases, the
1654 results of this method are ugly.
1657 This is reflected by the
1658 @code{beautiful} property, which it is an arbitrary parameter in the
1659 slur formatter. Useful values can only be determined by trial and
1663 @cindex Adjusting slurs
1665 @node Phrasing slurs
1666 @subsection Phrasing slurs
1668 @cindex phrasing slurs
1669 @cindex phrasing marks
1671 A phrasing slur (or phrasing mark) connects chords and is used to
1672 indicate a musical sentence. It is started using @code{\(} and @code{\)}
1675 @lilypond[fragment,verbatim,center,relative]
1676 \time 6/4 c' \( d () e f () e \) d
1679 Typographically, the phrasing slur behaves almost exactly like a normal
1680 slur. See also @seeinternals{PhrasingSlur}.
1684 @subsection Breath marks
1686 Breath marks are entered using @code{\breathe}. See also
1687 @seeinternals{BreathingSign}.
1689 @lilypond[fragment,relative]
1698 @cindex beats per minute
1699 @cindex metronome marking
1701 Metronome settings can be entered as follows:
1703 @cindex @code{\tempo}
1705 \tempo @var{duration} = @var{perminute}
1708 For example, @code{\tempo 4 = 76} requests output with 76 quarter notes
1713 The tempo setting is not printed, but is only used in the MIDI
1714 output. You can trick lily into producing a metronome mark,
1715 though. Details are in @ref{Text markup}.
1720 @subsection Text spanners
1721 @cindex Text spanners
1723 Some textual indications, e.g. rallentando or accelerando, often extend
1724 over many measures. This is indicated by following the text with a
1725 dotted line. You can create such texts using text spanners. The syntax
1728 \spanrequest \start "text"
1729 \spanrequest \stop "text"
1731 LilyPond will respond by creating a @internalsref{TextSpanner} grob (typically
1732 in @internalsref{Voice} context). The string to be printed, as well as the
1733 style is set through grob properties.
1735 An application---or rather, a hack---is to fake octavation indications.
1736 @lilypond[fragment,relative,verbatim]
1737 \relative c' { a''' b c a
1738 \property Voice.TextSpanner \set #'type = #'dotted-line
1739 \property Voice.TextSpanner \set #'edge-height = #'(0 . 1.5)
1740 \property Voice.TextSpanner \set #'edge-text = #'("8va " . "")
1741 \property Staff.centralCPosition = #-13
1742 a\spanrequest \start "text" b c a \spanrequest \stop "text" }
1760 @subsection Articulations
1761 @cindex Articulations
1763 @cindex articulations
1767 A variety of symbols can appear above and below notes to indicate
1768 different characteristics of the performance. They are added to a note
1769 by adding a dash and the the character signifying the
1770 articulation. They are demonstrated here.
1771 @lilypond[singleline]
1773 \notes \context Voice {
1774 \property Voice.TextScript \set #'font-family = #'typewriter
1775 \property Voice.TextScript \set #'font-shape = #'upright
1781 c''4-^_"c-\\^{ }" s4
1787 The script is automatically placed, but if you need to force
1788 directions, you can use @code{_} to force them down, or @code{^} to
1790 @lilypond[fragment, verbatim]
1795 Other symbols can be added using the syntax
1796 @var{note}@code{-\}@var{name}. Again, they can be forced up or down
1797 using @code{^} and @code{_}.
1801 @cindex staccatissimo
1810 @cindex organ pedal marks
1819 @cindex prallmordent
1823 @cindex thumb marking
1830 \property Score.LyricText \override #'font-family =#'typewriter
1831 \property Score.LyricText \override #'font-shape = #'upright
1832 \context Staff \notes {
1833 c''-\accent c''-\marcato c''-\staccatissimo c''^\fermata
1834 c''-\stopped c''-\staccato c''-\tenuto c''-\portato
1836 c''-\downbow c''^\lheel c''-\rheel c''^\ltoe
1837 c''-\rtoe c''-\turn c''-\open c''-\flageolet
1838 c''-\reverseturn c''-\trill c''-\prall c''-\mordent
1839 c''-\prallprall c''-\prallmordent c''-\upprall c''-\downprall
1840 c''-\upmordent c''-\downmordent c''-\pralldown c''-\prallup
1841 c''-\lineprall c''-\thumb c''-\segno c''-\coda
1843 \context Lyrics \lyrics {
1844 accent__ marcato__ staccatissimo__ fermata
1845 stopped__ staccato__ tenuto__ portato
1847 downbow__ lheel__ rheel__ ltoe
1848 rtoe__ turn__ open__ flageolet
1849 reverseturn__ trill__ prall__ mordent
1850 prallprall__ prallmordent__ uprall__ downprall
1851 upmordent__ downmordent__ pralldown__ prallup__
1852 lineprall__ thumb__ segno__ coda
1856 linewidth = 5.875\in
1865 Fingering instructions can also be entered in this shorthand. For
1866 finger changes, use markup texts:
1868 @lilypond[verbatim, singleline, fragment]
1869 c'4-1 c'4-2 c'4-3 c'4-4
1874 @cindex @code{\script}
1879 See also @seeinternals{Script} and @seeinternals{Fingering}.
1883 All of these note ornaments appear in the printed output but have no
1884 effect on the MIDI rendering of the music.
1886 Unfortunately, there is no support for adding fingering instructions or
1887 ornaments to individual note heads. Some hacks exist, though. See
1888 @file{input/test/script-horizontal.ly}.
1893 @subsection Text scripts
1894 @cindex Text scripts
1896 In addition, it is possible to place arbitrary strings of text or markup
1897 text (see @ref{Text markup}) above or below notes by using a string:
1900 By default, these indications do not influence the note spacing, but
1901 by using the command @code{\fatText}, the widths will be taken into
1904 @lilypond[fragment,singleline,verbatim] \relative c' {
1905 c4^"longtext" \fatText c4_"longlongtext" c4 }
1908 It is possible to use @TeX{} commands in the strings, but this should be
1909 avoided because it makes it impossible for LilyPond to compute the
1910 exact length of the string, which may lead to collisions. Also, @TeX{}
1911 commands won't work with direct PostScript output.
1912 @c (see @ref{PostScript output}).
1914 Text scripts are created in form of @internalsref{TextScript} grobs, in
1915 @internalsref{Voice} context.
1917 @ref{Text markup} describes how to change the font or access
1918 special symbols in text scripts.
1923 @subsection Grace notes
1927 @cindex @code{\grace}
1931 Grace notes are ornaments are written out ornaments
1932 @lilypond[relative=2,verbatim,ifragment]
1933 c4 \grace c16 c4 \grace { [c16 d16] } c4
1936 In normal notation, grace notes are supposed to take up no logical
1937 time in a measure. Such an idea is practical for normal notation, but
1938 is not strict enough to put it into a program. The model that LilyPond
1939 uses for grace notes internally is that all timing is done in two
1942 Every point in musical time consists of two rational numbers: one
1943 denotes the logical time, one denotes the grace timing. The above
1944 example is shown here with timing tuples.
1947 \score { \notes \relative c''{
1948 c4^"(0,0)" \grace c16_" "_"(1/4,-1/16)" c4^"(1/4,0)" \grace {
1949 [c16_"(2/4,-1/8)" d16^"(2/4,-1/16)" ] } c4_" "_"(2/4,0)"
1951 \paper { linewidth = 8.\cm }
1955 The advantage of this approach is that you can use almost any lilypond
1956 construction together with grace notes, for example slurs and clef
1957 changes may appear halfway in between grace notes:
1959 @lilypond[relative=2,verbatim,fragment]
1960 c4 \grace { [ c16 c, \clef bass c, b(] } )c4
1963 The placement of these grace notes is synchronized between different
1964 staffs, using this grace timing.
1966 @lilypond[relative=2,verbatim,fragment]
1967 < \context Staff = SA { e4 \grace { c16 d e f } e4 }
1968 \context Staff = SB { c4 \grace { g8 b } c4 } >
1972 Unbeamed eighth notes and shorter by default have a slash through the
1973 stem. This can be controlled with grob property @code{flag-style} of
1974 @internalsref{Stem}. The change in formatting is accomplished by
1975 inserting @code{\startGraceMusic} before handling the grace notes, and
1976 @code{\stopGraceMusic} after finishing the grace notes. You can add to
1977 these definitions to globally change grace note formatting. The
1978 standard definitions are in @file{ly/grace-init.ly}.
1981 @lilypond[fragment,verbatim]
1982 \relative c'' \context Voice {
1983 \grace c8 c4 \grace { [c16 c16] } c4
1985 \property Voice.Stem \override #'flag-style = #'()
1987 \property Voice.Stem \revert #'flag-style
1992 If you want to end a note with a grace note, then the standard trick
1993 is to put the grace notes before a phantom ``space note'', e.g.
1994 @lilypond[fragment,verbatim, relative=2]
1997 { s2 \grace { [c16 d] } } >
2005 Grace note synchronization can also lead to surprises. Staff notation,
2006 such as key signatures, barlines, etc. are also synchronized. Take
2007 care when you mix staffs with grace notes and staffs without.
2009 @lilypond[relative=2,verbatim,fragment]
2010 < \context Staff = SA { e4 \bar "|:" \grace c16 d4 }
2011 \context Staff = SB { c4 \bar "|:" d4 } >
2014 Grace sections should only be used within sequential music
2015 expressions. Nesting, juxtaposing, or ending sequential music with a
2016 grace section is not supported, and might produce crashes or other
2028 @subsection Glissando
2031 @cindex @code{\glissando}
2033 A glissando line can be requested by attaching a @code{\glissando} to
2036 @lilypond[fragment,relative,verbatim]
2042 Printing of an additional text (such as @emph{gliss.}) must be done
2043 manually. See also @seeinternals{Glissando}.
2049 @subsection Dynamics
2062 @cindex @code{\ffff}
2072 Absolute dynamic marks are specified using an identifier after a
2073 note: @code{c4-\ff}. The available dynamic marks are: @code{\ppp},
2074 @code{\pp}, @code{\p}, @code{\mp}, @code{\mf}, @code{\f}, @code{\ff},
2075 @code{\fff}, @code{\fff}, @code{\fp}, @code{\sf}, @code{\sff},
2076 @code{\sp}, @code{\spp}, @code{\sfz}, and @code{\rfz}.
2078 @lilypond[verbatim,singleline,fragment,relative]
2079 c'\ppp c\pp c \p c\mp c\mf c\f c\ff c\fff
2085 @cindex @code{\decr}
2086 @cindex @code{\rced}
2092 A crescendo mark is started with @code{\cr} and terminated with
2093 @code{\rc} (the textual reverse of @code{cr}). A decrescendo mark is
2094 started with @code{\decr} and terminated with @code{\rced}. There are
2095 also shorthands for these marks. A crescendo can be started with
2096 @code{\<} and a decrescendo can be started with @code{\>}. Either one
2097 can be terminated with @code{\!}. Note that @code{\!} must go before
2098 the last note of the dynamic mark whereas @code{\rc} and @code{\rced} go
2099 after the last note. Because these marks are bound to notes, if you
2100 want several marks during one note, you have to use spacer notes.
2102 @lilypond[fragment,verbatim,center]
2103 c'' \< \! c'' d'' \decr e'' \rced
2104 < f''1 { s4 s4 \< \! s4 \> \! s4 } >
2107 You can also use a text saying @emph{cresc.} instead of hairpins. Here
2108 is an example how to do it:
2110 @lilypond[fragment,relative=2,verbatim]
2111 c4 \cresc c4 \endcresc c4
2118 You can also supply your own texts:
2119 @lilypond[fragment,relative,verbatim]
2121 \property Voice.crescendoText = "cresc. poco"
2122 \property Voice.crescendoSpanner = #'dashed-line
2129 Dynamics are grobs of @internalsref{DynamicText} and
2130 @internalsref{Hairpin}. Vertical positioning of these symbols is
2131 handled by the @internalsref{DynamicLineSpanner} grob. If you want to
2132 adjust padding or vertical direction of the dynamics, you must set
2133 properties for the @internalsref{DynamicLineSpanner} grob. Predefined
2134 identifiers to set the vertical direction are \dynamicUp and
2137 @cindex direction, of dynamics
2138 @cindex @code{\dynamicDown}
2139 @cindex @code{\dynamicUp}
2147 @cindex @code{\repeat}
2149 To specify repeats, use the @code{\repeat} keyword. Since repeats
2150 should work differently when played or printed, there are a few
2151 different variants of repeats.
2155 Repeated music is fully written (played) out. Useful for MIDI
2156 output, and entering repetitive music.
2159 This is the normal notation: Repeats are not written out, but
2160 alternative endings (voltas) are printed, left to right.
2163 Alternative endings are written stacked. This has limited use but may be
2164 used to typeset two lines of lyrics in songs with repeats, see
2165 @file{input/star-spangled-banner.ly}.
2171 Make beat or measure repeats. These look like percent signs.
2177 * Repeats and MIDI::
2178 * Manual repeat commands::
2180 * Tremolo subdivisions::
2185 @subsection Repeat syntax
2187 The syntax for repeats is
2190 \repeat @var{variant} @var{repeatcount} @var{repeatbody}
2193 If you have alternative endings, you may add
2194 @cindex @code{\alternative}
2196 \alternative @code{@{} @var{alternative1}
2198 @var{alternative3} @dots{} @code{@}}
2200 where each @var{alternative} is a music expression.
2202 Normal notation repeats are used like this:
2203 @lilypond[fragment,verbatim]
2205 \repeat volta 2 { c'4 d' e' f' }
2206 \repeat volta 2 { f' e' d' c' }
2209 With alternative endings:
2210 @lilypond[fragment,verbatim]
2212 \repeat volta 2 {c'4 d' e' f'}
2213 \alternative { {d'2 d'} {f' f} }
2216 Folded repeats look like this:
2219 @lilypond[fragment,verbatim]
2221 \repeat fold 2 {c'4 d' e' f'}
2222 \alternative { {d'2 d'} {f' f} }
2226 If you don't give enough alternatives for all of the repeats, then
2227 the first alternative is assumed to be repeated often enough to equal
2228 the specified number of repeats.
2230 @lilypond[fragment,verbatim]
2234 \repeat volta 4 { e | c2 d2 | e2 f2 | }
2235 \alternative { { g4 g g } { a | a a a a | b2. } }
2240 @node Repeats and MIDI
2241 @subsection Repeats and MIDI
2243 @cindex expanding repeats
2245 For instructions on how to unfoldi repeats for MIDI output, see
2246 the example file @file{input/test/unfold-all-repeats.ly}.
2251 Notice that timing information is not remembered at the start of an
2252 alternative, so you have to reset timing information after a repeat,
2253 e.g. using a bar-check (See @ref{Bar check}), setting
2254 @code{Score.measurePosition} or entering @code{\partial}. Slurs or ties
2255 are also not repeated.
2257 It is possible to nest @code{\repeat}s, although this probably is only
2258 meaningful for unfolded repeats.
2260 Folded repeats offer little more over simultaneous music.
2262 @node Manual repeat commands
2263 @subsection Manual repeat commands
2265 @cindex @code{repeatCommands}
2267 The property @code{repeatCommands} can be used to control the layout of
2268 repeats. Its value is a Scheme list of repeat commands, where each repeat
2276 @item (volta . @var{text})
2277 Print a volta bracket saying @var{text}.
2279 Stop a running volta bracket
2282 @lilypond[verbatim, fragment]
2284 \property Score.repeatCommands = #'((volta "93") end-repeat)
2286 \property Score.repeatCommands = #'((volta #f))
2291 Repeats brackets are @internalsref{VoltaBracket} grobs.
2293 @node Tremolo repeats
2294 @subsection Tremolo repeats
2295 @cindex tremolo beams
2297 To place tremolo marks between notes, use @code{\repeat} with tremolo
2299 @lilypond[verbatim,center,singleline]
2301 \context Voice \notes\relative c' {
2302 \repeat "tremolo" 8 { c16 d16 }
2303 \repeat "tremolo" 4 { c16 d16 }
2304 \repeat "tremolo" 2 { c16 d16 }
2305 \repeat "tremolo" 4 c16
2310 Tremolo beams are @internalsref{Beam} grobs. Single stem tremolos are
2311 @internalsref{StemTremolo}. The single stem tremolo @emph{must} be
2312 entered without @code{@{} and @code{@}}.
2316 Only powers of two and undotted notes are supported repeat counts.
2318 @node Tremolo subdivisions
2319 @subsection Tremolo subdivisions
2320 @cindex tremolo marks
2321 @cindex @code{tremoloFlags}
2323 Tremolo marks can be printed on a single note by adding
2324 `@code{:}[@var{length}]' after the note. The length must be at least 8.
2325 A @var{length} value of 8 gives one line across the note stem. If the
2326 length is omitted, then then the last value (stored in
2327 @code{Voice.tremoloFlags}) is used.
2329 @lilypond[verbatim,fragment,center]
2330 c'2:8 c':32 | c': c': |
2336 Tremolos in this style do not carry over into the MIDI output.
2339 @node Measure repeats
2340 @subsection Measure repeats
2342 @cindex percent repeats
2343 @cindex measure repeats
2345 In the @code{percent} style, a note pattern can be repeated. It is
2346 printed once, and then the pattern is replaced with a special sign.
2347 Patterns of a one and two measures are replaced by percent-like signs,
2348 patterns that divide the measure length are replaced by slashes.
2350 @lilypond[verbatim,singleline]
2351 \context Voice { \repeat "percent" 4 { c'4 }
2352 \repeat "percent" 2 { c'2 es'2 f'4 fis'4 g'4 c''4 }
2356 The signs are represented by these grobs: @internalsref{RepeatSlash} and
2357 @internalsref{PercentRepeat} and @internalsref{DoublePercentRepeat}.
2361 You can not nest percent repeats, e.g. by filling in the first measure
2362 with slashes, and repeating that measure with percents.
2364 @node Rhythmic music
2365 @section Rhythmic music
2367 Sometimes you might want to show only the rhythm of a melody. This can
2368 be done with the rhythmic staff. All pitches of notes on such a staff
2369 are squashed, and the staff itself looks has a single staff line:
2371 @lilypond[fragment,relative,verbatim]
2372 \context RhythmicStaff {
2374 c4 e8 f g2 | r4 g r2 | g1:32 | r1 |
2379 * Percussion staves::
2382 @node Percussion staves
2383 @subsection Percussion staves
2386 To typeset more than one piece of percussion to be played by the same
2387 musician one typically uses a multiline staff where each staff
2388 position refers to a specific piece of percussion.
2390 LilyPond is shipped with a bunch of scheme functions which allows you
2391 to do this fairly easily.
2393 The system is based on the general midi drum-pitches.
2394 In order to use the drum pitches you include
2395 @file{ly/drumpitch-init.ly}. This file defines the pitches from the scheme
2396 variable @code{drum-pitch-names} - which definition can be read in
2397 @file{scm/drums.scm}. You see that each piece of percussion has a full
2398 name and an abbreviated name - and you may freely select whether to
2399 refer to the full name or the abbreviation in your music definition.
2401 To typeset the music on a staff you apply the scheme function
2402 @code{drums->paper} to the percussion music. This function takes a
2403 list of percussion instrument names, notehead scripts and staff
2404 positions (that is: pitches relative to the C-clef) and uses this to
2405 transform the input music by moving the pitch, changing the notehead
2406 and (optionally) adding a script:
2407 @lilypond[singleline,verbatim]
2408 \include "drumpitch-init.ly"
2409 up = \notes { crashcymbal4 hihat8 halfopenhihat hh hh hh openhihat }
2410 down = \notes { bassdrum4 snare8 bd r bd sn4 }
2412 \apply #(drums->paper 'drums) \context Staff <
2414 \context Voice = up { \voiceOne \up }
2415 \context Voice = down { \voiceTwo \down }
2420 In the above example the music was transformed using the list @code{'drums}.
2421 Currently the following lists are defined in @file{scm/drums.scm}:
2424 To typeset a typical drum kit on a five line staff.
2426 \include "drumpitch-init.ly"
2427 nam = \lyrics { cymc cyms cymr hh hhc hho hhho hhp cb hc
2428 bd sn ss tomh tommh tomml toml tomfh tomfl }
2429 mus = \notes { cymc cyms cymr hh hhc hho hhho hhp cb hc
2430 bd sn ss tomh tommh tomml toml tomfh tomfl s16 }
2433 \apply #(drums->paper 'drums) \context Staff <
2437 \context Lyrics \nam
2442 \remove Bar_engraver
2443 \remove Time_signature_engraver
2444 minimumVerticalExtent = #'(-4.0 . 5.0)
2448 \remove Stem_engraver
2453 Notice that the scheme supports six different toms.
2454 If you are using fewer toms then you simply select the toms that produce
2455 the desired result - i.e. to get toms on the three middle lines you
2456 use @code{tommh}, @code{tomml} and @code{tomfh}.
2458 Because the general midi contain no rimshots we use the sidestick for
2459 this purpose instead.
2461 To typeset timbales on a two line staff.
2462 @lilypond[singleline]
2463 \include "drumpitch-init.ly"
2464 nam = \lyrics { timh ssh timl ssl cb }
2465 mus = \notes { timh ssh timl ssl cb s16 }
2468 \apply #(drums->paper 'timbales) \context Staff <
2472 \context Lyrics \nam
2477 \remove Bar_engraver
2478 \remove Time_signature_engraver
2479 StaffSymbol \override #'line-count = #2
2480 StaffSymbol \override #'staff-space = #2
2481 minimumVerticalExtent = #'(-3.0 . 4.0)
2485 \remove Stem_engraver
2492 To typeset congas on a two line staff.
2493 @lilypond[singleline]
2494 \include "drumpitch-init.ly"
2495 nam = \lyrics { cgh cgho cghm ssh cgl cglo cglm ssl }
2496 mus = \notes { cgh cgho cghm ssh cgl cglo cglm ssl s16 }
2499 \apply #(drums->paper 'congas) \context Staff <
2503 \context Lyrics \nam
2508 \remove Bar_engraver
2509 \remove Time_signature_engraver
2510 StaffSymbol \override #'line-count = #2
2511 StaffSymbol \override #'staff-space = #2
2512 minimumVerticalExtent = #'(-3.0 . 4.0)
2516 \remove Stem_engraver
2522 To typeset bongos on a two line staff.
2523 @lilypond[singleline]
2524 \include "drumpitch-init.ly"
2525 nam = \lyrics { boh boho bohm ssh bol bolo bolm ssl }
2526 mus = \notes { boh boho bohm ssh bol bolo bolm ssl s16 }
2529 \apply #(drums->paper 'bongos) \context Staff <
2533 \context Lyrics \nam
2538 \remove Bar_engraver
2539 \remove Time_signature_engraver
2540 StaffSymbol \override #'line-count = #2
2541 StaffSymbol \override #'staff-space = #2
2542 minimumVerticalExtent = #'(-3.0 . 4.0)
2546 \remove Stem_engraver
2552 To typeset all kinds of simple percussion on one line staves.
2553 @lilypond[singleline]
2554 \include "drumpitch-init.ly"
2555 nam = \lyrics { tri trio trim gui guis guil cb cl tamb cab mar hc }
2556 mus = \notes { tri trio trim gui guis guil cb cl tamb cab mar hc s16 }
2559 \apply #(drums->paper 'percussion) \context Staff <
2563 \context Lyrics \nam
2568 \remove Bar_engraver
2569 \remove Time_signature_engraver
2570 StaffSymbol \override #'line-count = #1
2571 minimumVerticalExtent = #'(-2.0 . 3.0)
2575 \remove Stem_engraver
2582 If you don't like any of the predefined lists you can define your own
2583 list at the top of your file:
2585 @lilypond[singleline, verbatim]
2587 (bassdrum default #f ,(make-pitch -1 2 0))
2588 (snare default #f ,(make-pitch 0 1 0))
2589 (hihat cross #f ,(make-pitch 0 5 0))
2590 (pedalhihat xcircle "stopped" ,(make-pitch 0 5 0))
2591 (lowtom diamond #f ,(make-pitch -1 6 0))
2593 \include "drumpitch-init.ly"
2594 up = \notes { hh8 hh hh hh hhp4 hhp }
2595 down = \notes { bd4 sn bd toml8 toml }
2597 \apply #(drums->paper 'mydrums) \context Staff <
2599 \context Voice = up { \voiceOne \up }
2600 \context Voice = down { \voiceTwo \down }
2605 To use a modified existing list instead of building your own from
2606 scratch you can append your modifications to the start of the existing
2610 #(define mydrums (append `(
2611 (bassdrum default #f ,(make-pitch -1 2 0))
2612 (lowtom diamond #f ,(make-pitch -1 6 0))
2616 @c FIXME: Too many levels of headers when using subsubsections.
2617 @c Perhaps junk subsection ``Percussion staves''
2618 @subsubsection Percussion staves with normal staves
2619 When you include @file{drumpitch-init.ly} then the default pitches
2620 are overridden so that you after the inclusion cannot use the common
2621 dutch pitch names anymore. Hence you might wan't to reinclude
2622 @file{nederlands.ly} after the drum-pattern-definitions:
2623 @lilypond[singleline,verbatim]
2624 \include "drumpitch-init.ly"
2625 up = \notes { crashcymbal4 hihat8 halfopenhihat hh hh hh openhihat }
2626 down = \notes { bassdrum4 snare8 bd r bd sn4 }
2627 \include "nederlands.ly"
2628 bass = \notes \transpose c, { a4. e8 r e g e }
2631 \apply #(drums->paper 'drums) \context Staff = drums <
2633 \context Voice = up { \voiceOne \up }
2634 \context Voice = down { \voiceTwo \down }
2636 \context Staff = bass { \clef "F_8" \bass }
2641 @subsubsection Percussion midi output
2642 In order to produce correct midi output you need to produce two score
2643 blocks - one for the paper and one for the midi.
2644 To use the percussion channel you set the property @code{instrument}
2645 to @code{'drums}. Because the drum-pitches themself are similar to the
2646 general midi pitches all you have to do is to insert the voices with
2647 none of the scheme functions to get the correct midi output:
2651 \apply #(drums->paper 'mydrums) \context Staff <
2653 \context Voice = up @{ \voiceOne \up @}
2654 \context Voice = down @{ \voiceTwo \down @}
2660 \property Staff.instrument = #'drums
2669 This scheme is to be considered a temporary implementation. Even
2670 though the scheme will probably keep on working then the future might
2671 bring some other way of typesetting drums, and probably
2672 there will be made no great efforts in keeping things downwards
2677 @section Piano music
2679 Piano music is an odd type of notation. Piano staves are two normal
2680 staves coupled with a brace. The staves are largely independent, but
2681 sometimes voices can cross between the two staves. The
2682 @internalsref{PianoStaff} is especially built to handle this cross-staffing
2683 behavior. In this section we discuss the @internalsref{PianoStaff} and some
2684 other pianistic peculiarities.
2687 * Automatic staff changes::
2688 * Manual staff switches::
2691 * Voice follower lines::
2695 @c . {Automatic staff changes}
2696 @node Automatic staff changes
2697 @subsection Automatic staff changes
2698 @cindex Automatic staff changes
2700 Voices can switch automatically between the top and the bottom
2701 staff. The syntax for this is
2703 \autochange Staff \context Voice @{ @dots{}@var{music}@dots{} @}
2705 The autochanger switches on basis of pitch (central C is the turning
2706 point), and it looks ahead skipping over rests to switch rests in
2707 advance. Here is a practical example:
2709 @lilypond[verbatim,singleline]
2710 \score { \notes \context PianoStaff <
2711 \context Staff = "up" {
2712 \autochange Staff \context Voice = VA < \relative c' {
2713 g4 a b c d r4 a g } > }
2714 \context Staff = "down" {
2719 Spacer rests are used to prevent the bottom staff from
2720 terminating too soon.
2723 @node Manual staff switches
2724 @subsection Manual staff switches
2726 @cindex manual staff switches
2727 @cindex staff switch, manual
2729 Voices can be switched between staves manually, using the following command:
2731 \translator Staff = @var{staffname} @var{music}
2733 The string @var{staffname} is the name of the staff. It switches the
2734 current voice from its current staff to the Staff called
2735 @var{staffname}. Typically @var{staffname} is @code{"up"} or
2743 Piano pedal instruction can be expressed using
2744 @code{\sustainDown}, @code{\sustainUp}, @code{\unaCorda},
2745 @code{\treCorde}, @code{\sostenutoDown} and @code{\sostenutoUp}.
2747 These identifiers are shorthands for spanner commands of the types
2748 @internalsref{Sustain}, @internalsref{UnaCorda} and @internalsref{Sostenuto}:
2750 @lilypond[fragment,verbatim]
2751 c''4 \spanrequest \start "Sustain" c''4
2752 c''4 \spanrequest \stop "Sustain"
2755 The symbols that are printed can be modified by setting
2756 @code{pedal@var{X}Strings}, where @var{X} is one of the pedal types:
2757 Sustain, Sostenuto or UnaCorda. Refer to the generated documentation of
2758 @rgrob{SustainPedal}, for example, for more information.
2760 Pedals can also be indicated by a sequence of brackets, by setting the
2761 @code{pedal-type} property of SustainPedal grobs:
2763 @lilypond[fragment,verbatim]
2764 \property Staff.SustainPedal \override #'pedal-type = #'bracket
2765 c''4 \sustainDown d''4 e''4 a'4
2766 \sustainUp \sustainDown
2767 f'4 g'4 a'4 \sustainUp
2770 A third style of pedal notation is a mixture of text and brackets,
2771 obtained by setting @code{pedal-type} to @code{mixed}:
2773 @lilypond[fragment,verbatim]
2774 \property Staff.SustainPedal \override #'pedal-type = #'mixed
2775 c''4 \sustainDown d''4 e''4 c'4
2776 \sustainUp \sustainDown
2777 f'4 g'4 a'4 \sustainUp
2780 The default '*Ped' style for sustain and damper pedals corresponds to
2781 @code{\pedal-type = #'text}. However, @code{mixed} is the default style
2782 for a sostenuto pedal:
2784 @lilypond[fragment,verbatim]
2785 c''4 \sostenutoDown d''4 e''4 c'4 f'4 g'4 a'4 \sostenutoUp
2788 For fine-tuning of the appearance of a pedal bracket, the properties
2789 @code{edge-width}, @code{edge-height}, and @code{shorten-pair} of
2790 @code{PianoPedalBracket} grobs (see the detailed documentation of
2791 @rgrob{PianoPedalBracket}) can be modified. For example, the bracket
2792 may be extended to the end of the note head.
2794 @lilypond[fragment,verbatim]
2795 \property Staff.PianoPedalBracket \override
2796 #'shorten-pair = #'(0 . -1.0)
2797 c''4 \sostenutoDown d''4 e''4 c'4
2798 f'4 g'4 a'4 \sostenutoUp
2805 @subsection Arpeggio
2808 @cindex broken arpeggio
2809 @cindex @code{\arpeggio}
2811 You can specify an arpeggio sign on a chord by attaching an
2812 @code{\arpeggio} to a note of the chord.
2815 @lilypond[fragment,relative,verbatim]
2816 \context Voice <c\arpeggio e g c>
2819 When an arpeggio crosses staves in piano music, you attach an arpeggio
2820 to the chords in both staves, and set
2821 @code{PianoStaff.connectArpeggios}.
2823 @lilypond[fragment,relative,verbatim]
2824 \context PianoStaff <
2825 \property PianoStaff.connectArpeggios = ##t
2826 \context Voice = one { <c'\arpeggio e g c> }
2827 \context Voice = other { \clef bass <c,,\arpeggio e g>}
2831 This command creates @internalsref{Arpeggio} grobs. Cross staff arpeggios
2832 are @code{PianoStaff.Arpeggio}.
2834 To add an arrow head to explicitly specify the direction of the
2835 arpeggio, you should set the arpeggio grob property
2836 @code{arpeggio-direction}.
2838 @lilypond[fragment,relative,verbatim]
2840 \property Voice.Arpeggio \set #'arpeggio-direction = #1
2842 \property Voice.Arpeggio \set #'arpeggio-direction = #-1
2847 A square bracket on the left indicates that the player should not
2848 arpeggiate the chord. To draw these brackets, set the
2849 @code{molecule-callback} property of @code{Arpeggio} or
2850 @code{PianoStaff.Arpeggio} grobs to @code{\arpeggioBracket}, and use
2851 @code{\arpeggio} statements within the chords as before.
2853 @lilypond[fragment,relative,verbatim]
2854 \context PianoStaff <
2855 \property PianoStaff.connectArpeggios = ##t
2856 \property PianoStaff.Arpeggio \override
2857 #'molecule-callback = \arpeggioBracket
2858 \context Voice = one { <c'\arpeggio e g c> }
2859 \context Voice = other { \clef bass <c,,\arpeggio e g>}
2866 It is not possible to mix connected arpeggios and unconnected
2867 arpeggios in one PianoStaff at the same time.
2871 @node Voice follower lines
2872 @subsection Voice follower lines
2874 @cindex follow voice
2875 @cindex staff switching
2878 @cindex @code{followVoice}
2880 Whenever a voice switches to another staff a line connecting the notes
2881 can be printed automatically. This is enabled if the property
2882 @code{PianoStaff.followVoice} is set to true:
2884 @lilypond[fragment,relative,verbatim]
2885 \context PianoStaff <
2886 \property PianoStaff.followVoice = ##t
2887 \context Staff \context Voice {
2889 \translator Staff=two
2892 \context Staff=two {\clef bass \skip 1*2 }
2896 The associated grob is @internalsref{VoiceFollower}.
2902 Tablature notation is used music for plucked string instruments. It
2903 notates pitches not by using note heads, but by indicating on which
2904 string and fret a note must be played. LilyPond offers limited
2905 support for tablature, by abusing the fingering system.
2908 * Tablatures basic::
2909 * Non-guitar tablatures::
2910 * Tablature in addition to normal staff::
2913 @node Tablatures basic
2914 @subsection Tablatures basic
2915 @cindex Tablatures basic
2917 Tablature can be typeset with Lilypond by using the
2918 @internalsref{TabStaff} and @internalsref{TabVoice} contexts. As
2919 tablature is a recent feature in Lilypond, most of the guitar special
2920 effects such as hammer, pull, bend are not yet supported.
2922 With the @internalsref{TabStaff}, the string number associated to a note
2923 is given though the fingering mechanism, e.g. @code{c4-3} for a C
2924 quarter on the third string. The string 1 is the lowest one, and the
2925 tuning defaults to the standard guitar tuning (with 6 strings).
2927 @lilypond[fragment,verbatim]
2930 \property Staff.Stem \override #'direction = #1
2938 @node Non-guitar tablatures
2939 @subsection Non-guitar tablatures
2940 @cindex Non-guitar tablatures
2942 There are many ways to customize Lilypond tablatures.
2944 First you can change the number of strings, by setting the number of
2945 lines in the @internalsref{TabStaff}. You can change the strings
2946 tuning. A string tuning is given as a Scheme list with one integer
2947 number for each string, the number being the pitch of an open string.
2949 Finally, it is possible to change the Scheme function to format the
2950 tablature note text. The default is @var{fret-number-tablature-format},
2951 which uses the fret number, but for some instruments that may not use
2952 this notation, just create your own tablature-format function. This
2953 function takes three argument: the string number, the string tuning and
2957 @node Tablature in addition to normal staff
2958 @subsection Tablature in addition to normal staff
2959 @cindex Tablature in addition to normal staff
2961 It is possible to typeset both tablature and a "normal" staff, as
2962 commonly done in many parts.
2964 A common trick for that is to put the notes in a variables, and to hide
2965 the fingering information (which correspond to the string number) for
2969 @c @lily pond[verbatim]
2976 \context StaffGroup <
2978 % Hide fingering number
2979 \property Staff.Fingering \override #'transparent = ##t
2984 \property Staff.Stem \override #'direction = #1
2998 LilyPond has support for both entering and printing chords.
2999 @lilypond[verbatim,singleline]
3000 twoWays = \notes \transpose c'' {
3010 < \context ChordNames \twoWays
3011 \context Voice \twoWays > }
3014 This example also shows that the chord printing routines do not try to
3015 be intelligent. If you enter @code{f bes d}, it does not interpret
3016 this as an inversion.
3018 As you can see chords really are a set of pitches. They are internally
3019 stored as simultaneous music expressions. This means you can enter
3020 chords by name and print them as notes, enter them as notes and print
3021 them as chord names, or (the most common case) enter them by name, and
3026 * Printing named chords::
3031 @subsection Chords mode
3034 Chord mode is a mode where you can input sets of pitches using common
3035 names. It is introduced by the keyword @code{\chords}. It is similar
3036 to note mode, but words are also looked up in a chord modifier table
3037 (containing @code{maj}, @code{dim}, etc). Dashes and carets are used
3038 to indicate chord additions and subtractions, so articulation scripts
3039 can not be entered in Chord mode.
3041 Throughout these examples, chords have been shifted around the staff
3042 using @code{\transpose}.
3044 @lilypond[fragment,verbatim]
3048 c:9 c:9-.5+.7+ c:3-.5-
3058 The second type of modifier that may appear after the @code{:} is a
3059 named modifier. Named modifiers are listed in the file
3060 @file{chord-modifiers.ly}. The available modifiers are @code{m} and
3061 @code{min} which lower the 3rd half a step, `@code{aug}' which
3062 raises the 5th, `@code{dim}' which lowers the 5th,
3063 `@code{maj}' which adds a raised 7th, and `@code{sus}'
3064 which replaces the 5th with a 4th.
3066 @lilypond[fragment,verbatim]
3069 c1:m c:min7 c:maj c:aug c:dim c:sus
3075 Chord subtractions are used to eliminate notes from a chord. The
3076 notes to be subtracted are listed after a @code{^} character,
3079 @lilypond[fragment,verbatim,center]
3088 Chord inversions can be specified by appending `@code{/}' and the name
3089 of a single note to a chord. In a chord inversion, the inverted note is
3090 transposed down until it is the lowest note in the chord. If the note
3091 is not in the chord, a warning will be printed.
3093 @lilypond[fragment,verbatim,center]
3103 Bass notes can be added by `@code{/+}' and
3104 the name of a single note to a chord. This has the effect of
3105 adding the specified note to the chord, lowered by an octave,
3106 so it becomes the lowest note in the chord.
3108 @lilypond[fragment,verbatim,center]
3117 The formal syntax for named chords is as follows:
3119 @var{tonic}[@var{duration}][@code{-}@var{modifiers}][@code{^}@var{subtractions}][@code{/}@var{inversion}][@code{/+}@var{bass}].
3122 @var{tonic} should be the tonic note of the chord, and @var{duration} is
3123 the chord duration in the usual notation. There are two kinds of
3124 modifiers. One type is formed by @emph{chord additions}. Additions are
3125 obtained by listing intervals separated by dots. An interval is written
3126 by its number with an optional @code{+} or @code{-} to indicate raising
3127 or lowering by half a step. Chord additions have two effects: they adds
3128 the specified interval and all lower odd numbered intervals to the
3129 chord, and they may lower or raise the specified interval.
3134 Implementation details are gory. For example @code{c:4} not only adds
3135 a fourth, but also removes the third.
3138 @c . {Printing named chords}
3139 @node Printing named chords
3140 @subsection Printing named chords
3142 @cindex printing chord names
3146 For displaying printed chord names, use the @internalsref{ChordNames} context.
3147 The chords may be entered either using the notation described above, or
3148 directly using simultaneous music.
3150 @lilypond[verbatim,singleline]
3152 \chords {a1 b c} <d f g> <e g b>
3156 \context ChordNames \scheme
3157 \context Staff \transpose c'' \scheme
3162 You can make the chord changes stand out by setting
3163 @code{ChordNames.chordChanges} to true. This will only display chord
3164 names when there's a change in the chords scheme and at the start of a
3169 c1:m c:m \break c:m c:m d
3173 \context ChordNames {
3174 \property ChordNames.chordChanges = ##t
3176 \context Staff \transpose c'' \scheme
3178 \paper{linewidth= 9.\cm}
3182 LilyPond examines chords specified as lists of notes to determine a name
3183 to give the chord. LilyPond will not try to identify chord inversions or
3184 an added bass note, which may result in strange chord names when chords
3185 are entered as a list of pitches:
3187 @lilypond[verbatim,center,singleline]
3196 \context ChordNames \scheme
3197 \context Staff \scheme
3203 By default, a chord name system proposed by Harald Banter (See
3204 @ref{Literature}) is used. The system is very regular and predictable.
3205 Typical American style chord names may be selected by setting the
3206 @code{style} property of the @code{ChordNames.ChordName} grob to
3207 @code{'american}. Similarly @code{'jazz} selects Jazz chordnames.
3209 Routines that determine the names to be printed are written in Scheme,
3210 and may be customized by the user. The code can be found in
3211 @file{scm/chord-name.scm}. Here's an example showing the differences in
3215 @c maybe just junk verbatim option?
3216 @lilypond[verbatim,singleline]
3226 \context ChordNames = banter \scheme
3227 \context ChordNames = american {
3228 \property ChordNames.ChordName \override
3229 #'style = #'american \scheme }
3230 \context ChordNames = jazz {
3231 \property ChordNames.ChordName \override
3232 #'style = #'jazz \scheme }
3233 \context Staff \transpose c'' \scheme
3240 @section Writing parts
3242 Orchestral music involves some special notation, both in the full score,
3243 as in the individual parts. This section explains how to tackle common
3244 problems in orchestral music.
3251 * Instrument names::
3253 * Multi measure rests::
3254 * Automatic part combining::
3255 * Hara kiri staves::
3256 * Sound output for transposing instruments::
3259 @c . {Rehearsal marks}
3260 @node Rehearsal marks
3261 @subsection Rehearsal marks
3262 @cindex Rehearsal marks
3264 @cindex @code{\mark}
3266 To print a rehearsal mark, use the @code{\mark} command.
3267 @lilypond[fragment,verbatim]
3278 As you can see, the mark is incremented automatically if you use
3279 @code{\mark \default}. The value to use is stored in the property
3280 @code{rehearsalMark} is used and automatically incremented. The grob
3281 is @internalsref{RehearsalMark} in @internalsref{Score} context. See
3282 @code{input/test/boxed-molecule.ly} if you need boxes around the
3285 The @code{\mark} command can also be used to put signs like coda,
3286 segno and fermatas on a barline. The trick is to use the text markup
3287 mechanism to access the fermata symbol.
3288 @lilypond[fragment,verbatim,relative=1]
3289 c1 \mark #'(music "scripts-ufermata")
3293 The problem is that marks that occur at a line break are typeset only
3294 at the beginning of the next line, opposite to what you want for the
3295 fermata. This can be corrected by the following property setting
3297 \property Score.RehearsalMark \override
3298 #'visibility-lambda = #begin-of-line-invisible
3304 @cindex barlines, putting symbols on
3308 @subsection Bar numbers
3312 @cindex measure numbers
3313 @cindex currentBarNumber
3315 Bar numbers are printed by default at the start of the line. The
3316 number itself is a property that can be set by modifying the
3317 @code{currentBarNumber} property, i.e.
3319 \property Score.currentBarNumber = #217
3322 If you want boxed bar numbers, see the example file
3323 @code{input/test/boxed-molecule.ly}.
3325 See also @seeinternals{BarNumber}.
3329 Printing bar numbers at regular intervals is not implemented.
3330 Barnumbers can collide with the StaffGroup, if there is one at the
3331 top. To solve this, You have to twiddle with the
3332 @internalsref{padding} property of @internalsref{BarNumber} if your
3333 score starts with a @internalsref{StaffGroup}.
3335 @node Instrument names
3336 @subsection Instrument names
3338 In scores, the instrument name is printed before the staff. This can
3339 be done by setting @code{Staff.instrument} and
3340 @code{Staff.instr}. This will print a string before the start of the
3341 staff. For the first start, @code{instrument} is used, for the next
3342 ones @code{instr} is used.
3344 @lilypond[verbatim,singleline]
3345 \property Staff.instrument = "ploink " { c''4 }
3348 You can also use markup texts to construct more complicated instrument
3352 @lilypond[verbatim,singleline]
3354 '((font-relative-size . -2 ) (music "accidentals--1")))
3357 \property Staff.instrument = #`((kern . 0.5) (lines
3358 "2 Clarinetti" (columns " (B" ,text-flat ")")))
3366 When you put a name on a grand staff or piano staff the width of the
3367 brace is not taken into account. You must add extra spaces to the end of
3368 the name to avoid a collision.
3371 @subsection Transpose
3373 @cindex transposition of pitches
3374 @cindex @code{\transpose}
3376 A music expression can be transposed with @code{\transpose}. The syntax
3379 \transpose @var{pitch} @var{musicexpr}
3382 This means that middle C in @var{musicexpr} is transposed to
3385 @code{\transpose} distinguishes between enharmonic pitches: both
3386 @code{\transpose cis'} or @code{\transpose des'} will transpose up half
3387 a tone. The first version will print sharps and the second version
3390 @lilypond[singleline, verbatim]
3391 mus =\notes { \key d \major cis d fis g }
3392 \score { \notes \context Staff {
3400 If you want to use both @code{\transpose} and @code{\relative}, then
3401 you must use @code{\transpose} first. @code{\relative} will have no
3402 effect music that appears inside a @code{\transpose}.
3404 @c . {Multi measure rests}
3405 @node Multi measure rests
3406 @subsection Multi measure rests
3407 @cindex Multi measure rests
3411 Multi measure rests are entered using `@code{R}'. It is specifically
3412 meant for full bar rests and for entering parts: the rest can expand to
3414 rests, or it can be printed as a single multimeasure rest This expansion
3415 is controlled by the property @code{Score.skipBars}. If this is set to true,
3416 Lily will not expand empty measures, and the appropriate number is added
3419 @lilypond[fragment,verbatim]
3420 \time 3/4 r2. | R2. | R2.*2
3421 \property Score.skipBars = ##t R2.*17 R2.*4
3424 Notice that the @code{R2.} is printed as a whole rest, centered in the
3427 @cindex whole rests for a full measure
3429 The grob for this object is @internalsref{MultiMeasureRest}.
3433 Currently, there is no way to automatically condense multiple rests
3434 into a single multimeasure rest. Multi measure rests do not take part
3437 @cindex condensing rests
3439 @node Automatic part combining
3440 @subsection Automatic part combining
3441 @cindex automatic part combining
3442 @cindex part combiner
3445 Automatic part combining is used to merge two parts of music onto a
3446 staff in an intelligent way. It is aimed primarily at typesetting
3447 orchestral scores. When the two parts are identical for a period of
3448 time, only one is shown. In places where the two parts differ, they
3449 are typeset as separate voices, and stem directions are set
3450 automatically. Also, solo and @emph{a due} parts can be identified
3453 The syntax for part combining is
3456 \partcombine @var{context} @var{musicexpr1} @var{musicexpr2}
3458 where the pieces of music @var{musicexpr1} and @var{musicexpr2} will be
3459 combined into one context of type @var{context}. The music expressions
3460 must be interpreted by contexts whose names should start with @code{one}
3463 The most useful function of the part combiner is to combine parts into
3464 one voice, as common for wind parts in orchestral scores:
3466 @lilypond[verbatim,singleline,fragment]
3468 \context Voice=one \partcombine Voice
3469 \context Thread=one \relative c'' {
3472 \context Thread=two \relative c'' {
3478 Notice that the first @code{g} appears only once, although it was
3479 specified twice (once in each part). Stem, slur and tie directions are
3480 set automatically, depending whether there is a solo or unisono. The
3481 first part (with context called @code{one}) always gets up stems, and
3482 `solo', while the second (called @code{two}) always gets down stems and
3485 If you just want the merging parts, and not the textual markings, you
3486 may set the property @var{soloADue} to false.
3488 @lilypond[verbatim,singleline,fragment]
3490 \property Staff.soloADue = ##f
3491 \context Voice=one \partcombine Voice
3492 \context Thread=one \relative c'' {
3495 \context Thread=two \relative c'' {
3501 There are a number of other properties that you can use to tweak the
3502 behavior of part combining, refer to the automatically generated
3503 documentation of @reng{Thread_devnull_engraver} and
3504 @reng{Voice_devnull_engraver}. Look at the documentation of the
3505 responsible engravers, @code{Thread_devnull_engraver},
3506 @code{Voice_devnull_engraver} and @code{A2_engraver}.
3510 In @code{soloADue} mode, when the two voices play the same notes on and
3511 off, the part combiner may typeset @code{a2} more than once in a
3514 @lilypond[fragment,singleline]
3516 \context Voice=one \partcombine Voice
3517 \context Thread=one \relative c'' {
3520 \context Thread=two \relative c'' {
3526 @cindex @code{Thread_devnull_engraver}
3527 @cindex @code{Voice_engraver}
3528 @cindex @code{A2_engraver}
3530 @node Hara kiri staves
3531 @subsection Hara kiri staves
3533 In orchestral scores, staff lines that only have rests are usually removed.
3534 This saves some space. LilyPond also supports this through the hara
3535 kiri@footnote{Hara kiri, also called Seppuku, is the ritual suicide of
3536 the Japanese Samourai warriors.} staff. This staff commits suicide when
3537 it finds itself to be empty after the line-breaking process. It will
3538 not disappear when it contains normal rests, you must use multi measure
3541 The hara kiri staff is specialized version of the @internalsref{Staff}
3542 context. It is available as the context identifier
3543 @code{\HaraKiriStaffContext}. Observe how the second staff in this
3544 example disappears in the second line.
3548 \notes \relative c' <
3549 \context Staff = SA { e4 f g a \break c1 }
3550 \context Staff = SB { c4 d e f \break R1 }
3554 \translator { \HaraKiriStaffContext }
3560 @node Sound output for transposing instruments
3561 @subsection Sound output for transposing instruments
3563 When you want to make a MIDI file from a score containing transposed
3564 and untransposed instruments, you have to instruct LilyPond the pitch
3565 offset (in semitones) for the transposed instruments. This is done
3566 using the @code{transposing} property. It does not affect printed
3569 @cindex @code{transposing}
3572 \property Staff.instrument = #"Cl. in B-flat"
3573 \property Staff.transposing = #-2
3579 @node Ancient notation
3580 @section Ancient notation
3583 * Ancient note heads::
3590 @node Ancient note heads
3591 @subsection Ancient note heads
3593 To get a longa note head, you have to use mensural note heads. This
3594 is accomplished by setting the @code{style} property of the
3595 NoteHead grob to @code{mensural}. There is also a note head style
3596 @code{baroque} which gives mensural note heads for @code{\longa} and
3597 @code{\breve} but standard note heads for shorter notes.
3599 @lilypond[fragment,singleline,verbatim]
3600 \property Voice.NoteHead \set #'style = #'mensural
3601 \property Voice.NoteHead \set #'font-family = #'ancient
3606 @subsection Custodes
3611 A @emph{custos} (plural: @emph{custodes}; latin word for `guard') is a
3612 staff context symbol that appears at the end of a staff line. It
3613 anticipates the pitch of the first note(s) of the following line and
3614 thus helps the player or singer to manage line breaks during
3615 performance, thus enhancing readability of a score.
3620 \property Staff.Custos \set #'style = #'mensural
3625 \consists Custos_engraver
3631 Custodes were frequently used in music notation until the 17th century.
3632 There were different appearances for different notation styles.
3633 Nowadays, they have survived only in special forms of musical notation
3634 such as via the @emph{editio vaticana} dating back to the beginning of
3637 For typesetting custodes, just put a @code{Custos_engraver} into the
3638 @internalsref{Staff} context when declaring the @code{\paper} block. In this
3639 block, you can also globally control the appearance of the custos symbol
3640 by setting the custos @code{style} property. Currently supported styles
3641 are @code{vaticana}, @code{medicaea}, @code{hufnagel} and
3648 \consists Custos_engraver
3649 Custos \override #'style = #'mensural
3654 The property can also be set locally, for example in a @code{\notes}
3659 \property Staff.Custos \override #'style = #'vaticana
3660 c'1 d' e' d' \break c' d' e' d'
3665 @subsection Ancient clefs
3667 LilyPond supports a variety of clefs, many of them ancient. These can
3668 be selected from the @code{ancient} font family, by setting
3669 @code{Staff.clefGlyph}) to one of the following values
3678 @item clefs-vaticana_do
3679 Editio Vaticana style do clef
3680 @item clefs-vaticana_fa
3681 Editio Vaticana style fa clef
3682 @item clefs-medicaea_do
3683 Editio Medicaea style do clef
3684 @item clefs-medicaea_fa
3685 Editio Medicaea style fa clef
3686 @item clefs-mensural1_c
3687 modern style mensural C clef
3688 @item clefs-mensural2_c
3689 historic style small mensural C clef
3690 @item clefs-mensural3_c
3691 historic style big mensural C clef
3692 @item clefs-mensural1_f
3693 historic style traditional mensural F clef
3694 @item clefs-mensural2_f
3695 historic style new mensural F clef
3696 @item clefs-mensural_g
3697 historic style mensural G clef
3698 @item clefs-hufnagel_do
3699 historic style hufnagel do clef
3700 @item clefs-hufnagel_fa
3701 historic style hufnagel fa clef
3702 @item clefs-hufnagel_do_fa
3703 historic style hufnagel combined do/fa clef
3704 @item clefs-percussion
3705 modern style percussion clef
3708 @emph{Modern style} means ``as is typeset in current editions.''
3709 @emph{Historic style} means ``as was typeset or written in contemporary
3710 historic editions''. @emph{Editio XXX style} means ``as is/was printed in
3713 @cindex Vaticana, Editio
3714 @cindex Medicaea, Editio
3715 @cindex hufnagel clefs
3719 @subsection Figured bass
3721 @cindex Basso continuo
3723 LilyPond has limited support for figured bass:
3725 @lilypond[verbatim,fragment]
3727 \context FiguredBass
3732 \context Voice { c4 g8 }
3736 The support for figured bass consists of two parts: there is an input
3737 mode, introduced by @code{\figures}, where you can enter bass figures
3738 as numbers, and there is a context called @internalsref{FiguredBass}
3739 that takes care of making @internalsref{BassFigure} grobs.
3741 In figures input mode, a group of bass figures is delimited by
3742 @code{<} and @code{>}. The duration is entered after the @code{>}.
3747 \context FiguredBass
3751 Accidentals are added to the numbers if you alterate them by
3752 appending @code{-}, @code{!} and @code{+}.
3758 \context FiguredBass
3759 \figures { <4- 6+ 7!> }
3762 Spaces or dashes may be inserted by using @code{_}. Brackets are
3763 introduced with @code{[} and @code{]}.
3769 \context FiguredBass
3770 \figures { < [4 6] 8 [_ 12]> }
3773 Although the support for figured bass may superficially resemble chord
3774 support, it works much simpler: in figured bass simply stores the
3775 numbers, and then prints the numbers you entered. There is no
3776 conversion to pitches, and no realizations of the bass are played in
3780 @c . {Tuning output}
3782 @section Tuning output
3784 LilyPond tries to take as much formatting as possible out of your
3785 hands. Nevertheless, there are situations where it needs some help, or
3786 where you want to override its decisions. In this section we discuss
3787 ways to do just that.
3789 Formatting is internally done by manipulating so called grobs (graphic
3790 objects). Each grob carries with it a set of properties (grob
3791 properties) specific to that object. For example, a stem grob has
3792 properties that specify its direction, length and thickness.
3794 The most direct way of tuning the output is by altering the values of
3795 these properties. There are two ways of doing that: first, you can
3796 temporarily change the definition of a certain type of grob, thus
3797 affecting a whole set of objects. Second, you can select one specific
3798 object, and set a grob property in that object.
3801 * Tuning groups of grobs ::
3802 * Tuning per grob ::
3807 @node Tuning groups of grobs
3808 @subsection Tuning groups of grobs
3810 @cindex grob description
3814 A grob definition is a Scheme association list, that is stored in a
3815 context property. By assigning to that property (using plain
3816 @code{\property}), you can change the resulting grobs.
3818 @lilypond[verbatim, fragment]
3819 c'4 \property Voice.Stem = #'()
3822 The @code{\property} assignment effectively empties the definition of
3823 the Stem object. One of the effects is that the recipe of how it should be
3824 printed is erased, with the effect of rendering it invisible. The above
3825 assignment is available as a standard identifier, for the case that you
3829 \property Voice.Stem = \turnOff
3836 This mechanism is fairly crude, since you can only set, but not modify,
3837 the definition of a grob. For this reason, there is a more advanced
3840 The definition of a grob is actually a list of default grob
3841 properties. For example, the definition of the Stem grob (available in
3842 @file{scm/grob-description.scm}), defines the following values for
3847 (beamed-lengths . (0.0 2.5 2.0 1.5))
3848 (Y-extent-callback . ,Stem::height)
3852 You can add a property on top of the existing definition, or remove a
3853 property, thus overriding the system defaults:
3855 c'4 \property Voice.Stem \override #'thickness = #4.0
3856 c'4 \property Voice.Stem \revert #'thickness
3859 You should balance @code{\override} and @code{\revert}. If that's too
3860 much work, you can use the @code{\set} shorthand. It performs a revert
3861 followed by an override. The following example gives exactly the same
3862 result as the previous one.
3864 c'4 \property Voice.Stem \set #'thickness = #4.0
3865 c'4 \property Voice.Stem \set #'thickness = #0.8
3868 If you use @code{\set}, you must explicitly restore the default.
3871 Formally the syntax for these constructions is
3873 \property @var{context}.@var{grobname} \override @var{symbol} = @var{value}
3874 \property @var{context}.@var{grobname} \set @var{symbol} = @var{value}
3875 \property @var{context}.@var{grobname} \revert @var{symbol}
3877 Here @var{symbol} is a Scheme expression of symbol type, @var{context}
3878 and @var{grobname} are strings and @var{value} is a Scheme expression.
3881 If you revert a setting which was not set in the first place, then it
3882 has no effect. However, if the setting was set as a system default, it
3883 may remove the default value, and this may give surprising results,
3884 including crashes. In other words, @code{\override} and @code{\revert},
3885 must be carefully balanced.
3887 These are examples of correct nesting of @code{\override}, @code{\set},
3890 A clumsy but correct form:
3892 \override \revert \override \revert \override \revert
3895 Shorter version of the same:
3897 \override \set \set \revert
3900 A short form, using only @code{\set}. This requires you to know the
3903 \set \set \set \set @var{to default value}
3906 If there is no default (i.e. by default, the grob property is unset),
3909 \set \set \set \revert
3912 For the digirati, the grob description is an Scheme association
3913 list. Since a Scheme list is a singly linked list, we can treat it as a
3914 stack, and @code{\override} and @code{\revert} are just push and pop
3915 operations. This pushing and popping is also used for overriding
3916 automatic beaming settings.
3920 LilyPond will hang or crash if @var{value} contains cyclic references.
3921 The backend is not very strict in type-checking grob properties. If you
3922 @code{\revert} properties that are expected to be set by default,
3928 @node Tuning per grob
3929 @subsection Tuning per grob
3931 @cindex \outputproperty
3933 A second way of tuning grobs is the more arcane @code{\outputproperty}
3934 feature. The syntax is as follows:
3936 \outputproperty @var{predicate} @var{symbol} = @var{value}
3938 Here @code{predicate} is a Scheme function taking a grob argument, and
3939 returning a boolean. This statement is processed by the
3940 @code{Output_property_engraver}. It instructs the engraver to feed all
3941 grobs that it sees to @var{predicate}. Whenever the predicate returns
3942 true, the grob property @var{symbol} will be set to @var{value}.
3944 You will need to combine this statement with @code{\context} to select
3945 the appropriate context to apply this to.
3947 Here are some random examples.
3950 In the following example, all note heads occurring at current staff
3951 level, are shifted up and right by setting their @code{extra-offset}
3954 @lilypond[fragment,verbatim,singleline]
3956 \context Staff \outputproperty
3957 #(make-type-checker 'note-head-interface)
3958 #'extra-offset = #'(0.5 . 0.75)
3962 @cindex @code{extra-offset}
3964 In this example, the predicate checks the @code{text} grob property, to
3965 shift only the `m.d.' text, but not the fingering instruction "2".
3966 @lilypond[verbatim,singleline]
3967 #(define (make-text-checker text)
3968 (lambda (grob) (equal? text (ly-get-grob-property grob 'text))))
3971 \notes\relative c''' {
3972 \property Voice.Stem \set #'direction = #1
3973 \outputproperty #(make-text-checker "m.d.")
3974 #'extra-offset = #'(-3.5 . -4.5)
3982 If possible, avoid this feature: the semantics are not very clean, and
3983 the syntax and semantics are up for rewrite.
3988 @node Font selection
3989 @subsection Font selection
3991 The most common thing to change about the appearance of fonts is
3992 their size. The font size of a @internalsref{Voice},
3993 @internalsref{Staff} or @internalsref{Thread} context, can be easily
3994 changed by setting the @code{fontSize} property for that context:
3995 @lilypond[fragment,relative=1]
3996 c4 c4 \property Voice.fontSize = #-1
3999 This command will not change the size of variable symbols, such as
4000 beams or slurs. You can use this command to get smaller symbol for
4001 cue notes, but that involves some more subtleties. An elaborate
4002 example of those is in @file{input/test/cue-notes.ly}.
4008 The font used for printing a grob can be selected by setting
4009 @code{font-name}, e.g.
4011 \property Staff.TimeSignature
4012 \set #'font-name = #"cmr17"
4014 You may use any font which is available to @TeX{}, such as foreign
4015 fonts or fonts that do not belong to the Computer Modern font family.
4016 Font selection for the standard fonts, @TeX{}'s Computer Modern fonts,
4017 can also be adjusted with a more fine-grained mechanism. By setting
4018 the grob properties described below, you can select a different font.
4019 All three mechanisms work for every grob that supports
4020 @code{font-interface}.
4024 A symbol indicating the general class of the typeface. Supported are
4025 @code{roman} (Computer Modern), @code{braces} (for piano staff
4026 braces), @code{music} (the standard music font), @code{ancient} (the
4027 ancient notation font) @code{dynamic} (font for dynamic signs) and
4031 A symbol indicating the shape of the font, there are typically several
4032 font shapes available for each font family. Choices are @code{italic},
4033 @code{caps} and @code{upright}
4036 A symbol indicating the series of the font. There are typically several
4037 font series for each font family and shape. Choices are @code{medium}
4040 @item font-relative-size
4041 A number indicating the size relative the standard size. For example,
4042 with 20pt staff height, relative size -1 corresponds to 16pt staff
4043 height, and relative size +1 corresponds to 23 pt staff height.
4045 @item font-design-size
4046 A number indicating the design size of the font.
4048 This is a feature of the Computer Modern Font: each point size has a
4049 slightly different design. Smaller design sizes are relatively wider,
4050 which enhances readability.
4053 For any of these properties, the value @code{*} (i.e. the @emph{symbol},
4054 @code{*}, entered as @code{#'*}), acts as a wildcard. This can be used
4055 to override default setting, which are always present. For example:
4057 \property Lyrics . LyricText \override #'font-series = #'bold
4058 \property Lyrics . LyricText \override #'font-family = #'typewriter
4059 \property Lyrics . LyricText \override #'font-shape = #'*
4062 @cindex @code{font-style}
4064 There are also pre-cooked font selection qualifiers. These are
4065 selected through the grob property @code{font-style}. For example,
4066 the style @code{finger} selects family @code{number} and relative size
4067 @code{-3}. Styles available include @code{volta}, @code{finger},
4068 @code{tuplet}, @code{timesig}, @code{mmrest}, @code{script},
4069 @code{large}, @code{Large} and @code{dynamic}. The style sheets and
4070 tables for selecting fonts are located in @file{scm/font.scm}. Refer
4071 to this file for more information.
4073 @cindex magnification
4075 The size of the font may be scaled with the grob property
4076 @code{font-magnification}. For example, @code{2.0} blows up all
4077 letters by a factor 2 in both directions.
4081 Relative size is not linked to any real size.
4083 There is no style sheet provided for other fonts besides the @TeX{}
4084 family, and the style sheet can not be modified easiyl.
4086 @cindex font selection
4087 @cindex font magnification
4088 @cindex @code{font-interface}
4092 @subsection Text markup
4096 LilyPond has an internal mechanism to typeset texts. You can
4097 form text markup expressions by composing scheme expressions
4098 in the following way.
4100 @lilypond[verbatim, singleline]
4105 c^#'(italic "italic")
4106 d_#'((bold italic) "ff")
4108 f_#'(lines "one" (bold "two"))
4109 g^#'(music "noteheads-2" ((raise . 2.4) "flags-u3"))
4113 Normally, the Scheme markup text is stored in the @code{text} property
4114 of a grob. Formally, it is defined as follows:
4117 text: string | (head? text+)
4118 head: markup | (markup+)
4119 markup-item: property | abbrev
4120 property: (@var{key} . @var{value})
4121 abbrev: @code{columns lines roman music bold italic named super sub}
4122 @code{overstrike text finger volta timesig mmrest mark script}
4123 @code{large Large dynamic}
4126 The markup is broken down and converted into a list of grob properties,
4127 which are prepended to the property list. The @var{key}-@var{value}
4128 pair is a grob property. A list of properties available is included in
4129 the generated documentation for @internalsref{text-interface}.
4131 The following abbreviations are defined:
4134 horizontal mode: set all text on one line (default)
4136 vertical mode: set every text on a new line
4140 selects the Feta font (the standard font for music notation glyphs),
4141 and uses named lookup
4148 lookup by character name
4150 plain text lookup (by character value)
4156 the next text or character overstrikes this one
4158 select fingering number fontstyle
4160 select volta number fontstyle
4162 select time signature number fontstyle
4164 select multi measure rest number fontstyle
4166 select mark number fontstyle
4168 select scriptsize roman fontstyle
4170 select large roman fontstyle
4172 select Large roman fontstyle
4174 select dynamics fontstyle
4178 @cindex metronome mark
4180 One practical application of complicated markup is to fake a metronome
4184 #(define note '(columns
4185 (music "noteheads-2" ((kern . -0.1) "flags-stem"))))
4186 #(define eight-note `(columns ,note ((kern . -0.1)
4187 (music ((raise . 3.5) "flags-u3")))))
4188 #(define dotted-eight-note
4189 `(columns ,eight-note (music "dots-dot")))
4192 \notes\relative c'' {
4193 a1^#`((columns (font-relative-size . -1)) ,dotted-eight-note " = 64")
4199 TextScript \override #'font-shape = #'upright
4207 The syntax and semantics of markup texts are not clean, and both
4208 syntax and semantics are slated for a rewrite.
4210 LilyPond does not do kerning, and there generally spaces texts
4216 @section Global layout
4218 The global layout determined by three factors: the page layout, the
4219 iline breaks and the spacing. These all influence each other: The
4220 choice of spacing determines how densely each system of music is set,
4221 whree line breaks breaks are chosen, and thus ultimately how many
4222 pages a piece of music takes. In this section we will explain how the
4223 lilypond spacing engine works, and how you can tune its results.
4225 Globally spoken, this procedure happens in three steps: first,
4226 flexible distances (``springs'') are chosen, based on durations. All
4227 possible line breaking combination are tried, and the one with the
4228 best results---a layout that has uniform density and requires as
4229 little stretching or cramping as possible---is chosen. When the score
4230 is processed by @TeX{}, page are filled with systems, and page breaks
4231 are chosen whenever the page gets full.
4234 * Vertical spacing::
4235 * Horizontal spacing::
4242 @node Vertical spacing
4243 @subsection Vertical spacing
4245 @cindex vertical spacing
4246 @cindex distance between staffs
4247 @cindex staff distance
4248 @cindex between staves, distance
4250 The height of each system is determined automatically by lilypond, to
4251 keep systems from bumping into each other, some minimum distances are
4252 set. By changing these, you can put staffs closer together, and thus
4253 put more systems onto one page.
4255 Normally staves are stacked vertically. To make
4256 staves maintain a distance, their vertical size is padded. This is
4257 done with the property @code{minimumVerticalExtent}. It takes a pair
4258 of numbers, so if you want to make it smaller from its, then you could
4261 \property Staff.minimumVerticalExtent = #'(-4 . 4)
4263 This sets the vertical size of the current staff to 4 staff-space on
4264 either side of the center staff line. The argument of
4265 @code{minimumVerticalExtent} is interpreted as an interval, where the
4266 center line is the 0, so the first number is generally negative. you
4267 could also make the staff larger at the bottom by setting it to
4268 @code{(-6 . 4)}. The default value is @code{(-6 . 6)}.
4270 Vertical aligment of staves is handled by the
4271 @internalsref{VerticalAlignment} grob, which lives at
4272 @internalsref{Score} level.
4274 The piano staffs are handled a little differently: to make cross-staff
4275 beaming work correctly, it necessary that the distance between staves
4276 is fixed. This is also done with a @internalsref{VerticalAlignment}
4277 grob, created in @internalsref{PianoStaff}, but a forced distance is
4278 set. This is done with the grob property #'forced-distance. If you
4279 want to override this, use a @code{\translator} block as follows:
4283 VerticalAlignment \override #'forced-distance = #9
4286 This would bring the staffs together at a distance of 9 staff spaces,
4287 and again this is measured from the center line of each staff.
4291 @node Horizontal spacing
4292 @subsection Horizontal Spacing
4294 The spacing engine translates differences in durations into
4295 stretchable distances (``springs'') of differing lengths. Longer
4296 durations get more space, shorter durations get less. The basis for
4297 assigning spaces to durations, is that the shortest durations get a
4298 fixed amount of space, and the longer durations get more: doubling a
4299 duration adds a fixed amount of space to the note.
4301 For example, the following piece contains lots of half, quarter and
4302 8th notes, the eighth note is followed by 1 note head width. The The
4303 quarter note is followed by 2 NHW, the half by 3 NHW, etc.
4304 @lilypond[fragment, verbatim, relative=1]
4305 c2 c4. c8 c4. c8 c4. c8 c8 c8 c4 c4 c4
4308 These two amounts of space are @code{shortest-duration-space}
4309 @code{spacing-increment}, grob properties of
4310 @internalsref{SpacingSpanner}. Normally @code{spacing-increment} is
4311 set to 1.2, which is the width of a note head, and
4312 @code{shortest-duration-space} is set to 2.0, meaning that the
4313 shortest note gets 2 noteheads of space. For normal notes, this space
4314 is always counted from the left edge of the symbol, so the short notes
4315 in a score is generally followed by one note head width of space.
4317 If one would follow the above procedure exactly, then adding a single
4318 32th note to a score that uses 8th and 16th notes, would widen up the
4319 entire score a lot. The shortest note is no longer a 16th, but a 64th,
4320 thus adding 2 noteheads of space to every note. To prevent this, the
4321 shortest duration for spacing is not the shortest note in the score,
4322 but the most commonly found shortest note. Notes that are even
4323 shorter this are followed by a space that is proportonial to their
4324 duration relative to the common shortest note. So if we were to add
4325 only a few 16th notes to the example above, they would be followed by
4328 @lilypond[fragment, verbatim, relative=1]
4329 c2 c4. c8 c4. [c16 c] c4. c8 c8 c8 c4 c4 c4
4332 The most common shortest duration is determined as follows: in every
4333 measure, the shortest duration is determined. The most common short
4334 duration, is taken as the basis for the spacing, with the stipulation
4335 that this shortest duration should always be equal to or shorter than
4336 1/8th note. The shortest duration is printed when you run lilypond
4337 with @code{--verbose}. These durations may also be customized. If you
4338 set the @code{common-shortest-duration} in
4339 @internalsref{SpacingSpanner}, then this sets the base duration for
4340 spacing. The maximum duration for this base (normally 1/8th), is set
4341 through @code{base-shortest-duration}.
4343 @cindex @code{common-shortest-duration}
4344 @cindex @code{base-shortest-duration}
4345 @cindex @code{stem-spacing-correction}
4346 @cindex @code{spacing}
4348 In the introduction it was explained that stem directions influence
4349 spacing. This is controlled with @code{stem-spacing-correction} in
4350 @internalsref{NoteSpacing}. The @code{StaffSpacing} grob contains the
4351 same property for controlling the stem/barline spacing. In the
4352 following example shows these corrections, once with default settings,
4353 and once with exaggerated corrections.
4359 \property Staff.NoteSpacing \override #'stem-spacing-correction
4361 \property Staff.StaffSpacing \override #'stem-spacing-correction
4366 \paper { linewidth = -1. } }
4373 Spacing is determined on a score wide basis. If you have a score that
4374 changes its character (measured in durations) half way during the
4375 score, the part containing the longer durations will be spaced too
4378 Generating optically pleasing spacing is black magic. LilyPond tries
4379 to deal with a number of frequent cases. Here is an example that is
4380 not handled correctly, due to the combination of chord collisions and
4385 \context PianoStaff \notes \transpose c''' <
4386 \context Staff = up { s1 }
4387 \context Staff = down { [c8 c \translator Staff=up <c d> c
4388 \translator Staff=down c c c] }
4390 \paper { linewidth = -1 }
4397 @subsection Font size
4398 @cindex font size, setting
4399 @cindex staff size, setting
4400 @cindex @code{paper} file
4402 The Feta font provides musical symbols at seven different sizes.
4403 These fonts are 11 point, 13 point, 16 point, 19 pt, 20 point, 23
4404 point, and 26 point. The point size of a font is the height of the
4405 five lines in a staff when displayed in the font.
4407 Definitions for these sizes are the files @file{paperSZ.ly}, where
4408 @code{SZ} is one of 11, 13, 16, 19, 20, 23 and 26. If you include any
4409 of these files, the identifiers @code{paperEleven},
4410 @code{paperThirteen}, @code{paperSixteen}, @code{paperNineteen},
4411 @code{paperTwenty}, @code{paperTwentythree}, and @code{paperTwentysix}
4412 are defined respectively. The default @code{\paper} block is also
4413 set. These files should be imported at toplevel, i.e.
4415 \include "paper26.ly"
4419 The font definitions are generated using a Scheme function. For more
4420 details, see the file @file{scm/font.scm}.
4425 @subsection Line breaking
4428 @cindex breaking lines
4430 Line breaks are normally computed automatically. They are chosen such
4431 that it looks neither cramped nor loose, and that consecutive lines have
4434 Occasionally you might want to override the automatic breaks; you can
4435 do this by specifying @code{\break}. This will force a line break at
4436 this point. Line breaks can only occur at places where there are bar
4437 lines. If you want to have a line break where there is no bar line,
4438 you can force an invisible bar line by entering @code{\bar
4439 ""}. Similarly, @code{\noBreak} forbids a line break at a certain
4443 @cindex regular line breaks
4444 @cindex four bar music.
4446 If you want linebreaks at regular intervals, you can use the following:
4448 < \repeat 7 unfold @{ s1 * 4 \break @}
4452 This makes the following 28 measures (assuming 4/4 time) be broken every
4456 @subsection Page layout
4459 @cindex breaking pages
4461 @cindex @code{indent}
4462 @cindex @code{linewidth}
4464 The most basic settings influencing the spacing are @code{linewidth}
4465 and @code{indent}, both set in the @code{\paper} block. They control
4466 the indentation of the first line of music, and the lengths of the
4467 lines. If @code{linewidth} set to a negative value, a single
4468 unjustified line is produced. A similar effect for scores that are
4469 longer than one line, can be produced by setting @code{raggedright} to
4470 true in the @code{\paper} block.
4474 The page layout process happens outside lilypond. Ly2dvi sets page
4475 layout instructions. Ly2dvi responds to the following variables in the
4476 @code{\paper} block. The variable @code{textheight} sets the total
4477 height of the music on each page. The spacing between systems is
4478 controlled with @code{interscoreline}, its default is 16pt.
4479 The distance between the score lines will stretch in order to fill the
4480 full page @code{interscorelinefill} is set to a positive number. In
4481 that case @code{interscoreline} specifies the minimum spacing.
4483 @cindex @code{textheight}
4484 @cindex @code{interscoreline}
4485 @cindex @code{interscorelinefill}
4487 If the variable @code{lastpagefill} is defined (that is, it gets any
4488 value assigned in the @code{\paper} block), systems are evenly
4489 distributed vertically on the last page. This might produce ugly
4490 results in case there are not enough systems on the last page. Note
4491 that @command{lilypond-book} ignores @code{lastpagefill}. See
4492 @ref{Insert music snippets into your texts using lilypond-book} for
4495 @cindex @code{lastpagefill}
4497 Page breaks are normally computed by @TeX{}, so they are not under
4498 direct control of LilyPond. However, you can insert a commands into
4499 the @file{.tex} output to instruct @TeX{} where to break pages. You
4500 can insert a @code{\newpage} from within lilypond. This is done by
4501 setting the @code{between-systems-strings} on the
4502 @internalsref{NonMusicalPaperColumn} where the system is broken.
4506 @cindex @code{papersize}
4508 To change the paper size, you must first set the
4509 @code{papersize} paper variable variable. Set it to
4510 the strings @code{a4}, @code{letter}, or @code{legal}. After this
4511 specification, you must set the font as described above. If you want
4512 the default font, then use the 20 point font.
4515 \paper@{ papersize = "a4" @}
4516 \include "paper16.ly"
4519 The file @code{paper16.ly} will now include a file named @file{a4.ly}, which
4520 will set the paper variables @code{hsize} and @code{vsize} (used by
4521 Lilypond and @code{ly2dvi})
4531 LilyPond can produce MIDI output. The performance lacks lots of
4532 interesting effects, such as swing, articulation, slurring, etc., but it
4533 is good enough for proof-hearing the music you have entered. Ties,
4534 dynamics and tempo changes are interpreted.
4536 Dynamic marks, crescendi and decrescendi translate into MIDI volume
4537 levels. Dynamic marks translate to a fixed fraction of the available
4538 MIDI volume range, crescendi and decrescendi make the the volume vary
4539 linearly between their two extremities. The fractions be adjusted by
4540 overriding the @code{absolute-volume-alist} defined in
4541 @file{scm/midi.scm}.
4543 For each type of musical instrument (that MIDI supports), a volume range
4544 can be defined. This gives you basic equalizer control, which can
4545 enhance the quality of the MIDI output remarkably. You can add
4546 instruments and ranges or change the default settings by overriding the
4547 @code{instrument-equalizer-alist} defined in @file{scm/midi.scm}.
4549 Both loudness controls are combined to produce the final MIDI volume.
4555 * MIDI instrument names::
4560 @subsection MIDI block
4564 The MIDI block is analogous to the paper block, but it is somewhat
4565 simpler. The @code{\midi} block can contain:
4569 @item a @code{\tempo} definition
4570 @item context definitions
4573 Assignments in the @code{\midi} block are not allowed.
4577 @cindex context definition
4579 Context definitions follow precisely the same syntax as within the
4580 \paper block. Translation modules for sound are called performers.
4581 The contexts for MIDI output are defined in @file{ly/performer-init.ly}.
4584 @node MIDI instrument names
4585 @subsection MIDI instrument names
4587 @cindex instrument names
4588 @cindex @code{Staff.midiInstrument}
4589 @cindex @code{Staff.instrument}
4591 The MIDI instrument name is set by the @code{Staff.midiInstrument}
4592 property or, if that property is not set, the @code{Staff.instrument}
4593 property. The instrument name should be chosen from the list in
4594 @ref{MIDI instruments}.
4598 If the selected string does not exactly match, then LilyPond uses the
4599 default (Grand Piano). It is not possible to select an instrument by