4 @c A menu is needed before every deeper *section nesting of @nodes
5 @c Run M-x texinfo-all-menus-update
6 @c to automagically fill in these menus
7 @c before saving changes
18 @c .{Reference Manual}
20 @node Reference Manual
21 @chapter Reference Manual
23 This document describes GNU LilyPond and its input format. The last
24 revision of this document was made for LilyPond 1.3.145.
47 * Skipping corrected music::
48 * Interpretation context::
58 The purpose of LilyPond is explained informally by the term `music
59 typesetter'. This is not a fully correct name: not only does the
60 program print musical symbols, it also makes esthetic decisions.
61 Symbols and their placements are @emph{generated} from a high-level
62 musical description. In other words, LilyPond would be best described
63 by `music compiler' or `music to notation compiler'.
65 LilyPond is linked to GUILE, GNU's Scheme library for extension. The
66 Scheme library provides the glue that holds together the low-level
67 routines and separate modules which are written in C++.
69 When lilypond is run to typeset sheet music, the following happens:
71 @item GUILE Initialization: various scheme files are read
72 @item parsing: first standard @code{ly} initialization files are read, and
73 then the user @file{ly} file is read.
74 @item interpretation: the music in the file is processed ``in playing
75 order'', i.e. the order that you use to read sheet music, or the
76 order in which notes are played. The result of this step is a typesetting
80 The typesetting specification is solved: positions and formatting is
83 @item the visible results ("virtual ink") are written to the output file.
86 During these stages different types of data play the the main role:
87 during parsing, @strong{Music} objects are created. During the
88 interpretation, @strong{context}s are constructed, and with these contexts
89 a network of @strong{graphical objects} (``grobs'') is created. These
90 grobs contain unknown variables, and the network forms a set of
91 equations. After solving the equations and filling in these variables,
92 the printed output (in the form of @strong{molecules}) is written to an
95 These threemanship of tasks (parsing, translating, typesetting) and
96 data-structures (music, context, graphical objects) permeates the entire
97 design of the program.
104 The most basic forms of music are notes. We discuss how you enter them
105 here. Notes on their own don't form valid input, but for the sake of
106 brevity we omit obligatory lint such as @code{\score} blocks and
107 @code{\paper} declarations.
112 * Defining pitch names::
115 * Easy Notation note heads ::
127 @cindex Note specification
129 @cindex entering notes
131 The verbose syntax for pitch specification is
133 @cindex @code{\pitch}
135 \pitch @var{scmpitch}
138 @var{scmpitch} is a pitch scheme object, see @ref{Pitch data type}.
140 In Note and Chord mode, pitches may be designated by names. The default
141 names are the Dutch note names. The notes are specified by the letters
142 @code{a} through @code{g} (where the octave is formed by notes ranging
143 from @code{c}, to @code{b}). The pitch @code{c} is an octave below
144 middle C and the letters span the octave above that C.
146 @cindex note names, Dutch
148 In Dutch, a sharp is formed by adding @code{-is} to the end of a pitch
149 name. A flat is formed by adding @code{-es}. Double sharps and double
150 flats are obtained by adding @code{-isis} or @code{-eses}. @code{aes}
151 and @code{ees} are contracted to @code{as} and @code{es} in Dutch, but
152 both forms are accepted.
154 LilyPond has predefined sets of notenames for various other languages.
155 To use them, simply include the language specific init file. For
156 example: @code{\include "english.ly"}. The available language files and
157 the names they define are:
160 Note Names sharp flat
161 nederlands.ly c d e f g a bes b -is -es
162 english.ly c d e f g a bf b -s/-sharp -f/-flat
163 deutsch.ly c d e f g a b h -is -es
164 norsk.ly c d e f g a b h -iss/-is -ess/-es
165 svenska.ly c d e f g a b h -iss -ess
166 italiano.ly do re mi fa sol la sib si -d -b
167 catalan.ly do re mi fa sol la sib si -d/-s -b
175 The optional octave specification takes the form of a series of
176 single quote (`@code{'}') characters or a series of comma
177 (`@code{,}') characters. Each @code{'} raises the pitch by one
178 octave; each @code{,} lowers the pitch by an octave.
180 @lilypond[fragment,verbatim,center]
181 c' c'' es' g' as' gisis' ais'
184 @c . {Defining pitch names}
185 @node Defining pitch names
186 @subsection Defining pitch names
188 @cindex defining pitch names
189 @cindex pitch names, defining
191 Note names and chord modifiers can be customised for nationalities. The
192 syntax is as follows.
194 @cindex @code{\pitchnames}
195 @cindex @code{\chordmodifiers}
197 \pitchnames @var{scheme-alist}
198 \chordmodifiers @var{scheme-alist}
201 See @file{ly/nederlands.ly} and @file{ly/chord-modifiers.ly} for
202 specific examples how to do this.
208 @subsection Durations
212 @cindex @code{\duration}
214 The syntax for a verbose duration specification is
216 \duration @var{scmduration}
218 Here, @var{scmduration} is a Scheme object of type @code{Duration}. See
219 @ref{Duration} for more information.
222 In Note, Chord, and Lyrics mode, durations may be designated by numbers
223 and dots: durations are entered as their reciprocal values. For notes
224 longer than a whole you must use identifiers.
228 c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64
230 r1 r2 r4 r8 r16 r32 r64 r64
236 \notes \relative c'' {
238 a1 a2 a4 a8 a16 a32 a64 a64
240 r1 r2 r4 r8 r16 r32 r64 r64
245 \remove "Clef_engraver"
246 \remove "Staff_symbol_engraver"
247 \remove "Time_signature_engraver"
248 \consists "Pitch_squash_engraver"
254 To get a longa note head, you have to use a mensural note heads. This
255 is done accomplished by setting the @code{style} property of the
256 NoteHead grob to @code{mensural}.
258 @lilypond[fragment,singleline,verbatim]
259 \property Voice.NoteHead \set #'style = #'mensural
263 If the duration is omitted then it is set to the previous duration
264 entered. At the start of parsing a quarter note is assumed. The
265 duration can be followed by a dot (`@code{.}') to obtain dotted note
269 @lilypond[fragment,verbatim,center]
275 You can alter the length of duration by appending
276 `@code{*}@var{fraction}'. This will not affect the appearance of the
277 notes or rests produced.
283 A note specification has the form
286 @var{pitch}[!][?][@var{duration}]
289 The alteration refers to what note is heard, not to whether an
290 accidental is printed. This is done depending on the key and context.
291 A reminder accidental
292 @cindex reminder accidental
294 can be forced by adding an exclamation mark @code{!} after the pitch. A
295 cautionary accidental,
296 @cindex cautionary accidental
297 i.e., an accidental within parentheses can be obtained by adding the
298 question mark `@code{?}' after the pitch.
300 @lilypond[fragment,verbatim,center]
301 cis' d' e' cis' c'? d' e' c'!
305 @node Easy Notation note heads
306 @subsection Easy Notation note heads
308 @cindex easy notation
311 A entirely different type of note head is the "easyplay" note head: a
312 note head that includes a note name. It is used in some publications by
313 Hal-Leonard Inc. music publishers.
315 @lilypond[singleline,verbatim]
316 \include "paper23.ly"
318 \notes { c'2 e'4 f' | g'1 }
319 \paper { \translator { \EasyNotation } }
323 Note that @code{EasyNotation} overrides a @code{Score} context. You
324 probably will want to print it with magnification to make it better
325 readable, see @ref{Output scaling}.
331 If you view the result with Xdvi, then staff lines will show through the
332 letters. Printing the postscript file obtained either by using dvips or
333 the @code{-f ps} option of lilypond produces the correct result.
343 A tie connects two adjacent note heads of the same pitch. When used
344 with chords, it connects all of the note heads whose pitches match.
345 Ties are indicated using the tilde symbol `@code{~}'. If you try to tie
346 together chords which have no common pitches then no ties will be
349 @lilypond[fragment,verbatim,center]
350 e' ~ e' <c' e' g'> ~ <c' e' g'>
353 If you dislike the amount of ties created for a chord, you set
354 @code{Voice.sparseTies} to true, resulting in a smaller number of
356 @lilypond[fragment,verbatim,center]
357 \property Voice.sparseTies = ##t
358 <c' e' g'> ~ <c' e' g'>
361 In its meaning a tie is just a way of extending a note duration, similar
362 to the augmentation dot: the following example are two ways of notating
363 exactly the same concept.
365 @lilypond[fragment, singleline]
369 The name of the tie grob is @code{Voice.Tie}.
373 At present, the tie is implemented as a separate thing, temporally
374 located in between the notes. There is also no way to convert
375 between tied notes, dotted notes and plain notes.
377 Tieing only a subset of the note heads of a chord is not supported in a
378 simple way. It can be achieved by moving the tie-engraver into Thread
379 context and turning on an off ties per Thread.
387 @cindex @code{\times}
389 Tuplets are made out of a music expression by multiplying their duration
392 @cindex @code{\times}
394 \times @var{fraction} @var{musicexpr}
397 The duration of @var{musicexpr} will be multiplied by the fraction.
398 In print, the fraction's denominator will be printed over the notes,
399 optionally with a bracket. The most common tuplet is the triplet in
400 which 3 notes have the length of 2, so the notes are 2/3 of
401 their written length:
403 @lilypond[fragment,verbatim,center]
404 g'4 \times 2/3 {c'4 c' c'} d'4 d'4
407 The property @code{tupletSpannerDuration} specifies how long brackets
408 should last. With this, you can make lots of tuplets while typing
409 @code{\times} only once, thus saving typing work.
411 @lilypond[fragment, relative, singleline, verbatim]
412 \property Voice.tupletSpannerDuration = #(make-moment 1 4)
413 \times 2/3 { c''8 c c c c c }
416 The format of the number is determined by the property
417 @code{tupletNumberFormatFunction}. The default prints only the
418 denominator, but if you set it to the Scheme function
419 @code{fraction-tuplet-formatter} will print @var{num}:@var{den} instead.
421 @cindex @code{tupletNumberFormatFunction}
422 @cindex tuplet formatting
424 Tuplet brackets are printed as @code{TupletBracket} grobs
432 Rests are entered like notes, with note name `@code{r}'. The grob is
448 Skips the amount of time specified by @var{duration}. If no other music
449 is played, a gap will be left for the skipped time without any notes
450 printed. The shorthand is only available in Note and Chord mode.
455 @section Staff notation
457 @cindex Staff notation
469 @subsection Key signature
474 Changing the key signature is done with the @code{\key} command.
476 @code{\key} @var{pitch} @var{type}
479 @cindex @code{\minor}
480 @cindex @code{\major}
481 @cindex @code{\minor}
482 @cindex @code{\ionian}
483 @cindex @code{\locrian}
484 @cindex @code{\aeolian}
485 @cindex @code{\mixolydian}
486 @cindex @code{\lydian}
487 @cindex @code{\phrygian}
488 @cindex @code{\dorian}
490 Here, @var{type} should be @code{\major} or @code{\minor} to get
491 @var{pitch}-major or @var{pitch}-minor, respectively. The second
492 argument is optional; the default is major keys. The @var{\context}
493 argument can also be given as an integer, which tells the number of
494 semitones that should be added to the pitch given in the subsequent
495 @code{\key} commands to get the corresponding major key, e.g.,
496 @code{\minor} is defined as 3. The standard mode names @code{\ionian},
497 @code{\locrian}, @code{\aeolian}, @code{\mixolydian}, @code{\lydian},
498 @code{\phrygian}, and @code{\dorian} are also defined.
500 This command sets context property @code{Staff.keySignature}.
502 The printed signature is a @code{KeySignature} grob.
504 @cindex @code{keySignature}
511 \clef @var{clefname} @code{;}
517 \property Staff.clefGlyph = @var{glyph associated with clefname}
518 \property Staff.clefPosition = @var{clef Y-position for clefname}
519 \property Staff.clefOctavation = @var{extra pitch of clefname}
522 Any change in these properties creates a clef (a @code{Clef} grob).
524 Supported clef-names include
527 @item treble, violin, G, G2
551 Supported associated glyphs (for @code{Staff.clefGlyph}) are:
560 @item clefs-vaticana_do
561 Editio Vaticana style do clef
562 @item clefs-vaticana_fa
563 Editio Vaticana style fa clef
564 @item clefs-medicaea_do
565 Editio Medicaea style do clef
566 @item clefs-medicaea_fa
567 Editio Medicaea style fa clef
568 @item clefs-mensural1_c
569 modern style mensural C clef
570 @item clefs-mensural2_c
571 historic style small mensural C clef
572 @item clefs-mensural3_c
573 historic style big mensural C clef
574 @item clefs-mensural1_f
575 historic style traditional mensural F clef
576 @item clefs-mensural2_f
577 historic style new mensural F clef
578 @item clefs-mensural_g
579 historic style mensural G clef
580 @item clefs-hufnagel_do
581 historic style hufnagel do clef
582 @item clefs-hufnagel_fa
583 historic style hufnagel fa clef
584 @item clefs-hufnagel_do_fa
585 historic style hufnagel combined do/fa clef
586 @item clefs-percussion
587 modern style percussion clef
590 @emph{Modern style} means ``as is typeset in current editions.''
591 @emph{Historic style} means ``as was typeset or written in contemporary
592 historic editions''. @emph{Editio XXX style} means ``as is/was printed in
595 @cindex Vaticana, Editio
596 @cindex Medicaea, Editio
597 @cindex hufnagel clefs
600 @c . {Time signature}
602 @subsection Time signature
603 @cindex Time signature
607 The time signature is changed by the @code{\time} command. Syntax:
609 \time @var{numerator}@code{/}@var{denominator}
611 Internally, this is a shortcut for doing
613 \property Score.timeSignatureFraction = #'(@var{numerator} . @var{denominator})
616 The property @code{timeSignatureFraction} is used to determine where bar
617 lines should be inserted, and how automatic beams should be generated.
619 The grob is @code{TimeSignature}. There are many options for the layout
620 of this grob. They are selected through the @code{style} grob
621 property. See @file{input/test/time.ly} for examples.
628 @cindex partial measure
629 @cindex measure, partial
630 @cindex shorten measures
631 @cindex @code{\partial}
633 Partial measures are entered using the @code{\partial} command:
635 \partial @var{duration}
638 Internally, this is a shortcut for
641 \property Score.measurePosition = -@var{length of duration}
645 The property @code{measurePosition} contains a rational number
646 indicating how much of the measure has passed at this point.
649 @node Unmetered music
650 @subsection Unmetered music
652 Bar lines and bar numbers are calculated automatically. For unmetered
653 music (e.g. cadenzas), this is not desirable. The property
654 @code{Score.timing} can be used to switch off this automatic timing
656 @lilypond[fragment,relative,singleline,verbatim]
658 \property Score.timing = ##f
660 \property Score.timing = ##t
664 The identifiers @code{\cadenzaOn} and @code{\cadenzaOff} can be used to
665 achieve the same effect.
671 @subsection Bar lines
675 @cindex measure lines
682 This is a shortcut for doing
684 \property Score.whichBar = @var{bartype}
687 You are encouraged to use @code{\repeat} for repetitions. See
691 @cindex Bar_line_engraver
693 @cindex repeatCommands
694 @cindex defaultBarType
696 Whenever @code{whichBar} is set to a string, a bar line of that type is
697 created. @code{whichBar} is usually set automatically: at the start of
698 a measure it is set to @code{defaultBarType}. The contents of
699 @code{repeatCommands} is used to override default measure bars.
701 @code{whichBar} can also be set directly, using @code{\property} or
702 @code{\bar }. These settings take precedence over automatic @code{whichBar}
705 @code{Bar_engraver} creates @code{BarLine} grobs.
712 Polyphonic parts, i.e. parts with more than one voice on a staff can be
713 typeset with LilyPond. To use this, instantiate a separate Voice
714 context for each part, and assign a stem direction to each part.
715 @lilypond[fragment,verbatim]
717 < \context Voice = VA { \stemUp b'4 a' g' f' e' }
718 \context Voice = VB { \stemDown g'4 g' g' g' g' } >
721 When there are more than two voices on a staff, you must also indicate
722 which voice should moved horizontally in case of a collision. This can
723 be done with the identifiers @code{\shiftOff}, @code{\shiftOn},
724 @code{\shiftOnn}, etc. (which sets grob property @code{horizontal-shift}
725 in @code{NoteColumn}).
727 @lilypond[fragment, verbatim]
728 \context Staff \notes\relative c''<
735 \context Voice=three {
736 \shiftOnn \stemUp ais
738 \context Voice=four {
739 \shiftOnnn \stemUp fis
744 The most convenient way is to use the identifiers @code{\voiceOne}
745 through @code{\voiceFour}, which also set slur and tie directions in the
748 @lilypond[singleline, verbatim]
750 \context Staff < \context Voice = VA { \voiceOne cis2 b }
751 \context Voice = VB { \voiceThree b4 ais ~ ais4 gis4 }
752 \context Voice = VC { \voiceTwo fis4~ fis4 f ~ f } >
755 Normally, note heads with a different number of dots are not merged, but
756 if you set the grob property @code{merge-differently-dotted}, they are:
758 @lilypond[verbatim,fragment,singleline]
760 \context Voice = VA { \voiceOne
762 \property Staff.NoteCollision \override #'merge-differently-dotted = ##t
765 \context Voice = VB { \voiceTwo [g'8. f16] [g'8. f'16] }
769 LilyPond also vertically shifts rests that are opposite of a stem.
771 @lilypond[singleline,verbatim]
773 \context Voice { \stemUp c''4 }
774 \context Voice =VB { r4 }
778 Note head collisions (horizontal shifting of note heads) are handled by
779 the @code{NoteCollision} grob. @code{RestCollision} handles vertical
782 @cindex @code{NoteCollision}
783 @cindex @code{RestCollision}
788 Resolving collisions is a very intricate subject, and LilyPond only
789 handles a few situations. When it can not cope, you are advised to use
790 @code{force-hshift} of the NoteColumn grob and @code{staff-position} of
791 the Rest grob to override typesetting decisions.
796 Beams are used to group short notes into chunks that are aligned with
797 the metrum. LilyPond guesses where beams should be inserted. If you're
798 not satisfied with the automatic beaming, you can specify which patterns
799 to beam automatically. In specific cases, you can also explicitly enter
803 @c . {Automatic beams}
804 @subsection Automatic beams
806 @cindex @code{Voice.autoBeamSettings}
807 @cindex @code{(end * * * *)}
808 @cindex @code{(begin * * * *)}
811 In normal time signatures, automatic beams can start on any note but can
812 only end in a few positions within the measure: beams can end on a beat,
813 or at durations specified by the properties in
814 @code{Voice.autoBeamSettings}. The defaults for @code{autoBeamSettings}
815 are defined in @file{scm/auto-beam.scm}.
817 Changing the value of @code{autoBeamSettings} is done using
818 @code{\override} and unset using @code{\revert}:
820 \property Voice.autoBeamSettings \override #'(@var{BE} @var{N} @var{M} @var{P} @var{Q}) = @var{dur}
821 \property Voice.autoBeamSettings \revert #'(@var{BE} @var{N} @var{M} @var{P} @var{Q})
823 Here, @var{BE} is the symbol @code{begin} or @code{end}. It determines
824 whether the rule applies to begin or end-points. The quantity
825 @var{N}/@var{M} refers to a time signature (wildcards, `@code{* *}' may
826 be entered to designate all time signatures), @var{P}/@var{Q} refers to
827 the length of the beamed notes (and `@code{* *}' designates notes of any
830 For example, if you want automatic beams to end on every quarter note,
831 you can use the following:
833 \property Voice.autoBeamSettings \override
834 #'(end * * * *) = #(make-moment 1 4)
836 The duration a quarter note is 1/4 of a whole note. It is entered as
837 @code{(make-moment 1 4)}.
839 The same syntax can be used to specify beam starting points. In this
840 example, automatic beams can only end on a dotted quarter note.
842 \property Voice.autoBeamSettings \override
843 #'(begin * * * *) = #(make-moment 3 8)
845 In 4/4 time signature, this means that automatic beams could end only on
846 3/8 and on the fourth beat of the measure (after 3/4, that is 2 times
847 3/8 has passed within the measure).
849 You can also restrict rules to specific time signatures. A rule that
850 should only be applied in @var{N}/@var{M} time signature is formed by
851 replacing the first asterisks by @var{N} and @var{M}. For example, a
852 rule for 6/8 time exclusively looks like
854 \property Voice.autoBeamSettings \override
855 #'(begin 6 8 * *) = ...
858 If you want a rule to apply to certain types of beams, you can use the
859 second pair of asterisks. Beams are classified according to the shortest
860 note they contain. For a beam ending rule that only applies to beams
861 with 32nd notes (and no shorter notes), you would use @code{(end * * 1
865 @c Automatic beams can not be put on the last note in a score.
867 If a score ends while an automatic beam has not been ended and is still
868 accepting notes, this last beam will not be typeset at all.
870 @cindex automatic beam generation
872 @cindex @code{Voice.noAutoBeaming}
874 Automatic beaming is on by default, but it can switched off by setting
875 @code{Voice.noAutoBeaming} to true. You you may find this necessary for
876 a melody that goes with lyrics.
880 It is not possible to specify beaming parameters for beams with mixed
881 durations, that differ from the beaming parameters of all separate
882 durations, ie, you'll have to specify manual beams to get:
883 @lilypond[fragment,singleline,relative]
884 \property Voice.autoBeamSettings
885 \override #'(end * * * *) = #(make-moment 3 8)
886 \time 12/8 c'8 c c c16 c c c c c [c c c c] c8 c c4
889 It is not possible to specify beaming parameters that act differently in
890 different parts of a measure. This means that it is not possible to use
891 automatic beaming in irregular meters such as @code{5/8}.
894 @cindex Automatic beams
895 @subsection Manual beams
896 @cindex beams, manual
900 In some cases it may be necessary to override LilyPond's automatic
901 beaming algorithm. For example, the auto beamer will not beam over
902 rests or bar lines, If you want that, specify the begin and end point
903 manually using @code{[} and @code{]}:
905 @lilypond[fragment,relative,verbatim]
907 r4 [r8 g'' a r8] r8 [g | a] r8
910 Whenever an manual beam is busy, the automatic beamer will not produce
913 @cindex @code{stemLeftBeamCount}
915 Normally, beaming patterns within a beam are determined automatically.
916 When this mechanism fouls up, the properties
917 @code{Voice.stemLeftBeamCount} and @code{Voice.stemRightBeamCount}. can
918 be used to control the beam subdivision on a stem. If you set either
919 property, it's value will be used only once, and then it is erased.
921 @lilypond[fragment,relative,verbatim]
924 [f8 r16 \property Voice.stemLeftBeamCount = #1 f g a]
927 @cindex @code{stemRightBeamCount}
929 The beam symbol (grob @code{Voice.Beam}, both for automatic and manual
930 beams) can be tweaked through grob-properties @code{height} and
931 @code{staff-position}. These specify vertical location and vertical
932 span. Both are measured half staff-spaces.
935 Set @code{height} to zero, to get horizontal beams:
937 @lilypond[fragment,relative,verbatim]
938 \property Voice.Beam \set #'direction = #1
939 \property Voice.Beam \set #'height = #0
943 Here's how you'd specify a weird looking beam that instead of being
944 horizontal, falls two staff spaces:
946 @lilypond[fragment,relative,verbatim]
947 \property Voice.Beam \set #'staff-position = #4
948 \property Voice.Beam \set #'height = #-4
951 @cindex @code{default-neutral-direction}
953 @node Expressive marks
954 @section Expressive marks
969 A slur indicates that notes are to be played bound or @emph{legato}.
970 They are entered using parentheses:
972 @lilypond[fragment,verbatim,center]
973 f'()g'()a' [a'8 b'(] a'4 g'2 )f'4
977 Slurs avoid crossing stems, and are generally attached to note heads.
978 However, in some situations with beams, slurs may be attached to stem
979 ends. If you want to override this layout you can do this through
980 @code{Voice.Slur}'s grob-property @code{attachment}. It's value is a
981 pair of symbols, specifying the attachment type of the left and right end points.
983 @lilypond[fragment,relative,verbatim]
984 \property Voice.Slur \set #'direction = #1
985 \property Voice.Stem \set #'length = #5.5
987 \property Voice.Slur \set #'attachment = #'(stem . stem)
991 If a slur would strike through a stem or beam, the slur will be moved
992 away upward or downward. If this happens, attaching the slur to the
993 stems might look better:
995 @lilypond[fragment,relative,verbatim]
996 \property Voice.Stem \set #'direction = #1
997 \property Voice.Slur \set #'direction = #1
999 \property Voice.Slur \set #'attachment = #'(stem . stem)
1004 Similarly, the curvature of a slur is adjusted to stay clear of note
1005 heads and stems. When that would increase the curvature too much, the
1006 slur is reverted to its default shape. The threshold for this decision
1007 is in @code{Voice.Slur}'s grob-property @code{beautiful}. It is loosely
1008 related to the enclosed area between the slur and the notes. Usually,
1009 the default setting works well, but in some cases you may prefer a
1010 curved slur when LilyPond decides for a vertically moved one. You can
1011 indicate this preference by increasing the @code{beautiful} value:
1013 @lilypond[verbatim,singleline,relative]
1014 \property Voice.Beam \override #'direction = #-1
1015 \property Voice.Slur \override #'direction = #1
1016 c'16( a' f' a a f a, )c,
1017 c( a' f' a a f d, )c
1018 \property Voice.Slur \override #'beautiful = #5.0
1019 c( a' f' a a f d, )c
1024 @code{beautiful} is an arbitrary parameter in the slur formatter.
1025 Useful values can only be determined by trial and error.
1027 @cindex Adusting slurs
1030 @subsection Phrasing slur
1032 @cindex phrasing slur
1033 @cindex phrasing mark
1035 A phrasing slur (or phrasing mark) connects chords and is used to
1036 indicate a musical sentence. It is started using @code{\(} and @code{\)}
1039 @lilypond[fragment,verbatim,center,relative]
1040 \time 6/4 c''\((d)e f(e)\)d
1043 Typographically, the phrasing slur behaves almost exactly like a normal
1044 slur. The grob associated with it is @code{Voice.PhrasingSlur}.
1047 @subsection Breath marks
1049 Breath marks are entered using @code{\breathe}. The result is
1050 @code{Voice.BreathingSign} grob.
1052 @lilypond[fragment,relative]
1061 Currently, only tick marks are supported, comma style breath marks are
1069 @cindex beats per minute
1070 @cindex metronome marking
1072 Metronome settings can be entered as follows:
1074 @cindex @code{\tempo}
1076 \tempo @var{duration} = @var{perminute}
1079 For example, @code{\tempo 4 = 76;} requests output with 76 quarter notes
1084 The tempo setting is not printed, but is only used in the MIDI
1085 output. You can trick lily into producing a metronome mark,
1086 though. Details are in @ref{Text markup}.
1091 @subsection Text spanner
1092 @cindex Text spanner
1094 Some textual indications, e.g. rallentando, accelerando, often extend
1095 over a many measures. This is indicated by following the text with a
1096 dotted line. You can create such texts using text spanners. The syntax
1099 \spanrequest \start "text"
1100 \spanrequest \stop "text"
1102 LilyPond will respond by creating a @code{Voice.TextSpanner} grob. The
1103 string to be printed, as well as the style is set through grob
1106 An application---or rather, a hack---is to fake octavation indications.
1107 @lilypond[fragment,relative,verbatim]
1108 \relative c' { a''' b c a
1109 \property Voice.TextSpanner \set #'type = #'dotted-line
1110 \property Voice.TextSpanner \set #'edge-height = #'(0 . 1.5)
1111 \property Voice.TextSpanner \set #'edge-text = #'("8va " . "")
1112 \property Staff.centralCPosition = #-13
1113 a\spanrequest \start "text" b c a \spanrequest \stop "text" }
1131 @subsection Articulation
1132 @cindex Articulation
1134 @cindex articulations
1138 A variety of symbols can appear above and below notes to indicate
1139 different characteristics of the performance. These symbols can be
1140 added to a note with `@var{note}@code{-\}@var{name}'. Numerous symbols
1141 are defined in @file{script.ly}. Symbols can be forced to appear above
1142 or below the note by writing `@var{note}@code{^\}@var{name}' and
1143 `@var{note}@code{_\}@var{name}' respectively. Here is a chart showing
1144 symbols on notes, with the name of the corresponding symbol appearing
1150 \property Score.LyricSyllable \override #'font-family =#'typewriter
1151 \property Score.LyricSyllable \override #'font-shape = #'upright
1152 \context Staff \notes {
1153 c''-\accent c''-\marcato c''-\staccatissimo c''-\fermata
1154 c''-\stopped c''-\staccato c''-\tenuto c''-\upbow
1155 c''-\downbow c''^\lheel c''-\rheel c''^\ltoe
1156 c''-\rtoe c''-\turn c''-\open c''-\flageolet
1157 c''-\reverseturn c''-\trill c''-\prall c''-\mordent
1158 c''-\prallprall c''-\prallmordent c''-\upprall c''-\downprall
1159 c''-\thumb c''-\segno c''-\coda
1161 \context Lyrics \lyrics {
1162 accent__ marcato__ staccatissimo__ fermata
1163 stopped__ staccato__ tenuto__ upbow
1164 downbow__ lheel__ rheel__ ltoe
1165 rtoe__ turn__ open__ flageolet
1166 reverseturn__ trill__ prall__ mordent
1167 prallprall__ prallmordent__ uprall__ downprall
1168 thumb__ segno__ coda
1172 linewidth = 5.875\in
1178 To save typing work, some shorthands are available:
1179 @lilypond[singleline]
1181 \notes \context Voice {
1182 \property Voice.TextScript \set #'font-family = #'typewriter
1183 \property Voice.TextScript \set #'font-shape = #'upright
1189 c''4-^_"c-\\^{ }" s4
1196 Fingering instructions can also be entered in this shorthand.
1197 @lilypond[verbatim, singleline, fragment]
1198 c'4-1 c'4-2 c'4-3 c'4-4
1202 @cindex @code{\script}
1207 You can add scripts by editing @file{scm/script.scm}. This file contains
1208 a table, listing script definitions and aliases. The following syntax
1209 accesses a script definition from the table:
1215 Usually the @code{\script} keyword is not used directly. Various
1216 helpful identifier definitions appear in @file{script.ly}.
1218 Grobs for these objects are @code{Script} and @code{Fingering}.
1222 All of these note ornaments appear in the printed output but have no
1223 effect on the MIDI rendering of the music.
1225 Unfortunately, there is no support adding fingering instructions or
1226 ornaments to individual note heads. Some hacks exist, though. See
1227 @file{input/test/script-horizontal.ly}.
1232 @subsection Text scripts
1233 @cindex Text scripts
1235 In addition, it is possible to place arbitrary strings of text or markup
1236 text (see @ref{Text markup}) above or below notes by using a string:
1237 @code{c^"text"}. The text is typeset in italic by default.
1239 @c FIXME italic, are we sure?
1241 The amount of space taken by these indications by default does not
1242 influence, spacing, but setting @code{Voice.textNonEmpty} to true will
1243 take the widths into account. The identifier @code{\fatText} is defined
1244 in the standard includes.
1245 @lilypond[fragment,singleline,verbatim]
1246 \relative c' { c4^"longtext" \fatText c4_"longlongtext" c4 }
1249 Text scripts are created in form of @code{Voice.TextScript} grobs.
1251 For purposes of defining identifiers, a more verbose form also exists:
1254 \textscript @var{text}
1257 Defines a text to be printed over or under a note. @var{text} is a
1258 string or a markup text.
1262 foo = \textscript #'(finger "6")
1269 This is equivalent to @code{c4-6}.
1274 @subsection Grace notes
1283 @cindex @code{\grace}
1286 @cindex @code{graceAlignPosition}
1288 Grace notes are ornaments that are written out, but do not take up any
1289 logical time in a measure. LilyPond has limited support for grace notes.
1290 The syntax is as follows.
1292 \grace @var{musicexpr}
1295 When grace music is interpreted, a score-within-a-score is set up:
1296 @var{musicexpr} has its own time bookkeeping, and you could (for
1297 example) have a separate time signature within grace notes. While in
1298 this score-within-a-score, you can create notes, beams, slurs, etc.
1299 Unbeamed eighth notes and shorter by default have a slash through the
1302 @lilypond[fragment,verbatim]
1304 \grace c8 c4 \grace { [c16 c16] } c4
1305 \grace { \property Grace.Stem \override #'flag-style = #'() c16 } c4
1310 A grace note expression has duration 0; the next real note is assumed to
1311 be the main note. If you want the note to appear after the main note,
1312 set @code{Voice.graceAlignPosition} to @code{1}.
1317 At present, nesting @code{\grace} notes is not supported. The following
1318 may cause run-time errors:
1320 @code{\grace @{ \grace c32 c16 @} c4}
1322 Since the meaning of such a construct is unclear, we don't consider this
1323 a loss. Similarly, juxtaposing two @code{\grace} sections is
1324 syntactically valid, but makes no sense and may cause runtime errors.
1325 Ending a staff or score with grace notes may also generate a run-time
1326 error, since there will be no main note to attach the grace notes to.
1329 The present implementation of grace notes is not robust and generally
1330 kludgy. We expect it to change after LilyPond 1.4. Syntax changes might
1331 also be implemented.
1344 @subsection Glissando
1347 @cindex @code{\glissando}
1349 A glissando line (grob @code{Voice.Glissando}) can be requested by attaching a
1350 @code{\glissando} to a note:
1352 @lilypond[fragment,relative,verbatim]
1358 Printing of an additional text (such as @emph{gliss.}) must be done
1365 @subsection Dynamics
1378 @cindex @code{\ffff}
1388 Absolute dynamic marks are specified by using an identifier after a
1389 note: @code{c4-\ff}. The available dynamic marks are: @code{\ppp},
1390 @code{\pp}, @code{\p}, @code{\mp}, @code{\mf}, @code{\f}, @code{\ff},
1391 @code{\fff}, @code{\fff}, @code{\fp}, @code{\sf}, @code{\sff},
1392 @code{\sp}, @code{\spp}, @code{\sfz}, and @code{\rfz}.
1394 @lilypond[verbatim,singleline,fragment,relative]
1395 c''\ppp c\pp c \p c\mp c\mf c\f c\ff c\fff
1401 @cindex @code{\decr}
1402 @cindex @code{\rced}
1408 A crescendo mark is started with @code{\cr} and terminated with
1409 @code{\rc} (the textual reverse of @code{cr}). A decrescendo mark is
1410 started with @code{\decr} and terminated with @code{\rced}. There are
1411 also shorthands for these marks. A crescendo can be started with
1412 @code{\<} and a decrescendo can be started with @code{\>}. Either one
1413 can be terminated with @code{\!}. Note that @code{\!} must go before
1414 the last note of the dynamic mark whereas @code{\rc} and @code{\rced} go
1415 after the last note. Because these marks are bound to notes, if you
1416 want to get several marks during one note, you must use spacer notes.
1418 @lilypond[fragment,verbatim,center]
1419 c'' \< \! c'' d'' \decr e'' \rced
1420 < f''1 { s4 s4 \< \! s4 \> \! s4 } >
1423 You can also use a text saying @emph{cresc.} instead of hairpins. Here
1424 is an example how to do it:
1429 @lilypond[fragment,relative,verbatim]
1431 \property Voice.crescendoText = "cresc."
1432 \property Voice.crescendoSpanner = #'dashed-line
1437 For everyday use, we recommend the identifiers @code{\cresc},
1438 @code{endcresc}, @code{\dim} and @code{\enddim}.
1442 Dynamics are grobs of @code{Voice.DynamicText} and
1443 @code{Voice.Hairpin}. They are put together on
1444 @code{Voice.DynamicLineSpanner} to align them vertically.
1453 @cindex @code{\repeat}
1455 To specify repeats, use the @code{\repeat} keyword. Since repeats
1456 should work differently when played or printed, there are a few
1457 different variants of repeats.
1461 Repeated music is fully written (played) out. Useful for MIDI
1462 output, and entering repetitive music.
1465 This is the normal notation: Repeats are not written out, but
1466 alternative endings (voltas) are printed, left to right.
1469 Alternative endings are written stacked. This has no practical use
1476 Make measure repeats. These look like percent signs.
1482 * Manual repeat commands::
1484 * Tremolo subdivision::
1489 @subsection Repeat syntax
1491 The syntax for repeats is
1494 \repeat @var{variant} @var{repeatcount} @var{repeatbody}
1497 If you have alternative endings, you may add
1498 @cindex @code{\alternative}
1500 \alternative @code{@{} @var{alternative1}
1502 @var{alternative3} @dots{} @code{@}}
1504 where each @var{alternative} is a music expression.
1506 Normal notation repeats are used like this:
1507 @lilypond[fragment,verbatim]
1509 \repeat volta 2 { c'4 d' e' f' }
1510 \repeat volta 2 { f' e' d' c' }
1513 With alternative endings:
1514 @lilypond[fragment,verbatim]
1516 \repeat volta 2 {c'4 d' e' f'}
1517 \alternative { {d'2 d'} {f' f} }
1520 Folded repeats look like this:
1523 @lilypond[fragment,verbatim]
1525 \repeat fold 2 {c'4 d' e' f'}
1526 \alternative { {d'2 d'} {f' f} }
1530 If you don't give enough alternatives for all of the repeats, then
1531 the first alternative is assumed to be repeated often enough to equal
1532 the specified number of repeats.
1534 @lilypond[fragment,verbatim]
1538 \repeat volta 4 { e | c2 d2 | e2 f2 | }
1539 \alternative { { g4 g g } { a | a a a a | b2. } }
1546 Notice that timing information is not rembered at the start of an
1547 alternative, so you have to reset timing information after a repeat,
1548 e.g. using a bar-check (See @ref{Bar check}), setting
1549 @code{Score.measurePosition} or entering @code{\partial}. Slurs or ties
1550 are also not repeated.
1552 It is possible to nest @code{\repeat}, although it probably is only
1553 meaningful for unfolded repeats.
1555 Folded repeats offer little more over simultaneous music. However, it
1556 is to be expected that more functionality -- especially for the MIDI
1557 backend -- will be implemented at some point in the future.
1559 @node Manual repeat commands
1560 @subsection Manual repeat commands
1562 @cindex @code{repeatCommands}
1564 The property @code{repeatCommands} can be used to control the layout of
1565 repeats. Its value is a Scheme list of repeat commands, where each repeat
1573 @item (volta . @var{text})
1574 Print a volta bracket saying @var{text}.
1576 Stop a running volta bracket
1579 @lilypond[verbatim, fragment]
1581 \property Score.repeatCommands = #'((volta "93") end-repeat)
1583 \property Score.repeatCommands = #'((volta #f))
1588 Repeats brackets are @code{Staff.VoltaBracket} grobs.
1590 @node Tremolo repeats
1591 @subsection Tremolo repeats
1592 @cindex tremolo beams
1594 To place tremolo marks between notes, use @code{\repeat} with tremolo
1596 @lilypond[verbatim,center,singleline]
1598 \context Voice \notes\relative c' {
1599 \repeat "tremolo" 8 { c16 d16 }
1600 \repeat "tremolo" 4 { c16 d16 }
1601 \repeat "tremolo" 2 { c16 d16 }
1602 \repeat "tremolo" 4 c16
1607 Tremolo beams are @code{Voice.Beam} grobs. Single stem tremolos are
1608 @code{Voice.StemTremolo}.
1613 At present, the spacing between tremolo beams is not regular, since the
1614 spacing engine does not notice that not all notes are printed.
1616 @node Tremolo subdivision
1617 @subsection Tremolo subdivision
1618 @cindex tremolo marks
1619 @cindex @code{tremoloFlags}
1621 Tremolo marks can be printed on a single note by adding
1622 `@code{:}[@var{length}]' after the note. The length must be at least 8.
1623 A @var{length} value of 8 gives one line across the note stem. If the
1624 length is omitted, then then the last value (stored in
1625 @code{Voice.tremoloFlags}) is used.
1627 @lilypond[verbatim,fragment,center]
1630 Using this mechanism pays off when you entering many tremolos, since the
1631 default argument saves a lot of typing.
1636 Tremolos in this style do not carry over into the MIDI output.
1639 @node Measure repeats
1640 @subsection Measure repeats
1642 @cindex percent repeats
1643 @cindex measure repeats
1645 In the @code{percent} style, a note pattern can be repeated. It is
1646 printed once, and then the pattern is replaced with a special sign.
1647 Patterns of a one and two measures are replaced by percent signs,
1648 patterns that divide the measure length are replaced by slashes.
1650 @lilypond[verbatim,singleline]
1651 \context Voice { \repeat "percent" 4 { c'4 }
1652 \repeat "percent" 2 { c'2 es'2 f'4 fis'4 g'4 c''4 }
1656 The signs are represented by these grobs: @code{Voice.RepeatSlash} and
1657 @code{Voice.PercentRepeat} and @code{Voice.DoublePercentRepeat}.
1661 You can not nest percent repeats, e.g. by filling in the first measure
1662 with slashes, and repeating that measure with percents.
1664 @node Rhythmic music
1665 @section Rhythmic music
1672 @node Rhythmic staffs
1673 @subsection Rhythmic staffs
1675 Some times you might want to show only the rhythm of a melody. This can
1676 be done with the rhythmic staff. All pitches of notes on such a staff
1677 are squashed, and the staff itself looks has a single staff line:
1679 @lilypond[fragment,relative,verbatim]
1680 \context RhythmicStaff {
1682 c4 e8 f g2 | r4 g r2 | g1:32 | r1 |
1689 @section Piano music
1691 Piano music is an odd type of notation. Piano staffs are two normal
1692 staffs coupled with a brace. The staffs are largely independent, but
1693 sometimes voices can cross between the two staffs. The
1694 @code{PianoStaff} is especially built to handle this cross-staffing
1695 behavior. In this section we discuss the @code{PianoStaff} and some
1696 other pianistic peculiarities.
1699 * Automatic staff changes::
1700 * Manual staff switches::
1703 * Voice follower line::
1707 @c . {Automatic staff changes}
1708 @node Automatic staff changes
1709 @subsection Automatic staff changes
1710 @cindex Automatic staff changes
1712 Voices can be switched from top to bottom staff automatically. The
1715 \autochange @var{contexttype} @var{musicexp}
1717 This will switch the interpretation context of @var{musicexp} between a
1718 @var{contexttype} named @code{up} and @code{down}. Typically, you use
1719 @code{Staff} for @var{contexttype}. The autochanger switches on basis
1720 of pitch (central C is the turning point), and it looks ahead skipping
1721 over rests to switch rests in advance.
1723 @lilypond[verbatim,singleline]
1724 \score { \notes \context PianoStaff <
1725 \context Staff = "up" {
1726 \autochange Staff \context Voice = VA < \relative c' {
1727 g4 a b c d r4 a g } > }
1728 \context Staff = "down" {
1734 Note how spacer rests are used to prevent the bottom staff from
1735 terminating too soon.
1738 @node Manual staff switches
1739 @subsection Manual staff switches
1741 @cindex manual staff switches
1742 @cindex staff switch, manual
1744 Voices can be switched between staffs manually, using the following command:
1746 \translator Staff = @var{staffname} @var{music}
1748 The string @var{staffname} is the name of the staff. Typically it is
1749 @code{"up"} or @code{"down"}.
1751 Formally, this construct is a music expression indicating that the
1752 context which is a direct child of the a context of type
1753 @var{contexttype} should be shifted to a context of type
1754 @var{contexttype} and the specified name.
1756 @cindex @code{\translator}
1758 \translator @var{contexttype} = @var{name}
1767 Piano pedal instruction can be expressed using
1768 @code{\sustainDown}, @code{\sustainUp}, @code{\unaCorda},
1769 @code{\treCorde}, @code{\sostenutoDown} and @code{\sostenutoUp}.
1771 These identifiers are shorthands for spanner commands of the types
1772 @code{Sustain}, @code{UnaCorda} and @code{Sostenuto}:
1774 @lilypond[fragment,verbatim]
1775 c''4 \spanrequest \start "Sustain" c''4
1776 c''4 \spanrequest \stop "Sustain"
1779 The symbols that are printed can be modified by setting
1780 @code{pedal@var{X}Strings}, where @var{X} is one of the pedal
1781 types. Refer to the generated documentation for more information.
1786 Currently, brackets are not supported, only text markings (i.e. `*Ped'
1792 @subsection Arpeggio
1795 @cindex broken arpeggio
1796 @cindex @code{\arpeggio}
1798 You can specify an arpeggio sign on a chord by attaching an
1799 @code{\arpeggio} to a note of the chord.
1802 @lilypond[fragment,relative,verbatim]
1803 \context Voice <c'\arpeggio e g c>
1806 When an arpeggio crosses staffs in piano music, you attach an arpeggio
1807 to the chords in both staffs, and set
1808 @code{PianoStaff.connectArpeggios}.
1810 @lilypond[fragment,relative,verbatim]
1811 \context PianoStaff <
1812 \property PianoStaff.connectArpeggios = ##t
1813 \context Voice = one { <c''\arpeggio e g c> }
1814 \context Voice = other { \clef bass <c,,\arpeggio e g>}
1818 This command creates @code{Voice.Arpeggio} grobs. Cross staff arpeggios
1819 are @code{PianoStaff.Arpeggio}.
1823 It is not possible to mix connected arpeggios and unconnected arpeggios
1828 @node Voice follower line
1829 @subsection Voice follower line
1831 @cindex follow voice
1832 @cindex staff switching
1835 @cindex @code{followVoice}
1837 Whenever a voice switches to another staff a line connecting the notes
1838 can be printed automatically. This is enabled if the property
1839 @code{PianoStaff.followVoice} is set to true:
1841 @lilypond[fragment,relative,verbatim]
1842 \context PianoStaff <
1843 \property PianoStaff.followVoice = ##t
1844 \context Staff \context Voice {
1846 \translator Staff=two
1849 \context Staff=two {\clef bass \skip 1*2 }
1853 The associated grob is @code{Voice.VoiceFollower}.
1863 * Automatic syllable durations::
1869 @subsection Lyrics mode
1872 To print lyrics, you must first make a music expression from the lyric
1873 text. That music expression can be printed by selecting an appropriate
1877 @cindex @code{\lyrics}
1879 You can enter lyrics in a special input mode of LilyPond. This mode is
1880 called Lyrics mode, and it is introduced by the keyword @code{\lyrics}.
1881 The purpose of this mode is that you can enter lyrics as plain text,
1882 punctuation and accents without any hassle.
1884 Syllables are entered like notes, with pitches replaced by text. For
1885 example, @code{Twin- kle twin- kle} enters four syllables. Note that
1886 the hyphen has no special meaning for lyrics, and does not introduce
1889 Spaces can be introduced into a lyric either by using quotes
1890 (@code{"}) or by using an underscore without quotes: @code{He_could4
1891 not4}. All unquoted underscores are converted to spaces.
1893 The precise definition of this mode is in @ref{Lyrics mode
1896 @c . {Printing lyrics}
1897 @node Printing lyrics
1898 @subsection Printing lyrics
1901 Lyrics are printed by interpreting them in the @code{Lyrics} context.
1903 @lilypond[verbatim,singleline]
1904 \addlyrics \notes \relative c' {
1906 \property Staff.automaticMelismata = ##t
1909 \context Lyrics \lyrics {
1911 share the soft- __ ware; }
1915 Notes and syllable durations are matched automatically. This is
1916 accomplished using @code{\addlyrics}, which is documented in
1917 @ref{Automatic syllable durations}. Setting @code{automaticMelismata} in
1918 the melody staff will cause slurs to be interpreted as melismata.
1920 The Lyric syllables are @code{LyricsVoice.LyricSyllable} grobs.
1923 @cindex lyric extender
1926 As you can see, extender lines are entered as @code{__}. This will
1927 create an extender, a line that extends over the entire duration of the
1928 lyric. This line will run all the way to the start of the next lyric,
1929 so you may want to shorten it by using a blank lyric (using @code{_}).
1930 The grob for this symbol is @code{LyricsVoice.LyricExtender}.
1935 If you want to have hyphens centered between syllables (rather than
1936 attached to the end of the first syllable) you can use the special
1937 `@code{-}@code{-}' lyric as a separate word between syllables. This
1938 will result in a hyphen whose length varies depending on the space
1939 between syllables. It will be centered between the syllables. The grob
1940 for this symbol is @code{LyricsVoice.LyricHyphen}.
1942 @cindex Lyric hyphen
1944 @node Automatic syllable durations
1945 @subsection Automatic syllable durations
1946 @cindex Automatic syllable durations
1948 @cindex automatic lyric durations
1949 @cindex @code{\addlyrics}
1951 If you have lyrics that are set to a melody, you can import the rhythm
1952 of that melody into the lyrics using @code{\addlyrics}. The syntax for
1955 \addlyrics @var{musicexpr1 musicexpr2}
1958 Both @var{musicexpr1} and @var{musicexpr2} are interpreted, but every
1959 music event (``every syllable'') in @var{musicexpr2} is interpreted only
1960 when there are events in @var{musicexpr1}.
1962 @cindex @code{automaticMelismata}
1964 If the property @code{automaticMelismata} is set in the
1965 context of @var{musicexpr1}, no lyrics will be put on slurred or tied
1968 @lilypond[verbatim,fragment]
1971 \property Voice.automaticMelismata = ##t
1972 c8 () cis d8. e16 f2
1974 \context Lyrics \lyrics {
1978 If you want the lyric lines to be above the melody staff, or in some
1979 other, more complex configuration, then build that configuration first
1980 using simultaneous music, and use @code{\addlyrics} after that.
1982 @lilypond[verbatim, singleline]
1984 \context Lyrics = LA { s1 }
1985 \context Staff = SA { s1 }
1987 \context Staff = SA \relative c' { c4 e g g }
1988 \context Lyrics = LA \lyrics { geen ge -- don -- der } >
1991 For @code{\addlyrics} you should use a single rhythm melody, and single
1992 rhythm lyrics (a constant duration is the obvious choice). If you do
1993 not, you can get undesired effects when using multiple stanzas:
1995 @lilypond[verbatim,fragment]
1998 c8 () cis d8. e16 f2
2000 \context Lyrics \lyrics
2005 It is valid (but probably not very useful) to use notes instead of
2006 lyrics for @var{musicexpr2}.
2009 @subsection More stanzas
2013 If you have multiple stanzas printed underneath each other, the vertical
2014 groups of syllables should be aligned around punctuation. LilyPond can
2015 do this if you explain it which lyric lines belong to which melody.
2017 To this end, give the Voice context an identity, and set the LyricsVoice
2018 to a name starting with that identity followed by a dash.
2019 In the following example, the Voice
2020 identity is @code{duet}, and the identities of the LyricsVoices are
2021 @code{duet-1} and @code{duet-2}.
2024 @lilypond[singleline,verbatim]
2027 \notes \relative c'' \context Voice = duet { \time 3/4
2029 \lyrics \context Lyrics <
2030 \context LyricsVoice = "duet-1" {
2031 \property LyricsVoice . stanza = "Bert"
2032 Hi, my name is bert. }
2033 \context LyricsVoice = "duet-2" {
2034 \property LyricsVoice . stanza = "Ernie"
2035 Ooooo, ch\'e -- ri, je t'aime. }
2040 You can add stanza numbers by setting @code{LyricsVoice.Stanza} (for the
2041 first system) and @code{LyricsVoice.stz} for the following
2042 systems. Notice how you must surround dots with spaces in @code{\lyrics}
2048 @cindex stanza numbering
2056 LilyPond has support for both entering and printing chords. Chords are
2057 a harmonic device that is characterized by a set of pitches. They are
2058 internally stored as simultaneous music expressions. This means you can
2059 enter chords by name and print them as note head, enter them as notes
2060 and print them as chord names, or (the most common case) enter them by
2061 name, and print them as name.
2064 @lilypond[verbatim,singleline]
2065 twoWays = \notes \transpose c'' {
2075 < \context ChordNames \twoWays
2076 \context Voice \twoWays > }
2079 Note that this example also shows that the chord printing routines do
2080 not attempt to be intelligent. If you enter @code{f bes d}, it does not
2081 interpret this as an inversion.
2085 * Printing named chords::
2090 @subsection Chords mode
2093 Chord mode is a mode where you can input sets of pitches using common
2094 names. It is introduced by the keyword @code{\chords}. It is similar
2095 to note mode, but words are also looked up in a chord modifier table
2096 (containing @code{maj}, @code{dim}, etc).
2098 Dashes and carets are used to indicate chord additions and subtractions,
2099 so articulation scripts can not be entered in Chord mode.
2101 The syntax for named chords is as follows:
2103 @var{tonic}[@var{duration}][@code{-}@var{modifiers}][@code{^}@var{subtractions}][@code{/}@var{inversion}][@code{/+}@var{bass}].
2106 @var{tonic} should be the tonic note of the chord, and @var{duration} is
2107 the chord duration in the usual notation. There are two kinds of
2108 modifiers. One type is formed by @emph{chord additions}. Additions are
2109 obtained by listing intervals separated by dots. An interval is written
2110 by its number with an optional @code{+} or @code{-} to indicate raising
2111 or lowering by half a step. Chord additions have two effects: they adds
2112 the specified interval and all lower odd numbered intervals to the
2113 chord, and they may lower or raise the specified interval.
2115 Throughout these examples, chords have been shifted around the staff
2116 using @code{\transpose}.
2118 @lilypond[fragment,verbatim]
2122 c:9 c:9-.5+.7+ c:3-.5-
2132 The second type of modifier that may appear after the @code{:} is a
2133 named modifier. Named modifiers are listed in the file
2134 @file{chord-modifiers.ly}. The available modifiers are @code{m} and
2135 @code{min} which lower the 3rd half a step, `@code{aug}' which
2136 raises the 5th, `@code{dim}' which lowers the 5th,
2137 `@code{maj}' which adds a raised 7th, and `@code{sus}'
2138 which replaces the 5th with a 4th.
2140 @lilypond[fragment,verbatim]
2143 c1:m c:min7 c:maj c:aug c:dim c:sus
2149 Chord subtractions are used to eliminate notes from a chord. The
2150 notes to be subtracted are listed after a @code{^} character,
2153 @lilypond[fragment,verbatim,center]
2162 Chord inversions can be specified by appending `@code{/}' and the name
2163 of a single note to a chord. In a chord inversion, the inverted note is
2164 transposed down until it is the lowest note in the chord. If the note
2165 is not in the chord, a warning will be printed.
2167 @lilypond[fragment,verbatim,center]
2177 Bass notes can be added by `@code{/+}' and
2178 the name of a single note to a chord. This has the effect of
2179 adding the specified note to the chord, lowered by an octave,
2180 so it becomes the lowest note in the chord.
2182 @lilypond[fragment,verbatim,center]
2193 Implementation details are quite gory. For example @code{c:4} not only
2194 adds a fourth, but also removes the third.
2197 @c . {Printing named chords}
2198 @node Printing named chords
2199 @subsection Printing named chords
2201 @cindex printing chord names
2204 @cindex @code{ChordNames}
2207 For displaying printed chord names, use the @code{ChordNames} context.
2208 The chords may be entered either using the notation described above, or
2209 directly using simultaneous music.
2211 @lilypond[verbatim,singleline]
2213 \chords {a1 b c} <d f g> <e g b>
2217 \context ChordNames \scheme
2218 \context Staff \transpose c'' \scheme
2223 You can make the chord changes stand out by setting
2224 @code{ChordNames.chordChanges} to true. This will only display chord
2225 names when there's a change in the chords scheme and at the start of the
2230 c1:m c:m \break c:m c:m d
2234 \context ChordNames {
2235 \property ChordNames.chordChanges = ##t
2237 \context Staff \transpose c'' \scheme
2241 LilyPond examines chords specified as lists of notes to determine a name
2242 to give the chord. LilyPond will not try to identify chord inversions or
2243 an added bass note, which may result in strange chord names when chords
2244 are entered as a list of pitches:
2246 @lilypond[verbatim,center,singleline]
2255 \context ChordNames \scheme
2256 \context Staff \scheme
2262 By default, a chord name system proposed by Harald Banter (See
2263 @ref{Literature}) is used. The system is very regular and predictable.
2264 Typical American style chord names may be selected by setting the
2265 @code{style} property of the @code{ChordNames.ChordName} grob to
2266 @code{'american}. Similarly @code{'jazz} selects Jazz chordnames.
2268 Routines that determine the names to be printed are written in Scheme,
2269 and may be customized by the user. The code can be found in
2270 @file{scm/chord-name.scm}. Here's an example showing the differences in
2274 @c maybe just junk verbatim option?
2275 @lilypond[verbatim,singleline]
2285 \context ChordNames = banter \scheme
2286 \context ChordNames = american {
2287 \property ChordNames.ChordName \override
2288 #'style = #'american \scheme }
2289 \context ChordNames = jazz {
2290 \property ChordNames.ChordName \override
2291 #'style = #'jazz \scheme }
2292 \context Staff \transpose c'' \scheme
2299 @section Writing parts
2301 Orchestral music involves some special notation, both in the full score,
2302 as in the individual parts. This section explains how to tackle common
2303 problems in orchestral music.
2310 * Instrument names::
2312 * Sound output for transposing instruments::
2313 * Multi measure rests::
2314 * Automatic part combining::
2315 * Hara-kiri staffs::
2318 @c . {Rehearsal marks}
2319 @node Rehearsal marks
2320 @subsection Rehearsal marks
2321 @cindex Rehearsal marks
2323 @cindex @code{\mark}
2324 @cindex @code{Mark_engraver}
2327 \mark @var{unsigned}
2332 This command prints a rehearsal mark above the system. You can provide
2333 a number, a string or a markup text as argument. If you use
2334 @code{\default}, the value of property @code{rehearsalMark} is used and
2335 automatically incremented.
2337 @lilypond[fragment,verbatim]
2343 c1 \mark #'(music "scripts-segno")
2348 The grob is @code{Score.RehearsalMark}. See
2349 @code{input/test/boxed-molecule.ly} if you need boxes around the marks.
2352 @subsection Bar numbers
2354 Bar numbers (grob: @code{BarNumber}) are printed at the start of the
2355 line. See @code{input/test/boxed-molecule.ly} for boxed bar numbers.
2359 It is not possible to have bar numbers printed at regular intervals
2362 @node Instrument names
2363 @subsection Instrument names
2365 You can specify an instrument name for a staff by setting
2366 @code{Staff.instrument} and @code{Staff.instr}. This will print a string
2367 before the start of the staff. For the first start, @code{instrument} is
2368 used, for the next ones @code{instr} is used.
2370 @lilypond[verbatim,singleline]
2371 \property Staff.instrument = "ploink " { c''4 }
2374 This requires that you add the @code{Instrument_name_engraver} to the
2375 staff context. You can also use markup texts to construct more
2376 complicated instrument names:
2379 @lilypond[verbatim,singleline]
2381 '((font-relative-size . -2 ) (music "accidentals--1")))
2384 \property Staff.instrument = #`((kern . 0.5) (lines
2385 "2 Clarinetti" (rows " (B" ,text-flat ")")))
2388 \translator { \StaffContext } } }
2394 When you put a name on a grand staff or piano staff the width of the
2395 brace is not taken into account. You must add extra spaces to the end of
2396 the name to avoid a collision.
2399 @subsection Transpose
2401 @cindex transposition of pitches
2402 @cindex @code{\transpose}
2404 A music expression can be transposed with @code{\transpose}. The syntax
2407 \transpose @var{pitch} @var{musicexpr}
2410 This means that middle C in @var{musicexpr} is transposed to
2413 @code{\transpose} distinguishes between enharmonic pitches: both
2414 @code{\transpose cis'} or @code{\transpose des'} will transpose up half
2415 a tone. The first version will print sharps and the second version
2418 @lilypond[fragment,verbatim]
2421 { \key e \major c d e f }
2423 \transpose des'' { \key e \major c d e f }
2424 \transpose cis'' { \key e \major c d e f }
2428 If you want to use both @code{\transpose} and @code{\relative}, then
2429 you must use @code{\transpose} first. @code{\relative} will have no
2430 effect music that appears inside a @code{\transpose}.
2432 @node Sound output for transposing instruments
2433 @subsection Sound output transposing instruments
2435 When you want to play a score containing transposed and untransposed
2436 instruments, you have to instruct LilyPond the pitch offset (in
2437 semitones) for the transposed instruments. This is done using the
2438 @code{transposing} property. It does not affect printed output.
2440 @cindex @code{transposing}
2443 \property Staff.instrument = #"Cl. in B-flat"
2444 \property Staff.transposing = #-2
2448 @c . {Multi measure rests}
2449 @node Multi measure rests
2450 @subsection Multi measure rests
2451 @cindex Multi measure rests
2455 Multi measure rests are entered using `@code{R}'. It is specifically
2456 meant for entering parts: the rest can expand to fill a score with
2457 rests, or it can be printed as a single multimeasure rest This expansion
2458 is controlled by the property @code{Score.skipBars}. If this is set to true,
2459 Lily will not expand empty measures, and the appropriate number is added
2462 @lilypond[fragment,verbatim]
2463 \time 3/4 R2.*2 \property Score.skipBars = ##t R2.*17 R2.*4
2466 Currently, there is no way to condense multiple rests into a single
2469 @cindex condensing rests
2471 @node Automatic part combining
2472 @subsection Automatic part combining
2473 @cindex automatic part combining
2474 @cindex part combiner
2476 Automatic part combining is used to merge two parts of music onto a
2477 staff in an intelligent way. It is aimed primarily at typesetting hymns
2478 and orchestral scores. When the two parts are identical for a period of
2479 time, only one is shown. In places where the two parts differ, stem
2480 directions are set automatically. Also, soli and @emph{a due} parts can be
2481 identified and marke.
2483 The syntax for part combining is
2486 \partcombine @var{context} @var{musicexpr1} @var{musicexpr2}
2489 where the pieces of music @var{musicexpr1} and @var{musicexpr2} will be
2490 combined into one context @var{context}. The context names of the music
2491 expressions must start with the prefixes @code{one} and @code{two}.
2493 The most useful function of the part combiner to combining threads into
2494 one voice, as common for wind parts in orchestral scores:
2496 @lilypond[verbatim,singleline,fragment]
2498 \context Voice=one \partcombine Voice
2499 \context Thread=one \relative c'' {
2502 \context Thread=two \relative c'' {
2508 Notice that the first @code{g} appears only once, although it was
2509 specified twice (once in each Thread). Also note that stem, slur and tie
2510 directions are set automatically, depending whether there is a solo or
2511 unisono. The Thread called @code{one} always gets up stems, and "solo",
2512 while @code{two} always gets down stems and "Solo II".
2514 If you just want the splitting of Threads and setting of directions, and
2515 not the textual markings, you may set the property @var{soloADue} to
2516 false. This mode can be used to set hymns:
2518 @lilypond[verbatim,singleline,fragment]
2520 \property Staff.soloADue = ##f
2521 \context Voice=one \partcombine Voice
2522 \context Thread=one \relative c'' {
2525 \context Thread=two \relative c'' {
2531 There are a number of other properties that you can use to tweak
2532 the behavior of part combining, refer to the automatically generated
2533 documentation. Look for @code{Thread_devnull_engraver}
2534 @code{Voice_devnull_engraver} and @code{A2_engraver}.
2538 In @code{soloADue} mode, when the two voices play the same notes on and
2539 off, the part combiner may typeset @code{a2} more than once in a
2542 @lilypond[fragment,singleline]
2544 \context Voice=one \partcombine Voice
2545 \context Thread=one \relative c'' {
2548 \context Thread=two \relative c'' {
2554 @cindex @code{Thread_devnull_engraver}
2555 @cindex @code{Voice_engraver}
2556 @cindex @code{A2_engraver}
2558 @node Hara-kiri staffs
2559 @subsection Hara-kiri staffs
2561 In orchestral scores, staffs that only have rests are usually removed.
2562 This saves some space. LilyPond also supports this through the
2563 hara-kiri@footnote{Hara kiri, also called Seppuku, is the ritual suicide
2564 of the Japanese Samourai warriors.} staff. This staff commits suicide
2565 when it finds itself to be empty after the line-breaking process---note
2566 that it will not disappear when it contains normal rests, you must use
2567 multi measure rests.
2569 The hara kiri staff is specialized version of the Staff context. It is
2570 available as the context identifier @code{\HaraKiriStaffContext}.
2571 Observe how the second staff in this example disappears in the second
2576 \notes \relative c' <
2577 \context Staff = SA { e4 f g a \break c1 }
2578 \context Staff = SB { c4 d e f \break R1 }
2582 \translator { \HaraKiriStaffContext }
2595 A @emph{custos} (plural: @emph{custodes}; latin word for "guard") is a
2596 staff context symbol that appears at the end of a staff line. It
2597 anticipates the pitch of the first note(s) of the following line and
2598 thus helps the player or singer to manage line breaks during
2599 performance, thus enhancing readability of a score.
2603 \notes { c'1 d' e' d' \break c' d' e' d' }
2607 \consists Custos_engraver
2608 Custos \override #'style = #'mensural
2614 Custodes were frequently used in music notation until the 16th century.
2615 There were different appearences for different notation styles.
2616 Nowadays, they have survived only in special forms of musical notation
2617 such as via the @emph{editio vaticana} dating back to the beginning of
2620 For typesetting custodes, just put a @code{Custos_engraver} into the
2621 @code{StaffContext} when declaring the @code{\paper} block. In this
2622 block, you can also globally control the appearance of the custos symbol
2623 by setting the custos @code{style} property. Currently supported styles
2624 are @code{vaticana}, @code{medicaea}, @code{hufnagel} and
2631 \consists Custos_engraver
2632 Custos \override #'style = #'mensural
2637 The property can also be set locally, for example in a @code{\notes}
2642 \property Staff.Custos \override #'style = #'vaticana
2643 c'1 d' e' d' \break c' d' e' d'
2647 @c . {Tuning output}
2649 @section Tuning output
2651 LilyPond tries to take as much formatting as possible out of your
2652 hands. Nevertheless, there are situations where it needs some help, or
2653 where you want to override its decisions. In this section we discuss
2654 ways to do just that.
2656 Notation output is specified in so called grobs (graphic objects). Each
2657 grob carries with it a set of properties (grob properties) specific to
2658 that object. For example, a stem grob has properties that specify its
2659 direction, length and thickness.
2662 The most common way of tuning the output is to alter the values of these
2663 properties. There are two ways of doing that: first, you can temporarily
2664 change the definition of a certain type of grob, thus affecting a whole
2665 set of objects. Second, you can select one specific object, and set a
2669 * Tuning groups of grobs ::
2670 * Tuning per grob ::
2678 @node Tuning groups of grobs
2679 @subsection Tuning groups of grobs
2681 @cindex grob description
2683 A grob definition is a Scheme association list, that is stored in a context
2684 property. By assigning to that property (using plain @code{\property}),
2685 you can change the resulting grobs.
2687 @lilypond[verbatim, fragment]
2688 c'4 \property Voice.Stem = #'((meta . ((interfaces . ())))) c'4
2691 The @code{\property} assignment effectively empties the definition of
2692 the Stem object. One of the effects is that property specifying how it
2693 should be printed is erased, with the effect of rendering it invisible.
2694 The above assignment is available as a standard identifier, lest you
2698 \property Voice.Stem = \turnOff
2705 This mechanism is fairly crude, since you can only set, but not modify,
2706 the definition of a grob. For this reason, there is a more advanced
2707 mechanism: you can add a property on top of an existing definition, or
2708 remove a property: @code{\override} adds a settings, @code{\revert}
2709 removes that setting.
2712 c'4 \property Voice.Stem \override #'thickness = #4.0
2713 c'4 \property Voice.Stem \revert #'thickness
2717 For the digirati, the grob description is an Scheme association
2718 list. Since it is singly linked, we can treat it as a stack, and
2719 @code{\override} and @code{\revert} are just push and pop
2720 operations. This pushing and popping is also used for overriding automatic
2723 If you revert a setting which was not set in the first place, then it
2724 has no effect. However, if the setting was set as a system default, it
2725 may remove the default value, and this may give surprising results,
2726 including crashes. In other words, if you use @code{\override} and
2727 @code{\revert}, be sure to balance the overrides and reverts.
2729 If balancing them is too much work, use the @code{\set} shorthand. It
2730 performs a revert followed by an override:
2732 \property Voice.Stem \set #'thickness = #2.0
2735 Formally the syntax for these constructions is
2737 \property @var{context}.@var{grobname} \override @var{symbol} = @var{value}
2738 \property @var{context}.@var{grobname} \set @var{symbol} = @var{value}
2739 \property @var{context}.@var{grobname} \revert @var{symbol}
2741 Here @var{symbol} is a Scheme expression of symbol type, @var{context}
2742 and @var{grobname} are strings and @var{value} is a Scheme expression.
2745 Correct nesting of @code{\override}, @code{\set}, @code{\revert} is as
2749 \override \set \set \set \set
2753 This is always correct, but if you know the default value, you can also use
2756 \set @var{to default value}
2759 If there is no default (i.e. by default, the grob property is unset),
2762 \set \set \set \set \set
2769 LilyPond will hang or crash if @var{value} contains cyclic references.
2770 The backend is not very strict in type-checking grob properties. If you
2771 @code{\revert} properties that are expected to be set by default,
2774 Some grobs are created at the moment that their context is created. An
2775 example of such a grob is the staff itself (i.e. the horizontal lines).
2776 You can not change the appearance of the staff symbol by manipulating
2777 @code{\property Staff.StaffSymbol}. At the moment that @code{\property
2778 Staff} is interpreted, a Staff context is made, and the StaffSymbol is
2779 created before any @code{\override} is effective. You can deal with this
2780 either overriding properties in a @code{\translator} definition, or by
2781 using @code{\outputproperty}.
2786 @node Tuning per grob
2787 @subsection Tuning per grob
2789 @cindex \outputproperty
2791 A second way of tuning grobs is the more arcane @code{\outputproperty}
2793 Syntax is as follows
2795 \outputproperty @var{predicate} @var{symbol} = @var{value}
2797 Here @code{predicate} is a Scheme function taking a grob argument, and
2798 returning a boolean. This statement is processed by the
2799 @code{Output_property_engraver}. It instructs the engraver to feed all
2800 grobs that it sees to @var{predicate}. Whenever the predicate returns
2801 true, the grob property @var{symbol} will be set to @var{value}.
2803 You will need to combine this statement with @code{\context} to select
2804 the appropriate context to apply this to.
2806 If possible, avoid this feature: the semantics are not very clean, and
2807 the syntax and semantics are up for rewrite.
2809 Here are some random examples:
2811 @lilypond[fragment,verbatim,singleline]
2813 \context Staff \outputproperty
2814 #(make-type-checker 'note-head-interface)
2815 #'extra-offset = #'(0.5 . 0.75)
2819 @cindex @code{extra-offset}
2821 This selects all note heads occurring at current staff level, and sets
2822 the @code{extra-offset} of those heads to @code{(0.5,0.75)}, shifting
2825 Move the text "m.d.", but not the fingering instruction "2".
2826 @lilypond[verbatim,singleline]
2827 #(define (make-text-checker text)
2828 (lambda (grob) (equal? text (ly-get-grob-property grob 'text))))
2831 \notes\relative c''' {
2832 \property Voice.Stem \set #'direction = #1
2833 \outputproperty #(make-text-checker "m.d.")
2834 #'extra-offset = #'(-3.5 . -4.5)
2844 @subsection What to tune?
2846 This all tells you how to tune grobs, but what variables are there? The
2847 question is not answered in this manual (although you may encounter
2850 Grob properties are tied directly to the implementation of LilyPond, and
2851 they are thus a moving target. Documentation of such variables are part
2852 of the generated documentation: this documentation is generated from the
2853 sourcecode of lily for each version, so it is usually mch more up to
2854 date than this manual. It should be available from the same place where
2855 you got this manual.
2857 To decide how to tune a grob, you need to find the following information
2860 which grob to modify
2862 which property to modify
2864 which context the grob comes from.
2867 Included with the automatically generated documentation is a master list
2868 of grobs. Each one can be clicked, taking you to a overview of the
2869 available properties.
2871 There is also a master list of contexts. Clicking each takes you to an
2872 overview of the context, listing which grob types are created there.
2875 @node Font selection
2876 @subsection Font selection
2878 Most graphics in LilyPond are composed of characters of fonts. You can
2879 alter the characteristics of the font by setting certain grob
2880 properties. The mechanism that is used for this resembles LaTeX's New
2881 Font Selection Scheme. Within this scheme, a font is entirely
2882 characterized by its font name.
2884 For each grob that uses fonts (in other words, each grob that supports
2885 @code{font-interface}) a font-name must be selected before it can be
2886 printed. The font name is selected by looking at a number of grob
2891 The general class of the typeface. Supported are roman (Computer
2892 Modern), braces (for piano staff braces), music (the standard music
2893 font), dynamic (font for dynamic signs) and typewriter
2896 A symbol indicating the shape of the font, a finer gradation than
2897 font-family. Choices are italic and upright
2899 Symbol indicating the serie of the font. Series form a finer gradation
2900 than font-shape. Choices are medium and bold.
2902 @item font-relative-size
2903 A number indicating the size relative the standard size. For example,
2904 with 20pt staff height, relative size -1 corresponds to 16pt staff
2905 height, and relative size +1 corresponds to 23 pt staff height.
2907 @item font-design-size
2908 A number indicating the design size of the font.
2910 This is a feature of the Computer Modern Font: each point size has a
2911 slightly different design. Smaller design sizes are relatively wider,
2912 which enhances readability. Scalable type faces such TrueType and Adobe
2913 Type1 usually come as ``one design fits all sizes''.
2916 The name of the font, without the design size, eg. @code{cmr},
2917 @code{cmti}, etc. Setting this overrides font-family, font-shape and
2922 The font is selected by taking the first font that satisfies all
2923 qualifiers specified. You can override any of these fields through
2924 @code{\override} and @code{\revert}. The special value @code{*} matches
2925 any value for that qualifier.
2928 \property Lyrics.LyricText \override #'font-series = #'bold
2929 \property Lyrics.LyricText \override #'font-shape = #'*
2932 @cindex @code{font-style}
2934 There are also pre-cooked font selection qualifiers. These are selected
2935 through the grob property @code{font-style}. For example, the style
2936 @code{finger} selects family @code{number} and relative size @code{-3}.
2937 Styles available include: volta, finger, tuplet, timesig, mmrest,
2938 script, large, Large and dynamic.
2940 The style sheets and tables for selecting fonts are located in
2941 @file{scm/font.scm}. Refer to this file for more information.
2945 Relative size is not linked to any real size.
2947 There is no mechanism to select magnification of particular fonts,
2948 meaning that you don't have access to continuously scaled fonts. You
2949 can scale the entire output, of course, see @ref{Output scaling}.
2951 There is no style sheet provided for other fonts besides the @TeX{}
2954 @cindex font selection
2955 @cindex font magnification
2956 @cindex @code{font-interface}
2960 @subsection Text markup
2964 LilyPond has an internal mechanism to typeset texts. You can
2965 form text markup expressions by composing scheme expressions
2966 in the following way.
2968 @lilypond[verbatim, singleline]
2973 c^#'(italic "italic")
2974 d_#'((bold italic) "ff")
2976 f_#'(lines "one" (bold "two"))
2977 g^#'(music "noteheads-2" "flags-u3")
2981 Normally, the Scheme markup text is stored in the @code{text} property
2982 of a grob. Formally, it is defined as follows:
2985 text: string | (head? text+)
2986 head: markup | (markup+)
2987 markup-item: property | abbrev
2988 property: (@var{key} . @var{value})
2989 abbrev: @code{rows lines roman music bold italic named super sub text}
2990 @code{finger volta timesig mmrest mark script large Large dynamic}
2993 The markup is broken down and converted into a list of grob properties,
2994 which are prepended to the property list. The @var{key}-@var{value}
2995 pair is a grob property.
2997 The following abbreviations are currently defined:
3001 horizontal mode: set all text on one line (default)
3003 vertical mode: set every text on new line
3013 lookup by character name
3015 plain text lookup (by character value)
3021 select fingering number fontstyle
3023 select volta number fontstyle
3025 select time signature number fontstyle
3027 select multi measure rest number fontstyle
3029 select mark number fontstyle
3031 select scriptsize roman fontstyle
3033 select large roman fontstyle
3035 select Large roman fontstyle
3037 select dynamics fontstyle
3040 It is possible to use @TeX{} commands in the strings, but this should be
3041 avoided because this makes it impossible for LilyPond to compute the
3042 exact length of the string, which may lead to collisions. Also, @TeX{}
3043 commands won't work with direct PostScript output (see @ref{PostScript
3046 @cindex metronome mark
3048 One practical application of complicated markup is to fake a metronome
3052 #(define note '(rows
3053 (music "noteheads-2" ((kern . -0.1) "flags-stem"))))
3054 #(define eight-note `(rows ,note ((kern . -0.1)
3055 (music ((raise . 3.5) "flags-u3")))))
3056 #(define dotted-eight-note
3057 `(rows ,eight-note (music "dots-dot")))
3060 \notes\relative c'' {
3061 a1^#`((rows (font-relative-size . -1)) ,dotted-eight-note " = 64")
3067 TextScript \override #'font-shape = #'upright
3073 @node Invisible grobs
3074 @subsection Invisible grobs
3075 @cindex invisible grobs
3079 ben nog steeds niet kapot van de informatiedichtheid hier.
3085 You can imagine a number of situtations where you would want to make
3086 certain grobs not show up in the output. There may be aesthetic
3087 reasons, to make the output resemble an (old) manuscript as close as
3088 possible, or to make lessons or exercises for students.
3090 Grobs can be made invisible in a number of ways:
3092 Here's an example with blanked-out notes and stems:
3093 @lilypond[singleline,verbatim]
3095 \property Voice.NoteHead \override
3097 \property Voice.Stem \override
3098 #'transparent = ##t }
3101 \property Voice.NoteHead \revert #'transparent
3102 \property Voice.Stem \revert #'transparent }
3105 \notes\relative c'' {
3107 a b c b \blanknotes c \unblanknotes d
3113 A very rigorous way of removing grobs from the output is to remove the
3114 engraver that creates them. For example,
3117 \score {\notes { c'4 d'8 e'8 g2 }
3118 \paper { \translator {
3120 \remove Stem_engraver
3127 @subsection Embeded TeX
3128 @cindex embedded tex
3129 @cindex embedded tex
3131 You can use @TeX{} commands in text scripts, but this should be avoided
3132 because this makes it impossible for LilyPond to compute the exact
3133 length of the string, which may lead to collisions. Also, @TeX{}
3134 commands won't work with direct PostScript output (see @ref{PostScript
3137 @lilypond[fragment,relative,verbatim]
3138 a''^"3 $\\times$ \\`a deux"
3141 @subsection Embedded PostScript
3142 @cindex embedded postscript
3143 @cindex embedded postscript
3145 You can also use raw PostScript commands embedded in text scripts. This
3146 offers ultimate flexibitily, but you'll have to learn the arcane
3147 PostScript language. Currently, embedded PostScript will @strong{not}
3148 work with direct PostScript output. Note that all dimensions that you
3149 use are in @code{staff-space}s.
3153 \notes \relative c'' {
3154 a-#"\\embeddedps{3 4 moveto 5 3 rlineto stroke}"
3155 -#"\\embeddedps{ [ 0 1 ] 0 setdash 3 5 moveto 5 -3 rlineto stroke}"
3156 b-#"\\embeddedps{3 4 moveto 0 0 1 2 8 4 20 3.5 rcurveto stroke}"
3160 \paper { linewidth = 70*\staffspace }
3167 @section Page layout
3182 @subsection Paper block
3185 The most important output definition is the @code{\paper} block, for
3186 music notation. The syntax is
3189 @code{\paper @{} [@var{paperidentifier}] @var{items} @code{@}}
3192 where each of the items is one of
3195 @item An assignment.
3197 @item A context definition. See @ref{Notation Contexts} for
3198 more information on context definitions.
3200 @item \stylesheet declaration. Its syntax is
3202 \stylesheet @var{alist}
3205 See @file{scm/font.scm} for details of @var{alist}.
3206 @item an \elementdescriptions declaration.
3208 \elementdescriptions @var{alist}
3210 See @file{scm/grob-description.scm} for details of @var{alist}.
3214 @c . {Paper variables}
3215 @node Paper variables
3216 @subsection Paper variables
3217 @cindex Paper variables
3219 The paper block has some variables you may want to use or change:
3222 @cindex @code{indent}
3224 The indentation of the first line of music.
3225 @cindex @code{staffspace}
3227 @item @code{staffspace}
3228 The distance between two staff lines, calculated from the center
3229 of the lines. If you want scale independent output, then you should
3230 use either this or @code{stafflinethickness}
3231 as a unit for distances you modify.
3233 @cindex @code{linewidth}
3234 @item @code{linewidth}
3235 Sets the width of the lines.
3237 If set to a negative value, a single unjustified line is produced.
3238 @c rename to singleLinePaper ?
3239 The shorthand @code{\singleLine} defines a default paper block that
3240 produces a single line.
3242 @cindex @code{textheight}
3244 @item @code{textheight}
3245 Sets the total height of the music on each page. Only used by
3248 @cindex @code{interscoreline}
3250 @item @code{interscoreline}
3251 Sets the spacing between systems.
3253 @cindex @code{interscorelinefill}
3257 @item @code{interscorelinefill}
3258 If set to a positive number, the distance between the score
3259 lines will stretch in order to fill the full page. In that
3260 case @code{interscoreline} specifies the minimum spacing.
3265 @cindex @code{stafflinethickness}
3267 @item @code{stafflinethickness}
3268 Determines the thickness of staff lines, and also acts as a scaling
3269 parameter for other line thicknesses.
3276 @subsection Font size
3279 The Feta font provides musical symbols at six different sizes. These
3280 fonts are 11 point, 13 point, 16 point, 20 point,
3281 23 point, and 26 point. The point size of a font is the
3282 height of the five lines in a staff when displayed in the font.
3284 Definitions for these sizes are the files @file{paperSZ.ly}, where
3285 @code{SZ} is one of 11, 13, 16, 20, 23 and 26. If you include any of
3286 these files, the identifiers @code{paperEleven}, @code{paperThirteen},
3287 @code{paperSixteen}, @code{paperTwenty}, @code{paperTwentythree}, and
3288 @code{paperTwentysix} are defined respectively. The default
3289 @code{\paper} block is also set.
3291 The font definitions are generated using a Scheme function. For more
3292 details, see the file @file{font.scm}.
3298 @subsection Paper size
3303 @cindex @code{papersize}
3305 To change the paper size, you must first set the
3306 @code{papersize} variable at top level. Set it to
3307 the strings @code{a4}, @code{letter}, or @code{legal}. After this
3308 specification, you must set the font as described above. If you want
3309 the default font, then use the 20 point font. The new paper size will
3310 not take effect if the font is not loaded and selected afterwards.
3314 \include "paper16.ly"
3318 \paper @{ \paperSixteen @}
3322 The file @code{paper16.ly} will now include a file named @file{a4.ly}, which
3323 will set the paper variables @code{hsize} and @code{vsize} (used by
3328 @subsection Line break
3331 @cindex breaking lines
3333 Line breaks are normally computed automatically. They are chosen such
3334 that the resulting spacing has low variation, and looks neither cramped
3337 Occasionally you might want to override the automatic breaks; you can do
3338 this by specifying @code{\break}. This will force a line break at this
3339 point. Do remember that line breaks can only occur at places where there
3340 are barlines. If you want to have a line break where there is no
3341 barline, you can force an invisible barline by entering @code{\bar ""}.
3343 Similarly, @code{\noBreak} forbids a line break at a certain point.
3345 @cindex @code{\penalty}
3347 The @code{\break} and @code{\noBreak} commands are defined in terms of
3348 the penalty command:
3353 This encourages or discourages LilyPond to make a line break at this
3358 The scaling of the @code{\penalty} argument is not well-defined. The
3359 command is rather kludgy, and slated for rewriting.
3363 @subsection Page break
3366 @cindex breaking pages
3369 Page breaks are normally computed by @TeX{}, so they are not under
3370 direct control of LilyPond. However, you can insert a commands into the
3371 @file{.tex} output to instruct @TeX{} where to break pages. For more
3372 details, see the example file @file{input/test/between-systems.ly}
3376 @c . {Output scaling}
3377 @node Output scaling
3378 @subsection Output scaling
3392 There is no mechanism to select magnification of particular fonts,
3393 meaning that you don't have access to continuously scaled fonts.
3397 @c . {Output formats}
3398 @node Output formats
3399 @section Output formats
3401 LilyPond can output processed music in different output formats.
3405 * PostScript output::
3407 * ASCIIScript output::
3411 @subsection TeX output
3414 LilyPond will use @TeX{} by default. Even if you want to produce
3415 PostScript output for viewing or printing, you should normally have
3416 LilyPond produce @TeX{} first. The .tex output must be processed by
3417 @TeX{} (@strong{not} La@TeX{}) to generate a .dvi. Then, @file{Dvips}
3418 is used to generate PostScript. Alternatively, @file{ly2dvi} can be
3419 used to generate the .dvi for you.
3422 @node PostScript output
3423 @subsection PostScript output
3424 @cindex PostScript output
3425 @cindex direct PostScript output
3427 LilyPond can produce PostScript directly, without going through @TeX{}.
3428 Currently, this is mainly useful if you cannot use TeX, because direct
3429 PostScript output has some problems; see Bugs below.
3432 $ lilypond -fps foo.ly
3433 GNU LilyPond 1.3.144
3434 Now processing: `foo.ly'
3436 Interpreting music...[3]
3437 Preprocessing elements...
3438 Calculating column positions...
3439 paper output to foo.ps...
3441 $ cat /usr/share/lilypond/pfa/feta20.pfa foo.ps | lpr
3447 Text font selection is broken.
3449 The .ps file does not contain the .pfa font files. To print a .ps
3450 created through direct postscript output, you should prepend the
3451 necessary .pfa files to LilyPond's .ps output, or upload them to the
3452 printer before printing.
3454 Titling is not generated.
3457 @subsection Scheme output
3458 @cindex Scheme output
3460 In the typesetting stage, LilyPond builds a page description, which is
3461 then written to disk in postscript, @TeX{} or ASCII art. Before it is
3462 written, the page description is represented as Scheme expressions. You
3463 can also dump these Scheme expressions to a file, which may be
3464 convenient for debugging output routines. This done with the Scheme
3468 $ lilypond -fscm foo.ly
3469 GNU LilyPond 1.3.144
3470 Now processing: `foo.ly'
3472 Interpreting music...[3]
3473 Preprocessing elements...
3474 Calculating column positions...
3475 paper output to foo.scm...
3478 ;;; Usage: guile -s x.scm > x.tex
3479 (primitive-load-path 'standalone.scm)
3483 $ guile -s foo.scm > foo.tex
3487 @node ASCIIScript output
3488 @subsection ASCIIScript output
3489 @cindex ASCIIScript output
3490 @cindex ascii script
3493 LilyPond can output ASCII Art. This is a two step process, LilyPond
3494 produces an ASCII description file, dubbed ASCIIScript (extension
3495 @file{.as}). ASCIIScript has a small and simple command set that
3496 includes font selection, character and string printing and line drawing
3497 commands. The program @file{as2text} is used to translate an .as file
3500 To produce ASCII Art, you must include an ASCII Art paper definition
3501 file in your .ly, one of:
3503 \include "paper-as5.ly"
3504 \include "paper-as9.ly"
3507 Here's an example use for ASCII Art output (the example file
3508 @file{as-email.ly} is included in the LilyPond distribution), the staff
3509 symbol has been made invisible:
3512 $ lilypond -fas as-email.ly
3513 GNU LilyPond 1.3.144
3514 Now processing: `as-email.ly'
3516 Interpreting music...[3]
3517 Preprocessing elements...
3518 Calculating column positions... [2]
3519 paper output to as-email.as...
3521 $ as2text as-email.as 2>/dev/null
3523 |/ |##|##| | | | | |
3524 /| | | | | |\ |\ |\ |\ |\ |
3525 / |_ 3 | | | | 5 | )| )| )| )| )|
3526 | /| \ 8 * * * | 8 * * * * * |
3536 The ASCII Art fonts are far from complete and not very well designed.
3537 It's easy to change the glyphs, though; if you think you can do better,
3538 have a look at @file{mf/*.af}.
3540 Lots of resizable symbols such as slurs, ties, tuplets are missing.
3542 The poor looks of most ASCII Art output and its limited general
3543 usefulness make that ASCII Art output has a low priority; it may be
3544 dropped in future versions.
3551 LilyPond can produce MIDI output. The performance lacks lots of
3552 interesting effects, such as swing, articulation, slurring, etc., but it
3553 is good enough for proof-hearing the music you have entered. Ties,
3554 dynamics and tempo changes are interpreted.
3556 The MIDI volume is composed of two elements: the current dynamics of the
3557 voice and the type of musical instrument.
3559 Dynamic marks, crescendi and decrescendi translate into MIDI volume
3560 levels. Dynamic marks translate to a fixed fraction of the available
3561 MIDI volume range, crescendi and decrescendi make the the volume vary
3562 linearly between their two extremities. The fractions be adjusted by
3563 overriding the @code{absolute-volume-alist} defined in
3564 @file{scm/midi.scm}.
3566 For each type of musical instrument (that MIDI supports), a volume range
3567 can be defined. This gives you basic equaliser control, which can
3568 enhance the quality of the MIDI output remarkably. You can add
3569 instruments and ranges or change the default settings by overriding
3570 the @code{instrument-equaliser-alist} defined in @file{scm/midi.scm}.
3574 It is currently not possible to use the percussion channel (generally
3575 channel 10 of a MIDI file).
3579 * MIDI instrument names::
3584 @subsection MIDI block
3588 The MIDI block is analogous to the paper block, but it is somewhat
3589 simpler. The @code{\midi} block can contain:
3593 @item a @code{\tempo} definition
3594 @item context definitions
3597 Assignments in the @code{\midi} block are not allowed.
3601 @cindex context definition
3603 Context definitions follow precisely the same syntax as within the
3604 \paper block. Translation modules for sound are called performers.
3605 The contexts for MIDI output are defined in @file{ly/performer.ly}.
3608 @node MIDI instrument names
3609 @subsection MIDI instrument names
3611 @cindex instrument names
3612 @cindex @code{Staff.midiInstrument}
3613 @cindex @code{Staff.instrument}
3615 The MIDI instrument name is set by the @code{Staff.midiInstrument}
3616 property or, if that property is not set, the @code{Staff.instrument}
3617 property. The instrument name should be chosen from the list in
3618 @ref{MIDI instruments}.
3622 If the selected string does not exactly match, then LilyPond uses the
3623 default piano. It is not possible to select an instrument by number.
3635 @section Music entry
3643 One of the applications of LilyPond is to enter music from existing
3644 written or printed material. When you're doing this kind of copying
3645 work, you can easily make mistakes. This section deals with tricks and
3646 features that help you enter music, and find and correct mistakes.
3650 @subsection Relative
3652 @cindex relative octave specification
3654 Octaves are specified by adding @code{'} and @code{,} to pitch names.
3655 When you copy existing music, it is easy to accidentally put a pitch in
3656 the wrong octave and hard to find such an error. To prevent these
3657 errors, LilyPond features octave entry.
3659 @cindex @code{\relative}
3661 \relative @var{startpitch} @var{musicexpr}
3664 The octave of notes that appear in @var{musicexpr} are calculated as
3665 follows: If no octave changing marks are used, the basic interval
3666 between this and the last note is always taken to be a fourth or less.
3667 The octave changing marks @code{'} and @code{,} can then
3668 be added to raise or lower the pitch by an extra octave. Upon entering
3669 relative mode, an absolute starting pitch must be specified that will
3670 act as the predecessor of the first note of @var{musicexpr}.
3672 This distance is determined without regarding accidentals: a
3673 @code{fisis} following a @code{ceses} will be put above the
3676 Entering music that changes octave frequently is easy in relative mode.
3677 @lilypond[fragment,singleline,verbatim,center]
3683 And octave changing marks are used for intervals greater than a fourth.
3684 @lilypond[fragment,verbatim,center]
3686 c g c f, c' a, e'' }
3689 If the preceding item is a chord, the first note of the chord is used
3690 to determine the first note of the next chord. But other notes
3691 within the second chord are determined by looking at the immediately
3694 @lilypond[fragment,verbatim,center]
3701 @cindex @code{\notes}
3703 The pitch after the @code{\relative} contains a notename. To parse
3704 the pitch as a notename, you have to be in note mode, so there must
3705 be a surrounding @code{\notes} keyword (which is not
3708 The relative conversion will not affect @code{\transpose},
3709 @code{\chords} or @code{\relative} sections in its argument. If you
3710 want to use relative within transposed music, you must place an
3711 additional @code{\relative} inside the @code{\transpose}.
3716 @subsection Bar check
3720 @cindex @code{barCheckNoSynchronize}
3724 Whenever a bar check is encountered during interpretation, a warning
3725 message is issued if it doesn't fall at a measure boundary. This can
3726 help you find errors in the input. Depending on the value of
3727 @code{barCheckNoSynchronize}, the beginning of the measure will be
3728 relocated, so this can also be used to shorten measures.
3730 A bar check is entered using the bar symbol, @code{|}
3732 @c . {Point and click}
3733 @node Point and click
3734 @subsection Point and click
3736 Point and click lets you find notes in the input by clicking on them in
3737 the Xdvi window. This makes it very easy to find input that causes some
3738 error in the sheet music.
3740 To use it, you need the following software
3744 @uref{ftp://ftp.math.berkeley.edu/pub/Software/TeX/xdvi.tar.gz,plain
3745 Xdvi} version 22.36 or newer.
3747 Note that most @TeX{} distributions ship with xdvik, which is a
3748 different and less well maintained program. To find out which xdvi you
3749 are running, try @code{xdvi --version} or @code{xdvi.bin --version}.
3753 Add one of these lines to the top of your .ly file. The first one is for
3754 line location only. The second one is more convenient, but requires
3755 patching @code{emacsclient} and @code{server.el}.
3758 #(set! point-and-click line-location)
3759 #(set! point-and-click line-column-location)
3762 In the emacs startup file (usually @file{~/.emacs}), add the following
3767 If you want emacs to jump to the exact spot (and not just the line) on a
3768 click, you must enable column positioning. To do so, you need to patch
3769 emacsclient. Apply @file{emacsclient.patch} (included with the source
3770 package) to @file{emacsclient.c} and @file{server.el} from the emacs
3771 source code. Recompile and stick the recompiled emacsclient into a bin
3772 directory, and put @file{server.el} into a elisp directory
3773 (eg. @file{~/usr/share/emacs/}). Add the following to your @file{.emacs}
3774 init file, before invoking server-start.
3777 (setq load-path (cons "~/usr/share/emacs" load-path))
3781 Xdvi must be configured to use the emacs editor. Before starting, set
3782 the environment variable @code{XEDITOR} to one of these strings. The
3783 second one, that also specifies the column, only works if you have
3784 patched your emacsclient and server, and have compiled your @code{.ly}
3785 file using the @code{line-column-location} setting (see above).
3787 emacsclient --no-wait +%l %f
3788 emacsclient --no-wait +%l:%c %f
3790 Xdvi also must be configured to find the fonts. Refer to the
3791 xdvi documentation for more information.
3793 When viewing, control-mousebutton 1 will take you to the originating
3794 line and column. Control-mousebutton 2 will show all clickable boxes.
3798 When you convert the TeX file to PostScript using dvips, dvips
3799 will complain about not finding @code{src:X:Y} files. Those complaints are
3800 harmless, and can be ignored.
3802 When using @code{line-colum-location}, the cursor will be one off; it
3803 will not jump to the exact note that you clicked, but to the next one.
3804 We hope to fix this before 1.4.
3806 @node Skipping corrected music
3807 @section Skipping corrected music
3809 The property @code{Score.skipTypesetting} can be used to switch on and
3810 off typesetting completely during the interpretation phase. When
3811 typesetting is switched off, the music is processed much more quickly.
3812 You can use this to skip over the parts of a score that you have already
3815 @lilypond[fragment,singleline,verbatim]
3816 \relative c'' { c8 d
3817 \property Score.skipTypesetting = ##t
3819 \property Score.skipTypesetting = ##f
3824 @node Interpretation context
3825 @section Interpretation context
3828 * Notation Contexts::
3829 * Creating contexts::
3830 * Default contexts::
3831 * Context properties::
3832 * Changing context definitions::
3833 * Defining new contexts::
3837 @c . {Notation Contexts}
3838 @node Notation Contexts
3839 @subsection Notation Contexts
3841 @cindex notation contexts
3843 Notation contexts are objects that only exist during a run of LilyPond.
3844 During the interpretation phase of LilyPond (when it prints
3845 "interpreting music"), the music expresiion in a @code{\score} block is
3846 interpreted in time order. This is the same order that humans hear and
3849 During this interpretation, the notation context is holds the state for
3850 the current point within the music. It contains information like
3853 @item What notes are playing at this point?
3854 @item What symbols will be printed at this point?
3855 @item What is the current key signature, time signature, point within
3859 Contexts are grouped hierarchically: A @code{Voice} context is
3860 contained in a @code{Staff} context (because a staff can contain
3861 multiple voices at any point), a @code{Staff} context is contained in
3862 a @code{Score}, @code{StaffGroup}, or @code{ChoirStaff} context (because
3863 these can all contain multiple staffs).
3866 Contexts associated with sheet music output are called @emph{notation
3867 contexts}, those for sound output are called performance contexts.
3870 @node Creating contexts
3871 @subsection Creating contexts
3873 @cindex @code{\context}
3874 @cindex context selection
3876 Contexts for a music expression can be selected manually, using the
3877 following music expression.
3880 \context @var{contexttype} [= @var{contextname}] @var{musicexpr}
3883 This instructs lilypond to interpret @var{musicexpr} within the context
3884 of type @var{contexttype} and with name @var{contextname}. If this
3885 context does not exist, it will be created.
3887 @lilypond[verbatim,singleline]
3889 \notes \relative c'' {
3890 c4 <d4 \context Staff = "another" e4> f
3896 In this example, the @code{c} and @code{d} are printed on the
3897 default staff. For the @code{e}, a context Staff called
3898 @code{another} is specified; since that does not exist, a new
3899 context is created. Within @code{another}, a (default) Voice context
3900 is created for the @code{e4}. When all music referring to a
3901 context is finished, the context is ended as well. So after the
3902 third quarter, @code{another} is removed.
3906 @node Default contexts
3907 @subsection Default contexts
3909 Most music expressions don't need @code{\context}: they inherit the
3910 notation context from their parent. Each note is a music expression, and
3911 as you can see in the following example, only the sequential music
3912 enclosing the three notes has an explicit context.
3914 @lilypond[verbatim,singleline]
3915 \score { \notes \context Voice = goUp { c'4 d' e' } }
3918 There are some quirks that you must keep in mind when dealing with
3921 First, every top-level music is interpreted by the Score context, in other
3922 words, you may think of @code{\score} working like
3925 \context Score @var{music}
3929 Second, sequential music follows the contexts of its
3930 ``children''. Consider the following example.
3932 @lilypond[verbatim, singleline]
3933 \score { \context Score \notes { c'4 ( d' )e' } }
3936 The sequential music is interpreted by the Score context initially
3937 (notice that the @code{\context} specification is redundant), but when a
3938 note is encountered, contexts are setup to accept that note. In this
3939 case, a Thread, Voice and Staff are created. The rest of the sequential
3940 music is also interpreted with the same Thread, Voice and Staff context,
3941 putting the notes on the same staff, in the same voice.
3943 This is a convenient mechanism, but do not expect opening chords to work
3944 without @code{\context}. For every note, a separate staff is
3947 @lilypond[verbatim, singleline]
3948 \score { \notes <c'4 es'> }
3951 Of course, if the chord is preceded by a normal note in sequential
3952 music, the chord will be interpreted by the Thread of the preceding
3954 @lilypond[verbatim,singleline]
3955 \score { \notes { c'4 <c'4 es'> } }
3960 @node Context properties
3961 @subsection Context properties
3963 Notation contexts can be modified from within the @file{.ly} file. The
3964 following music expression does that job:
3966 @cindex @code{\property}
3968 \property @var{contextname}.@var{propname} = @var{value}
3971 Sets the @var{propname} property of the context @var{contextname} to the
3972 specified Scheme expression @var{value}. All @var{propname} and
3973 @var{contextname} are strings, which are typically unquoted.
3975 Properties that are set in one context are inherited by all of the
3976 contained contexts. This means that a property valid for the
3977 @code{Voice} context can be set in the @code{Score} context (for
3978 example) and thus take effect in all @code{Voice} contexts.
3980 Properties can be unset using the following expression:
3982 \property @var{contextname}.@var{propname} \unset
3985 @cindex properties, unsetting
3986 @cindex @code{\unset}
3988 This removes the definition of @var{propname} in @var{contextname}. If
3989 @var{propname} was not defined in @var{contextname} (but was inherited
3990 from a higher context), then this has no effect.
3995 The syntax of @code{\unset} is asymetric: @code{\property \unset} is not
3996 the inverse of @code{\property \set}.
3999 @c . {Context definitions}
4000 @node Changing context definitions
4001 @subsection Changing context definitions
4003 @cindex context definition
4004 @cindex translator definition
4006 The most common way to define a context is by extending an existing
4007 context. You can change an existing context from the paper block, by
4008 first initializing a translator with an existing context identifier:
4012 @var{context-identifier}
4015 Then you can add engravers, remove engravers.
4016 The syntax for these operations are respectively
4018 \remove @var{engravername}
4019 \consists @var{engravername}
4023 Here @var{engravername} is a string, the name of an engraver in the
4026 @var{propname} = @var{value}
4030 @lilypond[verbatim,singleline]
4034 \translator { \StaffContext
4035 \remove Clef_engraver
4041 You can also set properties in a translator definition. The syntax is as
4044 @var{propname} is a string and @var{value} is a Scheme
4047 @var{propname} = @var{value}
4048 @var{propname} \set @var{symbol} = @var{value}
4049 @var{propname} \override @var{symbol} = @var{value}
4050 @var{propname} \revert @var{symbol}
4054 These type of property assignments happen before interpretation starts,
4055 so a @code{\property} expression will override any predefined settings.
4058 To simplify editing translators, all standard contexts have standard
4059 identifiers called @var{name}@code{Context}, e.g. @code{StaffContext},
4060 @code{VoiceContext}.
4062 @node Defining new contexts
4063 @subsection Defining new contexts
4065 If you want to build a context from scratch, you must also supply the
4066 following extra information:
4068 @item A name, specified by @code{\name @var{contextname};}.
4070 @item A cooperation module. This is specified by @code{\type
4077 \type "Engraver_group_engraver"
4080 \consists "Staff_symbol_engraver"
4081 \consists "Note_head_engraver"
4082 \consistsend "Axis_group_engraver"
4086 Basic building blocks of translation are called engravers; they are
4087 special C++ classes.
4089 The argument of @code{\type} is the name for a special engraver that
4090 handles cooperation between simple engravers such as
4091 @code{Note_head_engraver} and @code{Staff_symbol_engraver}. Alternatives
4092 for this engraver are the following:
4094 @cindex @code{Engraver_group_engraver}
4095 @item @code{Engraver_group_engraver}
4096 The standard cooperation engraver.
4098 @cindex @code{Score_engraver}
4100 @item @code{Score_engraver}
4101 This is cooperation module that should be in the top level context,
4102 and only the toplevel context.
4104 @cindex @code{Grace_engraver_group}
4106 @item @code{Grace_engraver_group}
4107 This is a special cooperation module (resembling
4108 @code{Score_engraver}) that is used to created an embedded
4115 @item @code{\alias} @var{alternate-name}
4116 This specifies a different name. In the above example,
4117 @code{\property Staff.X = Y} will also work on @code{SimpleStaff}s
4119 @item @code{\consistsend} @var{engravername}
4120 Analogous to @code{\consists}, but makes sure that
4121 @var{engravername} is always added to the end of the list of
4124 Some engraver types need to be at the end of the list; this
4125 insures they are put there, and stay there, if a user adds or
4126 removes engravers. This command is usually not needed for
4129 @item @code{\accepts} @var{contextname}
4130 Add @var{contextname} to the list of context this context can
4131 contain. The first listed context is the context to create by
4134 @item @code{\denies}. The opposite of @code{\accepts}. Added for
4135 completeness, but is never used in practice.
4138 @item @code{\name} @var{contextname}
4139 This sets name of the context, e.g. @code{Staff}, @code{Voice}. If
4140 the name is not specified, the translator won't do anything.
4143 In the @code{\paper} block, it is also possible to define translator
4144 identifiers. Like other block identifiers, the identifier can only
4145 be used as the very first item of a translator. In order to define
4146 such an identifier outside of @code{\score}, you must do
4151 foo = \translator @{ @dots{} @}
4158 \translator @{ \foo @dots{} @}
4166 @cindex paper types, engravers, and pre-defined translators
4173 @c . {Syntactic details}
4174 @node Syntactic details
4175 @section Syntactic details
4176 @cindex Syntactic details
4178 This section describes details that were too boring to be put elsewhere.
4183 * Music expressions::
4184 * Manipulating music expressions::
4192 @subsection Top level
4195 This section describes what you may enter at top level.
4199 @subsubsection Score
4202 @cindex score definition
4204 The output is generated combining a music expression with an output
4205 definition. A score block has the following syntax:
4208 \score @{ @var{musicexpr} @var{outputdefs} @}
4211 @var{outputdefs} are zero or more output definitions. If none is
4212 supplied, the default @code{\paper} block will be added.
4216 @c . {Default output}
4217 @subsubsection Default output
4219 Default values for the @code{\paper} and @code{\midi} block are set by
4220 entering such a block at top-level.
4223 @subsubsection Header
4225 @cindex @code{\header}
4228 A header describes bibilographic information of the file's contents. It
4229 can also appear in a @code{\score} block. Tools like @code{ly2dvi} can
4230 use this information for generating titles. Key values that are used by
4231 @code{ly2dvi} are: title, subtitle, composer, opus, poet, instrument,
4232 metre, arranger, piece and tagline.
4234 @cindex @code{ly2dvi}
4238 \header @{ @var{key1} = @var{val1}
4239 @var{key2} = @var{val2} @dots{} @}
4242 It is customary to put the @code{\header} at the top of the file.
4244 @subsubsection Default output
4246 A @code{\midi} or @code{\paper} block at top-level sets the default
4248 paper block for all scores that lack an explicit paper block.
4252 @subsection Identifiers
4255 All of the information in a LilyPond input file, is represented as a
4256 Scheme value. In addition to normal Scheme data types (such as pair,
4257 number, boolean, etc.), LilyPond has a number of specialized data types,
4264 @item Translator_def
4268 @item Music_output_def
4269 @item Moment (rational number)
4272 LilyPond also includes some transient object types. Objects of these
4273 types are built during a LilyPond run, and do not `exist' per se within
4274 your input file. These objects are created as a result of your input
4275 file, so you can include commands in the input to manipulate them,
4276 during a lilypond run.
4279 @item Grob: short for Graphical object. See @ref{Grobs}.
4280 @item Molecule: device-independent page output object,
4281 including dimensions. Produced by some Grob functions
4283 @item Translator: object that produces audio objects or Grobs. This is
4284 not yet user accessible.
4285 @item Font_metric: object representing a font. (See @ref{Font metrics})
4290 @node Music expressions
4291 @subsection Music expressions
4293 @cindex music expressions
4295 Music in LilyPond is entered as a music expression. Notes, rests, lyric
4296 syllables are music expressions, and you can combine music expressions
4297 to form new ones, for example by enclosing a list of expressions in
4298 @code{\sequential @{ @}} or @code{< >}. In the following example, a
4299 compound expression is formed out of the quarter note @code{c} and a
4300 quarter note @code{d}:
4303 \sequential @{ c4 d4 @}
4306 @cindex Sequential music
4307 @cindex @code{\sequential}
4308 @cindex sequential music
4311 @cindex Simultaneous music
4312 @cindex @code{\simultaneous}
4314 The two basic compound music expressions are simultaneous and
4318 \sequential @code{@{} @var{musicexprlist} @code{@}}
4319 \simultaneous @code{@{} @var{musicexprlist} @code{@}}
4321 For both, there is a shorthand:
4323 @code{@{} @var{musicexprlist} @code{@}}
4327 @code{<} @var{musicexprlist} @code{>}
4329 for simultaneous music.
4330 In principle, the way in which you nest sequential and simultaneous to
4331 produce music is not relevant. In the following example, three chords
4332 are expressed in two different ways:
4334 @lilypond[fragment,verbatim,center]
4335 \notes \context Voice {
4336 <a c'> <b d' > <c' e'>
4337 < { a b c' } { c' d' e' } >
4342 Other compound music expressions include
4345 \transpose @var{pitch} @var{expr}
4346 \apply @var{func} @var{expr}
4347 \context @var{type} = @var{id} @var{expr}
4348 \times @var{fraction} @var{expr}
4352 @c . {Manipulating music expressions}
4353 @node Manipulating music expressions
4354 @subsection Manipulating music expressions
4356 The @code{\apply} mechanism gives you access to the internal
4357 representation of music. You can write Scheme-functions that operate
4358 directly on it. The syntax is
4360 \apply #@var{func} @var{music}
4362 This means that @var{func} is applied to @var{music}. The function
4363 @var{func} should return a music expression.
4365 This example replaces the text string of a script. It also shows a dump
4366 of the music it processes, which is useful if you want to know more
4367 about how music is stored.
4369 @lilypond[verbatim,singleline]
4370 #(define (testfunc x)
4371 (if (equal? (ly-get-mus-property x 'text) "foo")
4372 (ly-set-mus-property x 'text "bar"))
4374 (ly-set-mus-property x 'elements
4375 (map testfunc (ly-get-mus-property x 'elements)))
4380 \apply #testfunc { c4_"foo" }
4384 For more information on what is possible, see the automatically
4385 generated documentation.
4388 Directly accessing internal representations is dangerous: the
4389 implementation is subject to changes, so you should avoid this feature
4392 A final example is a function that reverses a piece of music in time:
4394 @lilypond[verbatim,singleline]
4395 #(define (reverse-music music)
4396 (let* ((elements (ly-get-mus-property music 'elements))
4397 (reversed (reverse elements))
4398 (span-dir (ly-get-mus-property music 'span-direction)))
4399 (ly-set-mus-property music 'elements reversed)
4401 (ly-set-mus-property music 'span-direction (- span-dir)))
4402 (map reverse-music reversed)
4405 music = \notes { c'4 d'4( e'4 f'4 }
4407 \score { \context Voice {
4409 \apply #reverse-music \music
4415 @c . {Span requests}
4421 @subsubsection Span requests
4422 @cindex Span requests
4424 Notational constructs that start and end on different notes can be
4425 entered using span requests. The syntax is as follows:
4429 \spanrequest @var{startstop} @var{type}
4433 @cindex @code{\start}
4434 @cindex @code{\stop}
4436 This defines a spanning request. The @var{startstop} parameter is either
4437 -1 (@code{\start}) or 1 (@code{\stop}) and @var{type} is a string that
4438 describes what should be started. Much of the syntactic sugar is a
4439 shorthand for @code{\spanrequest}, for example,
4441 @lilypond[fragment,verbatim,center]
4442 c'4-\spanrequest \start "slur"
4443 c'4-\spanrequest \stop "slur"
4446 Among the supported types are @code{crescendo}, @code{decrescendo},
4447 @code{beam}, @code{slur}. This is an internal command. Users are
4448 encouraged to use the shorthands which are defined in the initialization
4449 file @file{spanners.ly}.
4454 @subsection Assignments
4457 Identifiers allow objects to be assigned to names during the parse
4458 stage. To assign an identifier, you use @var{name}@code{=}@var{value}
4459 and to refer to an identifier, you preceed its name with a backslash:
4460 `@code{\}@var{name}'. @var{value} is any valid Scheme value or any of
4461 the input-types listed above. Identifier assignments can appear at top
4462 level in the LilyPond file, but also in @code{\paper} blocks.
4464 An identifier can be created with any string for its name, but you will
4465 only be able to refer to identifiers whose names begin with a letter,
4466 being entirely alphabetical. It is impossible to refer to an identifier
4467 whose name is the same as the name of a keyword.
4469 The right hand side of an identifier assignment is parsed completely
4470 before the assignment is done, so it is allowed to redefine an
4471 identifier in terms of its old value, e.g.
4477 When an identifier is referenced, the information it points to is
4478 copied. For this reason, an identifier reference must always be the
4479 first item in a block.
4483 \paperIdent % wrong and invalid
4487 \paperIdent % correct
4492 @c . {Lexical modes}
4494 @subsection Lexical modes
4495 @cindex Lexical modes
4498 @cindex @code{\notes}
4499 @cindex @code{\chords}
4500 @cindex @code{\lyrics}
4502 To simplify entering notes, lyrics, and chords, LilyPond has three
4503 special input modes on top of the default mode: note, lyrics and chords
4504 mode. These input modes change the way that normal, unquoted words are
4505 interpreted: for example, the word @code{cis} may be interpreted as a
4506 C-sharp, as a lyric syllable `cis' or as a C-sharp major triad
4509 A mode switch is entered as a compound music expressions
4511 @code{\notes} @var{musicexpr}
4512 @code{\chords} @var{musicexpr}
4513 @code{\lyrics} @var{musicexpr}.
4516 In each of these cases, these expressions do not add anything to the
4517 meaning of their arguments. They are just a way to indicate that the
4518 arguments should be parsed in indicated mode. The modes are treated in
4519 more detail in @ref{Lyrics} and @ref{Chords}.
4521 You may nest different input modes.
4525 @subsection Ambiguities
4530 The grammar contains a number of ambiguities. We hope to resolve them at
4534 @item The assignment
4539 is interpreted as the string identifier assignment. However,
4540 it can also be interpreted as making a string identifier @code{\foo}
4541 containing @code{"bar"}, or a music identifier @code{\foo}
4542 containing the syllable `bar'.
4544 @item If you do a nested repeat like
4556 then it is ambiguous to which @code{\repeat} the
4557 @code{\alternative} belongs. This is the classic if-then-else
4558 dilemma. It may be solved by using braces.
4560 @item The parser is not sophisticated enough to distinguish at the
4562 @code{c4*2 / 3 } and @code{c4*2 / g} (in chord mode).
4569 @c . {Lexical details}
4570 @node Lexical details
4571 @section Lexical details
4573 Even more boring details, now on lexical side of the input parser.
4584 * Version information::
4589 @subsection Comments
4592 @cindex block comment
4593 @cindex line comment
4597 A one line comment is introduced by a @code{%} character.
4598 Block comments are started by @code{%@{} and ended by @code{%@}}.
4599 They cannot be nested.
4602 @subsection Direct Scheme
4606 @cindex Scheme, in-line code
4609 LilyPond contains a Scheme interpreter (the GUILE library) for
4610 internal use. In some places Scheme expressions also form valid syntax:
4611 whereever it is allowed,
4615 evaluates the specified Scheme code. If this is used at toplevel, then
4616 the result is discarded. Example:
4618 \property Staff.TestObject \override #'foobar = #(+ 1 2)
4621 @code{\override} expects two Scheme expressions, so there are two Scheme
4622 expressions. The first one is a symbol (@code{foobar}), the second one
4623 an integer (namely, 3).
4625 Scheme is a full-blown programming language, and a full discussion is
4626 outside the scope of this document. Interested readers are referred to
4627 the website @uref{http://www.schemers.org/} for more information on
4632 @subsection Keywords
4636 Keywords start with a backslash, followed by a number of lower case
4637 alphabetic characters. These are all the keywords.
4640 apply arpeggio autochange spanrequest commandspanrequest
4641 simultaneous sequential accepts alternative bar breathe
4642 char chordmodifiers chords clef cm consists consistsend
4643 context denies duration dynamicscript elementdescriptions
4644 font grace header in lyrics key mark pitch
4645 time times midi mm name pitchnames notes outputproperty
4646 override set revert partial paper penalty property pt
4647 relative remove repeat addlyrics partcombine score
4648 script stylesheet skip textscript tempo translator
4653 @subsection Integers
4661 Formed from an optional minus sign followed by digits. Arithmetic
4662 operations cannot be done with integers, and integers cannot be mixed
4667 @cindex real numbers
4673 Formed from an optional minus sign and a sequence of digits followed
4674 by a @emph{required} decimal point and an optional exponent such as
4675 @code{-1.2e3}. Reals can be built up using the usual operations:
4676 `@code{+}', `@code{-}', `@code{*}', and
4677 `@code{/}', with parentheses for grouping.
4685 A real constant can be followed by one of the dimension keywords:
4686 @code{\mm} @code{\pt}, @code{\in}, or @code{\cm}, for millimeters,
4687 points, inches and centimeters, respectively. This converts the number
4688 a number that is the internal representation of that dimension.
4696 Begins and ends with the @code{"} character. To include a @code{"}
4697 character in a string write @code{\"}. Various other backslash
4698 sequences have special interpretations as in the C language. A string
4699 that contains no spaces can be written without the quotes. See
4700 @ref{Lexical modes} for details on unquoted strings; their
4701 interpretation varies depending on the situation. Strings can be
4702 concatenated with the @code{+} operator.
4704 The tokenizer accepts the following commands. They have no grammatical
4705 function, hence they can appear anywhere in the input.
4709 @subsection Main input
4712 @cindex @code{\maininput}
4714 The @code{\maininput} command is used in init files to signal that the
4715 user file must be read. This command cannot be used in a user file.
4717 @node File inclusion
4718 @subsection File inclusion
4719 @cindex @code{\include}
4721 \include @var{filename}
4724 Include @var{filename}. The argument @var{filename} may be a quoted string (an
4725 unquoted string will not work here!) or a string identifier. The full
4726 filename including the @file{.ly} extension must be given,
4729 @node Version information
4730 @subsection Version information
4731 @cindex @code{\version}
4733 \version @var{string}
4736 Specify the version of LilyPond that a file was written for. The
4737 argument is a version string in quotes, for example @code{"1.2.0"}.
4738 This is used to detect invalid input, and to aid
4739 @code{convert-ly} a tool that automatically upgrades input files. See
4740 See @ref{convert-ly} for more information on @code{convert-ly}.
4749 @c .{Local emacs vars}
4752 @c minor-mode: font-lock
4753 @c minor-mode: outline
4754 @c outline-layout: (-1 : 0)
4755 @c outline-use-mode-specific-leader: "@c \."
4756 @c outline-primary-bullet: "{"
4757 @c outline-stylish-prefixes: nil
4758 @c outline-override-protect: t