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
11 @unnumberedsubsec Bugs
16 @c .{Reference Manual}
18 @node Reference Manual
19 @chapter Reference Manual
21 This document describes GNU LilyPond and its input format. The last
22 revision of this document was for LilyPond 1.3.141.
44 * Skipping corrected music::
45 * Interpretation context::
55 The purpose of LilyPond is explained informally by the term `music
56 typesetter'. This is not a fully correct name: not only does the
57 program print musical symbols, it also makes esthetic decisions.
58 Symbols and their placements are @emph{generated} from a high-level
59 musical description. In other words, LilyPond would be best described
60 by `music compiler' or `music to notation compiler'.
62 LilyPond is linked to GUILE, GNU's Scheme library for extension. The
63 Scheme library provides the glue that holds together the low-level
64 routines and separate modules general, which are C++.
66 When lilypond is run to typeset sheet music, the following happens:
68 @item GUILE Initialization: various scheme files are read
69 @item parsing: first standard @code{ly} initialization files are read, and
70 then the user @file{ly} file is read.
71 @item interpretation: the music in the file is processed ``in playing
72 order'', i.e. the order that you use to read sheet music, or the
73 order in which notes are played.
76 in this step, the results of the interpretation, a typesetting
77 specification, is solved.
79 @item the visible results ("virtual ink") is written to the output file.
82 During these stages different types of data play the the main role:
83 during parsing, @strong{Music} objects are created. During the
84 interpretation, @strong{context} is constructed, and with this context
85 af network of @strong{graphical objects} (``grobs'') is created. The
86 grobs contain unknown variables, and the network forms a set of
87 equations. After solving the equations and filling in these variables,
88 the printed output (in the form of @strong{molecules}) is written to an
91 These threemanship of tasks (parsing, translating, typesetting) and
92 data-structures (music, context, graphical objects) permeates the entire
93 design of the program. This manual is ordered in terms of user
94 tasks. With each concept will be explained to which of the three parts
103 The most basic forms of music are notes. We discuss how you enter them
104 here. Notes on their own don't form valid input, but for the sake of
105 brevity we omit obligotary lint such as @code{\score} blocks and
106 @code{\paper} declarations.
111 * Defining pitch names::
114 * 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 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 note, use identifiers.
230 c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64
232 r1 r2 r4 r8 r16 r32 r64 r64
238 \notes \relative c'' {
239 a\longa a\breve \autoBeamOff
240 a1 a2 a4 a8 a16 a32 a64 a64
242 r1 r2 r4 r8 r16 r32 r64 r64
247 \remove "Clef_engraver";
248 \remove "Staff_symbol_engraver";
249 \remove "Time_signature_engraver";
250 \consists "Pitch_squash_engraver";
257 As you can see, the longa is not printed. To get a longa note head, you
258 have to use a mensural note heads. This is done accomplished by setting
259 the @code{style} property of the NoteHead grob to @code{mensural}.
261 If the duration is omitted then it is set to the previous duration
262 entered. At the start of parsing a quarter note is assumed. The
263 duration can be followed by a dot (`@code{.}') to obtain dotted note
267 @lilypond[fragment,verbatim,center]
273 You can alter the length of duration by appending
274 `@code{*}@var{fraction}'. This will not affect the appearance of the
275 notes or rests produced.
281 A note specification has the form
284 @var{pitch}[@var{octavespec}][!][?][@var{duration}]
287 LilyPond will determine what accidentals to typeset depending on the key
288 and context. The alteration refers to what note is heard, not to whether
289 an accidental is printed. A reminder accidental
290 @cindex reminder accidental
292 can be forced by adding an exclamation mark @code{!} after the pitch. A
293 cautionary accidental,
294 @cindex cautionary accidental
295 i.e., an accidental within parentheses can be obtained by adding the
296 question mark `@code{?}' after the pitch.
298 @lilypond[fragment,verbatim,center]
299 cis' d' e' cis' c'? d' e' c'!
303 @node Easy Notation note heads
304 @subsection Easy Notation note heads
306 @cindex easy notation
309 A entirely different type of note head is the "easyplay" note head: a
310 note head that includes a note name. It is used in some publications by
311 Hal-Leonard Inc. music publishers.
313 @lilypond[singleline,verbatim]
314 \include "paper26.ly"
316 \notes { c'2 e'4 f' | g'1 }
317 \paper { \translator { \EasyNotation } }
321 Note that @code{EasyNotation} overrides a @code{Score} context. You
322 probably will want to print it with magnification to make it better
328 If you view the result with Xdvi, then staff lines will show through the
329 letters. Printing the postscript file obtained either by using dvips or
330 the @code{-f ps} option of lilypond will produce the desired result.
340 A tie connects two adjacent note heads of the same pitch. When used
341 with chords, it connects all of the note heads whose pitches match.
342 Ties are indicated using the tilde symbol `@code{~}'.
343 If you try to tie together chords which have no common pitches, a
344 warning message will appear and no ties will be created.
346 @lilypond[fragment,verbatim,center]
347 e' ~ e' <c' e' g'> ~ <c' e' g'>
350 If you dislike the amount of ties created for a chord, you set
351 @code{Voice.sparseTies} to true, resulting in a smaller number of
353 @lilypond[fragment,verbatim,center]
354 \property Voice.sparseTies = ##t
355 <c' e' g'> ~ <c' e' g'>
358 In its meaning a tie is just a way of extending a note duration, similar
359 to the augmentation dot: the following example are three ways of notating
360 exactly the same concept.
361 @lilypond[fragment, singleline]
367 At present, the tie is implemented as a separate thing, temporally
368 located in between the notes. There is also no way to convert
369 between tied notes, dotted notes and plain notes.
371 Tieing only a subset of the note heads of a chord is not supported in a
372 simple way. It can be achieved by moving the tie-engraver into Thread
373 context and turning off ties per Thread.
381 @cindex @code{\times}
383 Tuplets are made out of a music expression by multiplying their duration
386 @cindex @code{\times}
388 \times @var{fraction} @var{musicexpr}
391 The duration of @var{musicexpr} will be multiplied by the fraction.
392 In print, the fraction's denominator will be printed over the notes,
393 optionally with a bracket. The most common tuplet is the triplet in
394 which 3 notes have the length of 2, so the notes are 2/3 of
395 their written length:
397 @lilypond[fragment,verbatim,center]
398 g'4 \times 2/3 {c'4 c' c'} d'4 d'4
401 The property @code{tupletSpannerDuration} specifies how long brackets
402 should last. With this, you can make lots of tuplets while typing
403 @code{\times} only once. This saves typing work when you must make lots
406 @lilypond[fragment, relative, singleline, verbatim]
407 \property Voice.tupletSpannerDuration = #(make-moment 1 4)
408 \times 2/3 { c''8 c c c c c }
416 Rests are entered like notes, with note name `@code{r}'.
426 \skip @var{duration} @code{;}
431 Skips the amount of time specified by @var{duration}. If no other music
432 is played, a gap will be left for the skipped time with no notes
433 printed. The shorthand is only available in Note and Chord mode.
438 @subsection Note mode
443 @cindex @code{\notes}
445 Note mode is the lexical mode generally used for inputting notes. The
451 This instructs the tokenizer to interpret @var{expr} in note mode. If a
452 a sequence of alfabetical characters, like @code{foobar}, LilyPond first
453 checks if @code{foobar} is a pitch name. If it is not a pitch name,
454 then it is treated as a string.
456 Numbers and dots indicate durations, so you can enter floating point
457 numbers in this mode.
461 @section Staff notation
463 @cindex Staff notation
475 @subsection Key signature
480 Changing the key signature is done with the @code{\key} command.
482 @code{\key} @var{pitch} @var{type} @code{;}
485 @cindex @code{\minor}
486 @cindex @code{\major}
487 @cindex @code{\minor}
488 @cindex @code{\ionian}
489 @cindex @code{\locrian}
490 @cindex @code{\aeolian}
491 @cindex @code{\mixolydian}
492 @cindex @code{\lydian}
493 @cindex @code{\phrygian}
494 @cindex @code{\dorian}
496 Here, @var{type} should be @code{\major} or @code{\minor} to get
497 @var{pitch}-major or @var{pitch}-minor, respectively. The second
498 argument is optional; the default is major keys. The @var{\context}
499 argument can also be given as an integer, which tells the number of
500 semitones that should be added to the pitch given in the subsequent
501 @code{\key} commands to get the corresponding major key, e.g.,
502 @code{\minor} is defined as 3. The standard mode names @code{\ionian},
503 @code{\locrian}, @code{\aeolian}, @code{\mixolydian}, @code{\lydian},
504 @code{\phrygian}, and @code{\dorian} are also defined.
506 This command sets context property @code{Staff.keySignature}.
508 @cindex @code{keySignature}
515 \clef @var{clefname} @code{;}
521 \property Staff.clefGlyph = @var{glyph associated with clefname}
522 \property Staff.clefPosition = @var{clef Y-position for clefname}
523 \property Staff.clefOctavation = @var{extra pitch of clefname}
526 Supported clef-names include
529 @item treble, violin, G, G2: G clef on 2nd line
530 @item french: G clef on 1st line
531 @item soprano: C clef on 1st line
532 @item mezzosoprano: C clef on 2nd line
533 @item alto: C clef on 3rd line
534 @item tenor: C clef on 4th line
535 @item baritone: C clef on 5th line
536 @item varbaritone: F clef on 3rd line
537 @item bass, F: F clef on 4th line
538 @item subbass: F clef on 5th line
539 @item percussion: percussion clef
542 Supported associated glyphs (for @code{Staff.clefGlyph}) are:
545 @item clefs-C: modern style C clef
546 @item clefs-F: modern style F clef
547 @item clefs-G: modern style G clef
548 @item clefs-vaticana_do: Editio Vaticana style do clef
549 @item clefs-vaticana_fa: Editio Vaticana style fa clef
550 @item clefs-medicaea_do: Editio Medicaea style do clef
551 @item clefs-medicaea_fa: Editio Medicaea style fa clef
552 @item clefs-mensural1_c: modern style mensural C clef
553 @item clefs-mensural2_c: historic style small mensural C clef
554 @item clefs-mensural3_c: historic style big mensural C clef
555 @item clefs-mensural1_f: historic style traditional mensural F clef
556 @item clefs-mensural2_f: historic style new mensural F clef
557 @item clefs-mensural_g: historic style mensural G clef
558 @item clefs-hufnagel_do: historic style hufnagel do clef
559 @item clefs-hufnagel_fa: historic style hufnagel fa clef
560 @item clefs-hufnagel_do_fa: historic style hufnagel combined do/fa clef
561 @item clefs-percussion: modern style percussion clef
564 @emph{Modern style} means ``as is typeset in current editions.''
565 @emph{Historic style} means ``as was typeset or written in contemporary
566 historic editions''. @emph{Editio XXX style} means ``as is/was printed in
569 @cindex Vaticana, Editio
570 @cindex Medicaea, Editio
571 @cindex hufnagel clefs
574 @c . {Time signature}
576 @subsection Time signature
577 @cindex Time signature
581 The time signature is changed by the @code{\time} command. Syntax:
583 \time @var{numerator}@code{/}@var{denominator} @code{;}
585 Internally, this is a shortcut for doing
587 \property Score.timeSignatureFraction = #'(@var{numerator} . @var{denominator})
590 [TODO: discuss options for layout]
597 @cindex partial measure
598 @cindex measure, partial
599 @cindex shorten measures
600 @cindex @code{\partial}
602 Partial measures are entered using the @code{\partial} command:
604 \partial @var{duration} @code{;}
607 Internally, this is a shortcut for
610 \property Score.measurePosition = -@var{length of duration}
615 @node Unmetered music
616 @subsection Unmetered music
618 Bar lines and bar numbers are calculated automatically. For unmetered
619 music (e.g. cadenzas), this is not desirable. The property
620 @code{Score.timing} can be used to switch off this automatic timing
622 @lilypond[fragment,relative,singleline,verbatim]
624 \property Score.timing = ##f
626 \property Score.timing = ##t
630 The identifiers @code{\cadenzaOn} and @code{\cadenzaOff} can be used to
631 achieve the same effect.
637 @subsection Bar lines
641 @cindex measure lines
648 This is a shortcut for doing
650 \property Score.whichBar = @var{bartype}
653 You are encouraged to use @code{\repeat} for repetitions. See
654 @ref{Repeats}, and the documentation of @code{whichBar} in the generated
658 @cindex Bar_line_engraver
660 @cindex repeatCommands
661 @cindex defaultBarType
663 Bar lines are created by the @code{Bar_line_engraver}. That engraver examines
664 @code{whichBar} at every moment. Whenever it is set to a string, it will
665 create a bar with that type. @code{whichBar} is usually set
666 automatically: at the start of a measure it is set to
667 @code{defaultBarType}. The contents of @code{repeatCommands} is used to
668 override default measure bars.
670 @code{whichBar} can also be set directly, using @code{\property} or
671 @code{\bar ; }. These settings take precedence over automatic @code{whichBar}
680 Polyphonic parts, i.e. parts with more than one voice on a staff can be
681 typeset with LilyPond. To use this, instantiate a separate Voice
682 context for each part, and assign a stem direction to each part.
683 @lilypond[fragment,verbatim]
685 < \context Voice = VA { \stemUp b'4 a' g' f' e' }
686 \context Voice = VB { \stemDown g'4 g' g' g' g' } >
689 When there are more than two voices on a staff, you must also indicate
690 which voice should moved horizontally in case of a collision. This can
691 be done with the identifiers @code{\shiftOff}, @code{\shiftOn},
692 @code{\shiftOnn}, etc. (which sets grob property @code{horizontal-shift}
693 in @code{NoteColumn}).
695 @lilypond[fragment, verbatim]
696 \context Staff \notes\relative c''<
703 \context Voice=three {
704 \shiftOnn \stemUp ais
706 \context Voice=four {
707 \shiftOnnn \stemUp fis-2
712 The most convenient way is to use the identifiers @code{\voiceOne}
713 through @code{\voiceFour}, which also set slur and tie directions in the
716 @lilypond[singleline, verbatim]
718 \context Staff < \context Voice = VA { \voiceOne cis2 b }
719 \context Voice = VB { \voiceThree b4 ais ~ ais4 gis4 }
720 \context Voice = VC { \voiceTwo fis4~ fis4 f ~ f } >
724 LilyPond also vertically shifts rests that are opposite of a stem.
726 @lilypond[singleline,verbatim]
728 \context Voice { \stemUp c''4 }
729 \context Voice =VB { r4 }
733 Note head collisions (horizontal shifting of note heads) are handled by
734 the @code{NoteCollision} grob. @code{RestCollision} handles vertical
737 @cindex @code{NoteCollision}
738 @cindex @code{RestCollision}
743 Resolving collisions is a very intricate subject, and LilyPond only
744 handles a few situations. When it can not cope, you are advised to use
745 @code{force-hshift} of the NoteColumn grob and @code{staff-position} of
746 the Rest grob to override typesetting decisions.
748 [TODO: doc merge-differently-dotted]
753 Beams are used to group short notes into chunks that are aligned with
754 the metrum. LilyPond guesses where beams should be inserted, but if
755 you're not satisfied with the automatic beaming, you can either instruct
756 lilypond which patterns to beam automatically. In specific cases, you
757 can also specify explicitly what to beam and what not.
760 @c . {Automatic beams}
761 @subsection Automatic beams
763 @cindex @code{Voice.autoBeamSettings}
764 @cindex @code{(end * * * *)}
765 @cindex @code{(begin * * * *)}
767 A large number of Voice properties are used to decide how to generate
768 beams. Their default values appear in @file{scm/auto-beam.scm}.
770 By default, automatic beams can start on any note@footnote{In exotic
771 time signatures such as 1/8 and 1/16 this is not true} but can only end
772 in a few positions within the measure: they can end on a beat, or at
773 durations specified by the properties in
774 @code{Voice.autoBeamSettings}. The defaults for @code{autoBeamSettings}
775 are defined in @file{scm/auto-beam.scm}.
777 The syntax for changing the value @code{autoBeamSettings} is set using
778 @code{\override} and unset using @code{\revert}:
780 \property Voice.autoBeamSettings \override #'(@var{BE} @var{N} @var{M} @var{P} @var{Q}) = @var{dur}
781 \property Voice.autoBeamSettings \revert #'(@var{BE} @var{N} @var{M} @var{P} @var{Q})
783 Here, @var{BE} is the symbol @code{begin} or @code{end}. It determines
784 whether the rule applies to begin or end-points. The quantity
785 @var{N}/@var{M} refers to a time signature (@code{* *} may be entered to
786 designate all time signatures), @var{P}/@var{Q} refers to the length of
787 the beamed notes (@code{* *} designate notes of any length).
789 If you want automatic beams to end on every quarter note, you can
792 \property Voice.autoBeamSettings \override
793 #'(end * * * *) = #(make-moment 1 4)
795 The duration a quarter note is 1/4 of a whole note. It is entered as
796 @code{(make-moment 1 4)}.
798 The same syntax can be used to specify beam starting points. In this
799 example, you automatic beams can only end on a dotted quarter note.
801 \property Voice.autoBeamSettings \override
802 #'(begin * * * *) = #(make-moment 3 8)
804 In 4/4 time signature, this means that automatic beams could end only on
805 3/8 and on the fourth beat of the measure (after 3/4, that is 2 times
806 3/8 has passed within the measure).
808 You can also restrict rules to specific time signatures. A rule that
809 should only be applied in @var{N}/@var{M} time signature is formed by
810 replacing the first asterisks by @var{N} and @var{M}. For example, a
811 rule for 6/8 time exclusively looks like
813 \property Voice.autoBeamSettings \override
814 #'(begin 6 8 * *) = ...
817 If you want a rule to apply to certain types of beams, you can use the
818 second pair of asterisks. Beams are classified according to the shortest
819 note they contain. For a beam ending rule that only applies to beams
820 with 32nd notes (and no shorter notes), you would use @code{(end * * 1
824 @c Automatic beams can not be put on the last note in a score.
826 If a score ends while an automatic beam has not been ended and is still
827 accepting notes, this last beam will not be typeset at all.
829 @cindex automatic beam generation
831 @cindex @code{Voice.noAutoBeaming}
833 Automatic beaming is on by default, but it can switched off by setting
834 @code{Voice.noAutoBeaming} to true. You you may find this necessary for
835 a melody that goes with lyrics.
839 It is not possible to specify beaming parameters for beams with mixed
840 durations, that differ from the beaming parameters of all separate
841 durations, ie, you'll have to specify manual beams to get:
842 @lilypond[fragment,singleline,relative]
843 \property Voice.autoBeamSettings
844 \override #'(end * * * *) = #(make-moment 3 8)
845 \time 12/8; c'8 c c c16 c c c c c [c c c c] c8 c c4
848 It is not possible to specify beaming parameters that act differently in
849 different parts of a measure, eg, in irregular meters such as @code{5/8}
850 that breaks down to @code{2/8 +3/8} or @code{3/8 + 2/8}, automatic beams
851 won't act according to the broken down parts @code{2/8} and @code{3/8}.
854 @cindex Automatic beams
855 @subsection Manual beams
856 @cindex beams, manual
860 In some cases it may be necessary to override LilyPond's automatic
861 beaming algorithm. For example, the auto beamer will not beam over
862 rests or bar lines, so if you want that, specify the begin and end point
863 manually using @code{[} and @code{]}:
865 @lilypond[fragment,relative,verbatim]
867 r4 [r8 g'' a r8] r8 [g | a] r8
870 Whenever an manual beam is busy, the auto beam will not produce
873 @cindex @code{stemLeftBeamCount}
875 If you have specific wishes for the number of beams, you can fully
876 control the number of beams through the properties
877 @code{Voice.stemLeftBeamCount} and @code{Voice.stemRightBeamCount}.
879 @lilypond[fragment,relative,verbatim]
882 [f8 r16 \property Voice.stemLeftBeamCount = #1 f g a]
885 @cindex @code{stemRightBeamCount}
887 The beam symbol can be tweaked through @code{Voice.Beam}'s
888 grob-properties @code{height} and @code{staff-position},
891 Set @code{height} to zero, to get horizontal beams:
893 @lilypond[fragment,relative,verbatim]
894 \property Voice.Beam \set #'direction = #1
895 \property Voice.Beam \set #'height = #0
899 Here's how you'd specify a weird looking beam that instead of being
900 horizontal, falls two staff spaces:
902 @lilypond[fragment,relative,verbatim]
903 \property Voice.Beam \set #'staff-position = #2
904 \property Voice.Beam \set #'height = #-2
907 @cindex @code{default-neutral-direction}
909 @node Expressive marks
910 @section Expressive marks
925 A slur indicates that notes are to be played bound or @emph{legato}. In
926 lilypond, they are entered using parentheses:
927 @lilypond[fragment,verbatim,center]
928 f'()g'()a' [a'8 b'(] a'4 g'2 )f'4
932 Slurs avoid crossing stems, and are attached to note heads whenever
933 possible. In some instances involving beams slurs may be attached to a
934 stem end. If you want to override this layout you can do this through
935 @code{Voice.Slur}'s grob-property @code{attachment}:
937 Maybe reinclude other slur features and move back to tricks? Esp. the
938 second example, how to fix, can be very helpful.
940 @lilypond[fragment,relative,verbatim]
941 \property Voice.Slur \set #'direction = #1
942 \property Voice.Stem \set #'length = #5.5
944 \property Voice.Slur \set #'attachment = #'(stem . stem)
948 If a slur would strike through a stem or beam, the slur will be moved
949 away upward or downward. If this happens, attaching the slur to the
950 stems might look better:
952 @lilypond[fragment,relative,verbatim]
953 \property Voice.Stem \set #'direction = #1
954 \property Voice.Slur \set #'direction = #1
956 \property Voice.Slur \set #'attachment = #'(stem . stem)
961 Similarly, the curvature of a slur is adjusted to stay clear of note
962 heads and stems. When that would increase the curvature too much, the
963 slur is reverted to its default shape. The threshold for this decision
964 is in @code{Voice.Slur}'s grob-property @code{beautiful}. It is loosely
965 related to the enclosed area between the slur and the notes. Usually,
966 the default setting works well, but in some cases you may prefer a
967 curved slur when LilyPond decides for a vertically moved one. You can
968 express this by increasing the @code{beautiful} value:
970 @lilypond[verbatim,singleline,relative]
971 \property Voice.Beam \override #'direction = #-1
972 \property Voice.Slur \override #'direction = #1
973 c'16( a' f' a a f a, )c,
975 \property Voice.Slur \override #'beautiful = #5.0
981 The definition for @code{beautiful} is vague, the default setting is
982 experimental computer science.
984 @cindex Adusting slurs
987 @subsection Phrasing slur
989 @cindex phrasing slur
990 @cindex phrasing mark
992 A phrasing slur (or phrasing mark) connects chords and is used to
993 indicate a musical sentence. It is entered using @code{\(} and
996 @lilypond[fragment,verbatim,center,relative]
997 \time 6/4; c''\((d)e f(e)\)d
1000 Typographically, the phrasing slur behaves almost exactly like a normal
1001 slur. The grob associated with it is @code{Voice.PhrasingSlur}.
1004 @subsection Breath marks
1006 Breath marks are entered using @code{\breathe}:
1008 @lilypond[fragment,relative]
1012 Currently, only tick marks are supported, comma style breath marks are
1013 not. The grob for this object is called @code{Voice.BreathingSign}.
1018 Currently, only tick marks are supported, comma style breath marks are
1026 @cindex beats per minute
1027 @cindex metronome marking
1029 @cindex @code{\tempo}
1031 \tempo @var{duration} = @var{perminute} @code{;}
1034 Used to specify the tempo. For example, @code{\tempo 4 = 76;} requests
1035 output with 76 quarter notes per minute.
1039 The tempo setting is not printed, but is currently only used in the MIDI
1045 @subsection Text spanner
1046 @cindex Text spanner
1048 Some textual indications, e.g. rallentando, accelerando, often extend
1049 over a many measures. This is indicated by following the text with a
1050 dotted line. You can create such texts in LilyPond using
1051 text spanners. The syntax is as follows:
1053 \spanrequest \start "text"
1054 \spanrequest \stop "text"
1056 LilyPond will respond by creating a @code{Voice.TextSpanner} grob. The
1057 string to be printed, as well as the style is set through grob
1060 An application---or rather, a hack---is to fake octavation indications.
1061 @lilypond[fragment,relative,verbatim]
1062 \relative c' { a'''' b c a
1063 \property Voice.TextSpanner \set #'type = #'dotted-line
1064 \property Voice.TextSpanner \set #'edge-height = #'(0 . 1.5)
1065 \property Voice.TextSpanner \set #'edge-text = #'("8va " . "")
1066 \property Staff.centralCPosition = #-13
1067 a\spanrequest \start "text" b c a \spanrequest \stop "text" }
1085 @subsection Articulation
1086 @cindex Articulation
1088 @cindex articulations
1092 A variety of symbols can appear above and below notes to indicate
1093 different characteristics of the performance. These symbols can be
1094 added to a note with `@var{note}@code{-\}@var{name}'. Numerous symbols
1095 are defined in @file{script.ly} and @file{script.scm}. Symbols can be
1096 forced to appear above or below the note by writing
1097 `@var{note}@code{^\}@var{name}' and `@var{note}@code{_\}@var{name}'
1098 respectively. Here is a chart showing symbols above notes, with the
1099 name of the corresponding symbol appearing underneath.
1104 \property Score.LyricSyllable \override #'font-family =
1106 \property Score.LyricSyllable \override #'font-shape = #'upright
1107 c''-\accent c''-\marcato c''-\staccatissimo c''-\fermata
1108 c''-\stopped c''-\staccato c''-\tenuto c''-\upbow
1109 c''-\downbow c''^\lheel c''-\rheel c''^\ltoe
1110 c''-\rtoe c''-\turn c''-\open c''-\flageolet
1111 c''-\reverseturn c''-\trill c''-\prall c''-\mordent
1112 c''-\prallprall c''-\prallmordent c''-\upprall c''-\downprall
1113 c''-\thumb c''-\segno c''-\coda
1115 \context Lyrics \lyrics {
1116 accent__ marcato__ staccatissimo__ fermata
1117 stopped__ staccato__ tenuto__ upbow
1118 downbow__ lheel__ rheel__ ltoe
1119 rtoe__ turn__ open__ flageolet
1120 reverseturn__ trill__ prall__ mordent
1121 prallprall__ prallmordent__ uprall__ downprall
1122 thumb__ segno__ coda
1126 linewidth = 5.875\in;
1132 To save typing work, some shorthands are available:
1133 @lilypond[singleline]
1135 \notes \context Voice {
1136 \property Voice.TextScript \set #'font-family = #'typewriter
1137 \property Voice.TextScript \set #'font-shape = #'upright
1143 c''4-^_"c-\\^{ }" s4
1150 Fingering instructions can also be entered in this shorthand.
1151 @lilypond[verbatim, singleline, fragment]
1152 c'4-1 c'4-2 c'4-3 c'4-4
1156 @cindex @code{\script}
1165 Defines a script printing request. The argument is a string which
1166 points into the script-alias table defined in @file{scm/script.scm}.
1167 Usually the @code{\script} keyword is not used directly. Various
1168 helpful identifier definitions appear in @file{script.ly}.
1170 For information on how to add scripts, consult @file{scm/script.scm}.
1175 All of these note ornaments appear in the printed output but have no
1176 effect on the MIDI rendering of the music.
1178 Unfortunately, there is no support adding fingering instructions or
1179 ornaments to individual note heads. Some hacks exist, though. See
1180 @file{input/test/script-horizontal.ly}.
1185 @subsection Text scripts
1186 @cindex Text scripts
1188 In addition, it is possible to place arbitrary strings of text or markup
1189 text (see @ref{Text markup}) above or below notes by using a string:
1190 @code{c^"text"}. The text is typeset in italic by default.
1192 The amount of space taken by these indications by default does not
1193 influence, spacing, but setting @code{Voice.textNonEmpty} to true will
1194 take the widths into account. The identifier @code{\fattext} is defined
1195 in the standard includes.
1196 @lilypond[fragment,singleline,verbatim]
1197 \relative c' { c4^"longtext" \fatText c4_"longlongtext" c4 }
1200 Text scripts are created in form of @code{Voice.TextScript} grobs.
1202 For purposes of defining identifiers, a more verbose form also exists:
1205 \textscript @var{text}
1208 Defines a text to be printed over or under a note. @var{text} is a
1209 string or a markup text.
1213 foo = \textscript #'(finger "6")
1220 This is equivalent to @code{c4-6 c4-"foo"}.
1225 @subsection Grace notes
1234 @cindex @code{\grace}
1237 @cindex @code{graceAlignPosition}
1239 Grace notes are ornaments that are written out, but do not take up any
1240 logical time in a measure. LilyPond has limited support for grace notes.
1241 The syntax is as follows.
1243 \grace @var{musicexpr}
1246 When grace music is interpreted, a score-within-a-score is set up:
1247 @var{musicexpr} has its own time bookkeeping, and you could (for
1248 example) have a separate time signature within grace notes. While in
1249 this score-within-a-score, you can create notes, beams, slurs, etc.
1250 Unbeamed eighth notes and shorter by default have a slash through the
1251 stem. This behavior can be controlled with the
1252 @code{Stem}.@code{flag-style} property.
1254 @lilypond[fragment,verbatim]
1256 \grace c8 c4 \grace { [c16 c16] } c4
1257 \grace { \property Grace.Stem \override #'flag-style = #'() c16 } c4
1262 At present, nesting @code{\grace} notes is not supported. The following
1263 may cause run-time errors:
1265 @code{\grace @{ \grace c32 c16 @} c4}
1267 Since the meaning of such a construct is unclear, we don't consider this
1268 a loss. Similarly, juxtaposing two @code{\grace} sections is
1269 syntactically valid, but makes no sense and may cause runtime errors.
1270 Ending a staff or score with grace notes may also generate a run-time
1271 error, since there will be no main note to attach the grace notes to.
1274 A grace note expression has duration 0; the next real note is assumed to
1275 be the main note. If you want the note to appear after the main note,
1276 set @code{Voice.graceAlignPosition} to @code{1}.
1280 The present implementation of grace notes is not robust and generally
1281 kludgy. We expect it to change after LilyPond 1.4. Syntax changes might
1282 also be implemented.
1295 @subsection Glissando
1298 @cindex @code{\glissando}
1300 A glissando line can be requested by attaching a @code{\glissando} to a
1303 @lilypond[fragment,relative,verbatim]
1309 Printing of an additional text (such as @emph{gliss.}) must be done
1316 @subsection Dynamics
1329 @cindex @code{\ffff}
1339 Absolute dynamic marks are specified by using an identifier after a
1340 note: @code{c4-\ff}. The available dynamic marks are: @code{\ppp},
1341 @code{\pp}, @code{\p}, @code{\mp}, @code{\mf}, @code{\f}, @code{\ff},
1342 @code{\fff}, @code{\fff}, @code{\fp}, @code{\sf}, @code{\sff},
1343 @code{\sp}, @code{\spp}, @code{\sfz}, and @code{\rfz}.
1345 @lilypond[verbatim,singleline,fragment,relative]
1346 c''\ppp c\pp c \p c\mp c\mf c\f c\ff c\fff
1350 @cindex Crescendo and Decrescendo
1354 @cindex @code{\decr}
1355 @cindex @code{\rced}
1361 A crescendo mark is started with @code{\cr} and terminated with
1362 @code{\rc} (the textual reverse of @code{cr}). A decrescendo mark is
1363 started with @code{\decr} and terminated with @code{\rced}. There are
1364 also shorthands for these marks. A crescendo can be started with
1365 @code{\<} and a decrescendo can be started with @code{\>}. Either one
1366 can be terminated with @code{\!}. Note that @code{\!} must go before
1367 the last note of the dynamic mark whereas @code{\rc} and @code{\rced} go
1368 after the last note. Because these marks are bound to notes, if you
1369 want to get several marks during one note, you must use spacer notes.
1371 @lilypond[fragment,verbatim,center]
1372 c'' \< \! c'' d'' \decr e'' \rced
1373 < f''1 { s4 s4 \< \! s4 \> \! s4 } >
1376 You can also use a text saying @emph{cresc.} instead of hairpins. Here
1377 is an example how to do it:
1379 @lilypond[fragment,relative,verbatim]
1381 \property Voice.crescendoText = "cresc."
1382 \property Voice.crescendoSpanner = #'dashed-line
1395 @cindex @code{\repeat}
1397 To specify repeats, use the @code{\repeat} keyword. Since repeats
1398 should work differently when played or printed, there are a few
1399 different variants of repeats.
1403 Repeated music is fully written (played) out. Useful for MIDI
1407 This is the normal notation: Repeats are not written out, but
1408 alternative endings (voltas) are printed, left to right.
1411 Alternative endings are written stacked. Which is unfortunately not
1412 practical for anything right now.
1418 Make measure repeats. These look like percent signs.
1424 * Manual repeat commands::
1426 * Tremolo subdivision::
1431 @subsection Repeat syntax
1433 The syntax for repeats is
1436 \repeat @var{variant} @var{repeatcount} @var{repeatbody}
1439 If you have alternative endings, you may add
1440 @cindex @code{\alternative}
1442 \alternative @code{@{} @var{alternative1}
1444 @var{alternative3} @dots{} @code{@}}
1446 where each @var{alternative} is a music expression.
1448 Normal notation repeats are used like this:
1449 @lilypond[fragment,verbatim]
1451 \repeat volta 2 { c'4 d' e' f' }
1452 \repeat volta 2 { f' e' d' c' }
1455 With alternative endings:
1456 @lilypond[fragment,verbatim]
1458 \repeat volta 2 {c'4 d' e' f'}
1459 \alternative { {d'2 d'} {f' f} }
1462 Folded repeats look like this:@footnote{Folded repeats offer little
1463 more over simultaneous music. However, it is to be expected that
1464 more functionality -- especially for the MIDI backend -- will be
1465 implemented at some point in the future.}
1467 @lilypond[fragment,verbatim]
1469 \repeat fold 2 {c'4 d' e' f'}
1470 \alternative { {d'2 d'} {f' f} }
1474 If you don't give enough alternatives for all of the repeats, then
1475 the first alternative is assumed to be repeated often enough to equal
1476 the specified number of repeats.
1478 @lilypond[fragment,verbatim]
1482 \repeat volta 3 { e | c2 d2 | e2 f2 | }
1483 \alternative { { g4 g g } { a | a a a a | b2. } }
1490 As you can see, LilyPond doesn't remember the timing information, nor
1491 are slurs or ties repeated, so you have to reset timing information
1492 after a repeat, e.g. using a bar-check (See @ref{Bar check}),
1493 @code{Score.measurePosition} or @code{\partial}. We hope to fix this
1496 It is possible to nest @code{\repeat}, although it probably is only
1497 meaningful for unfolded repeats.
1499 @node Manual repeat commands
1500 @subsection Manual repeat commands
1502 @cindex @code{repeatCommands}
1504 The property @code{repeatCommands} can be used to control the layout of
1505 repeats. Its value is a Scheme list of repeat commands, where each repeat
1513 @item (volta . @var{text})
1514 Print a volta bracket saying @var{text}.
1516 Stop a running volta bracket
1519 @lilypond[verbatim, fragment]
1521 \property Score.repeatCommands = #'((volta "93") end-repeat)
1523 \property Score.repeatCommands = #'((volta #f))
1528 @node Tremolo repeats
1529 @subsection Tremolo repeats
1530 @cindex tremolo beams
1532 To place tremolo marks between notes, use @code{\repeat} with tremolo
1534 @lilypond[verbatim,center,singleline]
1536 \context Voice \notes\relative c' {
1537 \repeat "tremolo" 8 { c16 d16 }
1538 \repeat "tremolo" 4 { c16 d16 }
1539 \repeat "tremolo" 2 { c16 d16 }
1540 \repeat "tremolo" 4 c16
1548 At present, the spacing between tremolo beams is not regular, since the
1549 spacing engine does not notice that not all notes are printed.
1551 @node Tremolo subdivision
1552 @subsection Tremolo subdivision
1553 @cindex tremolo marks
1554 @cindex @code{tremoloFlags}
1556 Tremolo marks can be printed on a single note by adding
1557 `@code{:}[@var{length}]' after the note. The length must be at least 8.
1558 A @var{length} value of 8 gives one line across the note stem. If the
1559 length is omitted, then then the last value (stored in
1560 @code{Voice.tremoloFlags}) is used.
1562 @lilypond[verbatim,fragment,center]
1565 Using this mechanism pays off when you entering many tremolos, since the
1566 default argument saves a lot of typing.
1571 Tremolos in this style do not carry over into the MIDI output.
1574 @node Measure repeats
1575 @subsection Measure repeats
1577 @cindex percent repeats
1578 @cindex measure repeats
1580 In the @code{percent} style, a note pattern can be repeated. It is
1581 printed once, and then the pattern is replaced with a special sign.
1583 @lilypond[verbatim,singleline]
1584 \context Voice { \repeat "percent" 4 { c'4 }
1585 \repeat "percent" 2 { c'2 es'2 f'4 fis'4 g'4 c''4 }
1591 You can not nest percent repeats, filling in the first measure with
1592 slashes, and repeating that measure with percents.
1594 @node Rhythmic music
1595 @section Rhythmic music
1602 @node Rhythmic staffs
1603 @subsection Rhythmic staffs
1605 Some times you might want to show only the rhythm of a melody. This can
1606 be done with the rhythmic staff. All pitches of notes on such a staff
1607 are squashed, and the staff itself looks has a single staff line:
1609 @lilypond[fragment,relative ]
1610 \context RhythmicStaff {
1612 c4 e8 f g2 | r4 g r2 | g1:32 | r1 |
1619 @section Piano music
1621 Piano music is an odd type of notation: two staffs are largely
1622 independent, but sometimes voices can cross between the two staffs. The
1623 @code{PianoStaff} is especially built to handle this cross-staffing
1624 behavior. In this section we discuss the @code{PianoStaff} and some
1625 other pianistic peculiarities.
1628 * Automatic staff changes::
1629 * Manual staff switches::
1636 @c . {Automatic staff changes}
1637 @node Automatic staff changes
1638 @subsection Automatic staff changes
1639 @cindex Automatic staff changes
1641 Voices can be switched from top to bottom staff automatically. The
1644 \autochange @var{contexttype} @var{musicexp}
1646 This will switch notation context of @var{musicexp} between a
1647 @var{contexttype} named @code{up} and @code{down}. Typically, you use
1648 @code{Staff} for @var{contexttype}. The autochanger switches on basis
1649 of pitch (central C is the turning point), and it looks ahead skipping
1650 over rests to switch rests in advance.
1652 @lilypond[verbatim,singleline]
1653 \score { \notes \context PianoStaff <
1654 \context Staff = "up" {
1655 \autochange Staff \context Voice = VA < \relative c' {
1656 g4 a b c d r4 a g } > }
1657 \context Staff = "down" {
1663 Note how spacer rests are used to prevent the bottom staff from
1664 terminating too soon.
1667 @node Manual staff switches
1668 @subsection Manual staff switches
1670 @cindex manual staff switches
1671 @cindex staff switch, manual
1673 Voices can be switched between staffs manually, using the following command:
1675 \translator Staff = @var{which} @var{music}
1677 The string @var{which} is the name of the staff. Typically it is
1678 @code{"up"} or @code{"down"}.
1680 Formally, this construct is a music expression indicating that the
1681 context which is a direct child of the a context of type
1682 @var{contexttype} should be shifted to a context of type
1683 @var{contexttype} and the specified name.
1685 @cindex @code{\translator}
1687 \translator @var{contexttype} = @var{name}
1696 Piano pedal instruction can be expressed using
1697 @code{\sustainDown}, @code{\sustainUp}, @code{\unaCorda},
1698 @code{\treCorde}, @code{\sostenutoDown} and @code{\sostenutoUp}.
1700 These identifiers are shorthands for spanner commands of the types
1701 @code{Sustain}, @code{UnaCorda} and @code{Sostenuto}:
1703 @lilypond[fragment,verbatim]
1704 c''4 \spanrequest \start "Sustain" c''4 c''4 \spanrequest \stop "Sustain"
1707 The symbols that are printed can be modified by setting
1708 @code{pedal@var{X}Strings}, where @var{X} is one of the pedal
1709 types. Refer to the generated documentation for more information.
1714 Currently, brackets are not supported, only text markings (ie. *Ped
1720 @subsection Arpeggio
1723 @cindex broken arpeggio
1724 @cindex @code{\arpeggio}
1726 You can specify an arpeggio sign on a chord by attaching an
1727 @code{\arpeggio} to a note of the chord.
1730 @lilypond[fragment,relative,verbatim]
1731 \context Voice <c'\arpeggio e g c>
1734 When an arpeggio crosses staffs in piano music, you attach an arpeggio
1735 to the chords in both staffs, and set
1736 @code{PianoStaff.connectArpeggios}.
1738 @lilypond[fragment,relative,verbatim]
1739 \context PianoStaff <
1740 \property PianoStaff.connectArpeggios = ##t
1741 \context Voice = one { <c''\arpeggio e g c> }
1742 \context Voice = other { \clef bass; <c,,\arpeggio e g>}
1746 This command creates @code{Arpeggio} grobs.
1750 It is not possible to mix
1751 connected arpeggios and unconnected arpeggios at the same time.
1754 @c . {VoiceFollower}
1756 @subsection VoiceFollower
1758 @cindex follow voice
1759 @cindex staff switching
1762 @cindex @code{followVoice}
1764 Whenever a voice switches to another staff a line connecting the notes
1765 can be printed automatically. This is enabled if the property
1766 @code{PianoStaff.followVoice} is set to true:
1768 @lilypond[fragment,relative,verbatim]
1769 \context PianoStaff <
1770 \property PianoStaff.followVoice = ##t
1771 \context Staff \context Voice {
1773 \translator Staff=two
1776 \context Staff=two {\clef bass; \skip 1*2;}
1789 * Automatic syllable durations::
1795 @subsection Lyrics mode
1798 To print lyrics in LilyPond, you must first make a music expression from
1799 the lyric text. When they're in a music expression, that music
1800 expression can be printed by selecting an appropriate context. We shall
1801 discuss lyric printing in this order.
1805 @cindex @code{\lyrics}
1807 You can enter lyrics in a special input mode of LilyPond. This mode is
1808 called Lyrics mode, and it is introduced by the keyword @code{\lyrics}.
1809 The purpose of this mode is that you can enter lyrics as plain text,
1810 punctuation and accents without any hassle.
1812 The precise definition of this mode is in @ref{Lyrics mode
1813 definition}. The definition itself is ludicrous, and this will remain so
1814 until the authors of LilyPond acquire a deeper understanding of
1815 character encoding, or someone else steps up to fix this.
1817 Syllables are entered like notes, with pitches replaced by text. For
1818 example, @code{Twin- kle twin- kle} enters four syllables. Note that
1819 the hyphen has no special meaning for lyrics, and does not introduce
1822 Spaces can be introduced into a lyric either by using quotes
1823 (@code{"}) or by using an underscore without quotes: @code{He_could4
1824 not4}. All unquoted underscores are converted to spaces.
1826 @c . {Printing lyrics}
1827 @node Printing lyrics
1828 @subsection Printing lyrics
1831 Normally, you will want to have notes and syllables matched
1832 automatically. This is accomplished using @code{\addlyrics}, which is
1833 documented in @ref{Automatic syllable durations}. Setting
1834 @code{automaticMelismata} in the melody staff, will cause slurs to be
1835 interpreted as melismata. Lyric syllables must be interpreted within a
1836 @code{Lyrics} context in order to printing them.
1838 @lilypond[verbatim,singleline]
1839 \addlyrics \notes \relative c' {
1841 \property Staff.automaticMelismata = ##t
1844 \context Lyrics \lyrics {
1846 share the so -- ftware; }
1850 @cindex lyric extender
1853 As you can see, extender lines are entered as @code{__}. This will
1854 create an extender, a line that extends over the entire duration of the
1855 lyric. This line will run all the way to the start of the next lyric,
1856 so you may want to shorten it by using a blank lyric (using @code{_}).
1860 If you want to have hyphens centered between syllables (rather than
1861 attached to the end of the first syllable) you can use the special
1862 `@code{-}@code{-}' lyric as a separate word between syllables. This
1863 will result in a hyphen which length varies depending on the space
1864 between syllables, and which will be centered between the syllables.
1866 @cindex Lyric hyphen
1868 @node Automatic syllable durations
1869 @subsection Automatic syllable durations
1870 @cindex Automatic syllable durations
1872 @cindex automatic lyric durations
1873 @cindex @code{\addlyrics}
1875 If you have lyrics that are set to a melody, you can import the rhythm
1876 of that melody into the lyrics using @code{\addlyrics}. The syntax for
1879 \addlyrics @var{musicexpr1 musicexpr2}
1882 This means that both @var{musicexpr1} and @var{musicexpr2} are
1883 interpreted, but that every non-command atomic music expression
1884 (``every syllable'') in @var{musicexpr2} is interpreted using timing
1885 of @var{musicexpr1}.
1886 @cindex @code{automaticMelismata}
1888 If the property @code{automaticMelismata} is set in the
1889 context of @var{musicexpr1}, no lyrics will be put on slurred or tied
1892 @lilypond[verbatim,fragment]
1895 \property Voice.automaticMelismata = ##t
1896 c8 () cis d8. e16 f2
1898 \context Lyrics \lyrics {
1902 If you want the lyric lines to be above the melody staff, or in some
1903 other, more complex configuration, then build that configuration first
1904 using simultaneous music, and use @code{\addlyrics} after that.
1906 @lilypond[verbatim, singleline]
1908 \context Lyrics = LA { s1 }
1909 \context Staff = SA { s1 }
1911 \context Staff = SA \relative c' { c4 e g g }
1912 \context Lyrics = LA \lyrics { geen ge -- don -- der } >
1915 For @code{\addlyrics} you should use a single rhythm melody, and single
1916 rhythm lyrics (a constant duration is the obvious choice). If you do
1917 not, you can get undesired effects when using multiple stanzas:
1919 @lilypond[verbatim,fragment]
1922 c8 () cis d8. e16 f2
1924 \context Lyrics \lyrics
1929 It is valid (but probably not very useful) to use notes instead of
1930 lyrics for @var{musicexpr2}.
1933 @subsection More stanzas
1937 If you have multiple stanzas printed underneath each other, the separate
1938 syllables should be aligned around punctuation. LilyPond can do this if
1939 you explain it which lyric lines belong to which melody.
1941 To this end, give the Voice context an identity, and set the LyricsVoice
1942 to name starting with that identity. In the following example, the Voice
1943 identity is @code{duet}, and the identities of the LyricsVoices are
1944 @code{duet-1} and @code{duet-2}.
1947 @lilypond[singleline,verbatim]
1950 \notes \relative c'' \context Voice = duet { \time 3/4;
1952 \lyrics \context Lyrics <
1953 \context LyricsVoice = "duet-1" {
1954 \property LyricsVoice . stanza = "Bert"
1955 Hi, my name is bert. }
1956 \context LyricsVoice = "duet-2" {
1957 \property LyricsVoice . stanza = "Ernie"
1958 Ooooo, ch\'e -- ri, je t'aime. }
1963 You can add stanza numbers by setting @code{LyricsVoice.Stanza} (for the
1964 first system) and @code{LyricsVoice.stz} for the following systems.
1966 @cindex stanza numbering
1974 LilyPond has support for both entering and printing chords. Chords are
1975 a harmonic device that is characterized by a set of pitches. It is
1976 something different from simultaneous music, although you can express a
1977 chord using simultaneous music. In fact, chords are internally stored as
1978 simultaneous music expressions. This means you can enter chords by name,
1979 and print them as note head, or enter as notes and print as chord names:
1982 @lilypond[verbatim,singleline]
1983 twoWays = \notes \transpose c'' {
1993 < \context ChordNames \twoWays
1994 \context Staff \twoWays > }
1997 Note that this example also shows that the LilyPond chord does not
1998 attempt to be intelligent, if you enter @code{f bes d}, it does no
1999 attempt to find out whether it this is an inversion.
2003 * Printing named chords::
2008 @subsection Chords mode
2011 Chord mode is a mode where you can input sets of pitches using common
2012 names. It is introduced by the keyword @code{\chords}. It is similar
2013 to note mode, but words are also looked up in a chord modifier table
2014 (containing @code{maj}, @code{dim}, etc).
2016 Dashes and carets are used to indicate chord additions and subtractions,
2017 so articulation scripts can not be entered in Chord mode.
2019 The syntax for named chords is as follows:
2022 @var{tonic}[@var{duration}][@code{-}@var{modifiers}][@code{^}@var{subtractions}][@code{/}@var{inversion}][@code{/+}@var{bass}].
2025 @var{tonic} should be the tonic note of the chord, and @var{duration}
2026 is the chord duration in the usual notation. There are two kinds of
2027 modifiers. One type is @emph{chord additions}, which are obtained by
2028 listing intervals separated by dots. An interval is written by its
2029 number with an optional @code{+} or @code{-} to indicate raising or
2030 lowering by half a step. Chord additions has two effects: It adds
2031 the specified interval and all lower odd numbered intervals to the
2032 chord, and it may lower or raise the specified interval. Intervals
2033 must be separated by a dot (@code{.}).
2035 Throughout these examples, chords have been shifted around the staff
2036 using @code{\transpose}.
2038 @lilypond[fragment,verbatim]
2042 c:9 c:9-.5+.7+ c:3-.5- c:4.6.8
2052 The second type of modifier that may appear after the @code{:} is a
2053 named modifier. Named modifiers are listed in the file
2054 @file{chord-modifiers.ly}. The available modifiers are @code{m} and
2055 @code{min} which lower the 3rd half a step, `@code{aug}' which
2056 raises the 5th, `@code{dim}' which lowers the 5th,
2057 `@code{maj}' which adds a raised 7th, and `@code{sus}'
2058 which replaces the 5th with a 4th.
2060 @lilypond[fragment,verbatim]
2063 c1:m c:min7 c:maj c:aug c:dim c:sus
2069 Chord subtractions are used to eliminate notes from a chord. The
2070 notes to be subtracted are listed after a @code{^} character,
2073 @lilypond[fragment,verbatim,center]
2082 Chord inversions can be specified by appending `@code{/}' and the name
2083 of a single note to a chord. In a chord inversion, the inverted note is
2084 transposed down until it is the lowest note in the chord. If the
2085 specified note is not in the chord, a warning will be printed.
2087 @lilypond[fragment,verbatim,center]
2097 Bass notes can be added by `@code{/+}' and
2098 the name of a single note to a chord. This has the effect of
2099 adding the specified note to the chord, lowered by an octave,
2100 so it becomes the lowest note in the chord.
2102 @lilypond[fragment,verbatim,center]
2114 @c . {Printing named chords}
2115 @node Printing named chords
2116 @subsection Printing named chords
2118 @cindex printing chord names
2121 @cindex @code{ChordNames}
2124 For displaying printed chord names, use the @code{ChordNames} context.
2125 The chords may be entered either using the notation described above, or
2126 directly using simultaneous music.
2128 @lilypond[verbatim,singleline]
2130 \chords {a1 b c} <d f g> <e g b>
2134 \context ChordNames \scheme
2135 \context Staff \transpose c'' \scheme
2140 You can make the chord changes stand out by setting property
2141 @code{ChordNames.chordChanges} to true. This will only display chord
2142 names when there's a change in the chords scheme and at the start of the
2147 c1:m \break c:m c:m c:m d
2152 \context ChordNames {
2153 \property ChordNames.chordChanges = ##t
2155 \context Staff \transpose c'' \scheme
2159 LilyPond examines chords specified as lists of notes to determine a name
2160 to give the chord. LilyPond will not try to identify chord inversions or
2161 an added bass note, which may result in strange chord names when chords
2162 are entered as a list of pitches:
2164 @lilypond[verbatim,center,singleline]
2173 \context ChordNames \scheme
2174 \context Staff \scheme
2180 By default LilyPond uses chord name system proposed by Harald Banter
2181 (See @ref{Literature}). The system is is unambiguous and has a logical
2182 structure. Typical American style chord names may be selected by
2183 setting the @code{style} property of the @code{ChordNames.ChordName}
2184 grob to @code{'american}. Similarly @code{'jazz} selects Jazz
2187 Routines that determine the names to be printed are written in Scheme,
2188 and may be customized by the user. The code can be found in
2189 @file{scm/chord-name.scm}. Here's an example showing the differences in
2193 @c maybe just junk verbatim option?
2194 @lilypond[verbatim,singleline]
2204 \context ChordNames = banter \scheme
2205 \context ChordNames = american {
2206 \property ChordNames.ChordName \override
2207 #'style = #'american \scheme }
2208 \context ChordNames = jazz {
2209 \property ChordNames.ChordName \override
2210 #'style = #'jazz \scheme }
2211 \context Staff \transpose c'' \scheme
2218 @section Writing parts
2220 Orchestral music involves some special notation, both in the full score,
2221 as in the individual parts. This section explains how to tackle common
2222 problems in orchestral music.
2229 * Instrument names::
2231 * Sound output for transposing instruments::
2232 * Multi measure rests::
2233 * Automatic part combining::
2234 * Hara-kiri staffs::
2237 @c . {Rehearsal marks}
2238 @node Rehearsal marks
2239 @subsection Rehearsal marks
2240 @cindex Rehearsal marks
2242 @cindex @code{\mark}
2243 @cindex @code{Mark_engraver}
2246 \mark @var{unsigned};
2251 With this command, you can print a rehearsal mark above the system. You
2252 can provide a number, a string or a markup text as argument. If there is
2253 no argument, the property @code{rehearsalMark} is used and automatically
2256 @lilypond[fragment,verbatim]
2262 c1 \mark #'(music "scripts-segno") ;
2268 @subsection Bar numbers
2270 Bar numbers are printed at the start of the line by default. This is
2271 done by the @code{Bar_number_engraver} in the Score context.
2275 It is currently not possible to make boxed bar numbers, or print them at
2279 @node Instrument names
2280 @subsection Instrument names
2282 You can specify an instrument name for a staff by setting
2283 @code{Staff.instrument} and @code{Staff.instr}. This will print a string
2284 before the start of the staff. For the first start, @code{instrument} is
2285 used, for the next ones @code{instr} is used.
2287 @lilypond[verbatim,singleline]
2289 \property Staff.instrument = "ploink " { c''4 } }
2291 \translator { \StaffContext
2292 \consists "Instrument_name_engraver"; } } }
2295 This requires that you add the @code{Instrument_name_engraver} to the
2296 staff context. You can also use markup texts to construct more
2297 complicated instrument names:
2300 @lilypond[verbatim,singleline]
2302 '((font-relative-size . -2 ) (music "accidentals--1")))
2305 \property Staff.instrument = #`((kern . 0.5) (lines
2306 "2 Clarinetti" (rows " (B" ,text-flat ")")))
2309 \translator { \StaffContext
2310 \consists "Instrument_name_engraver"; } } }
2316 When you put a name on a grand staff or piano staff (By adding an
2317 @code{Instrument_name_engraver} to that context and setting
2318 e.g. @code{\property GrandStaff.instrument}), the width of the brace is
2319 not taken into account. You must add extra spaces to the end of the name
2320 to avoid a collision.
2323 @subsection Transpose
2325 @cindex transposition of pitches
2326 @cindex @code{\transpose}
2328 A music expression can be transposed with @code{\transpose}. The syntax
2331 \transpose @var{pitch} @var{musicexpr}
2334 This means that middle C in @var{musicexpr} is transposed to
2337 @code{\transpose} distinguishes between enharmonic pitches: both
2338 @code{\transpose cis'} or @code{\transpose des'} will transpose up half
2339 a tone. The first version will print sharps and the second version
2342 @lilypond[fragment,verbatim]
2345 { \key e \major; c d e f }
2347 \transpose des'' { \key e \major; c d e f }
2348 \transpose cis'' { \key e \major; c d e f }
2352 If you want to use both @code{\transpose} and @code{\relative}, then
2353 you must use @code{\transpose} first. @code{\relative} will have no
2354 effect music that appears inside a @code{\transpose}.
2356 @node Sound output for transposing instruments
2357 @subsection Sound output transposing instruments
2359 When you want to play a score containing transposed and untransposed
2360 instruments, you have to instruct LilyPond the pitch offset (in
2361 semitones) for the transposed instruments. This is done using the
2362 @code{transposing} property. It does not affect printed output.
2364 @cindex @code{transposing}
2367 \property Staff.instrument = #"Cl. in B-flat"
2368 \property Staff.transposing = #-2
2372 @c . {Multi measure rests}
2373 @node Multi measure rests
2374 @subsection Multi measure rests
2375 @cindex Multi measure rests
2379 Multi measure rests are entered using `@code{R}'. It is specifically
2380 meant for entering parts: the rest can expand to fill a score with
2381 rests, or it can be printed as a single multimeasure rest This expansion
2382 is controlled by the property @code{Score.skipBars}. If this is set to true,
2383 Lily will not expand empty measures, and the appropriate number is added
2386 @lilypond[fragment,verbatim]
2387 \time 3/4; R2.*2 \property Score.skipBars = ##t R2.*17 R2.*4
2390 Currently, there is no way to condense multiple rests into a single
2393 @cindex condensing rests
2395 @node Automatic part combining
2396 @subsection Automatic part combining
2397 @cindex automatic part combining
2398 @cindex part combiner
2400 Automatic part combining is used to merge two parts of music onto on
2401 staff in an intelligent way. It is aimed primarily at typesetting Hymns
2402 and orchestral scores. When the two parts are identical for a period of
2403 time, only one is shown. In places where the two parts differ, stem
2404 directions are set automatically. Also, soli and @emph{a due} parts can be
2405 identified and marke.
2407 The syntax for part combining is
2410 \partcombine @var{context} @var{musicexpr1} @var{musicexpr2}
2413 where the pieces of music @var{musicexpr1} and @var{musicexpr2} will be
2414 combined into one context @var{context}. The context names of the music
2415 expressions must start with the prefixes @code{one} and @code{two}.
2417 The most useful function of the part combiner to combining threads into
2418 one voice, as common for wind parts in orchestral scores:
2420 @lilypond[verbatim,singleline,fragment]
2422 \context Voice=one \partcombine Voice
2423 \context Thread=one \relative c'' {
2426 \context Thread=two \relative c'' {
2432 Notice that the first @code{g} appears only once, although it was
2433 specified twice (once in each Thread). Also note that stem, slur and tie
2434 directions are set automatically, depending whether there is a solo or
2435 unisono. The Thread called @code{one} always gets up stems, and "solo",
2436 while @code{two} always gets down stems and "Solo II".
2438 If you just want the splitting of Threads and setting of directions, and
2439 not the textual markings, you may set the property @var{soloADue} to
2440 false. This mode can be used to set hymns:
2442 @lilypond[verbatim,singleline,fragment]
2444 \property Staff.soloADue = ##f
2445 \context Voice=one \partcombine Voice
2446 \context Thread=one \relative c'' {
2449 \context Thread=two \relative c'' {
2455 There are a number of other properties that you can use to tweak
2456 the behavior of part combining, refer to the automatically generated
2457 documentation. Look for @code{Thread_devnull_engraver}
2458 @code{Voice_devnull_engraver} and @code{A2_engraver}.
2462 In @code{soloADue} mode, when the two voices play the same notes on and
2463 off, the part combiner may typeset @code{a2} more than once in a
2466 @lilypond[fragment,singleline]
2468 \context Voice=one \partcombine Voice
2469 \context Thread=one \relative c'' {
2472 \context Thread=two \relative c'' {
2478 @cindex @code{Thread_devnull_engraver}
2479 @cindex @code{Voice_engraver}
2480 @cindex @code{A2_engraver}
2482 @node Hara-kiri staffs
2483 @subsection Hara-kiri staffs
2485 In orchestral scores, staffs that only have rests are usually removed.
2486 This saves some space. LilyPond also supports this through the
2487 hara-kiri@footnote{Hara kiri, also called Seppuku, is the ritual suicide
2488 of the Japanese Samourai warriors.} staff. This staff commits suicide
2489 when it finds itself to be empty after the line-breaking process---note
2490 that it will not disappear when it contains normal rests, you must use
2491 multi measure rests.
2493 The hara kiri staff is specialized version of the Staff context. It is
2494 available as the context identifier @code{\HaraKiriStaffContext}.
2495 Observe how the second staff in this example disappears in the second
2500 \notes \relative c' <
2501 \context Staff = SA { e4 f g a \break c1 }
2502 \context Staff = SB { c4 d e f \break R1 }
2506 \translator { \HaraKiriStaffContext }
2519 A @emph{custos} (plural: @emph{custodes}; latin word for "guard") is a
2520 staff context symbol that appears at the end of a staff line. It
2521 anticipates the pitch of the first note(s) of the following line and
2522 thus helps the player or singer to manage line breaks during
2523 performance, thus enhancing readability of a score.
2527 \notes { c'1 d' e' d' \break c' d' e' d' }
2531 \consists Custos_engraver;
2532 Custos \override #'style = #'mensural;
2538 Custodes were frequently used in music notation until the 16th century.
2539 There were different appearences for different notation styles.
2540 Nowadays, they have survived only in special forms of musical notation
2541 such as via the @emph{editio vaticana} dating back to the beginning of
2544 For typesetting custodes, just put a @code{Custos_engraver} into the
2545 @code{StaffContext} when declaring the @code{\paper} block. In this
2546 block, you can also globally control the appearance of the custos symbol
2547 by setting the custos @code{style} property. Currently supported styles
2548 are @code{vaticana}, @code{medicaea}, @code{hufnagel} and
2555 \consists Custos_engraver;
2556 Custos \override #'style = #'mensural;
2561 The property can also be set locally, for example in a @code{\notes}
2566 \property Staff.Custos \override #'style = #'vaticana
2567 c'1 d' e' d' \break c' d' e' d'
2571 @c . {Tuning output}
2573 @section Tuning output
2575 LilyPond tries to take as much formatting as possible out of your
2576 hands. Nevertheless, there are situations where it needs some help, or
2577 where you want to override its decisions. In this section we discuss
2578 ways to do just that.
2580 Notation output is specified in so called grobs (graphic objects). Each
2581 grob carries with it a set of properties (grob properties) specific to
2582 that object. For example, a stem grob has properties that specify its
2583 direction, length and thickness.
2586 The most common way of tuning the output is to alter the values of these
2587 properties. There are two ways of doing that: first, you can temporarily
2588 change the definition of a certain type of grob, thus affecting a whole
2589 set of objects. Second, you can select one specific object, and set a
2593 * Tuning groups of grobs ::
2594 * Tuning per grob ::
2601 @node Tuning groups of grobs
2602 @subsection Tuning groups of grobs
2604 @cindex grob description
2606 A grob definition is a Scheme association list, that is stored in a context
2607 property. By assigning to that property (using plain @code{\property}),
2608 you can change the resulting grobs.
2610 @lilypond[verbatim, fragment]
2611 c'4 \property Voice.Stem = #'((meta . ((interfaces . ())))) c'4
2614 The @code{\property} assignment effectively empties the definition of
2615 the Stem object. One of the effects is that property specifying how it
2616 should be printed is erased, with the effect of rendering it invisible.
2617 The above assignment is available as a standard identifier, lest you
2620 \property Voice.Stem = \turnOff
2627 This mechanism is fairly crude, since you can only set, but not modify,
2628 the definition of a grob. For this reason, there is a more advanced
2629 mechanism: you can add a property on top of an existing definition, or
2630 remove a property: @code{\override} adds a settings, @code{\revert}
2631 removes that setting.
2634 c'4 \property Voice.Stem \override #'thickness = #4.0
2635 c'4 \property Voice.Stem \revert #'thickness
2639 For the digirati, the grob description is an Scheme association
2640 list. Since it is singly linked, we can treat it as a stack, and
2641 @code{\override} and @code{\revert} are just push and pop
2642 operations. This pushing and popping is also used for overriding automatic
2645 If you revert a setting which was not set in the first place, then it
2646 has no effect. However, if the setting was set as a system default, it
2647 may remove the default value, and this may give surprising results,
2648 including crashes. In other words, if you use @code{\override} and
2649 @code{\revert}, be sure to balance the overrides and reverts.
2651 If balancing them is too much work, use the @code{\set} shorthand. It
2652 performs a revert followed by an override:
2654 \property Voice.Stem \set #'thickness = #2.0
2657 Formally the syntax for these constructions is
2659 \property @var{context}.@var{grobname} \override @var{symbol} = @var{value}
2660 \property @var{context}.@var{grobname} \set @var{symbol} = @var{value}
2661 \property @var{context}.@var{grobname} \revert @var{symbol}
2663 Here @var{symbol} is a Scheme expression of symbol type, @var{context}
2664 and @var{grobname} are strings and @var{value} is a Scheme expression.
2667 Correct nesting of @code{\override}, @code{\set}, @code{\revert} is as
2671 \override \set \set \set \set
2675 This is always correct, but if you know the default value, you can also use
2678 \set @var{to default value}
2681 If there is no default (i.e. by default, the grob property is unset),
2684 \set \set \set \set \set
2691 LilyPond will hang or crash if @var{value} contains cyclic references.
2692 The backend is not very strict in type-checking grob properties. If you
2693 @code{\revert} properties that are expected to be set by default,
2698 @node Tuning per grob
2699 @subsection Tuning per grob
2701 @cindex \outputproperty
2703 A second way of tuning grobs is the more arcane @code{\outputproperty}
2705 Syntax is as follows
2707 \outputproperty @var{predicate} @var{symbol} = @var{value}
2709 Here @code{predicate} is a Scheme function taking a grob argument, and
2710 returning a boolean. This statement is processed by the
2711 @code{Output_property_engraver}. It instructs the engraver to feed all
2712 grobs that it sees to @var{predicate}. Whenever the predicate returns
2713 true, the grob property @var{symbol} will be set to @var{value}.
2715 You will need to combine this statement with @code{\context} to select
2716 the appropriate context to apply this to.
2718 If possible, avoid this feature: the semantics are not very clean, and
2719 the syntax and semantics are up for rewrite.
2721 Here are some random examples:
2723 @lilypond[fragment,verbatim,singleline]
2725 \context Staff \outputproperty
2726 #(make-type-checker 'note-head-interface)
2727 #'extra-offset = #'(0.5 . 0.75)
2731 @cindex @code{extra-offset}
2733 This selects all note heads occurring at current staff level, and sets
2734 the @code{extra-offset} of those heads to @code{(0.5,0.75)}, shifting
2737 Move the text "m.d.", but not the fingering instruction "2".
2738 @lilypond[verbatim,singleline]
2739 #(define (make-text-checker text)
2740 (lambda (grob) (equal? text (ly-get-grob-property grob 'text))))
2743 \notes\relative c''' {
2744 \property Voice.Stem \set #'direction = #1
2745 \outputproperty #(make-text-checker "m.d.")
2746 #'extra-offset = #'(-3.5 . -4.5)
2756 @subsection What to tune?
2758 This all tells you how to tune grobs, but what variables are there? The
2759 question is not answered in this manual (although you may encounter
2762 Grob properties are tied directly to the implementation of LilyPond, and
2763 they are thus a moving target. Documentation of such variables are part
2764 of the generated documentation: this documentation is generated from the
2765 sourcecode of lily for each version, so it is usually mch more up to
2766 date than this manual. It should be available from the same place where
2767 you got this manual.
2769 To decide how to tune a grob, you need to find the following information
2772 which grob to modify
2774 which property to modify
2776 which context the grob comes from.
2779 Included with the automatically generated documentation is a master list
2780 of grobs. Each one can be clicked, taking you to a overview of the
2781 available properties.
2783 There is also a master list of contexts. Clicking each takes you to an
2784 overview of the context, listing which grob types are created there.
2787 @node Font selection
2788 @subsection Font selection
2790 Most graphics in LilyPond are composed of characters of fonts. You can
2791 alter the characteristics of the font by setting certain grob
2792 properties. The mechanism that is used for this resembles LaTeX's New
2793 Font Selection Scheme. Within this scheme, a font is entirely
2794 characterized by its font name.
2796 For each grob that uses fonts (in other words, each grob that supports
2797 @code{font-interface}) a font-name must be selected before it can be
2798 printed. The font name is selected by looking at a number of grob
2803 The general class of the typeface. Supported are roman (Computer
2804 Modern), braces (for piano staff braces), music (the standard music
2805 font), dynamic (font for dynamic signs) and typewriter
2808 A symbol indicating the shape of the font, a finer gradation than
2809 font-family. Choices are italic and upright
2811 Symbol indicating the serie of the font. Series form a finer gradation
2812 than font-shape. Choices are medium and bold.
2814 @item font-relative-size
2815 A number indicating the size relative the standard size. For example,
2816 with 20pt staff height, relative size -1 corresponds to 16pt staff
2817 height, and relative size +1 corresponds to 23 pt staff height.
2819 @item font-design-size
2820 A number indicating the design size of the font.
2822 This is a feature of the Computer Modern Font: each point size has a
2823 slightly different design. Smaller design sizes are relatively wider,
2824 which enhances readability. Scalable type faces such TrueType and Adobe
2825 Type1 usually come as ``one design fits all sizes''.
2828 The name of the font, without the design size, eg. @code{cmr},
2829 @code{cmti}, etc. Setting this overrides font-family, font-shape and
2834 The font is selected by taking the first font that satisfies all
2835 qualifiers specified. You can override any of these fields through
2836 @code{\override} and @code{\revert}. The special value @code{*} matches
2837 any value for that qualifier.
2840 \property Lyrics.LyricText \override #'font-series = #'bold
2841 \property Lyrics.LyricText \override #'font-shape = #'*
2844 @cindex @code{font-style}
2846 There are also pre-cooked font selection qualifiers. These are selected
2847 through the grob property @code{font-style}. For example, the style
2848 @code{finger} selects family @code{number} and relative size @code{-3}.
2849 Styles available include: volta, finger, tuplet, timesig, mmrest,
2850 script, large, Large and dynamic.
2852 The style sheets and tables for selecting fonts are located in
2853 @file{scm/font.scm}. Refer to this file for more information.
2857 Relative size is not linked to any real size. There is no mechanism to
2858 select magnifications of fonts, meaning that you can not scale fonts
2859 continuoussly. There is no style sheet provided for other fonts besides
2862 @cindex font selection
2863 @cindex font magnification
2864 @cindex @code{font-interface}
2868 @subsection Text markup
2872 LilyPond has an internal mechanism to typeset texts. You can
2873 form text markup expressions by composing scheme expressions
2874 in the following way.
2876 @lilypond[verbatim, singleline]
2881 c^#'(italic "italic")
2882 d_#'((bold italic) "ff")
2884 f_#'(lines "one" (bold "two"))
2885 g^#'(music "noteheads-2" "flags-u3")
2889 Normally, the Scheme markup text is stored in the @code{text} property
2890 of a grob. Formally, it is defined as follows:
2893 text: string | (head? text+)
2894 head: markup | (markup+)
2895 markup-item: property | abbrev
2896 property: (@var{key} . @var{value})
2897 abbrev: @code{rows lines roman music bold italic named super sub text}
2898 @code{finger volta timesig mmrest mark script large Large dynamic}
2901 The markup is broken down and converted into a list of grob properties,
2902 which are prepended to the property list. The @var{key}-@var{value}
2903 pair is a grob property.
2905 The following abbreviations are currently defined:
2909 horizontal mode: set all text on one line (default)
2911 vertical mode: set every text on new line
2921 lookup by character name
2923 plain text lookup (by character value)
2929 select fingering number fontstyle
2931 select volta number fontstyle
2933 select time signature number fontstyle
2935 select multi measure rest number fontstyle
2937 select mark number fontstyle
2939 select scriptsize roman fontstyle
2941 select large roman fontstyle
2943 select Large roman fontstyle
2945 select dynamics fontstyle
2948 It is possible to use @TeX{} commands in the strings, but this should be
2949 avoided because this makes it impossible for LilyPond to compute the
2950 exact length of the string, which may lead to collisions. Also, @TeX{}
2951 commands won't work with direct postscript output.
2953 @cindex metronome mark
2955 One practical application of complicated markup is to fake a metronome
2959 #(define note '(rows
2960 (music "noteheads-2" ((kern . -0.1) "flags-stem"))))
2961 #(define eight-note `(rows ,note ((kern . -0.1)
2962 (music ((raise . 3.5) "flags-u3")))))
2963 #(define dotted-eight-note
2964 `(rows ,eight-note (music "dots-dot")))
2967 \notes\relative c'' {
2968 a1^#`((rows (font-relative-size . -1)) ,dotted-eight-note " = 64")
2974 TextScript \override #'font-shape = #'upright
2980 @node Embedded @TeX{}
2981 @subsection Embeded @TeX{}
2982 @cindex embedded tex
2983 @cindex embedded tex
2985 You can use @TeX{} commands in text scripts, but this should be avoided
2986 because this makes it impossible for LilyPond to compute the exact
2987 length of the string, which may lead to collisions. Also, @TeX{}
2988 commands won't work with direct PostScript output.
2990 @lilypond[fragment,relative,verbatim]
2991 a''^"3 $\\times$ \\`a deux"
2994 @subsection Embedded PostScript
2995 @cindex embedded postscript
2996 @cindex embedded postscript
2998 You can also use raw PostScript commands embedded in text scripts. This
2999 offers ultimate flexibitily, but you'll have to learn the arcane
3000 PostScript language. Currently, embedded PostScript will @strong{not}
3001 work with direct PostScript output. Note that all dimensions that you
3002 use are in @code{staff-space}s.
3006 \notes \relative c'' {
3007 a-#"\\embeddedps{3 4 moveto 5 3 rlineto stroke}"
3008 -#"\\embeddedps{ [ 0 1 ] 0 setdash 3 5 moveto 5 -3 rlineto stroke}"
3009 b-#"\\embeddedps{3 4 moveto 0 0 1 2 8 4 20 3.5 rcurveto stroke}"
3013 \paper { linewidth = 70 * \staffspace; }
3020 @section Page layout
3034 @subsection Paper block
3037 The most important output definition is the @code{\paper} block, for
3038 music notation. The syntax is
3041 @code{\paper @{} [@var{paperidentifier}] @var{items} @code{@}}
3044 where each of the items is one of
3047 @item An assignment. The assignment must be terminated by a
3050 @item A context definition. See @ref{Notation Contexts} for
3051 more information on context definitions.
3053 @item \stylesheet declaration. Its syntax is
3055 \stylesheet @var{alist}
3058 See @file{scm/font.scm} for details of @var{alist}.
3059 @item an \elementdescriptions declaration.
3061 \elementdescriptions @var{alist}
3063 See @file{scm/grob-description.scm} for details of @var{alist}.
3067 @c . {Paper variables}
3068 @node Paper variables
3069 @subsection Paper variables
3070 @cindex Paper variables
3072 The paper block has some variables you may want to use or change:
3075 @cindex @code{indent}
3077 The indentation of the first line of music.
3078 @cindex @code{staffspace}
3080 @item @code{staffspace}
3081 The distance between two staff lines, calculated from the center
3082 of the lines. If you want scale independent output, then you should
3083 use either this or @code{stafflinethickness}
3084 as a unit for distances you modify.
3086 @cindex @code{linewidth}
3087 @item @code{linewidth}
3088 Sets the width of the lines.
3090 If set to a negative value, a single unjustified line is produced.
3091 @c rename to singleLinePaper ?
3092 The shorthand @code{\singleLine} defines a default paper block that
3093 produces a single line.
3095 @cindex @code{textheight}
3097 @item @code{textheight}
3098 Sets the total height of the music on each page. Only used by
3101 @cindex @code{interscoreline}
3103 @item @code{interscoreline}
3104 Sets the spacing between systems.
3106 @cindex @code{interscorelinefill}
3110 @item @code{interscorelinefill}
3111 If set to a positive number, the distance between the score
3112 lines will stretch in order to fill the full page. In that
3113 case @code{interscoreline} specifies the minimum spacing.
3118 @cindex @code{stafflinethickness}
3120 @item @code{stafflinethickness}
3121 Determines the thickness of staff lines, and also acts as a scaling
3122 parameter for other line thicknesses.
3129 @subsection Font size
3132 The Feta font provides musical symbols at six different sizes. These
3133 fonts are 11 point, 13 point, 16 point, 20 point,
3134 23 point, and 26 point. The point size of a font is the
3135 height of the five lines in a staff when displayed in the font.
3137 Definitions for these sizes are the files @file{paperSZ.ly}, where
3138 @code{SZ} is one of 11, 13, 16, 20, 23 and 26. If you include any of
3139 these files, the identifiers @code{paperEleven}, @code{paperThirteen},
3140 @code{paperSixteen}, @code{paperTwenty}, @code{paperTwentythree}, and
3141 @code{paperTwentysix} are defined respectively. The default
3142 @code{\paper} block is also set.
3144 The font definitions are generated using a Scheme function. For more
3145 details, see the file @file{font.scm}.
3151 @subsection Paper size
3156 @cindex @code{papersize}
3158 To change the paper size, you must first set the
3159 @code{papersize} variable at top level. Set it to
3160 the strings @code{a4}, @code{letter}, or @code{legal}. After this
3161 specification, you must set the font as described above. If you want
3162 the default font, then use the 20 point font. The new paper size will
3163 not take effect if the font is not loaded and selected afterwards.
3167 \include "paper16.ly"
3171 \paper @{ \paperSixteen @}
3175 The file @code{paper16.ly} will now include a file named @file{a4.ly}, which
3176 will set the paper variables @code{hsize} and @code{vsize} (used by
3187 @subsection Line break
3190 @cindex breaking lines
3192 Line breaks are normally computed automatically. They are chosen such
3193 that the resulting spacing has low variation, and looks neither cramped
3196 Occasionally you might want to override the automatic breaks; you can do
3197 this by specifying @code{\break}. This will force a line break at this
3198 point. Do remember that line breaks can only occur at places where there
3199 are barlines. If you want to have a line break where there is no
3200 barline, you can force an invisible barline by entering @code{\bar "";}.
3202 Similarly, @code{\noBreak} forbids a line break at a certain point.
3204 @cindex @code{\penalty}
3206 The @code{\break} and @code{\noBreak} commands are defined in terms of
3207 the penalty command:
3209 \penalty @var{int} @code{;}
3212 This encourages or discourages LilyPond to make a line break at this
3217 The scaling of the @code{\penalty} argument is not well-defined. The
3218 command is rather kludgy, and slated for rewriting.
3222 @subsection Page break
3225 @cindex breaking pages
3228 Page breaks are normally computed by @TeX{}, so they are not under
3229 direct control of LilyPond. However, you can insert a commands into the
3230 @file{.tex} output to instruct @TeX{} where to break pages. For more
3231 details, see the example file @file{input/test/between-systems.ly}
3242 LilyPond can produce MIDI output. The performance lacks lots of
3243 interesting effects, such as swing, articulation, slurring, etc., but it
3244 is good enough for proof-hearing the music you have entered. Ties,
3245 dynamics and tempo changes are interpreted.
3247 The MIDI volume is composed of two elements: the current dynamics of the
3248 voice and the type of musical instrument.
3250 Dynamic marks, crescendi and decrescendi translate into MIDI volume
3251 levels. Dynamic marks translate to a fixed fraction of the available
3252 MIDI volume range, crescendi and decrescendi make the the volume vary
3253 linearly between their two extremities. The fractions be adjusted by
3254 overriding the @code{absolute-volume-alist} defined in
3255 @file{scm/midi.scm}.
3257 For each type of musical instrument (that MIDI supports), a volume range
3258 can be defined. This gives you basic equaliser control, which can
3259 enhance the quality of the MIDI output remarkably. You can add
3260 instruments and ranges or change the default settings by overriding
3261 the @code{instrument-equaliser-alist} defined in @file{scm/midi.scm}.
3265 It is currently not possible to use the percussion channel (generally
3266 channel 10 of a MIDI file).
3270 * MIDI instrument names::
3275 @subsection MIDI block
3279 The MIDI block is analogous to the paper block, but it is somewhat
3280 simpler. The @code{\midi} block can contain:
3284 @item a @code{\tempo} definition
3285 @item context definitions
3288 Assignments in the @code{\midi} block are not allowed.
3292 @cindex context definition
3294 Context definitions follow precisely the same syntax as within the
3295 \paper block. Translation modules for sound are called performers.
3296 The contexts for MIDI output are defined in @file{ly/performer.ly}.
3299 @node MIDI instrument names
3300 @subsection MIDI instrument names
3302 @cindex instrument names
3303 @cindex @code{Staff.midiInstrument}
3304 @cindex @code{Staff.instrument}
3306 The MIDI instrument name is set by the @code{Staff.midiInstrument}
3307 property or, if that property is not set, the @code{Staff.instrument}
3308 property. The instrument name should be chosen from the list in
3309 @ref{MIDI instruments}.
3313 If the selected string does not exactly match, then LilyPond uses the
3314 default piano. It is not possible to select an instrument by number.
3326 @section Music entry
3334 One of the applications of LilyPond is to enter music from existing
3335 written or printed material. When you're doing this kind of copying
3336 work, you can easily make mistakes. This section deals with tricks and
3337 features that help you enter music, and find and correct mistakes.
3341 @subsection Relative
3343 @cindex relative octave specification
3345 Octaves are specified by adding @code{'} and @code{,} to pitch names.
3346 When you copy existing music, it is easy to accidentally put a pitch in
3347 the wrong octave and hard to find such an error. To prevent these
3348 errors, LilyPond features octave entry.
3350 @cindex @code{\relative}
3352 \relative @var{startpitch} @var{musicexpr}
3355 The octave of notes that appear in @var{musicexpr} are calculated as
3356 follows: If no octave changing marks are used, the basic interval
3357 between this and the last note is always taken to be a fourth or less.
3358 The octave changing marks @code{'} and @code{,} can then
3359 be added to raise or lower the pitch by an extra octave. Upon entering
3360 relative mode, an absolute starting pitch must be specified that will
3361 act as the predecessor of the first note of @var{musicexpr}.
3363 This distance is determined without regarding accidentals: a
3364 @code{fisis} following a @code{ceses} will be put above the
3367 Entering music that changes octave frequently is easy in relative mode.
3368 @lilypond[fragment,singleline,verbatim,center]
3374 And octave changing marks are used for intervals greater than a fourth.
3375 @lilypond[fragment,verbatim,center]
3377 c g c f, c' a, e'' }
3380 If the preceding item is a chord, the first note of the chord is used
3381 to determine the first note of the next chord. But other notes
3382 within the second chord are determined by looking at the immediately
3385 @lilypond[fragment,verbatim,center]
3392 @cindex @code{\notes}
3394 The pitch after the @code{\relative} contains a notename. To parse
3395 the pitch as a notename, you have to be in note mode, so there must
3396 be a surrounding @code{\notes} keyword (which is not
3399 The relative conversion will not affect @code{\transpose},
3400 @code{\chords} or @code{\relative} sections in its argument. If you
3401 want to use relative within transposed music, you must place an
3402 additional @code{\relative} inside the @code{\transpose}.
3407 @subsection Bar check
3411 @cindex @code{barCheckNoSynchronize}
3415 Whenever a bar check is encountered during interpretation, a warning
3416 message is issued if it doesn't fall at a measure boundary. This can
3417 help you find errors in the input. Depending on the value of
3418 @code{barCheckNoSynchronize}, the beginning of the measure will be
3419 relocated, so this can also be used to shorten measures.
3421 A bar check is entered using the bar symbol, @code{|}
3423 @c . {Point and click}
3424 @node Point and click
3425 @subsection Point and click
3427 Point and click lets you find notes in the input by clicking on them in
3428 the Xdvi window. This makes it very easy to find input that causes some
3429 error in the sheet music.
3431 To use it, you need the following software
3435 @uref{ftp://ftp.math.berkeley.edu/pub/Software/TeX/xdvi.tar.gz,plain
3436 Xdvi} version 22.36 or newer.
3438 Note that most @TeX{} distributions ship with xdvik, which is a
3439 different and less well maintained program. To find out which xdvi you
3440 are running, try @code{xdvi --version} or @code{xdvi.bin --version}.
3444 Add one these lines to the top of your .ly file. The first one is for
3445 line location only. The second one is more convenient, but requires
3446 patching @code{emacsclient}.
3449 #(set! point-and-click line-location)
3450 #(set! point-and-click line-column-location)
3453 In the emacs startup file (usually @file{~/.emacs}), add the following
3458 If you want emacs to jump to the exact spot (and not just the line) on a
3459 click, you must enable column positioning. To do so, you need to patch
3460 emacsclient. Apply @file{emacsclient.patch} (included with the source
3461 package) to @file{emacsclient.c} and @file{server.el} from the emacs
3462 source code. Recompile and stick the recompiled emacsclient into a bin
3463 directory, and put @file{server.el} into a elisp directory
3464 (eg. @file{~/usr/share/emacs/}). Add the following to your @file{.emacs}
3465 init file, before invoking server-start.
3468 (setq load-path (cons "~/usr/share/emacs" load-path))
3472 Xdvi must be configured to use the emacs editor. Before starting, set
3473 the environment variable @code{XEDITOR} to
3475 emacsclient --no-wait +%c:%l %f
3477 Xdvi also must be configured to find the fonts. Refer to the
3478 xdvi documentation for more information.
3480 When viewing, control-mousebutton 1 will take you to the originating
3481 line and column. Control-mousebutton 2 will show all clickable boxes.
3485 When you convert the TeX file to PostScript using dvips, dvips
3486 will complain about not finding @code{src:X:Y} files. Those complaints are
3487 harmless, and can be ignored.
3490 @node Skipping corrected music
3491 @section Skipping corrected music
3493 The property @code{Score.skipTypesetting} can be used to switch on and
3494 off typesetting completely during the interpretation phase. When
3495 typesetting is switched off, the music is processed much more quickly.
3496 You can use this to skip over the parts of a score that you have already
3499 @lilypond[fragment,singleline,verbatim]
3500 \relative c'' { c8 d
3501 \property Score.skipTypesetting = ##t
3503 \property Score.skipTypesetting = ##f
3508 @node Interpretation context
3509 @section Interpretation context
3512 * Notation Contexts::
3513 * Creating contexts::
3514 * Default contexts::
3515 * Context properties::
3516 * Changing context definitions::
3517 * Defining new contexts::
3521 @c . {Notation Contexts}
3522 @node Notation Contexts
3523 @subsection Notation Contexts
3525 @cindex notation contexts
3527 Notation contexts are objects that only exist during a run of LilyPond.
3528 During the interpretation phase of LilyPond (when it prints
3529 "interpreting music"), the music expresiion in a @code{\score} block is
3530 interpreted in time order. This is the same order that humans hear and
3533 During this interpretation, the notation context is holds the state for
3534 the current point within the music. It contains information like
3537 @item What notes are playing at this point?
3538 @item What symbols will be printed at this point?
3539 @item What is the current key signature, time signature, point within
3543 Contexts are grouped hierarchically: A @code{Voice} context is
3544 contained in a @code{Staff} context (because a staff can contain
3545 multiple voices at any point), a @code{Staff} context is contained in
3546 a @code{Score}, @code{StaffGroup}, or @code{ChoirStaff} context (because
3547 these can all contain multiple staffs).
3550 Contexts associated with sheet music output are called @emph{notation
3551 contexts}, those for sound output are called performance contexts.
3554 @node Creating contexts
3555 @subsection Creating contexts
3557 @cindex @code{\context}
3558 @cindex context selection
3560 Contexts for a music expression can be selected manually, using the
3561 following music expression.
3564 \context @var{contexttype} [= @var{contextname}] @var{musicexpr}
3567 This instructs lilypond to interpret @var{musicexpr} within the context
3568 of type @var{contexttype} and with name @var{contextname}. If this
3569 context does not exist, it will be created.
3571 @lilypond[verbatim,singleline]
3573 \notes \relative c'' {
3574 c4 <d4 \context Staff = "another" e4> f
3580 In this example, the @code{c} and @code{d} are printed on the
3581 default staff. For the @code{e}, a context Staff called
3582 @code{another} is specified; since that does not exist, a new
3583 context is created. Within @code{another}, a (default) Voice context
3584 is created for the @code{e4}. When all music referring to a
3585 context is finished, the context is ended as well. So after the
3586 third quarter, @code{another} is removed.
3590 @node Default contexts
3591 @subsection Default contexts
3593 Most music expressions don't need @code{\context}: they inherit the
3594 notation context from their parent. Each note is a music expression, and
3595 as you can see in the following example, only the sequential music
3596 enclosing the three notes has an explicit context.
3598 @lilypond[verbatim,singleline]
3599 \score { \notes \context Voice = goUp { c'4 d' e' } }
3602 There are some quirks that you must keep in mind when dealing with
3605 First, every top-level music is interpreted by the Score context, in other
3606 words, you may think of @code{\score} working like
3609 \context Score @var{music}
3613 Second, sequential music follows the contexts of its
3614 ``children''. Consider the following example.
3616 @lilypond[verbatim, singleline]
3617 \score { \context Score \notes { c'4 ( d' )e' } }
3620 The sequential music is interpreted by the Score context initially
3621 (notice that the @code{\context} specification is redundant), but when a
3622 note is encountered, contexts are setup to accept that note. In this
3623 case, a Thread, Voice and Staff are created. The rest of the sequential
3624 music is also interpreted with the same Thread, Voice and Staff context,
3625 putting the notes on the same staff, in the same voice.
3627 This is a convenient mechanism, but do not expect opening chords to work
3628 without @code{\context}. For every note, a separate staff is
3631 @lilypond[verbatim, singleline]
3632 \score { \notes <c'4 es'> }
3635 Of course, if the chord is preceded by a normal note in sequential
3636 music, the chord will be interpreted by the Thread of the preceding
3638 @lilypond[verbatim,singleline]
3639 \score { \notes { c'4 <c'4 es'> } }
3644 @node Context properties
3645 @subsection Context properties
3647 Notation contexts can be modified from within the @file{.ly} file. The
3648 following music expression does that job:
3650 @cindex @code{\property}
3652 \property @var{contextname}.@var{propname} = @var{value}
3655 Sets the @var{propname} property of the context @var{contextname} to the
3656 specified Scheme expression @var{value}. All @var{propname} and
3657 @var{contextname} are strings, which are typically unquoted.
3659 Properties that are set in one context are inherited by all of the
3660 contained contexts. This means that a property valid for the
3661 @code{Voice} context can be set in the @code{Score} context (for
3662 example) and thus take effect in all @code{Voice} contexts.
3664 Properties can be unset using the following expression:
3666 \property @var{contextname}.@var{propname} \unset
3669 This removes the definition of @var{propname} in @var{contextname}. If
3670 @var{propname} was not defined in @var{contextname} (but was inherited
3671 from a higher context), then this has no effect.
3676 @code{\property \unset} is not the inverse of @code{\property \set}
3681 @c . {Context definitions}
3682 @node Changing context definitions
3683 @subsection Changing context definitions
3685 @cindex context definition
3686 @cindex translator definition
3688 The most common way to define a context is by extending an existing
3689 context. You can change an existing context from the paper block, by
3690 first initializing a translator with an existing context identifier:
3694 @var{context-identifier}
3697 Then you can add engravers, remove engravers.
3698 The syntax for these operations are respectively
3700 \remove @var{engravername}
3701 \consists @var{engravername}
3705 Here @var{engravername} is a string, the name of an engraver in the
3708 @var{propname} = @var{value}
3712 @lilypond[verbatim,singleline]
3716 \translator { \StaffContext
3717 \remove Clef_engraver;
3723 You can also set properties in a translator definition. The syntax is as
3726 @var{propname} is a string and @var{value} is a Scheme
3729 @var{propname} = @var{value}
3730 @var{propname} \set @var{symbol} = @var{value}
3731 @var{propname} \override @var{symbol} = @var{value}
3732 @var{propname} \revert @var{symbol}
3736 These type of property assignments happen before interpretation starts,
3737 so a @code{\property} expression will override any predefined settings.
3740 To simplify editing translators, all standard contexts have standard
3741 identifiers called @var{name}@code{Context}, e.g. @code{StaffContext},
3742 @code{VoiceContext}.
3744 @node Defining new contexts
3745 @subsection Defining new contexts
3747 If you want to build a context from scratch, you must also supply the
3748 following extra information:
3750 @item A name, specified by @code{\name @var{contextname};}.
3752 @item A cooperation module. This is specified by @code{\type
3759 \type "Engraver_group_engraver";
3760 \name "SimpleStaff";
3762 \consists "Staff_symbol_engraver";
3763 \consists "Note_head_engraver";
3764 \consistsend "Axis_group_engraver";
3768 Basic building blocks of translation are called engravers; they are
3769 special C++ classes.
3771 The argument of @code{\type} is the name for a special engraver that
3772 handles cooperation between simple engravers such as
3773 @code{Note_head_engraver} and @code{Staff_symbol_engraver}. Alternatives
3774 for this engraver are the following:
3776 @cindex @code{Engraver_group_engraver}
3777 @item @code{Engraver_group_engraver}
3778 The standard cooperation engraver.
3780 @cindex @code{Score_engraver}
3782 @item @code{Score_engraver}
3783 This is cooperation module that should be in the top level context,
3784 and only the toplevel context.
3786 @cindex @code{Grace_engraver_group}
3788 @item @code{Grace_engraver_group}
3789 This is a special cooperation module (resembling
3790 @code{Score_engraver}) that is used to created an embedded
3797 @item @code{\alias} @var{alternate-name} @code{;}
3798 This specifies a different name. In the above example,
3799 @code{\property Staff.X = Y} will also work on @code{SimpleStaff}s
3801 @item @code{\consistsend} @var{engravername} @code{;}
3802 Analogous to @code{\consists}, but makes sure that
3803 @var{engravername} is always added to the end of the list of
3806 Some engraver types need to be at the end of the list; this
3807 insures they are put there, and stay there, if a user adds or
3808 removes engravers. This command is usually not needed for
3811 @item @code{\accepts} @var{contextname} @code{;}
3812 Add @var{contextname} to the list of context this context can
3813 contain. The first listed context is the context to create by
3816 @item @code{\denies}. The opposite of @code{\accepts}. Added for
3817 completeness, but is never used in practice.
3820 @item @code{\name} @var{contextname} @code{;}
3821 This sets name of the context, e.g. @code{Staff}, @code{Voice}. If
3822 the name is not specified, the translator won't do anything.
3825 In the @code{\paper} block, it is also possible to define translator
3826 identifiers. Like other block identifiers, the identifier can only
3827 be used as the very first item of a translator. In order to define
3828 such an identifier outside of @code{\score}, you must do
3833 foo = \translator @{ @dots{} @}
3840 \translator @{ \foo @dots{} @}
3848 @cindex paper types, engravers, and pre-defined translators
3855 @c . {Syntactic details}
3856 @node Syntactic details
3857 @section Syntactic details
3858 @cindex Syntactic details
3860 This section describes details that were too boring to be put elsewhere.
3865 * Music expressions::
3866 * Manipulating music expressions::
3874 @subsection Top level
3877 This section describes what you may enter at top level.
3881 @subsubsection Score
3884 @cindex score definition
3886 The output is generated combining a music expression with an output
3887 definition. A score block has the following syntax:
3890 \score @{ @var{musicexpr} @var{outputdefs} @}
3893 @var{outputdefs} are zero or more output definitions. If none is
3894 supplied, the default @code{\paper} block will be added.
3898 @c . {Default output}
3899 @subsubsection Default output
3901 Default values for the @code{\paper} and @code{\midi} block are set by
3902 entering such a block at top-level.
3905 @subsubsection Header
3907 @cindex @code{\header}
3910 A header describes bibilographic information of the file's contents. It
3911 can also appear in a @code{\score} block. Tools like @code{ly2dvi} can
3912 use this information for generating titles. Key values that are used by
3913 @code{ly2dvi} are: title, subtitle, composer, opus, poet, instrument,
3914 metre, arranger, piece and tagline.
3916 @cindex @code{ly2dvi}
3920 \header @{ @var{key1} = @var{val1};
3921 @var{key2} = @var{val2}; @dots{} @}
3924 It is customary to put the @code{\header} at the top of the file.
3926 @subsubsection Default output
3928 A @code{\midi} or @code{\paper} block at top-level sets the default
3930 paper block for all scores that lack an explicit paper block.
3934 @subsection Identifiers
3937 All of the information in a LilyPond input file, is represented as a
3938 Scheme value. In addition to normal Scheme data types (such as pair,
3939 number, boolean, etc.), LilyPond has a number of specialized data types,
3946 @item Translator_def
3950 @item Music_output_def
3951 @item Moment (rational number)
3954 LilyPond also includes some transient object types. Objects of these
3955 types are built during a LilyPond run, and do not `exist' per se within
3956 your input file. These objects are created as a result of your input
3957 file, so you can include commands in the input to manipulate them,
3958 during a lilypond run.
3961 @item Grob: short for Graphical object. See @ref{Grobs}.
3962 @item Molecule: device-independent page output object,
3963 including dimensions. Produced by some Grob functions
3965 @item Translator: object that produces audio objects or Grobs. This is
3966 not yet user accessible.
3967 @item Font_metric: object representing a font. (See @ref{Font metrics})
3972 @node Music expressions
3973 @subsection Music expressions
3975 @cindex music expressions
3977 Music in LilyPond is entered as a music expression. Notes, rests, lyric
3978 syllables are music expressions, and you can combine music expressions
3979 to form new ones, for example by enclosing a list of expressions in
3980 @code{\sequential @{ @}} or @code{< >}. In the following example, a
3981 compound expression is formed out of the quarter note @code{c} and a
3982 quarter note @code{d}:
3985 \sequential @{ c4 d4 @}
3988 @cindex Sequential music
3989 @cindex @code{\sequential}
3990 @cindex sequential music
3993 @cindex Simultaneous music
3994 @cindex @code{\simultaneous}
3996 The two basic compound music expressions are simultaneous and
4000 \sequential @code{@{} @var{musicexprlist} @code{@}}
4001 \simultaneous @code{@{} @var{musicexprlist} @code{@}}
4003 For both, there is a shorthand:
4005 @code{@{} @var{musicexprlist} @code{@}}
4009 @code{<} @var{musicexprlist} @code{>}
4011 for simultaneous music.
4012 In principle, the way in which you nest sequential and simultaneous to
4013 produce music is not relevant. In the following example, three chords
4014 are expressed in two different ways:
4016 @lilypond[fragment,verbatim,center]
4017 \notes \context Voice {
4018 <a c'> <b d' > <c' e'>
4019 < { a b c' } { c' d' e' } >
4024 Other compound music expressions include
4027 \transpose @var{pitch} @var{expr}
4028 \apply @var{func} @var{expr}
4029 \context @var{type} = @var{id} @var{expr}
4030 \times @var{fraction} @var{expr}
4034 @c . {Manipulating music expressions}
4035 @node Manipulating music expressions
4036 @subsection Manipulating music expressions
4038 The @code{\apply} mechanism gives you access to the internal
4039 representation of music. You can write Scheme-functions that operate
4040 directly on it. The syntax is
4042 \apply #@var{func} @var{music}
4044 This means that @var{func} is applied to @var{music}. The function
4045 @var{func} should return a music expression.
4047 This example replaces the text string of a script. It also shows a dump
4048 of the music it processes, which is useful if you want to know more
4049 about how music is stored.
4051 @lilypond[verbatim,singleline]
4052 #(define (testfunc x)
4053 (if (equal? (ly-get-mus-property x 'text) "foo")
4054 (ly-set-mus-property x 'text "bar"))
4056 (ly-set-mus-property x 'elements
4057 (map testfunc (ly-get-mus-property x 'elements)))
4062 \apply #testfunc { c4_"foo" }
4066 For more information on what is possible, see the automatically
4067 generated documentation.
4070 Directly accessing internal representations is dangerous: the
4071 implementation is subject to changes, so you should avoid this feature
4074 A final example is a function that reverses a piece of music in time:
4076 @lilypond[verbatim,singleline]
4077 #(define (reverse-music music)
4078 (let* ((elements (ly-get-mus-property music 'elements))
4079 (reversed (reverse elements))
4080 (span-dir (ly-get-mus-property music 'span-direction)))
4081 (ly-set-mus-property music 'elements reversed)
4083 (ly-set-mus-property music 'span-direction (- span-dir)))
4084 (map reverse-music reversed)
4087 music = \notes { c'4 d'4( e'4 f'4 }
4089 \score { \context Voice {
4091 \apply #reverse-music \music
4097 @c . {Span requests}
4103 @subsubsection Span requests
4104 @cindex Span requests
4106 Notational constructs that start and end on different notes can be
4107 entered using span requests. The syntax is as follows:
4111 \spanrequest @var{startstop} @var{type}
4115 @cindex @code{\start}
4116 @cindex @code{\stop}
4118 This defines a spanning request. The @var{startstop} parameter is either
4119 -1 (@code{\start}) or 1 (@code{\stop}) and @var{type} is a string that
4120 describes what should be started. Much of the syntactic sugar is a
4121 shorthand for @code{\spanrequest}, for example,
4123 @lilypond[fragment,verbatim,center]
4124 c'4-\spanrequest \start "slur"
4125 c'4-\spanrequest \stop "slur"
4128 Among the supported types are @code{crescendo}, @code{decrescendo},
4129 @code{beam}, @code{slur}. This is an internal command. Users are
4130 encouraged to use the shorthands which are defined in the initialization
4131 file @file{spanners.ly}.
4136 @subsection Assignments
4139 Identifiers allow objects to be assigned to names during the parse
4140 stage. To assign an identifier, you use @var{name}@code{=}@var{value}
4141 and to refer to an identifier, you preceed its name with a backslash:
4142 `@code{\}@var{name}'. @var{value} is any valid Scheme value or any of
4143 the input-types listed above. Identifier assignments can appear at top
4144 level in the LilyPond file, but also in @code{\paper} blocks.
4146 Semicolons are forbidden after top level assignments, but mandatory in
4147 other places. The rules about semicolons and assignments are very
4148 confusing, but when LilyPond input evolves more towards Scheme, we hope
4149 that this problem will grow smaller.
4151 An identifier can be created with any string for its name, but you will
4152 only be able to refer to identifiers whose names begin with a letter,
4153 being entirely alphabetical. It is impossible to refer to an identifier
4154 whose name is the same as the name of a keyword.
4156 The right hand side of an identifier assignment is parsed completely
4157 before the assignment is done, so it is allowed to redefine an
4158 identifier in terms of its old value, e.g.
4164 When an identifier is referenced, the information it points to is
4165 copied. For this reason, an identifier reference must always be the
4166 first item in a block.
4170 \paperIdent % wrong and invalid
4174 \paperIdent % correct
4179 @c . {Lexical modes}
4181 @subsection Lexical modes
4182 @cindex Lexical modes
4185 @cindex @code{\notes}
4186 @cindex @code{\chords}
4187 @cindex @code{\lyrics}
4189 To simplify entering notes, lyrics, and chords, LilyPond has three
4190 special input modes on top of the default mode: note, lyrics and chords
4191 mode. These input modes change the way that normal, unquoted words are
4192 interpreted: for example, the word @code{cis} may be interpreted as a
4193 C-sharp, as a lyric syllable `cis' or as a C-sharp major triad
4196 A mode switch is entered as a compound music expressions
4198 @code{\notes} @var{musicexpr}
4199 @code{\chords} @var{musicexpr}
4200 @code{\lyrics} @var{musicexpr}.
4203 In each of these cases, these expressions do not add anything to the
4204 meaning of their arguments. They are just a way to indicate that the
4205 arguments should be parsed in indicated mode. The modes are treated in
4206 more detail in the @ref{Note entry}, @ref{Lyrics} and
4209 You may nest different input modes.
4213 @subsection Ambiguities
4218 The grammar contains a number of ambiguities. We hope to resolve them at
4222 @item The assignment
4228 can be interpreted as making a string identifier @code{\foo}
4229 containing @code{"bar"}, or a music identifier @code{\foo}
4230 containing the syllable `bar'.
4232 @item The assignment
4238 can be interpreted as making an integer identifier
4239 containing -6, or a Request identifier containing the
4240 fingering `6' (with neutral direction).
4242 @item If you do a nested repeat like
4254 then it is ambiguous to which @code{\repeat} the
4255 @code{\alternative} belongs. This is the classic if-then-else
4256 dilemma. It may be solved by using braces.
4258 @item (an as yet unidentified ambiguity :-)
4262 @c . {Lexical details}
4263 @node Lexical details
4264 @section Lexical details
4266 Even more boring details, now on lexical side of the input parser.
4277 * Version information::
4282 @subsection Comments
4285 @cindex block comment
4286 @cindex line comment
4290 A one line comment is introduced by a @code{%} character.
4291 Block comments are started by @code{%@{} and ended by @code{%@}}.
4292 They cannot be nested.
4295 @subsection Direct Scheme
4299 @cindex Scheme, in-line code
4302 LilyPond contains a Scheme interpreter (the GUILE library) for
4303 internal use. In some places Scheme expressions also form valid syntax:
4304 whereever it is allowed,
4308 evaluates the specified Scheme code. If this is used at toplevel, then
4309 the result is discarded. Example:
4311 \property Staff.TestObject \override #'foobar = #(+ 1 2)
4314 @code{\override} expects two Scheme expressions, so there are two Scheme
4315 expressions. The first one is a symbol (@code{foobar}), the second one
4316 an integer (namely, 3).
4318 Scheme is a full-blown programming language, and a full discussion is
4319 outside the scope of this document. Interested readers are referred to
4320 the website @uref{http://www.schemers.org/} for more information on
4325 @subsection Keywords
4329 Keywords start with a backslash, followed by a number of lower case
4330 alphabetic characters. These are all the keywords.
4333 apply arpeggio autochange spanrequest commandspanrequest
4334 simultaneous sequential accepts alternative bar breathe
4335 char chordmodifiers chords clef cm consists consistsend
4336 context denies duration dynamicscript elementdescriptions
4337 font grace header in lyrics key mark pitch
4338 time times midi mm name pitchnames notes outputproperty
4339 override set revert partial paper penalty property pt
4340 relative remove repeat addlyrics partcombine score
4341 script stylesheet skip textscript tempo translator
4346 @subsection Integers
4354 Formed from an optional minus sign followed by digits. Arithmetic
4355 operations cannot be done with integers, and integers cannot be mixed
4360 @cindex real numbers
4366 Formed from an optional minus sign and a sequence of digits followed
4367 by a @emph{required} decimal point and an optional exponent such as
4368 @code{-1.2e3}. Reals can be built up using the usual operations:
4369 `@code{+}', `@code{-}', `@code{*}', and
4370 `@code{/}', with parentheses for grouping.
4378 A real constant can be followed by one of the dimension keywords:
4379 @code{\mm} @code{\pt}, @code{\in}, or @code{\cm}, for millimeters,
4380 points, inches and centimeters, respectively. This converts the number
4381 a number that is the internal representation of that dimension.
4389 Begins and ends with the @code{"} character. To include a @code{"}
4390 character in a string write @code{\"}. Various other backslash
4391 sequences have special interpretations as in the C language. A string
4392 that contains no spaces can be written without the quotes. See
4393 @ref{Lexical modes} for details on unquoted strings; their
4394 interpretation varies depending on the situation. Strings can be
4395 concatenated with the @code{+} operator.
4397 The tokenizer accepts the following commands. They have no grammatical
4398 function, hence they can appear anywhere in the input.
4402 @subsection Main input
4405 @cindex @code{\maininput}
4407 The @code{\maininput} command is used in init files to signal that the
4408 user file must be read. This command cannot be used in a user file.
4410 @node File inclusion
4411 @subsection File inclusion
4412 @cindex @code{\include}
4414 \include @var{filename}
4417 Include @var{filename}. The argument @var{filename} may be a quoted string (an
4418 unquoted string will not work here!) or a string identifier. The full
4419 filename including the @file{.ly} extension must be given,
4422 @node Version information
4423 @subsection Version information
4424 @cindex @code{\version}
4426 \version @var{string} ;
4429 Specify the version of LilyPond that a file was written for. The
4430 argument is a version string in quotes, for example @code{"1.2.0"}.
4431 This is used to detect invalid input, and to aid
4432 @code{convert-ly} a tool that automatically upgrades input files. See
4433 See @ref{convert-ly} for more information on @code{convert-ly}.
4442 @c .{Local emacs vars}
4445 @c minor-mode: font-lock
4446 @c minor-mode: outline
4447 @c outline-layout: (-1 : 0)
4448 @c outline-use-mode-specific-leader: "@c \."
4449 @c outline-primary-bullet: "{"
4450 @c outline-stylish-prefixes: nil
4451 @c outline-override-protect: t