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
15 Rhythm staff (clef, x-notehead)
21 @unnumberedsubsec Bugs
26 @c .{Reference Manual}
28 @node Reference Manual
29 @chapter Reference Manual
31 This document describes GNU LilyPond and its input format. The last
32 revision of this document was for LilyPond 1.3.136.
53 * Interpretation context::
63 The purpose of LilyPond is explained informally by the term `music
64 typesetter'. This is not a fully correct name: not only does the
65 program print musical symbols, it also makes esthetic decisions.
66 Symbols and their placements are @emph{generated} from a high-level
67 musical description. In other words, LilyPond would be best described
68 by `music compiler' or `music to notation compiler'.
70 LilyPond is linked to GUILE, GNU's Scheme library for extension. The
71 Scheme library provides the glue that holds together the low-level
72 routines and separate modules general, which are C++
74 When lilypond is run to typeset sheet music, the following happens:
76 @item GUILE Initialization: various scheme files are read
77 @item parsing: first standard @code{ly} initialization files are read, and
78 then the user @file{ly} file is read.
79 @item interpretation: the music in the file is processed ``in playing
80 order'', i.e. the order that you use to read sheet music, or the
81 order in which notes are played.
84 in this step, the results of the interpretation, a typesetting
85 specification, is solved.
87 @item the visible results ("virtual ink") is written to the output file.
90 During these stages different types of data play the the main role:
91 during parsing, @strong{Music} objects are created. During the
92 interpretation, @strong{context} is constructed, and with this context
93 af network of @strong{graphical objects} (``grobs'') is created. The
94 grobs contain unknown variables, and the network forms a set of
95 equations. After solving the equations and filling in these variables,
96 the printed output (in the form of @strong{molecules}) is written to an
99 These threemanship of tasks (parsing, translating, typesetting) and
100 data-structures (music, context, graphical objects) permeates the entire
101 design of the program. This manual is ordered in terms of user
102 tasks. With each concept will be explained to which of the three parts
111 The most basic forms of music are notes. We discuss how you enter them
112 here. Notes on their own don't form valid input, but for the sake of
113 brevity we omit obligotary lint such as @code{\score} blocks and
114 @code{\paper} declarations.
119 * Defining pitch names::
122 * Easy Notation note heads ::
134 @cindex Note specification
136 @cindex entering notes
138 The verbose syntax for pitch specification is
140 @cindex @code{\pitch}
142 \pitch @var{scmpitch}
145 @var{scmpitch} is a pitch scheme object, see @ref{Pitch data type}.
147 In Note and Chord mode, pitches may be designated by names. The default
148 names are the Dutch note names. The notes are specified by the letters
149 @code{a} through @code{g} (where the octave is formed by notes ranging
150 from @code{c}, to @code{b}). The pitch @code{c} is an octave below
151 middle C and the letters span the octave above that C.
153 @cindex note names, Dutch
155 In Dutch, a sharp is formed by adding @code{-is} to the end of a pitch
156 name. A flat is formed by adding @code{-es}. Double sharps and double
157 flats are obtained by adding @code{-isis} or @code{-eses}. @code{aes}
158 and @code{ees} are contracted to @code{as} and @code{es} in Dutch, but
159 both forms are accepted.
161 LilyPond has predefined sets of notenames for various other languages.
162 To use them, simply include the language specific init file. For
163 example: @code{\include "english.ly"}. The available language files and
164 the names they define are:
167 Note Names sharp flat
168 nederlands.ly c d e f g a bes b -is -es
169 english.ly c d e f g a bf b -s/-sharp -f/-flat
170 deutsch.ly c d e f g a b h -is -es
171 norsk.ly c d e f g a b h -iss/-is -ess/-es
172 svenska.ly c d e f g a b h -iss -ess
173 italiano.ly do re mi fa sol la sib si -d -b
174 catalan.ly do re mi fa sol la sib si -d/-s -b
182 The optional octave specification takes the form of a series of
183 single quote (`@code{'}') characters or a series of comma
184 (`@code{,}') characters. Each @code{'} raises the pitch by one
185 octave; each @code{,} lowers the pitch by an octave.
187 @lilypond[fragment,verbatim,center]
188 c' c'' es' g' as' gisis' ais'
191 @c . {Defining pitch names}
192 @node Defining pitch names
193 @subsection Defining pitch names
195 @cindex defining pitch names
196 @cindex pitch names, defining
198 Note names and chord modifiers can be customised for nationalities. The
199 syntax is as follows.
201 @cindex @code{\pitchnames}
202 @cindex @code{\chordmodifiers}
204 \pitchnames @var{scheme-alist}
205 \chordmodifiers @var{scheme-alist}
208 See @file{ly/nederlands.ly} and @file{ly/chord-modifiers.ly} for
209 specific examples how to do this.
215 @subsection Durations
219 @cindex @code{\duration}
221 The syntax for a verbose duration specification is
223 \duration @var{scmduration}
225 Here, @var{scmduration} is a Scheme object of type Duration. See
226 @ref{Duration} for more information.
229 In Note, Chord, and Lyrics mode, durations may be designated by numbers
230 and dots: durations are entered as their reciprocal values. For notes
231 longer than a whole note, use identifiers.
237 c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64
239 r1 r2 r4 r8 r16 r32 r64 r64
245 \notes \relative c'' {
246 a\longa a\breve \autoBeamOff
247 a1 a2 a4 a8 a16 a32 a64 a64
249 r1 r2 r4 r8 r16 r32 r64 r64
254 \remove "Clef_engraver";
255 \remove "Staff_symbol_engraver";
256 \remove "Time_signature_engraver";
257 \consists "Pitch_squash_engraver";
264 As you can see, the longa is not printed. To get a longa note head, you
265 have to use a mensural note heads. This is done accomplished by setting
266 the @code{style} property of the NoteHead grob to @code{mensural}.
268 If the duration is omitted then it is set to the previous duration
269 entered. At the start of parsing a quarter note is assumed. The
270 duration can be followed by a dot (`@code{.}') to obtain dotted note
274 @lilypond[fragment,verbatim,center]
280 You can alter the length of duration by appending
281 `@code{*}@var{fraction}'. This will not affect the appearance of the
282 notes or rests produced.
288 A note specification has the form
291 @var{pitch}[@var{octavespec}][!][?][@var{duration}]
294 LilyPond will determine what accidentals to typeset depending on the key
295 and context. The alteration refers to what note is heard, not to whether
296 an accidental is printed. A reminder accidental
297 @cindex reminder accidental
299 can be forced by adding an exclamation mark @code{!} after the pitch. A
300 cautionary accidental,
301 @cindex cautionary accidental
302 i.e., an accidental within parentheses can be obtained by adding the
303 question mark `@code{?}' after the pitch.
305 @lilypond[fragment,verbatim,center]
306 cis' d' e' cis' c'? d' e' c'!
310 @node Easy Notation note heads
311 @subsection Easy Notation note heads
313 @cindex easy notation
316 A entirely different type of note head is the "easyplay" note head: a
317 note head that includes a note name. It is used in some publications by
318 Hal-Leonard Inc. music publishers.
320 @lilypond[singleline,verbatim]
321 \include "paper26.ly"
323 \notes { c'2 e'4 f' | g'1 }
324 \paper { \translator { \EasyNotation } }
328 Note that @code{EasyNotation} overrides a @code{Score} context. You
329 probably will want to print it with magnification to make it better
335 If you view the result with Xdvi, then staff lines will show through the
336 letters. Printing the postscript file obtained either by using dvips or
337 the @code{-f ps} option of lilypond will produce the desired result.
347 A tie connects two adjacent note heads of the same pitch. When used
348 with chords, it connects all of the note heads whose pitches match.
349 Ties are indicated using the tilde symbol `@code{~}'.
350 If you try to tie together chords which have no common pitches, a
351 warning message will appear and no ties will be created.
353 @lilypond[fragment,verbatim,center]
354 e' ~ e' <c' e' g'> ~ <c' e' g'>
357 If you dislike the amount of ties created for a chord, you set
358 @code{Thread.sparseTies} to true, resulting in a smaller number of
360 @lilypond[fragment,verbatim,center]
361 \property Thread.sparseTies = ##t
362 <c' e' g'> ~ <c' e' g'>
365 In its meaning a tie is just a way of extending a note duration, similar
366 to the augmentation dot: the following example are three ways of notating
367 exactly the same concept.
368 @lilypond[fragment, singleline]
374 At present, the tie is implemented as a separate thing, temporally
375 located in between the notes. There is also no way to convert
376 between tied notes, dotted notes and plain notes.
378 Tieing only a subset of the note heads of a chord is not supported in a
379 simple way. It can be achieved by moving the tie-engraver into Thread
380 context and turning off ties per Thread.
389 @subsubsection Tuplets
393 Tuplets are made out of a music expression by multiplying their duration
396 @cindex @code{\times}
398 \times @var{fraction} @var{musicexpr}
401 The duration of @var{musicexpr} will be multiplied by the fraction.
402 In print, the fraction's denominator will be printed over the notes,
403 optionally with a bracket. The most common tuplet is the triplet in
404 which 3 notes have the length of 2, so the notes are 2/3 of
405 their written length:
407 @lilypond[fragment,verbatim,center]
408 g'4 \times 2/3 {c'4 c' c'} d'4 d'4
411 [todo: document tupletSpannerDuration]
421 Rests are entered like notes, with note name `@code{r}'.
431 \skip @var{duration} @code{;}
436 Skips the amount of time specified by @var{duration}. If no other music
437 is played, a gap will be left for the skipped time with no notes
438 printed. The short hand is only available in Note and Chord mode.
443 @subsection Note mode
448 @cindex @code{\notes}
450 Note mode is the lexical mode generally used for inputting notes. The
456 This instructs the tokenizer to interpret @var{expr} in note mode. If a
457 a sequence of alfabetical characters, like @code{foobar}, LilyPond first
458 checks if @code{foobar} is a pitch name. If it is not a pitch name,
459 then it is treated as a string.
461 Numbers and dots indicate durations, so you can enter floating point
462 numbers in this mode.
466 @section Staff notation
468 @cindex Staff notation
478 @subsection Key signature
483 Changing the key signature is done with the @code{\key} command.
485 @code{\key} @var{pitch} @var{type} @code{;}
488 @cindex @code{\minor}
489 @cindex @code{\major}
490 @cindex @code{\minor}
491 @cindex @code{\ionian}
492 @cindex @code{\locrian}
493 @cindex @code{\aeolian}
494 @cindex @code{\mixolydian}
495 @cindex @code{\lydian}
496 @cindex @code{\phrygian}
497 @cindex @code{\dorian}
499 Here, @var{type} should be @code{\major} or @code{\minor} to get
500 @var{pitch}-major or @var{pitch}-minor, respectively. The second
501 argument is optional; the default is major keys. The @var{\context}
502 argument can also be given as an integer, which tells the number of
503 semitones that should be added to the pitch given in the subsequent
504 @code{\key} commands to get the corresponding major key, e.g.,
505 @code{\minor} is defined as 3. The standard mode names @code{\ionian},
506 @code{\locrian}, @code{\aeolian}, @code{\mixolydian}, @code{\lydian},
507 @code{\phrygian}, and @code{\dorian} are also defined.
509 This command sets context property @code{Staff.keySignature}.
511 @cindex @code{keySignature}
514 @subsection Clef changes
517 \clef @var{clefname} @code{;}
523 \property Staff.clefGlyph = @var{glyph associated with clefname}
524 \property Staff.clefPosition = @var{clef Y-position for clefname}
525 \property Staff.clefOctavation = @var{extra pitch of clefname}
528 Supported clef-names include
531 @item treble, violin, G, G2: G clef on 2nd line
532 @item french: G clef on 1st line
533 @item soprano: C clef on 1st line
534 @item mezzosoprano: C clef on 2nd line
535 @item alto: C clef on 3rd line
536 @item tenor: C clef on 4th line
537 @item baritone: C clef on 5th line
538 @item varbaritone: F clef on 3rd line
539 @item bass, F: F clef on 4th line
540 @item subbass: F clef on 5th line
541 @item percussion: percussion clef
544 Supported associated glyphs (for @code{Staff.clefGlyph}) are:
547 @item clefs-C: modern style C clef
548 @item clefs-F: modern style F clef
549 @item clefs-G: modern style G clef
550 @item clefs-vaticana_do: Editio Vaticana style do clef
551 @item clefs-vaticana_fa: Editio Vaticana style fa clef
552 @item clefs-medicaea_do: Editio Medicaea style do clef
553 @item clefs-medicaea_fa: Editio Medicaea style fa clef
554 @item clefs-mensural1_c: modern style mensural C clef
555 @item clefs-mensural2_c: historic style small mensural C clef
556 @item clefs-mensural3_c: historic style big mensural C clef
557 @item clefs-mensural1_f: historic style traditional mensural F clef
558 @item clefs-mensural2_f: historic style new mensural F clef
559 @item clefs-mensural_g: historic style mensural G clef
560 @item clefs-hufnagel_do: historic style hufnagel do clef
561 @item clefs-hufnagel_fa: historic style hufnagel fa clef
562 @item clefs-hufnagel_do_fa: historic style hufnagel combined do/fa clef
563 @item clefs-percussion: modern style percussion clef
566 @emph{Modern style} means ``as is typeset in current editions.''
567 @emph{Historic style} means ``as was typeset or written in contemporary
568 historic editions''. @emph{Editio XXX style} means ``as is/was printed in
571 @cindex Vaticana, Editio
572 @cindex Medicaea, Editio
573 @cindex hufnagel clefs
576 @c . {Time signature}
578 @subsection Time signature
579 @cindex Time signature
583 The time signature is changed by the @code{\time} command. Syntax:
585 \time @var{numerator}@code{/}@var{denominator} @code{;}
587 Internally, this is a short-cut for doing
589 \property Score.timeSignatureFraction = #'(@var{numerator} . @var{denominator})
592 [TODO: discuss options for layout]
595 @subsubsection Partial
599 @cindex partial measure
600 @cindex measure, partial
601 @cindex shorten measures
602 @cindex @code{\partial}
604 Partial measures are entered using the @code{\partial} command:
606 \partial @var{duration} @code{;}
609 Internally, this is a short cut for
612 \property Score.measurePosition = -@var{length of duration}
618 @subsection Bar lines
622 @cindex measure lines
629 This is a short-cut for doing
631 \property Score.whichBar = @var{bartype}
634 You are encouraged to use @code{\repeat} for repetitions. See
635 @ref{Repeats}, and the documentation of @code{whichBar} in the generated
639 @cindex Bar_line_engraver
641 @cindex repeatCommands
642 @cindex defaultBarType
644 Bar lines are created by the @code{Bar_line_engraver}. That engraver examines
645 @code{whichBar} at every moment. Whenever it is set to a string, it will
646 create a bar with that type. @code{whichBar} is usually set
647 automatically: at the start of a measure it is set to
648 @code{defaultBarType}. The contents of @code{repeatCommands} is used to
649 override default measure bars.
651 @code{whichBar} can also be set directly, using @code{\property} or
652 @code{\bar ; }. These settings take precedence over automatic @code{whichBar}
661 [TODO: collisions, rest-collisinos, voiceX identifiers, how to
662 which contexts to instantiate.]
666 @cindex @code{\shiftOff}
667 @item @code{\shiftOff}
668 Disable horizontal shifting of note heads that collide.
670 @cindex @code{\shiftOn}
671 @item @code{\shiftOn}
672 Enable note heads that collide with other note heads to be
673 shifted horiztonally. Also @code{\shiftOnn} and @code{\shiftOnnn}
674 set different shift values.
676 @cindex @code{\stemBoth}
677 @item @code{\stemBoth}
678 Allow stems and beams to point either upwards or
679 downwards, decided automatically by LilyPond.
681 @cindex @code{\stemDown}
682 @item @code{\stemDown}
683 Force stems and beams to point down.
685 @cindex @code{\stemUp}
687 Force stems and beams to point up.
690 @cindex @code{\slurBoth}
691 @cindex @code{\slurDown}
692 @cindex @code{\slurUp}
693 Similarly, for slurs use
697 @cindex @code{\slurBoth}
698 @cindex @code{\slurDown}
699 @cindex @code{\slurUp}
709 Beams are used to group short notes into chunks that are aligned with
710 the metrum. LilyPond guesses where beams should be inserted, but if
711 you're not satisfied with the automatic beaming, you can either instruct
712 lilypond which patterns to beam automatically. In specific cases, you
713 can also specify explicitly what to beam and what not.
716 @c . {Automatic beams}
717 @subsection Automatic beams
719 @cindex @code{Voice.autoBeamSettings}
720 @cindex @code{(end * * * *)}
721 @cindex @code{(begin * * * *)}
723 A large number of Voice properties are used to decide how to generate
724 beams. Their default values appear in @file{scm/auto-beam.scm}.
726 By default, automatic beams can start on any note@footnote{In exotic
727 time signatures such as 1/8 and 1/16 this is not true} but can only end
728 in a few positions within the measure: they can end on a beat, or at
729 durations specified by the properties in
730 @code{Voice.autoBeamSettings}. The defaults for @code{autoBeamSettings}
731 are defined in @file{scm/auto-beam.scm}.
733 The syntax for changing the value @code{autoBeamSettings} is set using
734 @code{\override} and unset using @code{\revert}:
736 \property Voice.autoBeamSettings \override #'(@var{BE} @var{N} @var{M} @var{P} @var{Q}) = @var{dur}
737 \property Voice.autoBeamSettings \revert #'(@var{BE} @var{N} @var{M} @var{P} @var{Q})
739 Here, @var{BE} is the symbol @code{begin} or @code{end}. It determines
740 whether the rule applies to begin or end-points. The quantity
741 @var{N}/@var{M} refers to a time signature (@code{* *} may be entered to
742 designate all time signatures), @var{P}/@var{Q} refers to the length of
743 the beamed notes (@code{* *} designate notes of any length).
745 If you want automatic beams to end on every quarter note, you can
748 \property Voice.autoBeamSettings \override
749 #'(end * * * *) = #(make-moment 1 4)
751 The duration a quarter note is 1/4 of a whole note. It is entered as
752 @code{(make-moment 1 4)}.
754 The same syntax can be used to specify beam starting points. In this
755 example, you automatic beams can only end on a dotted quarter note.
757 \property Voice.autoBeamSettings \override
758 #'(begin * * * *) = #(make-moment 3 8)
760 In 4/4 time signature, this means that automatic beams could end only on
761 3/8 and on the fourth beat of the measure (after 3/4, that is 2 times
762 3/8 has passed within the measure).
764 You can also restrict rules to specific time signatures. A rule that
765 should only be applied in @var{N}/@var{M} time signature is formed by
766 replacing the first asterisks by @var{N} and @var{M}. For example, a
767 rule for 6/8 time exclusively looks like
769 \property Voice.autoBeamSettings \override
770 #'(begin 6 8 * *) = ...
773 If you want a rule to apply to certain types of beams, you can use the
774 second pair of asterisks. Beams are classified according to the shortest
775 note they contain. For a beam ending rule that only applies to beams
776 with 32nd notes (and no shorter notes), you would use @code{(end * * 1
779 [say something about irregular meters. eg 5/8 = 2+3/8, 3+2/8]
781 Automatic beams can not be put on the last note in a score.
783 @cindex automatic beam generation
785 @cindex @code{Voice.noAutoBeaming}
787 Automatic beaming is on by default, but it can switched off by setting
788 @code{Voice.noAutoBeaming} to true. You you may find this necessary for
789 a melody that goes with lyrics.
792 @cindex Automatic beams
793 @subsubsection Manual beams
794 @cindex beams, manual
798 In some cases it may be necessary to override LilyPond's automatic
799 beaming algorithm. For example, the auto beamer will not beam over
800 rests or bar lines, so if you want that, specify the begin and end point
801 manually using @code{[} and @code{]}:
804 @lilypond[fragment,relative,verbatim]
806 r4 [r8 g'' a r8] r8 [g | a] r8
809 Whenever an manual beam is busy, the auto beam will not produce
812 @cindex @code{stemLeftBeamCount}
814 If you have specific wishes for the number of beams, you can fully
815 control the number of beams through the properties
816 @code{Voice.stemLeftBeamCount} and @code{Voice.stemRightBeamCount}.
818 @lilypond[fragment,relative,verbatim]
821 [f8 r16 \property Voice.stemLeftBeamCount = #1 f g a]
825 @cindex @code{stemRightBeamCount}
828 [FIXME: explain common tweaks.]
831 @node Expressive marks
832 @section Expressive marks
846 A slur indicates that notes are to be played bound or @emph{legato}. In
847 lilypond, they are entered using parentheses:
848 @lilypond[fragment,verbatim,center]
849 f'()g'()a' [a'8 b'(] a'4 g'2 )f'4
853 Slurs avoid crossing stems, and are attached to note heads whenever
854 possible. In some instances involving beams slurs may be attached to a
855 stem end. If you want to override this layout you can do this through
856 @code{Voice.Slur}'s grob-property @code{attachment}:
858 [TODO: remove this section]
859 Maybe reinclude other slur features and move back to tricks? Esp. the
860 second example, how to fix, can be very helpful.
863 @lilypond[fragment,relative,verbatim]
864 \property Voice.Slur \set #'direction = #1
865 \property Voice.Stem \set #'length = #5.5
867 \property Voice.Slur \set #'attachment = #'(stem . stem)
872 If a slur would strike through a stem or beam, the slur will be moved
873 away upward or downward. If this happens, attaching the slur to the
874 stems might look better:
877 @lilypond[fragment,relative,verbatim]
878 \property Voice.Stem \set #'direction = #1
879 \property Voice.Slur \set #'direction = #1
881 \property Voice.Slur \set #'attachment = #'(stem . stem)
887 Similarly, the curvature of a slur is adjusted to stay clear of note
888 heads and stems. When that would increase the curvature too much, the
889 slur is reverted to its default shape. The threshold for this decision
890 is in @code{Voice.Slur}'s grob-property @code{beautiful}. In some
891 cases, you may prefer curved slurs to vertically moved ones. You can
892 express this by increasing the @code{beautiful} value:
894 [hoe gedefd?? wat betekent beautiful = X?]
896 [dit voorbeeld is te lang: junken, of inkorten]
899 @lilypond[verbatim,singleline]
901 \notes \context PianoStaff <
903 \context Staff=up { s1 * 6/4 }
904 \context Staff=down <
906 \autochange Staff \context Voice
908 d,8( a' d f a d f d a f d )a
915 Slur \override #'beautiful = #5.0
916 Slur \override #'direction = #1
917 Stem \override #'direction = #-1
918 autoBeamSettings \override #'(end * * * *)
923 VerticalAlignment \override #'threshold = #'(5 . 5)
930 @cindex Adusting slurs
933 @subsection Phrasing slur
935 @cindex phrasing slur
936 @cindex phrasing mark
938 A phrasing slur (or phrasing mark) connects chords and is used to
939 indicate a musical sentence. It is entered using @code{\(} and
942 @lilypond[fragment,verbatim,center,relative]
943 \time 6/4; c''\((d)e f(e)\)d
946 Typographically, the phrasing slur behaves almost exactly like a normal
947 slur. The grob associated with it is @code{Voice.PhrasingSlur}.
950 @subsection Breath marks
952 Breath marks are entered using @code{\breathe}:
954 @lilypond[fragment,relative]
958 Currently, only tick marks are supported, comma style breath marks are
959 not. The grob for this object is called @code{Voice.BreathingSign}.
964 Currently, only tick marks are supported, comma style breath marks are
972 @cindex beats per minute
973 @cindex metronome marking
975 @cindex @code{\tempo}
977 \tempo @var{duration} = @var{perminute} @code{;}
980 Used to specify the tempo. For example, @code{\tempo 4 = 76;} requests
981 output with 76 quarter notes per minute.
985 The tempo setting is not printed, but is currently only used in the MIDI
997 @subsubsection Text spanner
1000 Some textual indications, e.g. rallentando, accelerando, often extend
1001 over a many measures. This is indicated by following the text with a
1002 dotted line. You can create such texts in LilyPond using
1003 text spanners. The syntax is as follows:
1005 \spanrequest \start "text"
1006 \spanrequest \stop "text"
1008 LilyPond will respond by creating a @code{Voice.TextSpanner} grob. The
1009 string to be printed, as well as the style is set through grob
1012 An application---or rather, a hack---is to fake octavation indications.
1013 @lilypond[fragment,relative,verbatim]
1014 \relative c' { a'''' b c a
1015 \property Voice.TextSpanner \set #'type = #'dotted-line
1016 \property Voice.TextSpanner \set #'edge-height = #'(0 . 1.5)
1017 \property Voice.TextSpanner \set #'edge-text = #'("8va " . "")
1018 \property Staff.centralCPosition = #-13
1019 a\spanrequest \start "text" b c a \spanrequest \stop "text" }
1035 @subsection Articulation
1036 @cindex Articulation
1038 @cindex articulations
1042 A variety of symbols can appear above and below notes to indicate
1043 different characteristics of the performance. These symbols can be
1044 added to a note with `@var{note}@code{-\}@var{name}'. Numerous symbols
1045 are defined in @file{script.ly} and @file{script.scm}. Symbols can be
1046 forced to appear above or below the note by writing
1047 `@var{note}@code{^\}@var{name}' and `@var{note}@code{_\}@var{name}'
1048 respectively. Here is a chart showing symbols above notes, with the
1049 name of the corresponding symbol appearing underneath.
1054 \property Score.LyricSyllable \override #'font-family =
1056 \property Score.LyricSyllable \override #'font-shape = #'upright
1057 c''-\accent c''-\marcato c''-\staccatissimo c''-\fermata
1058 c''-\stopped c''-\staccato c''-\tenuto c''-\upbow
1059 c''-\downbow c''^\lheel c''-\rheel c''^\ltoe
1060 c''-\rtoe c''-\turn c''-\open c''-\flageolet
1061 c''-\reverseturn c''-\trill c''-\prall c''-\mordent
1062 c''-\prallprall c''-\prallmordent c''-\upprall c''-\downprall
1063 c''-\thumb c''-\segno c''-\coda
1065 \context Lyrics \lyrics {
1066 accent__ marcato__ staccatissimo__ fermata
1067 stopped__ staccato__ tenuto__ upbow
1068 downbow__ lheel__ rheel__ ltoe
1069 rtoe__ turn__ open__ flageolet
1070 reverseturn__ trill__ prall__ mordent
1071 prallprall__ prallmordent__ uprall__ downprall
1072 thumb__ segno__ coda
1076 linewidth = 5.875\in;
1082 To save typing work, some shorthands are available:
1083 @lilypond[singleline]
1085 \notes \context Voice {
1086 \property Voice.TextScript \set #'font-family = #'typewriter
1087 \property Voice.TextScript \set #'font-shape = #'upright
1093 c''4-^_"c-\\^{ }" s4
1100 Fingering instructions can also be entered in this shorthand.
1101 @lilypond[verbatim, singleline, fragment]
1102 c'4-1 c'4-2 c'4-3 c'4-4
1106 @cindex @code{\script}
1115 Defines a script printing request. The argument is a string which
1116 points into the script-alias table defined in @file{scm/script.scm}.
1117 Usually the @code{\script} keyword is not used directly. Various
1118 helpful identifier definitions appear in @file{script.ly}.
1120 For information on how to add scripts, consult @file{scm/script.scm}.
1125 All of these note ornaments appear in the printed output but have no
1126 effect on the MIDI rendering of the music.
1128 Unfortunately, there is no support adding fingering instructions or
1129 ornaments to individual note heads. Some hacks exist, though. See
1130 @file{input/test/script-horizontal.ly}.
1135 @subsection Text scripts
1136 @cindex Text scripts
1138 In addition, it is possible to place arbitrary strings of text or markup
1139 text (see @ref{Text markup}) above or below notes by using a string:
1140 @code{c^"text"}. The text is typeset in italic by default.
1142 The amount of space taken by these indications by default does not
1143 influence, spacing, but setting @code{Voice.textNonEmpty} to true will
1144 take the widths into account. The identifier @code{\fattext} is defined
1145 in the standard includes.
1146 @lilypond[fragment,singleline]
1147 \relative c' { c4^"longtext" \fatText c4_"longlongtext" c4 }
1150 Text scripts are created in form of @code{Voice.TextScript} grobs.
1152 For purposes of defining identifiers, a more verbose form also exists:
1155 \textscript @var{text}
1158 Defines a text to be printed over or under a note. @var{text} is a
1159 string or a markup text.
1163 foo = \textscript #'(finger "6")
1170 This is equivalent to @code{c4-6 c4-"foo"}.
1175 @subsection Grace notes
1184 @cindex @code{\grace}
1187 @cindex @code{graceAlignPosition}
1189 Grace notes are ornaments that are written out, but do not take up any
1190 logical time in a measure. LilyPond has limited support for grace notes.
1191 The syntax is as follows.
1193 \grace @var{musicexpr}
1196 When grace music is interpreted, a score-within-a-score is set up:
1197 @var{musicexpr} has its own time bookkeeping, and you could (for
1198 example) have a separate time signature within grace notes. While in
1199 this score-within-a-score, you can create notes, beams, slurs, etc.
1200 Unbeamed eighth notes and shorter by default have a slash through the
1201 stem. This behavior can be controlled with the
1202 @code{Stem}.@code{flag-style} property.
1205 @lilypond[fragment,verbatim]
1207 \grace c8 c4 \grace { [c16 c16] } c4
1208 \grace { \property Grace.Stem \override #'flag-style = ##f c16 } c4
1215 At present, nesting @code{\grace} notes is not supported. The following
1216 may cause run-time errors:
1218 @code{\grace @{ \grace c32 c16 @} c4}
1220 Since the meaning of such a construct is unclear, we don't consider this
1221 a loss. Similarly, juxtaposing two @code{\grace} sections is
1222 syntactically valid, but makes no sense and may cause runtime errors.
1223 Ending a staff or score with grace notes may also generate a run-time
1224 error, since there will be no main note to attach the grace notes to.
1227 A grace note expression has duration 0; the next real note is assumed to
1228 be the main note. If you want the note to appear after the main note,
1229 set @code{Voice.graceAlignPosition} to @code{1}.
1233 The present implementation of grace notes is not robust and generally
1234 kludgy. We expect it to change after LilyPond 1.4. Syntax changes might
1235 also be implemented.
1248 @subsubsection Glissando
1251 @cindex @code{\glissando}
1253 A glissando line can be requested by attaching a @code{\glissando} to a
1257 @lilypond[fragment,relative,verbatim]
1264 Printing of an additional text (such as @emph{gliss.}) must be done
1271 @subsubsection Dynamics
1284 @cindex @code{\ffff}
1294 Absolute dynamic marks are specified by using an identifier after a
1295 note: @code{c4-\ff}. The available dynamic marks are: @code{\ppp},
1296 @code{\pp}, @code{\p}, @code{\mp}, @code{\mf}, @code{\f}, @code{\ff},
1297 @code{\fff}, @code{\fff}, @code{\fp}, @code{\sf}, @code{\sff},
1298 @code{\sp}, @code{\spp}, @code{\sfz}, and @code{\rfz}.
1301 @cindex Crescendo and Decrescendo
1305 @cindex @code{\decr}
1306 @cindex @code{\rced}
1312 A crescendo mark is started with @code{\cr} and terminated with
1313 @code{\rc} (the textual reverse of @code{cr}). A decrescendo mark is
1314 started with @code{\decr} and terminated with @code{\rced}. There are
1315 also shorthands for these marks. A crescendo can be started with
1316 @code{\<} and a decrescendo can be started with @code{\>}. Either one
1317 can be terminated with @code{\!}. Note that @code{\!} must go before
1318 the last note of the dynamic mark whereas @code{\rc} and @code{\rced} go
1319 after the last note. Because these marks are bound to notes, if you
1320 want to get several marks during one note, you must use spacer notes.
1322 @lilypond[fragment,verbatim,center]
1323 c'' \< \! c'' d'' \decr e'' \rced
1324 < f''1 { s4 \< \! s2 \> \! s4 } >
1329 You can also use a text saying @emph{cresc.} instead of hairpins. Here
1330 is an example how to do it:
1332 @lilypond[fragment,relative,verbatim]
1334 \property Voice.crescendoText = "cresc."
1335 \property Voice.crescendoSpanner = #'dashed-line
1351 @cindex @code{\repeat}
1353 To specify repeats, use the @code{\repeat} keyword. Since repeats
1354 should work differently when played or printed, there are a few
1355 different variants of repeats.
1359 Repeated music is fully written (played) out. Useful for MIDI
1363 This is the normal notation: Repeats are not written out, but
1364 alternative endings (voltas) are printed, left to right.
1367 Alternative endings are written stacked. Which is unfortunately not
1368 practical for anything right now.
1374 Make measure repeats. These look like percent signs.
1380 * Manual repeat commands::
1382 * Tremolo subdivision::
1387 @subsection Repeat syntax
1389 The syntax for repeats is
1392 \repeat @var{variant} @var{repeatcount} @var{repeatbody}
1395 If you have alternative endings, you may add
1396 @cindex @code{\alternative}
1398 \alternative @code{@{} @var{alternative1}
1400 @var{alternative3} @dots{} @code{@}}
1402 where each @var{alternative} is a music expression.
1404 Normal notation repeats are used like this:
1405 @lilypond[fragment,verbatim]
1407 \repeat volta 2 { c'4 d' e' f' }
1408 \repeat volta 2 { f' e' d' c' }
1411 With alternative endings:
1413 @lilypond[fragment,verbatim]
1415 \repeat volta 2 {c'4 d' e' f'}
1416 \alternative { {d'2 d'} {f' f} }
1420 Folded repeats look like this:@footnote{Folded repeats offer little
1421 more over simultaneous music. However, it is to be expected that
1422 more functionality -- especially for the MIDI backend -- will be
1423 implemented at some point in the future.}
1426 @lilypond[fragment,verbatim]
1428 \repeat fold 2 {c'4 d' e' f'}
1429 \alternative { {d'2 d'} {f' f} }
1435 If you don't give enough alternatives for all of the repeats, then
1436 the first alternative is assumed to be repeated often enough to equal
1437 the specified number of repeats.
1440 @lilypond[fragment,verbatim]
1444 \repeat volta 3 { e | c2 d2 | e2 f2 | }
1445 \alternative { { g4 g g } { a | a a a a | b2. } }
1453 As you can see, LilyPond doesn't remember the timing information, nor
1454 are slurs or ties repeated, so you have to reset timing information
1455 after a repeat, e.g. using a bar-check (See @ref{Bar check}),
1456 @code{Score.measurePosition} or @code{\partial}. We hope to fix this
1459 It is possible to nest @code{\repeat}, although it probably is only
1460 meaningful for unfolded repeats.
1462 @node Manual repeat commands
1463 @subsection Manual repeat commands
1465 @cindex @code{repeatCommands}
1467 The property @code{repeatCommands} can be used to control the layout of
1468 repeats. Its value is a Scheme list of repeat commands, where each repeat
1476 @item (volta . @var{text})
1477 Print a volta bracket saying @var{text}.
1479 Stop a running volta bracket
1482 @lilypond[verbatim, fragment]
1484 \property Score.repeatCommands = #'((volta "93") end-repeat)
1486 \property Score.repeatCommands = #'((volta #f))
1491 @node Tremolo repeats
1492 @subsection Tremolo repeats
1493 @cindex tremolo beams
1495 To place tremolo marks between notes, use @code{\repeat} with tremolo
1497 @lilypond[verbatim,center,singleline]
1499 \context Voice \notes\relative c' {
1500 \repeat "tremolo" 8 { c16 d16 }
1501 \repeat "tremolo" 4 { c16 d16 }
1502 \repeat "tremolo" 2 { c16 d16 }
1503 \repeat "tremolo" 4 c16
1511 At present, the spacing between tremolo beams is not regular, since the
1512 spacing engine does not notice that not all notes are printed.
1514 @node Tremolo subdivision
1515 @subsection Tremolo subdivision
1516 @cindex tremolo marks
1517 @cindex @code{tremoloFlags}
1519 Tremolo marks can be printed on a single note by adding
1520 `@code{:}[@var{length}]' after the note. The length must be at least 8.
1521 A @var{length} value of 8 gives one line across the note stem. If the
1522 length is omitted, then then the last value (stored in
1523 @code{Voice.tremoloFlags}) is used.
1525 @lilypond[verbatim,fragment,center]
1528 Using this mechanism pays off when you entering many tremolos, since the
1529 default argument saves a lot of typing.
1534 Tremolos in this style do not carry over into the MIDI output.
1537 @node Measure repeats
1538 @subsection Measure repeats
1540 @cindex percent repeats
1541 @cindex measure repeats
1543 In the @code{percent} style, a note pattern can be repeated. It is
1544 printed once, and then the pattern is replaced with a special sign.
1546 @lilypond[verbatim,singleline]
1547 \context Voice { \repeat "percent" 5 { c'1 } }
1550 At present, only repeats of whole measures are supported.
1554 @section Piano music
1556 Piano music is an odd type of notation: two staffs are largely
1557 independent, but sometimes voices can cross between the two staffs. The
1558 @code{PianoStaff} is especially built to handle this cross-staffing
1559 behavior. In this section we discuss the @code{PianoStaff} and some
1560 other pianistic peculiarities.
1563 * Automatic staff changes::
1564 * Manual staff switches::
1571 @c . {Automatic staff changes}
1572 @node Automatic staff changes
1573 @subsection Automatic staff changes
1574 @cindex Automatic staff changes
1576 Voices can be switched from top to bottom staff automatically. The
1579 \autochange @var{contexttype} @var{musicexp}
1581 This will switch notation context of @var{musicexp} between a
1582 @var{contexttype} named @code{up} and @code{down}. Typically, you use
1583 @code{Staff} for @var{contexttype}. The autochanger switches on basis
1584 of pitch (central C is the turning point), and it looks ahead skipping
1585 over rests to switch rests in advance.
1587 @lilypond[verbatim,singleline]
1588 \score { \notes \context PianoStaff <
1589 \context Staff = "up" {
1590 \autochange Staff \context Voice = VA < \relative c' {
1591 g4 a b c d r4 a g } > }
1592 \context Staff = "down" {
1598 Note how spacer rests are used to prevent the bottom staff from
1599 terminating too soon.
1602 @node Manual staff switches
1603 @subsection Manual staff switches
1605 @cindex manual staff switches
1606 @cindex staff switch, manual
1608 Voices can be switched between staffs manually, using the following command:
1610 \translator Staff = @var{which} @var{music}
1612 The string @var{which} is the name of the staff. Typically it is
1613 @code{"up"} or @code{"down"}.
1615 Formally, this construct is a music expression indicating that the
1616 context which is a direct child of the a context of type
1617 @var{contexttype} should be shifted to a context of type
1618 @var{contexttype} and the specified name.
1620 @cindex @code{\translator}
1622 \translator @var{contexttype} = @var{name}
1631 Piano pedal instruction can be expressed using
1632 @code{\sustainDown}, @code{\sustainUp}, @code{\unaChorda},
1633 @code{\treChorde}, @code{\sostenutoDown} and @code{\sostenutoUp}.
1635 These identifiers are short hands for spanner commands of the types
1636 @code{Sustain}, @code{UnaChorda} and @code{Sostenuto}:
1638 @lilypond[fragment,verbatim]
1639 c''4 \spanrequest \start "Sustain" c''4 c''4 \spanrequest \stop "Sustain"
1642 The symbols that are printed can be modified by setting
1643 @code{pedal@var{X}Strings}, where @var{X} is one of the pedal
1644 types. Refer to the generated documentation for more information.
1649 Currently, brackets are not supported, only text markings (ie. *Ped
1655 @subsection Arpeggio
1658 @cindex broken arpeggio
1659 @cindex @code{\arpeggio}
1661 You can specify an arpeggio sign on a chord by attaching an
1662 @code{\arpeggio} to a note of the chord.
1666 @lilypond[fragment,relative,verbatim]
1667 \context Voice <c'\arpeggio e g c>
1671 When an arpeggio crosses staffs in piano music, you attach an arpeggio
1672 to the chords in both staffs, and set
1673 @code{PianoStaff.connectArpeggios}.
1676 @lilypond[fragment,relative,verbatim]
1677 \context PianoStaff <
1678 \property PianoStaff.connectArpeggios = ##t
1679 \context Voice = one { <c''\arpeggio e g c> }
1680 \context Voice = other { \clef bass; <c,,\arpeggio e g>}
1685 This command creates @code{Arpeggio} grobs.
1689 It is not possible to mix
1690 connected arpeggios and unconnected arpeggios at the same time.
1693 @c . {Follow Thread}
1695 @subsection Follow Thread
1697 @cindex follow thread
1698 @cindex staff switching
1701 [todo: figure out different name, eg. voice line, switch indicator ? ]
1703 @cindex @code{followThread}
1705 Whenever a voice switches to another staff a line connecting the notes
1706 can be printed automatically. This is enabled if the property
1707 @code{PianoStaff.followThread} is set to true:
1710 @lilypond[fragment,relative,verbatim]
1711 \context PianoStaff <
1712 \property PianoStaff.followThread = ##t
1713 \context Staff \context Voice {
1715 \translator Staff=two
1718 \context Staff=two {\clef bass; \skip 1*2;}
1732 * Automatic syllable durations::
1738 @subsection Lyrics mode
1741 To print lyrics in LilyPond, you must first make a music expression from
1742 the lyric text. When they're in a music expression, that music
1743 expression can be printed by selecting an appropriate context. We shall
1744 discuss lyric printing in this order.
1748 @cindex @code{\lyrics}
1750 You can enter lyrics in a special input mode of LilyPond. This mode is
1751 called Lyrics mode, and it is introduced by the keyword @code{\lyrics}.
1752 The purpose of this mode is that you can enter lyrics as plain text,
1753 punctuation and accents without any hassle.
1755 The precise definition of this mode is in @ref{Lyrics mode
1756 definition}. The definition itself is ludicrous, and this will remain so
1757 until the authors of LilyPond acquire a deeper understanding of
1758 character encoding, or someone else steps up to fix this.
1760 Syllables are entered like notes, with pitches replaced by text. For
1761 example, @code{Twin- kle twin- kle} enters four syllables. Note that
1762 the hyphen has no special meaning for lyrics, and does not introduce
1765 Spaces can be introduced into a lyric either by using quotes
1766 (@code{"}) or by using an underscore without quotes: @code{He_could4
1767 not4}. All unquoted underscores are converted to spaces.
1769 @c . {Printing lyrics}
1770 @node Printing lyrics
1771 @subsection Printing lyrics
1774 Normally, you will want to have notes and syllables matched
1775 automatically. This is accomplished using @code{\addlyrics}, which is
1776 documented in @ref{Automatic syllable durations}. Setting
1777 @code{automaticMelismata} in the melody staff, will cause slurs to be
1778 interpreted as melismata. Lyric syllables must be interpreted within a
1779 @code{Lyrics} context in order to printing them.
1781 @lilypond[verbatim,singleline]
1782 \addlyrics \notes \relative c' {
1784 \property Staff.automaticMelismata = ##t
1787 \context Lyrics \lyrics {
1789 share the so -- ftware; }
1793 @cindex lyric extender
1796 As you can see, extender lines are entered as @code{__}. This will
1797 create an extender, a line that extends over the entire duration of the
1798 lyric. This line will run all the way to the start of the next lyric,
1799 so you may want to shorten it by using a blank lyric (using @code{_}).
1803 If you want to have hyphens centered between syllables (rather than
1804 attached to the end of the first syllable) you can use the special
1805 `@code{-}@code{-}' lyric as a separate word between syllables. This
1806 will result in a hyphen which length varies depending on the space
1807 between syllables, and which will be centered between the syllables.
1809 @cindex Lyric hyphen
1811 @node Automatic syllable durations
1812 @subsection Automatic syllable durations
1813 @cindex Automatic syllable durations
1815 @cindex automatic lyric durations
1816 @cindex @code{\addlyrics}
1818 If you have lyrics that are set to a melody, you can import the rhythm
1819 of that melody into the lyrics using @code{\addlyrics}. The syntax for
1822 \addlyrics @var{musicexpr1 musicexpr2}
1825 This means that both @var{musicexpr1} and @var{musicexpr2} are
1826 interpreted, but that every non-command atomic music expression
1827 (``every syllable'') in @var{musicexpr2} is interpreted using timing
1828 of @var{musicexpr1}.
1829 @cindex @code{automaticMelismata}
1831 If the property @code{automaticMelismata} is set in the
1832 context of @var{musicexpr1}, no lyrics will be put on slurred or tied
1835 @lilypond[verbatim,fragment]
1838 \property Voice.automaticMelismata = ##t
1839 c8 () cis d8. e16 f2
1841 \context Lyrics \lyrics {
1845 If you want the lyric lines to be above the melody staff, or in some
1846 other, more complex configuration, then build that configuration first
1847 using simultaneous music, and use @code{\addlyrics} after that.
1849 @lilypond[verbatim, singleline]
1851 \context Lyrics = LA { s1 }
1852 \context Staff = SA { s1 }
1854 \context Staff = SA \relative c' { c4 e g g }
1855 \context Lyrics = LA \lyrics { geen ge -- don -- der } >
1858 For @code{\addlyrics} you should use a single rhythm melody, and single
1859 rhythm lyrics (a constant duration is the obvious choice). If you do
1860 not, you can get undesired effects when using multiple stanzas:
1862 @lilypond[verbatim,fragment]
1865 c8 () cis d8. e16 f2
1867 \context Lyrics \lyrics
1872 It is valid (but probably not very useful) to use notes instead of
1873 lyrics for @var{musicexpr2}.
1876 @subsection More stanzas
1880 If you have multiple stanzas printed underneath each other, the separate
1881 syllables should be aligned around punctuation. LilyPond can do this if
1882 you explain it which lyric lines belong to which melody.
1884 To this end, give the Voice context an identity, and set the LyricsVoice
1885 to name starting with that identity. In the following example, the Voice
1886 identity is @code{duet}, and the identities of the LyricsVoices are
1887 @code{duet-1} and @code{duet-2}.
1890 @lilypond[singleline,verbatim]
1893 \notes \relative c'' \context Voice = duet { \time 3/4;
1895 \lyrics \context Lyrics <
1896 \context LyricsVoice = "duet-1" {
1897 \property LyricsVoice . stanza = "Bert"
1898 Hi, my name is bert. }
1899 \context LyricsVoice = "duet-2" {
1900 \property LyricsVoice . stanza = "Ernie"
1901 Ooooo, ch\'e -- ri, je t'aime. }
1906 You can add stanza numbers by setting @code{LyricsVoice.Stanza} (for the
1907 first system) and @code{LyricsVoice.stz} for the following systems.
1909 @cindex stanza numbering
1917 LilyPond has support for both entering and printing chords. Chords are
1918 a harmonic device that is characterized by a set of pitches. It is
1919 something different from simultaneous music, although you can express a
1920 chord using simultaneous music. In fact, chords are internally stored as
1921 simultaneous music expressions. This means you can enter chords by name,
1922 and print them as note head, or enter as notes and print as chord names:
1925 @lilypond[verbatim,singleline]
1926 twoWays = \notes \transpose c'' {
1936 < \context ChordNames \twoWays
1937 \context Staff \twoWays > }
1940 Note that this example also shows that the LilyPond chord does not
1941 attempt to be intelligent, if you enter @code{f bes d}, it does no
1942 attempt to find out whether it this is an inversion.
1946 * Printing named chords::
1951 @subsection Chords mode
1954 Chord mode is a mode where you can input sets of pitches using common
1955 names. It is introduced by the keyword @code{\chords}. It is similar
1956 to note mode, but words are also looked up in a chord modifier table
1957 (containing @code{maj}, @code{dim}, etc).
1959 Dashes and carets are used to indicate chord additions and subtractions,
1960 so articulation scripts can not be entered in Chord mode.
1962 The syntax for named chords is as follows:
1965 @var{tonic}[@var{duration}][@code{-}@var{modifiers}][@code{^}@var{subtractions}][@code{/}@var{inversion}][@code{/+}@var{bass}].
1968 @var{tonic} should be the tonic note of the chord, and @var{duration}
1969 is the chord duration in the usual notation. There are two kinds of
1970 modifiers. One type is @emph{chord additions}, which are obtained by
1971 listing intervals separated by dots. An interval is written by its
1972 number with an optional @code{+} or @code{-} to indicate raising or
1973 lowering by half a step. Chord additions has two effects: It adds
1974 the specified interval and all lower odd numbered intervals to the
1975 chord, and it may lower or raise the specified interval. Intervals
1976 must be separated by a dot (@code{.}).
1978 Throughout these examples, chords have been shifted around the staff
1979 using @code{\transpose}.
1984 @lilypond[fragment,verbatim]
1988 c:9 c:9-.5+.7+ c:3-.5- c:4.6.8
2000 The second type of modifier that may appear after the @code{:} is a
2001 named modifier. Named modifiers are listed in the file
2002 @file{chord-modifiers.ly}. The available modifiers are @code{m} and
2003 @code{min} which lower the 3rd half a step, `@code{aug}' which
2004 raises the 5th, `@code{dim}' which lowers the 5th,
2005 `@code{maj}' which adds a raised 7th, and `@code{sus}'
2006 which replaces the 5th with a 4th.
2010 @lilypond[fragment,verbatim]
2013 c1:m c:min7 c:maj c:aug c:dim c:sus
2021 Chord subtractions are used to eliminate notes from a chord. The
2022 notes to be subtracted are listed after a @code{^} character,
2025 @lilypond[fragment,verbatim,center]
2034 Chord inversions can be specified by appending `@code{/}' and the name
2035 of a single note to a chord. In a chord inversion, the inverted note is
2036 transposed down until it is the lowest note in the chord. If the
2037 specified note is not in the chord, a warning will be printed.
2039 @lilypond[fragment,verbatim,center]
2049 Bass notes can be added by `@code{/+}' and
2050 the name of a single note to a chord. This has the effect of
2051 adding the specified note to the chord, lowered by an octave,
2052 so it becomes the lowest note in the chord.
2054 @lilypond[fragment,verbatim,center]
2066 @c . {Printing named chords}
2067 @node Printing named chords
2068 @subsection Printing named chords
2070 @cindex printing chord names
2073 @cindex @code{ChordNames}
2076 For displaying printed chord names, use the @code{ChordNames} context.
2077 The chords may be entered either using the notation described above, or
2078 directly using simultaneous music.
2081 @lilypond[verbatim,singleline]
2083 \chords {a1 b c} <d f g> <e g b>
2087 \context ChordNames \scheme
2088 \context Staff \transpose c'' \scheme
2094 You can make the chord changes stand out by setting property
2095 @code{ChordNames.chordChanges} to true. This will only display chord
2096 names when there's a change in the chords scheme and at the start of the
2102 c1:m \break c:m c:m c:m d
2107 \context ChordNames {
2108 \property ChordNames.chordChanges = ##t
2110 \context Staff \transpose c'' \scheme
2115 LilyPond examines chords specified as lists of notes to determine a name
2116 to give the chord. LilyPond will not try to identify chord inversions or
2117 added base, which may result in strange chord names when chords are
2118 entered as a list of pitches:
2123 @lilypond[verbatim,center,singleline]
2132 \context ChordNamesVoice \scheme
2133 \context Staff \scheme
2140 By default LilyPond uses chord name system proposed by Harald Banter
2141 (See @ref{Literature}). The system is is unambiguous and has a logical
2142 structure. Typical American style chord names may be selected by
2143 setting the @code{style} property of the @code{ChordNames.ChordName}
2144 grob to @code{'american}. Similarly @code{'jazz} selects Jazz
2147 Routines that determine the names to be printed are written in Scheme,
2148 and may be customized by the user. The code can be found in
2149 @file{scm/chord-name.scm}.
2151 [3 short examples showing differences between american, banter and jazz]
2154 @section Writing parts
2156 Orchestral music involves some special notation, both in the full score,
2157 as in the individual parts. This section explains how to tackle common
2158 problems in orchestral music.
2165 * Instrument names::
2167 * Sound output for transposing instruments::
2168 * Multi measure rests::
2169 * Automatic part combining::
2170 * Hara-kiri staffs::
2173 @c . {Rehearsal marks}
2174 @node Rehearsal marks
2175 @subsection Rehearsal marks
2176 @cindex Rehearsal marks
2178 @cindex @code{\mark}
2179 @cindex @code{Mark_engraver}
2182 \mark @var{unsigned};
2187 With this command, you can print a rehearsal mark above the system. You
2188 can provide a number, a string or a markup text as argument. If there is
2189 no argument, the property @code{rehearsalMark} is used and automatically
2192 @lilypond[fragment,verbatim]
2198 c1 \mark #'(music "scripts-segno") ;
2204 @subsection Bar numbers
2206 Bar numbers are printed at the start of the line by default. This is
2207 done by the @code{Bar_number_engraver} in the Score context.
2211 It is currently not possible to make boxed bar numbers, or print them at
2215 @node Instrument names
2216 @subsection Instrument names
2218 You can specify an instrument name for a staff by setting
2219 @code{Staff.instrument} and @code{Staff.instr}. This will print a string
2220 before the start of the staff. For the first start, @code{instrument} is
2221 used, for the next ones @code{instr} is used.
2223 @lilypond[verbatim,singleline]
2225 \property Staff.instrument = "ploink " { c''4 } }
2227 \translator { \StaffContext
2228 \consists "Instrument_name_engraver"; } } }
2231 This requires that you add the @code{Instrument_name_engraver} to the
2236 @subsection Transpose
2238 @cindex transposition of pitches
2239 @cindex @code{\transpose}
2241 A music expression can be transposed with @code{\transpose}. The syntax
2244 \transpose @var{pitch} @var{musicexpr}
2247 This means that middle C in @var{musicexpr} is transposed to
2250 @code{\transpose} distinguishes between enharmonic pitches: both
2251 @code{\transpose cis'} or @code{\transpose des'} will transpose up half
2252 a tone. The first version will print sharps and the second version
2256 @lilypond[fragment,verbatim]
2259 { \key e \major; c d e f }
2261 \transpose des'' { \key e \major; c d e f }
2262 \transpose cis'' { \key e \major; c d e f }
2268 If you want to use both @code{\transpose} and @code{\relative}, then
2269 you must use @code{\transpose} first. @code{\relative} will have no
2270 effect music that appears inside a @code{\transpose}.
2272 @node Sound output for transposing instruments
2273 @subsection Sound output transposing instruments
2275 When you want to play a score containing transposed and untransposed
2276 instruments, you have to instruct LilyPond the pitch offset (in
2277 semitones) for the transposed instruments. This is done using the
2278 @code{transposing} property. It does not affect printed output.
2280 @cindex @code{transposing}
2283 \property Staff.instrument = #"Cl. in B-flat"
2284 \property Staff.transposing = #-2
2288 @c . {Multi measure rests}
2289 @node Multi measure rests
2290 @subsection Multi measure rests
2291 @cindex Multi measure rests
2295 Multi measure rests are entered using `@code{R}'. It is specifically
2296 meant for entering parts: the rest can expand to fill a score with
2297 rests, or it can be printed as a single multimeasure rest This expansion
2298 is controlled by the property @code{Score.skipBars}. If this is set to true,
2299 Lily will not expand empty measures, and the appropriate number is added
2302 @lilypond[fragment,verbatim]
2303 \time 3/4; R2.*2 \property Score.skipBars = ##t R2.*17 R2.*4
2306 Currently, there is no way to condense multiple rests into a single
2309 @cindex condensing rests
2311 @node Automatic part combining
2312 @subsection Automatic part combining
2313 @cindex automatic part combining
2314 @cindex part combiner
2316 Automatic part combining is used to merge two parts of music onto on
2317 staff in an intelligent way. It is aimed primarily at typesetting Hymns
2318 and orchestral scores. When the two parts are identical for a period of
2319 time, only one is shown. In places where the two parts differ, stem
2320 directions are set automatically. Also, soli and @`{a} due parts can be
2321 identified and marke.
2323 The syntax for part combining is
2326 \partcombine @var{context} @var{musicexpr1} @var{musicexpr2}
2329 where the pieces of music @var{musicexpr1} and @var{musicexpr2} will be
2330 combined into one context @var{context}. The names of the music
2331 expressions must start with the prefixes @code{one} and @code{two}.
2333 [Name of music expressions? is that context name? ]
2335 The most useful function of the part combiner to combining threads into
2336 one voice, as common for wind parts in orchestral scores:
2338 @lilypond[verbatim,singleline,fragment]
2340 \context Voice=one \partcombine Voice
2341 \context Thread=one \notes\relative c'' {
2344 \context Thread=two \notes\relative c'' {
2350 Notice that the first @code{g} appears only once, although it was
2351 specified twice (once in each Thread). Also note that stem, slur and tie
2352 directions are set automatically, depending whether there is a solo or
2355 There is actually a third engraver involved in part combining; the
2356 @code{Voice_devnull_engraver}. This one takes care of removing
2357 redundant spanners such as beams, slurs, ties, crescendi, etc. Note that
2358 the Thread called one always gets up stems, and "solo", while @code{two}
2359 always gets down stems and "Solo II".
2361 If you just want the splitting of Threads and setting of directions, and
2362 not the textual markings, you may set the property @var{soloADue} to
2363 false. There are a number of other properties that you can use to tweak
2364 the behavior of part combining, refer to the automatically generated
2365 documentation. Look for @code{Thread_devnull_engraver}
2366 @code{Voice_engraver} and @code{A2_engraver}.
2368 @cindex @code{Thread_devnull_engraver}
2369 @cindex @code{Voice_engraver}
2370 @cindex @code{A2_engraver}
2372 @node Hara-kiri staffs
2373 @subsection Hara-kiri staffs
2376 [TODO]@footnote{Harakiri, also called Seppuku, is the ritual suicide of
2377 the Japanese Samourai warriors.}
2387 A @emph{custos} (plural: @emph{custodes}; latin word for "guard") is a
2388 staff context symbol that appears at the end of a staff line. It
2389 anticipates the pitch of the first note(s) of the following line and
2390 thus helps the player or singer to manage line breaks during
2391 performance, thus enhancing readability of a score.
2396 \notes { c'1 d' e' d' \break c' d' e' d' }
2400 \consists Custos_engraver;
2401 Custos \override #'style = #'mensural;
2408 Custodes were frequently used in music notation until the 16th century.
2409 There were different appearences for different notation styles.
2410 Nowadays, they have survived only in special forms of musical notation
2411 such as via the @emph{editio vaticana} dating back to the beginning of
2414 For typesetting custodes, just put a @code{Custos_engraver} into the
2415 @code{StaffContext} when declaring the @code{\paper} block. In this
2416 block, you can also globally control the appearance of the custos symbol
2417 by setting the custos @code{style} property. Currently supported styles
2418 are @code{vaticana}, @code{medicaea}, @code{hufnagel} and
2425 \consists Custos_engraver;
2426 Custos \override #'style = #'mensural;
2431 The property can also be set locally, for example in a @code{\notes}
2436 \property Staff.Custos \override #'style = #'vaticana
2437 c'1 d' e' d' \break c' d' e' d'
2441 @c . {Tuning output}
2443 @section Tuning output
2445 LilyPond tries to take as much formatting as possible out of your
2446 hands. Nevertheless, there are situations where it needs some help, or
2447 where you want to override its decisions. In this section we discuss
2448 ways to do just that.
2450 Notation output is specified in so called grobs (graphic objects). Each
2451 grob carries with it a set of properties (grob properties) specific to
2452 that object. For example, a stem grob has properties that specify its
2453 direction, length and thickness.
2457 The most common way of tuning the output is to alter the values of these
2458 properties. There are two ways of doing that: first, you can
2459 specifically select a set of grobs at one point, and set properties as
2460 you wish, or secondly, you can (temporarily) modify the definition of a
2461 grob, thereby affecting an entire group of grobs.
2466 * Tuning groups of grobs ::
2467 * Tuning per grob ::
2472 @node Tuning groups of grobs
2473 @subsection Tuning groups of grobs
2475 @cindex grob description
2477 A grob definition is a Scheme association list, that is stored in a context
2478 property. By assigning to that property (using plain @code{\property}),
2479 you can change the resulting grobs.
2481 @lilypond[verbatim, fragment]
2482 c'4 \property Voice.Stem \override #'meta = #'((interfaces . ())) c'4
2485 The @code{\property} statement effectively empties the definition of the
2486 Stem object. One of the effects is that property specifying how it
2487 should be printed is erased, with the effect of rendering it invisible.
2493 This mechanism is fairly crude, since you can only set, but not modify,
2494 the definition of a grob. For this reason, there is a more advanced
2495 mechanism: you can add a property on top of an existing definition, or
2496 remove a property: @code{\override} adds a settings, @code{\revert}
2497 removes that setting.
2500 c'4 \property Voice.Stem \override #'thickness = #4.0
2501 c'4 \property Voice.Stem \revert #'thickness
2505 For the digirati, the grob description is an Scheme association
2506 list. Since it is singly linked, we can treat it as a stack, and
2507 @code{\override} and @code{\revert} are just push and pop
2508 operations. This pushing and popping is also used for overriding automatic
2511 If you revert a setting which was not set in the first place, then it
2512 has no effect. However, if the setting was set as a system default, it
2513 may remove the default value, and this may give surprising results,
2514 including crashes. In other words, if you use @code{\override} and
2515 @code{\revert}, be sure to balance the overrides and reverts.
2517 If balancing them is too much work, use the @code{\set} shorthand. It
2518 performs a revert followed by an override:
2520 \property Voice.Stem \set #'thickness = #2.0
2523 Formally the syntax for these constructions is
2525 \property @var{context}.@var{grobname} \override @var{symbol} = @var{value}
2526 \property @var{context}.@var{grobname} \set @var{symbol} = @var{value}
2527 \property @var{context}.@var{grobname} \revert @var{symbol}
2529 Here @var{symbol} is a Scheme expression of symbol type, @var{context}
2530 and @var{grobname} are strings and @var{value} is a Scheme expression.
2534 LilyPond will hang or crash if @var{value} contains cyclic references.
2538 @node Tuning per grob
2539 @subsection Tuning per grob
2541 @cindex \outputproperty
2543 A second way of tuning grobs is the more arcane @code{\outputproperty}
2545 Syntax is as follows
2547 \outputproperty @var{predicate} @var{symbol} = @var{value}
2549 Here @code{predicate} is a Scheme function taking a grob argument, and
2550 returning a boolean. This statement is processed by the
2551 @code{Output_property_engraver}. It instructs the engraver to feed all
2552 grobs that it sees to @var{predicate}. Whenever the predicate returns
2553 true, the grob property @var{symbol} will be set to @var{value}.
2555 You will need to combine this statement with @code{\context} to select
2556 the appropriate context to apply this to.
2558 If possible, avoid this feature: the semantics are not very clean, and
2559 the syntax and semantics are up for rewrite.
2561 Here are some random examples:
2563 @lilypond[fragment,verbatim,singleline]
2565 \context Staff \outputproperty
2566 #(make-type-checker 'note-head-interface)
2567 #'extra-offset = #'(0.5 . 0.75)
2571 @cindex @code{extra-offset}
2573 This selects all note heads occurring at current staff level, and sets
2574 the @code{extra-offset} of those heads to @code{(0.5,0.75)}, shifting
2577 Move the text "m.d.", but not the fingering instruction "2".
2578 @lilypond[verbatim,singleline]
2579 #(define (make-text-checker text)
2580 (lambda (grob) (equal? text (ly-get-grob-property grob 'text))))
2583 \notes\relative c''' {
2584 \property Voice.Stem \set #'direction = #1
2585 \outputproperty #(make-text-checker "m.d.")
2586 #'extra-offset = #'(-3.5 . -4.5)
2596 @subsection What to tune?
2598 This all tells you how to tune grobs, but what variables are there? The
2599 question is not answered in this manual (although you may encounter
2602 Grob properties are tied directly to the implementation of LilyPond, and
2603 they are thus a moving target. Documentation of such variables are part
2604 of the generated documentation: this documentation is generated from the
2605 sourcecode of lily for each version, so it is usually mch more up to
2606 date than this manual. It should be available from the same place where
2607 you got this manual.
2609 To decide how to tune a grob, you need to find the following information
2612 which grob to modify
2614 which property to modify
2616 which context the grob comes from.
2619 Included with the automatically generated documentation is a master list
2620 of grobs. Each one can be clicked, taking you to a overview of the
2621 available properties.
2623 There is also a master list of contexts. Clicking each takes you to an
2624 overview of the context, listing which grob types are created there.
2629 @subsection Text markup
2633 LilyPond has an internal mechanism to typeset texts. You can
2634 form text markup expressions by composing scheme expressions
2635 in the following way.
2640 @lilypond[verbatim, singleline]
2643 c^#'(upright "upright")
2644 c_#'((bold upright) "bold")
2645 d^#'(lines "one" ((bold upright) "two"))
2646 e_#'(music (named "noteheads-2" "flags-u3"))
2650 Normally, the Scheme markup text is stored in the @code{text} property
2651 of a grob. Formally, it is defined as follows:
2654 text: string | (head? text+)
2655 head: markup | (markup+)
2656 markup-item: property | abbrev | @var{fontstyle}
2657 property: (@var{key} . @var{value})
2658 abbrev: @code{rows lines roman music bold italic named super sub text}
2661 The markup is broken down and converted into a list of grob properties,
2662 which are prepended to the property list. The @var{key}-@var{value}
2663 pair is a grob property.
2665 The following abbreviations are currently
2670 horizontal mode: set all text on one line (default)
2672 vertical mode: set every text on new line
2682 lookup by character name
2684 plain text lookup (by character value)
2691 @var{fontstyle} may be any of @code{finger volta timesig mmrest mark
2692 script large Large dynamic}
2694 [wat is het verschil tussen fontstyle en abbrev?]
2697 It is possible to use @TeX{} commands in the strings, but this should be
2698 avoided because this makes it impossible for LilyPond to compute the
2699 exact length of the string, which may lead to collisions. Also, @TeX{}
2700 commands won't work with direct postscript output.
2704 @section Page layout
2718 @subsection Paper block
2721 The most important output definition is the @code{\paper} block, for
2722 music notation. The syntax is
2725 @code{\paper @{} [@var{paperidentifier}] @var{items} @code{@}}
2728 where each of the items is one of
2731 @item An assignment. The assignment must be terminated by a
2734 @item A context definition. See @ref{Notation Contexts} for
2735 more information on context definitions.
2737 @item \stylesheet declaration. Its syntax is
2739 \stylesheet @var{alist}
2742 See @file{scm/font.scm} for details of @var{alist}.
2743 @item an \elementdescriptions declaration.
2745 \elementdescriptions @var{alist}
2747 See @file{scm/grob-description.scm} for details of @var{alist}.
2751 @c . {Paper variables}
2752 @node Paper variables
2753 @subsection Paper variables
2754 @cindex Paper variables
2756 The paper block has some variables you may want to use or change:
2759 @cindex @code{indent}
2761 The indentation of the first line of music.
2762 @cindex @code{staffspace}
2764 @item @code{staffspace}
2765 The distance between two staff lines, calculated from the center
2766 of the lines. If you want scale independent output, then you should
2767 use either this or @code{stafflinethickness}
2768 as a unit for distances you modify.
2770 @cindex @code{linewidth}
2771 @item @code{linewidth}
2772 Sets the width of the lines.
2774 If set to a negative value, a single
2775 unjustified line is produced.
2777 @cindex @code{textheight}
2779 @item @code{textheight}
2780 Sets the total height of the music on each page. Only used by
2783 @cindex @code{interscoreline}
2785 @item @code{interscoreline}
2786 Sets the spacing between systems.
2788 @cindex @code{interscorelinefill}
2792 @item @code{interscorelinefill}
2793 If set to a positive number, the distance between the score
2794 lines will stretch in order to fill the full page. In that
2795 case @code{interscoreline} specifies the minimum spacing.
2800 @cindex @code{stafflinethickness}
2802 @item @code{stafflinethickness}
2803 Determines the thickness of staff lines, and also acts as a scaling
2804 parameter for other line thicknesses.
2811 @subsection Font size
2814 The Feta font provides musical symbols at six different sizes. These
2815 fonts are 11 point, 13 point, 16 point, 20 point,
2816 23 point, and 26 point. The point size of a font is the
2817 height of the five lines in a staff when displayed in the font.
2819 Definitions for these sizes are the files @file{paperSZ.ly}, where
2820 @code{SZ} is one of 11, 13, 16, 20, 23 and 26. If you include any of
2821 these files, the identifiers @code{paperEleven}, @code{paperThirteen},
2822 @code{paperSixteen}, @code{paperTwenty}, @code{paperTwentythree}, and
2823 @code{paperTwentysix} are defined respectively. The default
2824 @code{\paper} block is also set.
2826 The font definitions are generated using a Scheme function. For more
2827 details, see the file @file{font.scm}.
2833 @subsection Paper size
2838 @cindex @code{papersize}
2840 To change the paper size, you must first set the
2841 @code{papersize} variable at top level. Set it to
2842 the strings @code{a4}, @code{letter}, or @code{legal}. After this
2843 specification, you must set the font as described above. If you want
2844 the default font, then use the 20 point font. The new paper size will
2845 not take effect if the font is not loaded and selected afterwards.
2849 \include "paper16.ly"
2853 \paper @{ \paperSixteen @}
2857 The file @code{paper16.ly} will now include a file named @file{a4.ly}, which
2858 will set the paper variables @code{hsize} and @code{vsize} (used by
2869 @subsection Line break
2872 @cindex breaking lines
2874 Line breaks are normally computed automatically. They are chosen such
2875 that the resulting spacing has low variation, and looks neither cramped
2878 Occasionally you might want to override the automatic breaks; you can do
2879 this by specifying @code{\break}. This will force a line break at this
2880 point. Do remember that line breaks can only occur at places where there
2881 are barlines. If you want to have a line break where there is no
2882 barline, you can force an invisible barline by entering @code{\bar "";}.
2884 Similarly, @code{\noBreak} forbids a line break at a certain point.
2886 @cindex @code{\penalty}
2888 The @code{\break} and @code{\noBreak} commands are defined in terms of
2889 the penalty command:
2891 \penalty @var{int} @code{;}
2894 This encourages or discourages LilyPond to make a line break at this
2899 The scaling of the @code{\penalty} argument is not well-defined. The
2900 command is rather kludgy, and slated for rewriting.
2904 @subsection Page break
2907 @cindex breaking pages
2910 Page breaks are normally computed by @TeX{}, so they are not under
2911 direct control of LilyPond. However, you can insert a commands into the
2912 @file{.tex} output to instruct @TeX{} where to break pages. For more
2913 details, see the example file @file{input/test/between-systems.ly}
2924 LilyPond can produce MIDI output. The performance lacks lots of
2925 interesting effects, such as swing, articulation, slurring, tieing,
2926 etc., but it is good enough for proof-hearing the music you enter.
2928 Dynamics and tempo changes are interpreted. [TODO: mention volume
2929 control/Instrument Equaliser]
2934 It is currently not possible to use the percussion channel (generally
2935 channel 10 of a MIDI file).
2939 * MIDI instrument names::
2944 @subsection MIDI block
2948 The MIDI block is analogous to the paper block, but it is somewhat
2949 simpler. The @code{\midi} block can contain:
2953 @item a @code{\tempo} definition
2954 @item context definitions
2957 Assignments in the @code{\midi} block are not allowed.
2961 @cindex context definition
2963 Context definitions follow precisely the same syntax as within the
2964 \paper block. Translation modules for sound are called performers.
2965 The contexts for MIDI output are defined in @file{ly/performer.ly}.
2968 @node MIDI instrument names
2969 @subsection MIDI instrument names
2971 @cindex instrument names
2972 @cindex @code{Staff.midiInstrument}
2973 @cindex @code{Staff.instrument}
2975 The MIDI instrument name is set by the @code{Staff.midiInstrument}
2976 property or, if that property is not set, the @code{Staff.instrument}
2977 property. The instrument name should be chosen from the list in
2978 @ref{MIDI instruments}.
2982 If the selected string does not exactly match, then LilyPond uses the
2983 default piano. It is not possible to select an instrument by number.
2995 @section Music entry
3007 @subsection Relative
3009 @cindex relative octave specification
3011 Octaves are specified by adding @code{'} and @code{,} to pitch names.
3012 When you copy existing music, it is easy to accidentally put a pitch in
3013 the wrong octave and hard to find such an error. To prevent these
3014 errors, LilyPond features octave entry.
3016 @cindex @code{\relative}
3018 \relative @var{startpitch} @var{musicexpr}
3021 The octave of notes that appear in @var{musicexpr} are calculated as
3022 follows: If no octave changing marks are used, the basic interval
3023 between this and the last note is always taken to be a fourth or less.
3024 The octave changing marks @code{'} and @code{,} can then
3025 be added to raise or lower the pitch by an extra octave. Upon entering
3026 relative mode, an absolute starting pitch must be specified that will
3027 act as the predecessor of the first note of @var{musicexpr}.
3029 This distance is determined without regarding accidentals: a
3030 @code{fisis} following a @code{ceses} will be put above the
3033 Entering scales is straightforward in relative mode.
3035 @lilypond[fragment,verbatim,center]
3037 g a b c d e f g g, g
3041 And octave changing marks are used for intervals greater than a fourth.
3043 @lilypond[fragment,verbatim,center]
3045 c g c f, c' a, e'' }
3048 If the preceding item is a chord, the first note of the chord is used
3049 to determine the first note of the next chord. But other notes
3050 within the second chord are determined by looking at the immediately
3053 @lilypond[fragment,verbatim,center]
3060 @cindex @code{\notes}
3062 The pitch after the @code{\relative} contains a notename. To parse
3063 the pitch as a notename, you have to be in note mode, so there must
3064 be a surrounding @code{\notes} keyword (which is not
3067 The relative conversion will not affect @code{\transpose},
3068 @code{\chords} or @code{\relative} sections in its argument. If you
3069 want to use relative within transposed music, you must place an
3070 additional @code{\relative} inside the @code{\transpose}.
3075 @subsection Bar check
3079 @cindex @code{barCheckNoSynchronize}
3083 Whenever a bar check is encountered during interpretation, a warning
3084 message is issued if it doesn't fall at a measure boundary. This can
3085 help you find errors in the input. Depending on the value of
3086 @code{barCheckNoSynchronize}, the beginning of the measure will be
3087 relocated, so this can also be used to shorten measures.
3089 A bar check is entered using the bar symbol, @code{|}
3093 @c . {Point and click}
3094 @node Point and click
3095 @subsection Point and click
3099 @node Interpretation context
3100 @section Interpretation context
3103 * Notation Contexts::
3104 * Creating contexts::
3105 * Default contexts::
3106 * Context properties::
3107 * Changing context definitions::
3108 * Defining new contexts::
3112 @c . {Notation Contexts}
3113 @node Notation Contexts
3114 @subsection Notation Contexts
3116 @cindex notation contexts
3118 Notation contexts are objects that only exist during a run of LilyPond.
3119 During the interpretation phase of LilyPond (when lily prints
3120 "interpreting music"), music a @code{\score} block is interpreted in
3121 time order, i.e. in much the same order that humans read, play, and
3124 During this reading, the notation context is holds the state
3125 for the current point within the music. It contains information like
3128 @item What notes are playing at this point?
3129 @item What symbols will be printed at this point?
3130 @item What is the current key signature, time signature, point within
3134 Contexts are grouped hierarchically: A @code{Voice} context is
3135 contained in a @code{Staff} context (because a staff can contain
3136 multiple voices at any point), a @code{Staff} context is contained in
3137 a @code{Score}, @code{StaffGroup}, or @code{ChoirStaff} context (because
3138 these can all contain multiple staffs).
3141 Contexts associated with sheet music output are called @emph{notation
3142 contexts}, those for sound output are called performance contexts.
3145 @node Creating contexts
3146 @subsection Creating contexts
3148 @cindex @code{\context}
3149 @cindex context selection
3151 Contexts for a music expression can be selected manually, using the
3152 following music expression.
3155 \context @var{contexttype} [= @var{contextname}] @var{musicexpr}
3158 This instructs lilypond to interpret @var{musicexpr} within the context
3159 of type @var{contexttype} and with name @var{contextname}. If this
3160 context does not exist, it will be created.
3164 @lilypond[verbatim,singleline]
3166 \notes \relative c'' {
3167 c4 <d4 \context Staff = "another" e4> f
3174 In this example, the @code{c} and @code{d} are printed on the
3175 default staff. For the @code{e}, a context Staff called
3176 @code{another} is specified; since that does not exist, a new
3177 context is created. Within @code{another}, a (default) Voice context
3178 is created for the @code{e4}. When all music referring to a
3179 context is finished, the context is ended as well. So after the
3180 third quarter, @code{another} is removed.
3184 @node Default contexts
3185 @subsection Default contexts
3187 Most music expressions don't need @code{\context}: they inherit the
3188 notation context from their parent. Each note is a music expression, and
3189 as you can see in the following example, only the sequential music
3190 enclosing the three notes has an explicit context.
3192 @lilypond[verbatim,singleline]
3193 \score { \notes \context Voice = goUp { c'4 d' e' } }
3196 There are some quirks that you must keep in mind when dealing with
3199 Every top-level music is interpreted by the Score context, in other
3200 words, you may think of @code{\score} working like
3203 \context Score @var{music}
3207 Sequential music follows the contexts of its "children". Take this example
3208 @lilypond[verbatim, singleline]
3209 \score { \context Score \notes { c'4 ( d' )e' } }
3212 The sequential music is interpreted by the Score context initially
3213 (notice that the @code{\context} specification is redundant), but when a
3214 note is encountered, contexts are setup to accept that note. In this
3215 case, a Thread, Voice and Staff are created. The rest of the sequential
3216 music is also interpreted with the same Thread, Voice and Staff context,
3217 putting the notes on the same staff, in the same voice.
3219 This is a convenient mechanism, but do not expect opening chords to work
3220 without @code{\context}. For every note, a separate staff is
3223 @lilypond[verbatim, singleline]
3224 \score { \notes <c'4 es'> }
3227 Of course, if the chord is preceded by a normal note in sequential
3228 music, the chord will be interpreted by the Thread of the preceding
3230 @lilypond[verbatim,singleline]
3231 \score { \notes { c'4 <c'4 es'> } }
3236 @node Context properties
3237 @subsection Context properties
3239 Notation contexts can be modified from within the @file{.ly} file. The
3240 following music expression does that job:
3242 @cindex @code{\property}
3244 \property @var{contextname}.@var{propname} = @var{value}
3247 Sets the @var{propname} property of the context @var{contextname} to the
3248 specified Scheme expression @var{value}. All @var{propname} and
3249 @var{contextname} are strings, which are typically unquoted.
3251 Properties that are set in one context are inherited by all of the
3252 contained contexts. This means that a property valid for the
3253 @code{Voice} context can be set in the @code{Score} context (for
3254 example) and thus take effect in all @code{Voice} contexts.
3256 Properties can be unset using the following expression:
3258 \property @var{contextname}.@var{propname} \unset
3261 This removes the definition of @var{propname} in @var{contextname}. If
3262 @var{propname} was not defined in @var{contextname} (but was inherited
3263 from a higher context), then this has no effect.
3268 @code{\property \unset} is not the inverse of @code{\property \set}
3273 @c . {Context definitions}
3274 @node Changing context definitions
3275 @subsection Changing context definitions
3277 @cindex context definition
3278 @cindex translator definition
3280 The most common way to define a context is by extending an existing
3281 context. You can change an existing context from the paper block, by
3282 first initializing a translator with an existing context identifier:
3286 @var{context-identifier}
3289 Then you can add engravers, remove engravers and set context
3290 properties. The syntax for these operations are respectively
3292 \remove @var{engravername}
3293 \consists @var{engravername}
3294 @var{propname} = @var{value}
3297 Here @var{engravername} is a string, the name of an engraver in the
3298 system. @var{propname} is a string and @var{value} is a Scheme
3301 @lilypond[verbatim,singleline]
3305 \translator { \StaffContext
3306 \consists Instrument_name_engraver;
3308 \remove Clef_engraver;
3314 These type of property assignments happen before interpretation starts,
3315 so a @code{\property} expression will override any predefined settings.
3317 Engravers are the actual C++ modules that do the work in the
3318 interpretation phase.
3321 There are some pre-defined identifiers to simplify editing translators,
3322 they are defined in @file{ly/engraver.ly}. These pre-defined
3326 @cindex @code{StaffContext}
3327 @item @code{StaffContext}
3328 Default Staff context.
3329 @cindex @code{RhythmicStaffContext}
3331 @item @code{RhythmicStaffContext}
3332 Default RhythmicStaff context.
3333 @cindex @code{VoiceContext}
3335 @item @code{VoiceContext}
3336 Default Voice context.
3337 @cindex @code{ScoreContext}
3339 @item @code{ScoreContext}
3340 Default Score context.
3342 @cindex @code{HaraKiriStaffContext}
3344 @item @code{HaraKiriStaffContext}
3345 Staff context that does not print if it only contains rests. See
3346 @ref{Hara-kiri staffs}.
3349 @node Defining new contexts
3350 @subsection Defining new contexts
3352 If you want to build a context from scratch, you must also supply the
3353 following extra information:
3355 @item A name, specified by @code{\name @var{contextname};}.
3357 @item A cooperation engraver. This is specified by @code{\type
3362 A context definition has this syntax:
3366 \translator @code{@{}
3367 @var{translatorinit} @var{translatormodifierlist}
3371 @var{translatorinit} can be an identifier or
3375 where @var{typename} is one of
3377 The cooperation engraver groups other engravers, and specifies how they
3378 should cooperate. Choices are:
3381 @cindex @code{Engraver_group_engraver}
3382 @item @code{Engraver_group_engraver}
3383 The standard cooperation engraver.
3385 @cindex @code{Score_engraver}
3387 @item @code{Score_engraver}
3388 This is cooperation module that should be in the top level context,
3389 and only the toplevel context.
3391 @cindex @code{Grace_engraver_group}
3393 @item @code{Grace_engraver_group}
3394 This is a special cooperation module (resembling
3395 @code{Score_engraver}) that is used to created an embedded
3399 @var{translatormodifierlist} is a list of items where each item is
3403 @item @code{\consists} @var{engravername} @code{;}
3404 Add @var{engravername} to the list of modules in this context.
3405 The order of engravers added with @code{\consists} is
3408 @item @code{\consistsend} @var{engravername} @code{;}
3409 Analogous to @code{\consists}, but makes sure that
3410 @var{engravername} is always added to the end of the list of
3413 Some engraver types need to be at the end of the list; this
3414 insures they are put there, and stay there, if a user adds or
3415 removes engravers. This command is usually not needed for
3418 @item @code{\accepts} @var{contextname} @code{;}
3419 Add @var{contextname} to the list of context this context can
3420 contain. The first listed context is the context to create by
3423 @item @code{\denies}. The opposite of @code{\accepts}. Added for
3424 completeness, but is never used in practice.
3427 @item @code{\remove} @var{engravername} @code{;}
3428 Remove a previously added (with @code{\consists}) engraver.
3430 @item @code{\name} @var{contextname} @code{;}
3431 This sets name of the context, e.g. @code{Staff}, @code{Voice}. If
3432 the name is not specified, the translator won't do anything.
3434 @item @var{propname} @code{=} @var{value} @code{;}
3435 A property assignment.
3438 In the @code{\paper} block, it is also possible to define translator
3439 identifiers. Like other block identifiers, the identifier can only
3440 be used as the very first item of a translator. In order to define
3441 such an identifier outside of @code{\score}, you must do
3447 foo = \translator @{ @dots{} @}
3454 \translator @{ \foo @dots{} @}
3462 @cindex paper types, engravers, and pre-defined translators
3467 Properties can be preset within the @code{\translator} block
3468 corresponding to the appropriate context. In this case, the syntax
3472 @var{propname} @code{=} @var{value}
3475 The property settings are used during the interpretation phase. They
3476 are read by the LilyPond modules where interpretation contexts are
3477 built of. These modules are called @emph{translators}. Translators for
3478 notation are called @emph{engravers}, and translators for sound are
3479 called @emph{performers}.
3484 @c . {Syntactic details}
3485 @node Syntactic details
3486 @section Syntactic details
3487 @cindex Syntactic details
3491 * Music expressions::
3492 * Manipulating music expressions::
3500 @subsection Top level
3503 This section describes what you may enter at top level.
3507 @subsubsection Score
3510 @cindex score definition
3512 The output is generated combining a music expression with an output
3513 definition. A score block has the following syntax:
3516 \score @{ @var{musicexpr} @var{outputdefs} @}
3519 @var{outputdefs} are zero or more output definitions. If no output
3520 definition is supplied, the default @code{\paper} block will be added.
3524 @c . {Default output}
3525 @subsubsection Default output
3527 Default values for the @code{\paper} and @code{\midi} block are set by
3528 entering such a block at top-level.
3531 @subsubsection Header
3533 @cindex @code{\header}
3538 \header @{ @var{key1} = @var{val1};
3539 @cindex @code{ly2dvi}
3540 @var{key2} = @var{val2}; @dots{} @}
3544 A header describes the file's contents. It can also appear in a
3545 @code{\score} block. Tools like @code{ly2dvi} can use this
3546 information for generating titles. Key values that are used by
3547 @code{ly2dvi} are: title, subtitle, composer, opus, poet, instrument,
3548 metre, arranger, piece and tagline.
3550 It is customary to put the @code{\header} at the top of the file.
3552 @subsubsection Default output
3554 A @code{\midi} or @code{\paper} block at top-level sets the default
3556 paper block for all scores that lack an explicit paper block.
3560 @subsection Identifiers
3563 All of the information in a LilyPond input file, is represented as a
3564 Scheme value. In addition to normal Scheme data types (such as pair,
3565 number, boolean, etc.), LilyPond has a number of specialized data types,
3572 @item Translator_def
3576 @item Music_output_def
3577 @item Moment (rational number)
3580 LilyPond also includes some transient object types. Objects of these
3581 types are built during a LilyPond run, and do not `exist' per se within
3582 your input file. These objects are created as a result of your input
3583 file, so you can include commands in the input to manipulate them,
3584 during a lilypond run.
3587 @item Grob: short for Graphical object. See @ref{Grobs}.
3588 @item Molecule: device-independent page output object,
3589 including dimensions. Produced by some Grob functions
3591 @item Translator: object that produces audio objects or Grobs. This is
3592 not yet user accessible.
3593 @item Font_metric: object representing a font. (See @ref{Font metrics})
3598 @node Music expressions
3599 @subsection Music expressions
3601 @cindex music expressions
3603 Music in LilyPond is entered as a music expression. Notes, rests, lyric
3604 syllables are music expressions, and you can combine music expressions
3605 to form new ones, for example by enclosing a list of expressions in
3606 @code{\sequential @{ @}} or @code{< >}. In this example, a compound
3607 expression is formed out of the quarter note @code{c} and a quarter note
3611 \sequential @{ c4 d4 @}
3614 @cindex Sequential music
3615 @cindex @code{\sequential}
3616 @cindex sequential music
3619 @cindex Simultaneous music
3620 @cindex @code{\simultaneous}
3622 The two basic compound music expressions are simultaneous and
3626 \sequential @code{@{} @var{musicexprlist} @code{@}}
3627 \simultaneous @code{@{} @var{musicexprlist} @code{@}}
3629 For both, there is a shorthand:
3631 @code{@{} @var{musicexprlist} @code{@}}
3635 @code{<} @var{musicexprlist} @code{>}
3637 for simultaneous music.
3638 In principle, the way in which you nest sequential and simultaneous to
3639 produce music is not relevant. In the following example, three chords
3640 are expressed in two different ways:
3642 @lilypond[fragment,verbatim,center]
3643 \notes \context Voice {
3644 <a c'> <b d' > <c' e'>
3645 < { a b c' } { c' d' e' } >
3650 Other compound music expressions include
3653 \transpose @var{pitch} @var{expr}
3654 \apply @var{func} @var{expr}
3655 \context @var{type} = @var{id} @var{expr}
3656 \times @var{fraction} @var{expr}
3660 @c . {Manipulating music expressions}
3661 @node Manipulating music expressions
3662 @subsection Manipulating music expressions
3664 The @code{\apply} mechanism gives you access to the internal
3665 representation of music. You can write Scheme-functions that operate
3666 directly on it. The syntax is
3668 \apply #@var{func} @var{music}
3670 This means that @var{func} is applied to @var{music}. The function
3671 @var{func} should return a music expression.
3673 This example replaces the text string of a script. It also shows a dump
3674 of the music it processes, which is useful if you want to know more
3675 about how music is stored.
3677 #(define (testfunc x)
3678 (if (equal? (ly-get-mus-property x 'text) "foo")
3679 (ly-set-mus-property x 'text "bar"))
3681 (ly-set-mus-property x 'elements
3682 (map testfunc (ly-get-mus-property x 'elements)))
3687 \apply #testfunc { c4_"foo" }
3691 For more information on what is possible, see the @ref{Tricks} and the
3692 automatically generated documentation.
3695 Directly accessing internal representations is dangerous: the
3696 implementation is subject to changes, so you should avoid this feature
3701 @c . {Span requests}
3707 @subsubsection Span requests
3708 @cindex Span requests
3710 Notational constructs that start and end on different notes can be
3711 entered using span requests. The syntax is as follows:
3715 \spanrequest @var{startstop} @var{type}
3719 @cindex @code{\start}
3720 @cindex @code{\stop}
3722 This defines a spanning request. The @var{startstop} parameter is either
3723 -1 (@code{\start}) or 1 (@code{\stop}) and @var{type} is a string that
3724 describes what should be started. Much of the syntactic sugar is a
3725 shorthand for @code{\spanrequest}, for example,
3727 @lilypond[fragment,verbatim,center]
3728 c'4-\spanrequest \start "slur"
3729 c'4-\spanrequest \stop "slur"
3732 Among the supported types are @code{crescendo}, @code{decrescendo},
3733 @code{beam}, @code{slur}. This is an internal command. Users are
3734 encouraged to use the shorthands which are defined in the initialization
3735 file @file{spanners.ly}.
3740 @subsection Assignments
3743 Identifiers allow objects to be assigned to names during the parse
3744 stage. To assign an identifier, you use @var{name}@code{=}@var{value}
3745 and to refer to an identifier, you preceed its name with a backslash:
3746 `@code{\}@var{name}'. @var{value} is any valid Scheme value or any of
3747 the input-types listed above. Identifier assignments can appear at top
3748 level in the LilyPond file, but also in @code{\paper} blocks.
3750 Semicolons are forbidden after top level assignments, but mandatory in
3751 other places. The rules about semicolons and assignments are very
3752 confusing, but when LilyPond input evolves more towards Scheme, we hope
3753 that this problem will grow smaller.
3755 An identifier can be created with any string for its name, but you will
3756 only be able to refer to identifiers whose names begin with a letter,
3757 being entirely alphabetical. It is impossible to refer to an identifier
3758 whose name is the same as the name of a keyword.
3760 The right hand side of an identifier assignment is parsed completely
3761 before the assignment is done, so it is allowed to redefine an
3762 identifier in terms of its old value, e.g.
3768 When an identifier is referenced, the information it points to is
3769 copied. For this reason, an identifier reference must always be the
3770 first item in a block.
3774 \paperIdent % wrong and invalid
3778 \paperIdent % correct
3783 @c . {Lexical modes}
3785 @subsection Lexical modes
3786 @cindex Lexical modes
3789 @cindex @code{\notes}
3790 @cindex @code{\chords}
3791 @cindex @code{\lyrics}
3793 To simplify entering notes, lyrics, and chords, LilyPond has three
3794 special input modes on top of the default mode: note, lyrics and chords
3795 mode. These input modes change the way that normal, unquoted words are
3796 interpreted: for example, the word @code{cis} may be interpreted as a
3797 C-sharp, as a lyric syllable `cis' or as a C-sharp major triad
3800 A mode switch is entered as a compound music expressions
3802 @code{\notes} @var{musicexpr}
3803 @code{\chords} @var{musicexpr}
3804 @code{\lyrics} @var{musicexpr}.
3807 In each of these cases, these expressions do not add anything to the
3808 meaning of their arguments. They are just a way to indicate that the
3809 arguments should be parsed in indicated mode. The modes are treated in
3810 more detail in the @ref{Note entry}, @ref{Lyrics} and
3813 You may nest different input modes.
3817 @subsection Ambiguities
3822 The grammar contains a number of ambiguities. We hope to resolve them at
3826 @item The assignment
3832 can be interpreted as making a string identifier @code{\foo}
3833 containing @code{"bar"}, or a music identifier @code{\foo}
3834 containing the syllable `bar'.
3836 @item The assignment
3842 can be interpreted as making an integer identifier
3843 containing -6, or a Request identifier containing the
3844 fingering `6' (with neutral direction).
3846 @item If you do a nested repeat like
3858 then it is ambiguous to which @code{\repeat} the
3859 @code{\alternative} belongs. This is the classic if-then-else
3860 dilemma. It may be solved by using braces.
3862 @item (an as yet unidentified ambiguity :-)
3866 @c . {Lexical details}
3867 @node Lexical details
3868 @section Lexical details
3879 * Version information::
3884 @subsection Comments
3887 @cindex block comment
3888 @cindex line comment
3892 A one line comment is introduced by a @code{%} character.
3893 Block comments are started by @code{%@{} and ended by @code{%@}}.
3894 They cannot be nested.
3897 @subsection Direct Scheme
3901 @cindex Scheme, in-line code
3904 LilyPond contains a Scheme interpreter (the GUILE library) for
3905 internal use. In some places Scheme expressions also form valid syntax:
3906 whereever it is allowed,
3910 evaluates the specified Scheme code. If this is used at toplevel, then
3911 the result is discarded. Example:
3913 \property Staff.TestObject \override #'foobar = #(+ 1 2)
3916 @code{\override} expects two Scheme expressions, so there are two Scheme
3917 expressions. The first one is a symbol (@code{foobar}), the second one
3918 an integer (namely, 3).
3920 Scheme is a full-blown programming language, and a full discussion is
3921 outside the scope of this document. Interested readers are referred to
3922 the website @uref{http://www.schemers.org/} for more information on
3927 @subsection Keywords
3931 Keywords start with a backslash, followed by a number of lower case
3932 alphabetic characters. These are all the keywords.
3935 apply arpeggio autochange spanrequest commandspanrequest
3936 simultaneous sequential accepts alternative bar breathe
3937 char chordmodifiers chords clef cm consists consistsend
3938 context denies duration dynamicscript elementdescriptions
3939 font grace header in lyrics key mark pitch
3940 time times midi mm name pitchnames notes outputproperty
3941 override set revert partial paper penalty property pt
3942 relative remove repeat addlyrics partcombine score
3943 script stylesheet skip textscript tempo translator
3948 @subsection Integers
3956 Formed from an optional minus sign followed by digits. Arithmetic
3957 operations cannot be done with integers, and integers cannot be mixed
3962 @cindex real numbers
3968 Formed from an optional minus sign and a sequence of digits followed
3969 by a @emph{required} decimal point and an optional exponent such as
3970 @code{-1.2e3}. Reals can be built up using the usual operations:
3971 `@code{+}', `@code{-}', `@code{*}', and
3972 `@code{/}', with parentheses for grouping.
3980 A real constant can be followed by one of the dimension keywords:
3981 @code{\mm} @code{\pt}, @code{\in}, or @code{\cm}, for millimeters,
3982 points, inches and centimeters, respectively. This converts the number
3983 to a real that is the internal representation of dimensions.
3991 Begins and ends with the @code{"} character. To include a @code{"}
3992 character in a string write @code{\"}. Various other backslash
3993 sequences have special interpretations as in the C language. A string
3994 that contains no spaces can be written without the quotes. See
3995 @ref{Lexical modes} for details on unquoted strings; their
3996 interpretation varies depending on the situation. Strings can be
3997 concatenated with the @code{+} operator.
3999 The tokenizer accepts the following commands. They have no grammatical
4000 function, hence they can appear anywhere in the input.
4004 @subsection Main input
4007 @cindex @code{\maininput}
4009 The @code{\maininput} command is used in init files to signal that the
4010 user file must be read. This command cannot be used in a user file.
4012 @node File inclusion
4013 @subsection File inclusion
4014 @cindex @code{\include}
4016 \include @var{filename}
4019 Include @var{filename}. The argument @var{filename} may be a quoted string (an
4020 unquoted string will not work here!) or a string identifier. The full
4021 filename including the @file{.ly} extension must be given,
4024 @node Version information
4025 @subsection Version information
4026 @cindex @code{\version}
4028 \version @var{string} ;
4031 Specify the version of LilyPond that a file was written for. The
4032 argument is a version string in quotes, for example @code{"1.2.0"}.
4033 This is used to detect invalid input, and to aid
4034 @code{convert-ly} a tool that automatically upgrades input files. See
4035 See @ref{convert-ly} for more information on @code{convert-ly}.
4044 @c .{Local emacs vars}
4047 @c minor-mode: font-lock
4048 @c minor-mode: outline
4049 @c outline-layout: (-1 : 0)
4050 @c outline-use-mode-specific-leader: "@c \."
4051 @c outline-primary-bullet: "{"
4052 @c outline-stylish-prefixes: nil
4053 @c outline-override-protect: t