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)
20 @c .{Reference Manual}
22 @node Reference Manual
23 @chapter Reference Manual
25 This document describes GNU LilyPond and its input format. This document
26 has been revised for LilyPond 1.3.131
55 The purpose of LilyPond is explained informally by the term `music
56 typesetter'. This is not a fully correct name: not only does the
57 program print musical symbols, it also makes esthetic decisions. All
58 symbols and their placement is @emph{generated} from a high-level
59 musical description. In other words, LilyPond would be best described
60 by `music compiler' or `music to notation compiler'.
62 Internally, LilyPond is written in a mixture of Scheme and C++. Most of
63 the algorithms and low-level routines are written in C++, but these low
64 level components are glued together using Scheme data
65 structures. LilyPond is linked to GUILE, GNU's Scheme library for
68 When lilypond is run to typeset sheet music, the following happens:
71 @item GUILE Initialization: various scheme files are read
72 @item parsing: first standard .ly initialization files are read, and
73 then the user @file{.ly} file is read.
74 @item interpretation: the music in the file is processed "in playing
75 order", i.e. in the same order as your eyes scan sheet music, and in the
76 same order that you hear the notes play.
79 in this step, the results of the interpretation, a typesetting
80 specification, is solved.
82 @item the visible results ("virtual ink") is written to the output file.
85 These stages, involve data of a specific type: during parsing,
86 @strong{Music} objects are created. During the interpretation,
87 @strong{context} is constructed, and with this context af network of
88 @strong{graphical objects} (``grobs'') is created. The grobs contain
89 unknown variables, and the network forms a set of equations. After
90 solving the equations and filling in these variables, the printed output
91 (in the form of @strong{molecules}) is written to an output file.
93 These threemanship of tasks (parsing, translating, typesetting) and
94 data-structures (music, context, graphical objects) permeates the entire
95 design of the program. This manual is ordered in terms of user
96 tasks. With each concept will be explained to which of the three parts
99 LilyPond input can be classified into three types:
101 @item musical expressions: a musical expression is some combination of
103 @item output definitions: recipes for translating those musical
104 expressions into performances (MIDI) or graphics (eg. PostScript).
106 @item declarations: by declaring and naming musical expressions, you
107 can enter and edit them in manageable chunks.
121 * Defining pitch names::
130 @subsection Notes mode
134 @cindex @code{\notes}
135 Note mode is introduced by the keyword
136 @code{\notes}. In Note mode, words can only
137 contain alphabetic characters. If @code{word} is encountered,
138 LilyPond first checks for a notename of @code{word}. If no
139 notename is found, then @code{word} is treated as a string.
141 Since combinations of numbers and dots are used for indicating
142 durations, it is not possible to enter real numbers in this mode.
151 @cindex Note specification
153 @cindex entering notes
155 The verbose syntax for pitch specification is
157 @cindex @code{\pitch}
159 \pitch @var{scmpitch}
162 @var{scmpitch} is a pitch scheme object, see @ref{Pitch data type}.
164 In Note and Chord mode, pitches may be designated by names. The default
165 names are the Dutch note names. The notes are specified by the letters
166 @code{c} through @code{b}, where @code{c} is an octave below middle C
167 and the letters span the octave above that C. In Dutch,
168 @cindex note names, Dutch
169 a sharp is formed by adding @code{-is} to the end of a pitch name. A
170 flat is formed by adding @code{-es}. Double sharps and double flats are
171 obtained by adding @code{-isis} or @code{-eses}. @code{aes} and
172 @code{ees} are contracted to @code{as} and @code{es} in Dutch, but both
173 forms will be accepted.
175 LilyPond has predefined sets of notenames for various other languages.
176 To use them, simply include the language specific init file. For
177 example: @code{\include "english.ly"}. The available language files and
178 the names they define are:
181 Note Names sharp flat
182 nederlands.ly c d e f g a bes b -is -es
183 english.ly c d e f g a bf b -s/-sharp -f/-flat
184 deutsch.ly c d e f g a b h -is -es
185 norsk.ly c d e f g a b h -iss/-is -ess/-es
186 svenska.ly c d e f g a b h -iss -ess
187 italiano.ly do re mi fa sol la sib si -d -b
188 catalan.ly do re mi fa sol la sib si -d/-s -b
197 The optional octave specification takes the form of a series of
198 single quote (`@code{'}') characters or a series of comma
199 (`@code{,}') characters. Each @code{'} raises the pitch by one
200 octave; each @code{,} lowers the pitch by an octave.
202 @lilypond[fragment,verbatim,center]
203 c' d' e' f' g' a' b' c''
206 @lilypond[fragment,verbatim,center]
207 cis' dis' eis' fis' gis' ais' bis'
210 @lilypond[fragment,verbatim,center]
211 ces' des' es' fes' ges' as' bes'
214 @lilypond[fragment,verbatim,center]
215 cisis' eisis' gisis' aisis' beses'
218 @lilypond[fragment,verbatim,center]
219 ceses' eses' geses' ases' beses'
223 @c . {Defining pitch names}
224 @node Defining pitch names
225 @subsection Defining pitch names
227 @cindex defining pitch names
228 @cindex pitch names, defining
230 Note names and chord modifiers can be customised for nationalities. The
231 syntax is as follows.
233 @cindex @code{\pitchnames}
234 @cindex @code{\chordmodifiers}
236 \pitchnames @var{scheme-alist}
237 \chordmodifiers @var{scheme-alist}
240 See @file{ly/nederlands.ly} and @file{ly/chord-modifiers.ly} for
241 specific examples how to do this. Some national note names have been
242 provided, among others: Norwegian, Swedish, German, Italian, Catalan,
243 French, Dutch and English.
248 @subsection Durations
252 @cindex @code{\duration}
254 The syntax for an verbose duration specification is
256 \duration @var{scmduration}
259 In Note, Chord, and Lyrics mode, durations may be designated by numbers
260 and dots: durations are entered as their reciprocal values. For notes
261 longer than a whole note, use identifiers.
267 c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64
269 r1 r2 r4 r8 r16 r32 r64 r64
275 \notes \relative c'' {
276 a\longa a\breve \autoBeamOff
277 a1 a2 a4 a8 a16 a32 a64 a64
279 r1 r2 r4 r8 r16 r32 r64 r64
284 \remove "Clef_engraver";
285 \remove "Staff_symbol_engraver";
286 \remove "Time_signature_engraver";
287 \consists "Pitch_squash_engraver";
294 As you can see, the longa is not printed. To get a longa note head, you
295 have to use a mensural note heads. This is done accomplished by setting
296 the @code{style} property of the NoteHead grob to @code{mensural}.
298 If the duration is omitted then it is set equal to the previous duration
299 entered. At the start of parsing there is no previous duration, so then
300 a quarter note is assumed. The duration can be followed by a dot
301 (`@code{.}') to obtain dotted note lengths.
304 @lilypond[fragment,verbatim,center]
310 You can alter the length of duration by writing `@code{*}@var{fraction}'
311 after it. This will not affect the appearance of note heads or rests.
317 A note specification has the form
320 @var{pitch}[@var{octavespec}][!][?][@var{duration}]
324 LilyPond will determine what accidentals to typeset depending on the key
325 and context, so alteration refer to what note is heard, not to whether
326 accidentals are printed. A reminder accidental
327 @cindex reminder accidental
329 can be forced by adding an exclamation mark @code{!} after the pitch.
330 A cautionary accidental,
331 @cindex cautionary accidental
333 i.e., an accidental within parentheses can be obtained by adding the
334 question mark `@code{?}' after the pitch.
336 @lilypond[fragment,verbatim,center]
337 cis' d' e' cis' c'? d' e' c'!
346 Rests are entered like notes, with note name `@code{r}'.
347 There is also a note name
348 `@code{s}', which produces a space of the specified
359 \skip @var{duration} @code{;}
363 Skips the amount of time specified by @var{duration}. If no other
364 music is played, a gap will be left for the skipped time with no
365 notes printed. It works in Note Mode or Lyrics Mode. In Note mode,
366 this has the same effect as the spacer rest.
370 @c . {Music notation}
372 @section Music notation
373 @cindex Music notation
388 @code{\key} @var{pitch} @var{type} @code{;}
390 @cindex @code{\minor}
391 @cindex @code{\major}
392 @cindex @code{\minor}
393 @cindex @code{\ionian}
394 @cindex @code{\locrian}
395 @cindex @code{\aeolian}
396 @cindex @code{\mixolydian}
397 @cindex @code{\lydian}
398 @cindex @code{\phrygian}
399 @cindex @code{\dorian}
401 Change the key signature. @var{type} should be @code{\major} or
402 @code{\minor} to get @var{pitch}-major or @var{pitch}-minor,
403 respectively. The second argument is optional; the default is major
404 keys. The @var{\context} argument can also be given as an integer,
405 which tells the number of semitones that should be added to the pitch
406 given in the subsequent @code{\key} commands to get the corresponding
407 major key, e.g., @code{\minor} is defined as 3. The standard mode names
408 @code{\ionian}, @code{\locrian}, @code{\aeolian}, @code{\mixolydian},
409 @code{\lydian}, @code{\phrygian}, and @code{\dorian} are also defined.
411 This command sets @code{Staff.keySignature}.
415 @cindex @code{keySignature}
418 @subsubsection Clef changes
421 \clef @var{clefname} @code{;}
427 \property Staff.clefGlyph = @var{symbol associated with clefname}
428 \property Staff.clefPosition = @var{clef Y-position for clefname}
429 \property Staff.clefOctavation = @var{extra pitch of clefname}
432 Supported clef-names include
435 @item treble, violin, G, G2: G clef on 2nd line
436 @item french: G clef on 1st line
437 @item soprano: C clef on 1st line
438 @item mezzosoprano: C clef on 2nd line
439 @item alto: C clef on 3rd line
440 @item tenor: C clef on 4th line
441 @item baritone: C clef on 5th line
442 @item varbaritone: F clef on 3rd line
443 @item bass, F: F clef on 4th line
444 @item subbass: F clef on 5th line
445 @item percussion: percussion clef
448 Supported associated symbols (for Staff.clefGlyph) are:
451 @item clefs-C: modern style C clef
452 @item clefs-F: modern style F clef
453 @item clefs-G: modern style G clef
454 @item clefs-vaticana_do: Editio Vaticana style do clef
455 @item clefs-vaticana_fa: Editio Vaticana style fa clef
456 @item clefs-medicaea_do: Editio Medicaea style do clef
457 @item clefs-medicaea_fa: Editio Medicaea style fa clef
458 @item clefs-mensural1_c: modern style mensural C clef
459 @item clefs-mensural2_c: historic style small mensural C clef
460 @item clefs-mensural3_c: historic style big mensural C clef
461 @item clefs-mensural1_f: historic style traditional mensural F clef
462 @item clefs-mensural2_f: historic style new mensural F clef
463 @item clefs-mensural_g: historic style mensural G clef
464 @item clefs-hufnagel_do: historic style hufnagel do clef
465 @item clefs-hufnagel_fa: historic style hufnagel fa clef
466 @item clefs-hufnagel_do_fa: historic style hufnagel combined do/fa clef
467 @item clefs-percussion: modern style percussion clef
470 @emph{Modern style} means "as is typeset in current editions".
471 @emph{Historic style} means "as was typeset or written in contemporary
472 historic editions". @emph{Editio XXX style} means "as is/was printed in
476 @subsection Breath marks
478 Breath marks are entered using @code{\breathe}:
480 @lilypond[fragment,relative]
486 @c . {Time signature}
488 @subsection Time signature
489 @cindex Time signature
494 \time @var{numerator}@code{/}@var{denominator} @code{;}
497 A short-cut for doing
499 \property Score.timeSignatureFraction = #'(@var{numerator} . @var{denominator})
502 See the documentation of @code{timeSignatureFraction}
506 @subsubsection Partial
510 @cindex partial measure
511 @cindex measure, partial
512 @cindex shorten measures
513 @cindex @code{\partial}
515 \partial @var{duration} @code{;}
521 \property Score.measurePosition = @var{length of duration}
525 See the documentation of @code{measurePosition}.
536 [todo : collisiosn, rest-collisinos, voiceX identifiers, how to
537 which contexts to instantiate.]
541 @cindex @code{\shiftOff}
542 @item @code{\shiftOff}
543 Disable horizontal shifting of note heads that collide.
545 @cindex @code{\shiftOn}
546 @item @code{\shiftOn}
547 Enable note heads that collide with other note heads to be
548 shifted horiztonally. Also @code{\shiftOnn} and @code{\shiftOnnn}
549 set different shift values.
551 @cindex @code{\stemBoth}
552 @item @code{\stemBoth}
553 Allow stems, beams, and slurs to point either upwards or
554 downwards, decided automatically by LilyPond.
556 @cindex @code{\stemDown}
557 @item @code{\stemDown}
558 Force stems, beams, and slurs to point down.
560 @cindex @code{\stemUp}
562 Force stems, beams and slurs to point up.
587 @c . {Automatic beams}
588 @subsubsection Automatic beams
591 @cindex automatic beam generation
593 @cindex @code{Voice.noAutoBeaming}
595 LilyPond will group flagged notes and generate beams autmatically, where
598 This feature can be disabled by setting the @code{Voice.noAutoBeaming}
599 property to true, which you may find necessary for the melody that goes
600 with lyrics, eg. Automatic beaming can easily be overridden for
601 specific cases by specifying explicit beams. This is discussed in the
606 @cindex @code{Voice.autoBeamSettings}
607 @cindex @code{(end * * * *)}
608 @cindex @code{(begin * * * *)}
610 A large number of Voice properties are used to decide how to generate
611 beams. Their default values appear in @file{scm/auto-beam.scm}. In
612 general, beams can begin anywhere, but their ending location is
613 significant. Beams can end on a beat, or at durations specified by the
614 properties in @code{Voice.autoBeamSettings}. To end beams every quarter
615 note, for example, you could set the property @code{(end * * * *)} to
616 @code{(make-moment 1 4)}. To end beams at every three eighth notes you
617 would set it to @code{(make-moment 1 8)}. The same syntax can be used
618 to specify beam starting points using @code{(begin * * * *)}, eg:
621 \property Voice.autoBeamSettings \override
622 #'(end * * * *) = #(make-moment 1 4)
623 \property Voice.autoBeamSettings \override
624 #'(begin * * * *) = #(make-moment 1 8)
628 To allow different settings for different time signatures, instead of
629 the first two asterisks @code{* *} you can specify a time signature; use
630 @code{(end N M * *)} to restrict the definition to
631 `@var{N}@code{/}@var{M}' time. For example, to specify beams ending
632 only for 6/8 time you would use the property @code{(end 6 8 * *)}.
634 To allow different endings for notes of different durations, instead of
635 th last two asterisks you can specify a duration; use @code{(end * * N
636 M)} to restrict the definition to beams that contain notes of
637 `@var{N}@code{/}@var{M}' duration.
639 For example, to specify beam endings for beams that contain 32nd notes,
640 you would use @code{(end * * 1 32)}.
645 @cindex Automatic beams
646 @subsubsection Manual beams
647 @cindex beams, manual
651 In some cases it may be necessary to override LilyPond's automatic
652 beaming algorithm. For example, the auto beamer will not beam over
653 rests or bar lines, so if you want that, specify the begin and end point
654 manually using @code{[} and @code{]}:
657 @lilypond[fragment,relative,verbatim]
659 r4 [r8 g'' a r8] r8 [g | a] r8
664 @cindex @code{stemLeftBeamCount}
666 If you have specific wishes for the number of beams, you can fully
667 control the number of beams through the properties
668 y@code{Voice.stemLeftBeamCount} and @code{Voice.stemRightBeamCount}.
670 @lilypond[fragment,relative,verbatim]
673 [f8 r16 \property Voice.stemLeftBeamCount = #1 f g a]
677 @cindex @code{stemRightBeamCount}
680 @c . {Adjusting beams}
681 @unnumberedsubsubsec Adjusting beams
682 @cindex Adjusting beams
698 A slur connects chords and is used to indicate legato. Slurs avoid
699 crossing stems. A slur is started with @code{(} and stopped with
700 @code{)}. The starting @code{(} appears to the right of the first note
701 in the slur. The terminal @code{)} appears to the left of the last note
702 in the slur. This makes it possible to put a note in slurs from both
705 @lilypond[fragment,verbatim,center]
706 f'()g'()a' [a'8 b'(] a'4 g'2 )f'4
709 @c . {Adjusting slurs}
710 @unnumberedsubsubsec Adjusting slurs
713 @node Slur attachments
714 @subsubsection Slur attachments
716 The ending of a slur should whenever possible be attached to a note
717 head. Only in some instances where beams are involved, LilyPond may
718 attach a slur to a stem end. In some cases, you may want to override
719 LilyPond's decision, e.g., to attach the slur to the stem end. This can
720 be done through @code{Voice.Slur}'s grob-property @code{attachment}:
724 @lilypond[fragment,relative,verbatim]
725 \property Voice.Slur \set #'direction = #1
726 \property Voice.Stem \set #'length = #5.5
728 \property Voice.Slur \set #'attachment = #'(stem . stem)
733 Similarly, slurs can be attached to note heads even when beams are
737 @lilypond[fragment,relative,verbatim]
738 \property Voice.Slur \set #'direction = #1
739 \property Voice.Slur \set #'attachment = #'(head . head)
740 g''16()g()g()g()d'()d()d()d
744 If a slur would strike through a stem or beam, LilyPond will move the
745 slur away vertically (upward or downward). In some cases, this may
746 cause ugly slurs that you may want to correct:
749 @lilypond[fragment,relative,verbatim]
750 \property Voice.Stem \set #'direction = #1
751 \property Voice.Slur \set #'direction = #1
753 \property Voice.Slur \set #'attachment = #'(stem . stem)
758 LilyPond will increase the curvature of a slur trying to stay free of
759 note heads and stems. However, if the curvature would increase too much,
760 the slur will be reverted to its default shape. This decision is based
761 on @code{Voice.Slur}'s grob-property @code{beautiful} value. In some
762 cases, you may find ugly slurs beautiful, and tell LilyPond so by
763 increasing the @code{beautiful} value:
765 [hoe gedefd?? wat betekent beautiful = X?]
770 \notes \context PianoStaff <
772 \context Staff=up { s1 * 6/4 }
773 \context Staff=down <
775 \autochange Staff \context Voice
777 d,8( a' d f a d f d a f d )a
785 Slur \override #'beautiful = #5.0
786 Slur \override #'direction = #1
787 Stem \override #'direction = #-1
788 autoBeamSettings \override #'(end * * * *)
793 VerticalAlignment \override #'threshold = #'(5 . 5)
800 @cindex Adusting slurs
806 @subsection Phrasing slur
807 @cindex phrasing slur
808 @cindex phrasing mark
810 A phrasing slur (or phrasing mark) connects chords and is used to
811 indicate a musical sentence. Phrasing slurs avoid crossing stems. A
812 phrasing slur is started with @code{\(} and stopped with @code{\)}. The
813 starting @code{\(} appears to the right of the first note in the
814 phrasing slur. The terminal @code{\)} appears to the left of the last
815 note in the phrasing slur.
817 @lilypond[fragment,verbatim,center,relative]
818 \time 6/4; c''\((d)e f(e)\)d
821 [TODO: put together with breath mark.]
840 A tie connects two adjacent note heads of the same pitch. When used
841 with chords, it connects all of the note heads whose pitches match.
842 Ties are indicated using the tilde symbol `@code{~}'.
843 If you try to tie together chords which have no common pitches, a
844 warning message will appear and no ties will be created.
846 @lilypond[fragment,verbatim,center]
847 e' ~ e' <c' e' g'> ~ <c' e' g'>
855 @subsubsection Tuplets
859 Tuplets are made out of a music expression by multiplying their duration
862 @cindex @code{\times}
864 \times @var{fraction} @var{musicexpr}
867 The duration of @var{musicexpr} will be multiplied by the fraction.
868 In print, the fraction's denominator will be printed over the notes,
869 optionally with a bracket. The most common tuplet is the triplet in
870 which 3 notes have the length of 2, so the notes are 2/3 of
871 their written length:
873 @lilypond[fragment,verbatim,center]
874 g'4 \times 2/3 {c'4 c' c'} d'4 d'4
877 [todo: document tupletSpannerDuration]
883 @subsubsection Text spanner
888 @subsubsection Ottava
890 @unnumberedsubsubsec Ottava
892 [move to trick. Not a supported feature.]
894 @lilypond[fragment,relative,verbatim]
896 \property Voice.TextSpanner \set #'type = #'dotted-line
897 \property Voice.TextSpanner \set #'edge-height = #'(0 . 1.5)
898 \property Voice.TextSpanner \set #'edge-text = #'("8va " . "")
899 \property Staff.centralCPosition = #-13
900 a\spanrequest \start "text" b c a \spanrequest \stop "text"
907 @subsubsection Span requests
908 @cindex Span requests
910 @cindex @code{\spanrequest}
913 \spanrequest @var{startstop} @var{type}
915 @cindex @code{\start}
918 Define a spanning request. The @var{startstop} parameter is either -1
919 (@code{\start}) or 1 (@code{\stop}) and @var{type} is a string that
920 describes what should be started. Among the supported types are
921 @code{crescendo}, @code{decrescendo}, @code{beam}, @code{slur}.This is
922 an internal command. Users should use the shorthands which are defined
923 in the initialization file @file{spanners.ly}.
925 You can attach a (general) span request to a note using the following
928 @lilypond[fragment,verbatim,center]
929 c'4-\spanrequest \start "slur"
930 c'4-\spanrequest \stop "slur"
933 The slur syntax with parentheses is a shorthand for this.
937 @subsection Ornaments
946 @subsubsection Articulation
949 @cindex articulations
953 A variety of symbols can appear above and below notes to indicate
954 different characteristics of the performance. These symbols can be
955 added to a note with `@var{note}@code{-\}@var{name}'. Numerous symbols
956 are defined in @file{script.ly} and @file{script.scm}. Symbols can be
957 forced to appear above or below the note by writing
958 `@var{note}@code{^\}@var{name}' and `@var{note}@code{_\}@var{name}'
959 respectively. Here is a chart showing symbols above notes, with the
960 name of the corresponding symbol appearing underneath.
966 \property Score.LyricSyllable \override #'font-family =
968 \property Score.LyricSyllable \override #'font-shape = #'upright
969 c''-\accent c''-\marcato c''-\staccatissimo c''-\fermata
970 c''-\stopped c''-\staccato c''-\tenuto c''-\upbow
971 c''-\downbow c''^\lheel c''-\rheel c''^\ltoe
972 c''-\rtoe c''-\turn c''-\open c''-\flageolet
973 c''-\reverseturn c''-\trill c''-\prall c''-\mordent
974 c''-\prallprall c''-\prallmordent c''-\upprall c''-\downprall
975 c''-\thumb c''-\segno c''-\coda
977 \context Lyrics \lyrics {
978 accent__ marcato__ staccatissimo__ fermata
979 stopped__ staccato__ tenuto__ upbow
980 downbow__ lheel__ rheel__ ltoe
981 rtoe__ turn__ open__ flageolet
982 reverseturn__ trill__ prall__ mordent
983 prallprall__ prallmordent__ uprall__ downprall
988 linewidth = 5.875\in;
997 @subsubsection Text scripts
1000 In addition, it is possible to place arbitrary strings of text or markup
1001 text (see @ref{Text markup}) above or below notes by using a string
1002 instead of an identifier: @code{c^"text"}. It is possible to use @TeX{}
1003 commands, but this should be avoided because this makes it impossible
1004 for LilyPond to compute the exact length of the string, which may lead
1005 to collisions. Also, @TeX{} commands won't work with direct postscript
1006 output. Fingerings can be placed by simply using digits. All of these
1007 note ornaments appear in the printed output but have no effect on the
1008 MIDI rendering of the music.
1011 @unnumberedsubsubsec Fingerings
1014 To save typing, fingering instructions (digits 0 to 9 are
1015 supported) and single characters shorthands exist for a few
1020 \notes \context Voice {
1021 \property Voice.TextScript \set #'font-family = #'typewriter
1022 \property Voice.TextScript \set #'font-shape = #'upright
1028 c''4-^_"c-\\^{ }" s4
1035 linewidth = 5.875 \in;
1043 @cindex @code{\textscript}
1047 \textscript @var{text} @var{style}
1050 Defines a text to be printed over or under a note. @var{style} is a
1051 string that may be one of @code{roman}, @code{italic}, @code{typewriter},
1052 @code{bold}, @code{Large}, @code{large}, @code{dynamic} or @code{finger}.
1054 You can attach a general textscript request using this syntax:
1059 c4-\textscript "6" "finger"
1060 c4-\textscript "foo" "normal"
1065 This is equivalent to @code{c4-6 c4-"foo"}.
1067 @cindex @code{\script}
1076 Prints a symbol above or below a note. The argument is a string which
1077 points into the script-alias table defined in @file{scm/script.scm}.
1078 Usually the @code{\script} keyword is not used directly. Various
1079 helpful identifier definitions appear in @file{script.ly}.
1081 For information on how to add scripts, consult @file{scm/script.scm}.
1088 @subsection Grace notes
1097 @cindex @code{\grace}
1100 @cindex @code{graceAlignPosition}
1103 \grace @var{musicexpr}
1106 A grace note expression has duration 0; the next real note is
1107 assumed to be the main note.
1109 You cannot have the grace note after the main note, in terms of
1110 duration, and main notes, but you can typeset the grace notes to the
1111 right of the main note using the property
1112 @code{graceAlignPosition}.
1113 @cindex @code{flagStyle}
1115 When grace music is interpreted, a score-within-a-score is set up:
1116 @var{musicexpr} has its own time bookkeeping, and you could (for
1117 example) have a separate time signature within grace notes. While in
1118 this score-within-a-score, you can create notes, beams, slurs, etc.
1119 Unbeamed eighth notes and shorter by default have a slash through the
1120 stem. This behavior can be controlled with the
1121 @code{flagStyle} property.
1124 @lilypond[fragment,verbatim]
1126 \grace c8 c4 \grace { [c16 c16] } c4
1127 \grace { \property Grace.flagStyle = "" c16 } c4
1134 At present, nesting @code{\grace} notes is not supported. The following
1135 may cause run-time errors:
1137 @code{\grace @{ \grace c32 c16 @} c4}
1139 Since the meaning of such a construct is unclear, we don't consider
1140 this a loss. Similarly, juxtaposing two @code{\grace} sections is
1141 syntactically valid, but makes no sense and may cause runtime errors.
1143 Ending a staff or score with grace notes may also generate a run-time
1144 error, since there will be no main note to attach the grace notes to.
1146 The present implementation is not robust and generally kludgy. We expect
1147 it to change after LilyPond 1.4. Syntax changes might also be
1160 * Crescendo and Decrescendo::
1168 @subsubsection Glissando
1171 @cindex @code{\glissando}
1173 A glissando line can be requested by attaching a @code{\glissando} to a
1177 @lilypond[fragment,relative,verbatim]
1182 Printing of an additional text (such as @emph{gliss.}) must be done
1189 @subsubsection Dynamics
1202 @cindex @code{\ffff}
1216 Dynamic marks are specified by using an identifier after a note:
1217 @code{c4-\ff}. The available dynamic marks are:
1218 @code{\ppp}, @code{\pp}, @code{\p}, @code{\mp}, @code{\mf}, @code{\f},
1219 @code{\ff}, @code{\fff}, @code{\fff}, @code{\fp}, @code{\sf},
1220 @code{\sff}, @code{\sp}, @code{\spp}, @code{\sfz}, and @code{\rfz}.
1222 @c . {Crescendo and Decrescendo}
1223 @node Crescendo and Decrescendo
1224 @subsubsection Crescendo and Decrescendo
1226 @cindex Crescendo and Decrescendo
1230 @cindex @code{\decr}
1231 @cindex @code{\rced}
1238 A crescendo mark is started with @code{\cr} and terminated with
1239 @code{\rc}, the textual reverse of @code{cr}. A decrescendo mark is
1240 started with @code{\decr} and terminated with @code{\rced}. There are
1241 also shorthands for these marks. A crescendo can be started with
1242 @code{\<} and a decrescendo can be started with @code{\>}. Either one
1243 can be terminated with @code{\!}. Note that @code{\!} must go before
1244 the last note of the dynamic mark whereas @code{\rc} and @code{\rced} go
1245 after the last note. Because these marks are bound to notes, if you
1246 want to get several marks during one note, you must use spacer notes.
1248 @lilypond[fragment,verbatim,center]
1249 c'' \< \! c'' d'' \decr e'' \rced
1250 < f''1 { s4 \< \! s2 \> \! s4 } >
1253 You can also use a text saying @emph{cresc.} instead of hairpins. Here
1254 is an example how to do it:
1256 @lilypond[fragment,relative,verbatim]
1258 \property Voice.crescendoText = "cresc."
1259 \property Voice.crescendoSpanner = #'dashed-line
1268 @subsubsection Bar lines
1272 @cindex measure lines
1279 This is a short-cut for doing
1281 \property Score.whichBar = @var{bartype}
1284 You are encouraged to use @code{\repeat} for repetitions. See
1285 @ref{Repeats}, and the documentation of @code{whichBar} in
1286 @ref{(lilypond-internals)LilyPond context properties}.
1294 @subsection Bar check
1298 @cindex @code{barCheckNoSynchronize}
1302 Whenever a bar check is encountered during interpretation, a warning
1303 message is issued if it doesn't fall at a measure boundary. This can
1304 help you find errors in the input. Depending on the value of
1305 @code{barCheckNoSynchronize}, the beginning of the measure will be
1306 relocated, so this can also be used to shorten measures.
1308 A bar check is entered using the bar symbol, @code{|}
1320 @cindex @code{\repeat}
1322 In order to specify repeats, use the @code{\repeat}
1323 keyword. Since repeats look and sound differently when played or
1324 printed, there are a few different variants of repeats.
1328 Repeated music is fully written (played) out. Useful for MIDI
1332 This is the normal notation: Repeats are not written out, but
1333 alternative endings (voltas) are printed, left to right.
1336 Alternative endings are written stacked. Which is unfortunately not
1337 practical for anything right now.
1345 * Manual repeat commands::
1347 * Tremolo subdivision::
1351 @subsection Repeat syntax
1353 The syntax for repeats is
1356 \repeat @var{variant} @var{repeatcount} @var{repeatbody}
1359 If you have alternative endings, you may add
1361 @cindex @code{\alternative}
1363 \alternative @code{@{} @var{alternative1}
1365 @var{alternative3} @dots{} @code{@}}
1368 where each @var{alternative} is a Music expression.
1370 Normal notation repeats are used like this:
1374 @lilypond[fragment,verbatim]
1376 \repeat volta 2 { c'4 d' e' f' }
1377 \repeat volta 2 { f' e' d' c' }
1381 With alternative endings:
1385 @lilypond[fragment,verbatim]
1387 \repeat volta 2 {c'4 d' e' f'}
1388 \alternative { {d'2 d'} {f' f} }
1392 Folded repeats look like this:@footnote{Folded repeats offer little
1393 more over simultaneous music. However, it is to be expected that
1394 more functionality -- especially for the MIDI backend -- will be
1395 implemented at some point in the future.}
1399 @lilypond[fragment,verbatim]
1401 \repeat fold 2 {c'4 d' e' f'}
1402 \alternative { {d'2 d'} {f' f} }
1408 If you don't give enough alternatives for all of the repeats, then
1409 the first alternative is assumed to be repeated often enough to equal
1410 the specified number of repeats.
1413 @lilypond[fragment,verbatim]
1417 \repeat volta 3 { e | c2 d2 | e2 f2 | }
1418 \alternative { { g4 g g } { a | a a a a | b2. } }
1426 As you can see, LilyPond doesn't remember the timing information, nor
1427 are slurs or ties repeated, so you have to reset timing information
1428 after a repeat, eg using bar-checks, @code{Score.measurePosition} or
1429 @code{\partial}. We hope to fix this after 1.4.
1431 It is possible to nest @code{\repeat}, although it probably is only
1432 meaningful for unfolded repeats.
1434 @node Manual repeat commands
1435 @subsection Manual repeat commands
1437 @cindex @code{repeatCommands}
1439 The property @code{repeatCommands} can be used to control the layout of
1440 repeats. Its value is a Scheme list of repeat commands, where each repeat
1448 @item (volta . @var{text})
1449 Print a volta bracket saying @var{text}.
1451 Stop a running volta bracket
1454 @lilypond[verbatim, fragment]
1456 \property Score.repeatCommands = #'((volta "93") end-repeat)
1458 \property Score.repeatCommands = #'((volta #f))
1463 @node Tremolo repeats
1464 @subsection Tremolo repeats
1465 @cindex tremolo beams
1467 To place tremolo marks between notes, use @code{\repeat} with tremolo
1469 @lilypond[verbatim,center]
1471 \context Voice \notes\relative c' {
1472 \repeat "tremolo" 8 { c16 d16 }
1473 \repeat "tremolo" 4 { c16 d16 }
1474 \repeat "tremolo" 2 { c16 d16 }
1475 \repeat "tremolo" 4 c16
1478 linewidth = 40*\staffspace;
1483 @node Tremolo subdivision
1484 @subsection Tremolo subdivision
1485 @cindex tremolo marks
1486 @cindex @code{tremoloFlags}
1488 Tremolo marks can be printed on a single note by adding
1489 `@code{:}[@var{length}]' after the note. The length must be at least 8.
1490 A @var{length} value of 8 gives one line across the note stem. If the
1491 length is omitted, then the last value is used, or the value of the
1492 @code{tremoloFlags} property if there was no last value.
1494 @lilypond[verbatim,fragment,center]
1498 Tremolos in this style do not carry over into the MIDI output.
1500 Using this mechanism pays off when you entering many tremolos, since the
1501 default argument saves a lot of typing.
1509 @section Piano music
1511 * Automatic staff changes::
1512 * Manual staff switches::
1519 @c . {Automatic staff changes}
1520 @node Automatic staff changes
1521 @subsection Automatic staff changes
1522 @cindex Automatic staff changes
1524 Voices can be switched from top to bottom staff automatically. The
1527 \autochange @var{contexttype} @var{musicexp}
1529 This will switch notation context of @var{musicexp} between a
1530 @var{contexttype} named @code{up} and @code{down}. Typically, you use
1531 @code{Staff} for @var{contexttype}. The autochanger switches on basis
1532 of pitch (central C is the turning point), and it looks ahead skipping
1533 over rests to switch rests in advance.
1535 @lilypond[verbatim,singleline]
1536 \score { \notes \context PianoStaff <
1537 \context Staff = "up" {
1538 \autochange Staff \context Voice = VA < \relative c' { g4 a b c d r4 a g } >
1540 \context Staff = "down" {
1549 @node Manual staff switches
1550 @subsection Manual staff switches
1552 @cindex manual staff switches
1553 @cindex staff switch, manual
1555 @cindex @code{\translator}
1557 \translator @var{contexttype} = @var{name}
1560 A music expression indicating that the context which is a direct
1561 child of the a context of type @var{contexttype} should be shifted to
1562 a context of type @var{contexttype} and the specified name.
1564 Usually this is used to switch staffs in Piano music, e.g.
1567 \translator Staff = top @var{Music}
1576 Piano pedals can be entered using the following span requests of the
1577 types @code{Sustain}, @code{UnaChorda} and @code{Sostenuto}:
1578 @lilypond[fragment,verbatim]
1579 c''4 \spanrequest \start "Sustain" c4 c4 \spanrequest \stop "Sustain"
1582 For these verbose expressions, standard shorthands have been defined:
1592 The symbols that are printed can be modified by setting pedalXStrings,
1593 where one of the pedal types. Refer to the generaetd documentation for
1596 Currently, brackets are not supported, only text markings (ie. Ped*
1602 @subsection Arpeggio
1605 @cindex broken arpeggio
1606 @cindex @code{\arpeggio}
1608 You can specify an arpeggio sign on a chord by attaching an
1609 @code{\arpeggio} to a note of the chord.
1613 @lilypond[fragment,relative,verbatim]
1614 \context Voice <c'\arpeggio e g c>
1618 When an arpeggio crosses staffs in piano music, you attach an arpeggio
1619 to the chords in both staffs, and set
1620 @code{PianoStaff.connectArpeggios}. LilyPond will connect the arpeggios
1624 @lilypond[fragment,relative,verbatim]
1625 \context PianoStaff <
1626 \property PianoStaff.connectArpeggios = ##t
1627 \context Voice = one { <c''\arpeggio e g c> }
1628 \context Voice = other { \clef bass; <c,,\arpeggio e g>}
1635 @c . {Follow Thread}
1637 @subsection Follow Thread
1638 @cindex follow thread
1639 @cindex staff switching
1642 [todo: different name, eg. voice line ? ]
1644 @cindex @code{followThread}
1646 Whenever a voice switches to another staff a line connecting the notes
1647 can be printed automatically. This is enabled if the property
1648 @code{PianoStaff.followThread} is set to true:
1651 @lilypond[fragment,relative,verbatim]
1652 \context PianoStaff <
1653 \property PianoStaff.followThread = ##t
1654 \context Staff \context Voice {
1656 \translator Staff=two
1659 \context Staff=two {\clef bass; \skip 1*2;}
1673 * Automatic syllable durations::
1679 @subsection Lyrics mode
1683 @cindex @code{\lyrics}
1685 Lyrics mode is introduced by the keyword @code{\lyrics}. This mode has
1686 rules that make it easy to include punctuation and diacritical marks in
1687 words: The purpose of Lyrics mode is that you can enter lyrics in @TeX{}
1688 format or a standard encoding without needing quotes. The precise
1689 definition of this mode is ludicrous, and this will remain so until the
1690 authors of LilyPond acquire a deeper understanding of character
1691 encoding, or someone else steps up to fix this.
1693 A word in Lyrics mode begins with: an alphabetic character, @code{_},
1694 @code{?}, @code{!}, @code{:}, @code{'}, the control characters @code{^A}
1695 through @code{^F}, @code{^Q} through @code{^W}, @code{^Y}, @code{^^},
1696 any 8-bit character with ASCII code over 127, or a two-character
1697 combination of a backslash followed by one of @code{`}, @code{'},
1698 @code{"}, or @code{^}.
1700 Subsequent characters of a word can be any character that is not a digit
1701 and not white space. One important consequence of this is that a word
1702 can end with `@code{@}}', which may be confusing. However, LilyPond will
1703 issue a warning. Any @code{_} character which appears in an unquoted
1704 word is converted to a space. This provides a mechanism for introducing
1705 spaces into words without using quotes. Quoted words can also be used
1706 in Lyrics mode to specify words that cannot be written with the above
1707 rules. Here are some examples. Not all of these words are printable by
1712 2B_||_!2B % not a word because it starts with a digit
1713 ``Hello'' % not a word because it starts with `
1714 _ _ _ _ % 4 words, each one a space
1717 Since combinations of numbers and dots are used for indicating
1718 durations, you can not enter real numbers in this mode.
1720 @cindex lyrics expressions
1722 Syllables are entered like notes, with pitches replaced by text. For
1723 example, @code{Twin-4 kle4 twin-4 kle4} enters four syllables, each
1724 with quarter note duration. Note that the hyphen has no special
1725 meaning for lyrics, and does not introduce special symbols. See
1726 section @ref{Lexical modes} for a description of what is interpreted as
1729 Spaces can be introduced into a lyric either by using quotes
1730 (@code{"}) or by using an underscore without quotes: @code{He_could4
1731 not4}. All unquoted underscores are converted to spaces. Printing
1732 lyrics is discussed in the next section.
1735 @c . {Printing lyrics}
1736 @node Printing lyrics
1737 @subsection Printing lyrics
1741 Lyric syllables must be interpreted within a @code{Lyrics} context for
1742 printing them. Here is a full example:
1748 \notes \transpose c'' {
1750 e f g2 | e4 f g2 \bar "|.";
1752 \context Lyrics \lyrics {
1753 Va-4 der Ja- cob Va- der Ja- cob
1754 Slaapt gij nog?2 Slaapt4 gij nog?2
1766 @cindex lyric extender
1768 You may want a continuous line after the syllables to show melismata.
1769 To achieve this effect, add a @code{__} lyric as a separate word
1770 after the lyric to be extended. This will create an extender, a line
1771 that extends over the entire duration of the lyric. This line will
1772 run all the way to the start of the next lyric, so you may want to
1773 shorten it by using a blank lyric (using @code{_}).
1780 \notes \relative c'' {
1781 a4 () b () c () d | c () d () b () a | c () d () b () a
1783 \context Lyrics \lyrics {
1784 foo1 __ | bar2. __ _4 | baz1 __
1792 @cindex Lyric hyphen
1794 If you want to have hyphens centered between syllables (rather than
1795 attached to the end of the first syllable) you can use the special
1796 `@code{-}@code{-}' lyric as a separate word between syllables. This
1797 will result in a hyphen which length varies depending on the space
1798 between syllables, and which will be centered between the syllables.
1806 \notes \transpose c'' {
1808 e f g2 | e4 f g2 \bar "|.";
1810 \context Lyrics \lyrics {
1811 Va4 -- der Ja -- cob | Va -- der Ja -- cob |
1812 Slaapt gij nog?2 | Slaapt4 gij nog?2
1821 @c . {Automatic syllable durations}
1822 @node Automatic syllable durations
1823 @subsection Automatic syllable durations
1824 @cindex Automatic syllable durations
1827 @cindex automatic lyric durations
1828 @cindex @code{\addlyrics}
1830 If you have lyrics that are set to a melody, you can import the rhythm
1831 of that melody into the lyrics using @code{\addlyrics}. The syntax for
1834 \addlyrics @var{musicexpr1 musicexpr2}
1837 This means that both @var{musicexpr1} and @var{musicexpr2} are
1838 interpreted, but that every non-command atomic music expression
1839 (``every syllable'') in @var{musicexpr2} is interpreted using timing
1840 of @var{musicexpr1}.
1841 @cindex @code{automaticMelismata}
1843 If the property @code{automaticMelismata} is set in the
1844 context of @var{musicexpr1}, no lyrics will be put on slurred or tied
1848 @lilypond[verbatim,fragment]
1851 \property Voice.automaticMelismata = ##t
1852 c8 () cis d8. e16 f2
1854 \context Lyrics \lyrics {
1859 You should use a single rhythm melody, and single rhythm lyrics (a
1860 constant duration is the obvious choice). If you do not, you will get
1861 undesired effects when using multiple stanzas:
1864 @lilypond[verbatim,fragment]
1867 c8 () cis d8. e16 f2
1869 \context Lyrics \lyrics
1876 It is valid (but probably not very useful) to use notes instead of
1877 lyrics for @var{musicexpr2}.
1880 @subsection More stanzas
1884 If you have multiple stanzas printed underneath each other, the separate
1885 syllables should be aligned around punctuation. LilyPond can do this if
1886 you explain it which lyric lines belong to which melody.
1888 To this end, give the Voice context an identity, and set the LyricsVoice
1889 to name starting with that identity. In the following example, the Voice
1890 identity is @code{duet}, and the identities of the LyricsVoices are
1891 @code{duet-1} and @code{duet-2}.
1894 @lilypond[singleline,verbatim]
1897 \notes \relative c'' \context Voice = duet { \time 3/4; g2 e4 a2 f4 g2. }
1898 \lyrics \context Lyrics <
1899 \context LyricsVoice = "duet-1" {
1900 \property LyricsVoice . stanza = "Bert"
1901 Hi, my name is bert. }
1902 \context LyricsVoice = "duet-2" {
1903 \property LyricsVoice . stanza = "Ernie"
1904 Ooooo, ch\'e -- ri, je t'aime. }
1909 You can add stanza numbers by setting @code{LyricsVoice.Stanza} (for the
1910 first system) and @code{LyricsVoice.stz} for the following systems.
1912 @cindex stanza numbering
1920 [chords vs. simultaneous music]
1924 * Entering named chords::
1925 * Printing named chords::
1930 @subsection Chords mode
1933 Chord mode is introduced by the keyword
1934 @code{\chords}. It is similar to Note mode, but
1935 words are also looked up in a chord modifier table (containing
1936 @code{maj}, @code{dim}, etc).
1938 Since combinations of numbers and dots are used for indicating
1939 durations, you can not enter real numbers in this mode. Dashes
1940 and carets are used to indicate chord additions and subtractions,
1941 so scripts can not be entered in Chord mode.
1943 @c . {Entering named chords}
1944 @node Entering named chords
1945 @subsection Entering named chords
1946 @cindex Chords names
1948 Chord names are a way to generate simultaneous music expressions that
1949 correspond with traditional chord names. It can only be used in
1950 Chord mode (see section @ref{Lexical modes}).
1954 @var{tonic}[@var{duration}][@code{-}@var{modifiers}][@code{^}@var{subtractions}][@code{/}@var{inversion}][@code{/+}@var{bass}].
1957 @var{tonic} should be the tonic note of the chord, and @var{duration}
1958 is the chord duration in the usual notation. There are two kinds of
1959 modifiers. One type is @emph{chord additions}, which are obtained by
1960 listing intervals separated by dots. An interval is written by its
1961 number with an optional @code{+} or @code{-} to indicate raising or
1962 lowering by half a step. Chord additions has two effects: It adds
1963 the specified interval and all lower odd numbered intervals to the
1964 chord, and it may lower or raise the specified interval. Intervals
1965 must be separated by a dot (@code{.}).
1968 Throughout these examples, chords have been shifted around the staff
1969 using @code{\transpose}.
1974 @lilypond[fragment,verbatim]
1978 c:9 c:9-.5+.7+ c:3-.5- c:4.6.8
1990 The second type of modifier that may appear after the @code{:} is a
1991 named modifier. Named modifiers are listed in the file
1992 @file{chord-modifiers.ly}. The available modifiers are @code{m} and
1993 @code{min} which lower the 3rd half a step, `@code{aug}' which
1994 raises the 5th, `@code{dim}' which lowers the 5th,
1995 `@code{maj}' which adds a raised 7th, and `@code{sus}'
1996 which replaces the 5th with a 4th.
2000 @lilypond[fragment,verbatim]
2003 c1:m c:min7 c:maj c:aug c:dim c:sus
2011 Chord subtractions are used to eliminate notes from a chord. The
2012 notes to be subtracted are listed after a @code{^} character,
2015 @lilypond[fragment,verbatim,center]
2024 Chord inversions can be specified by appending `@code{/}' and
2025 the name of a single note to a chord. This has the effect of
2026 lowering the specified note by an octave so it becomes the lowest
2027 note in the chord. If the specified note is not in the chord, a
2028 warning will be printed.
2030 @lilypond[fragment,verbatim,center]
2040 Bass notes can be added by `@code{/+}' and
2041 the name of a single note to a chord. This has the effect of
2042 adding the specified note to the chord, lowered by an octave,
2043 so it becomes the lowest note in the chord.
2045 @lilypond[fragment,verbatim,center]
2054 The most interesting application is printing chord names, which is
2055 explained in the next subsection.
2057 You should not combine @code{\relative} with named chords. [FIXME]
2059 @c . {Printing named chords}
2060 @node Printing named chords
2061 @subsection Printing named chords
2067 @cindex printing chord names
2070 @cindex @code{ChordNames}
2071 @cindex @code{ChordNameVoice}
2073 For displaying printed chord names, use the @code{ChordNames} and
2074 @code{ChordNameVoice} contexts. The chords may be entered either using
2075 the notation described above, or directly using simultaneous music.
2078 @lilypond[verbatim,singleline]
2080 \chords {a1 b c} <d f g> <e g b>
2084 \context ChordNamesVoice \scheme
2085 \context Staff \transpose c'' \scheme
2091 You can make the chord changes stand out more by setting property
2092 @code{ChordNames.chordChanges} to true. This will only display chord
2093 names when there's a change in the chords scheme, but always display the
2094 chord name after a line break:
2100 c1:m \break c:m c:m c:m d
2105 \context ChordNames \scheme
2106 \context Staff \transpose c'' \scheme
2109 linewidth = 40 * \staffspace;
2121 LilyPond examines chords specified as lists of notes to determine a
2122 name to give the chord. LilyPond will not try to
2123 identify chord inversions or added base, which may result in strange
2124 chord names when chords are entered as a list of pitches:
2127 @lilypond[verbatim,center,singleline]
2136 \context ChordNamesVoice \scheme
2137 \context Staff \scheme
2143 To specify chord inversions, append @code{/<notename>}. To specify an
2144 added bass note, append @code{/+<notename}:
2147 @lilypond[verbatim,center,singleline]
2154 \context ChordNames \scheme
2155 \context Staff \transpose c'' \scheme
2161 The chord names that LilyPond should print are fully customizable. The
2162 code to print chord names is written in Scheme. It can be found in
2163 @file{scm/chord-name.scm}. Chord names are based on Banter style
2164 naming, which is unambiguous and has a logical structure. Typical
2165 American style chord names are implemented as a variation on Banter
2166 names, they can be selected by setting property @code{ChordName.style}
2171 \include "english.ly"
2176 df:m5- % Diminished triad
2177 c:5^3 % Root-fifth chord
2178 c:4^3 % Suspended fourth triad
2179 c:5+ % Augmented triad
2181 c:m5-.7- % Diminished seventh
2182 c:7+ % Major seventh
2183 c:7.4^3 % Dominant seventh suspended fourth
2184 c:5+.7 % Augmented dominant seventh
2185 c:m5-.7 % "Half" diminished seventh
2186 c:5-.7 % Dominant seventh flat fifth
2187 c:5-.7+ % Major seventh flat fifth
2188 c:m7+ % Minor-major seventh
2189 c:m7 % Minor seventh
2190 c:7 % Dominant seventh
2193 c:9^7 % Major triad w/added ninth
2194 c:6.9^7 % Six/Nine chord
2195 c:9 % Dominant ninth
2196 c:7+.9 % Major ninth
2197 c:m7.9 % Minor ninth
2202 \context ChordNames \scheme
2203 \context Staff \transpose c'' \scheme
2208 ChordName \override #'word-space = #1
2209 ChordName \override #'style = #'american
2216 Similarly, Jazz style chord names are implemented as a variation on
2217 American style names:
2223 c:6 % 6 = major triad with added sixth
2224 c:maj % triangle = maj
2229 c:m % m = minor triad
2230 c:m.6 % m6 = minor triad with added sixth
2231 c:m.7+ % m triangle = minor major seventh chord
2239 c:7.5+ % +7 = augmented dominant
2240 c:7.5- % 7b5 = hard diminished dominant
2247 c:13.9-^11 % 7(b9,13)
2248 c:13.9+^11 % 7(#9,13)
2250 c:13-.9-^11 % 7(b9,b13)
2251 c:13-.9+^11 % 7(#9,b13)
2253 % half diminished chords
2254 c:m5-.7 % slashed o = m7b5
2255 c:9.3-.5- % o/7(pure 9)
2258 c:m5-.7- % o = diminished seventh chord
2263 \context ChordNames \scheme
2264 \context Staff \transpose c'' \scheme
2269 ChordName \override #'word-space = #1
2270 ChordName \override #'style = #'jazz
2278 @section Writing parts
2283 * Instrument names::
2285 * Sound output for transposing instruments::
2286 * Multi measure rests::
2287 * Automatic part combining::
2290 @c . {Rehearsal marks}
2291 @node Rehearsal marks
2292 @subsection Rehearsal marks
2293 @cindex Rehearsal marks
2295 @cindex @code{\mark}
2296 @cindex @code{Mark_engraver}
2299 \mark @var{unsigned};
2304 With this command, you can print a rehearsal mark above the system. You
2305 can provide a number, a string or a markup text as argument. If there is
2306 no argument, the property @code{rehearsalMark} is used and automatically
2309 @lilypond[fragment,verbatim]
2315 c1 \mark #'(music "scripts-segno") ;
2320 @node Instrument names
2321 @subsection Instrument names
2323 You can specify an instrument name for a staff by setting
2324 @code{Staff.instrument} and @code{Staff.instr}. This will print a string
2325 before the start of the staff. For the first start, @code{instrument} is
2326 used, for the next ones @code{instr} is used.
2328 @lilypond[verbatim,singleline]
2330 \property Staff.instrument = "instr " { c''4 } }
2332 \translator { \StaffContext
2333 \consists "Instrument_name_engraver"; } } }
2336 This requires that you add the @code{Instrument_name_engraver} to the
2341 @subsection Transpose
2343 @cindex transposition of pitches
2344 @cindex @code{\transpose}
2346 A music expression can be transposed with @code{\transpose}. The syntax
2349 \transpose @var{pitch} @var{musicexpr}
2352 This means that middle C in @var{musicexpr} is transposed to
2355 @code{\transpose} distinguishes between enharmonic pitches: both
2356 @code{\transpose cis'} or @code{\transpose des'} will transpose up half
2357 a tone. The first version will print sharps and the second version
2361 @lilypond[fragment,verbatim]
2364 { \key e \major; c d e f }
2366 \transpose des'' { \key e \major; c d e f }
2367 \transpose cis'' { \key e \major; c d e f }
2373 If you want to use both @code{\transpose} and @code{\relative}, then
2374 you must use @code{\transpose} first. @code{\relative} will have no
2375 effect music that appears inside a @code{\transpose}.
2377 @node Sound output for transposing instruments
2378 @subsection Sound output transposing instruments
2380 When you want to play a score containing transposed and untransposed
2381 instruments, you have to instruct LilyPond the pitch offset (in
2382 semitones) for the transposed instruments. This is done using
2385 @cindex @code{transposing}
2388 \property Staff.instrument = #"Cl. in B-flat"
2389 \property Staff.transposing = #-2
2393 @c . {Multi measure rests}
2394 @node Multi measure rests
2395 @subsection Multi measure rests
2396 @cindex Multi measure rests
2400 Multi measure rests are entered using `@code{R}'. It is specifically
2401 meant for entering parts: the rest can expand to fill a score with
2402 rests, or it can be printed as a single multimeasure rest This expansion
2403 is controlled by the property @code{Score.skipBars}. If this is set to true,
2404 Lily will not expand empty measures, and the appropriate number is added
2407 @lilypond[fragment,verbatim]
2408 \time 3/4; R2.*2 \property Score.skipBars = ##t R2.*17 R2.*4
2411 Currently, there is no way to condense multiple rests into a single
2414 @cindex condensing rests
2416 @node Automatic part combining
2417 @subsection Automatic part combining
2428 A @emph{custos} (plural: @emph{custodes}; latin word for "guard") is a
2429 staff context symbol that appears at the end of a staff line. It
2430 anticipates the pitch of the first note(s) of the following line and
2431 thus helps the player or singer to manage line breaks during
2432 performance, thus enhancing readability of a score.
2437 \notes { c'1 d' e' d' \break c' d' e' d' }
2441 \consists Custos_engraver;
2442 Custos \override #'style = #'mensural;
2449 Custodes were frequently used in music notation until the 16th century.
2450 There were different appearences for different notation styles.
2451 Nowadays, they have survived only in special forms of musical notation
2452 such as via the editio vaticana dating back to the beginning of the 20th
2455 For typesetting custodes, just put a @code{Custos_engraver} into the
2456 @code{StaffContext} when declaring the @code{\paper} block. In this
2457 block, you can also globally control the appearance of the custos symbol
2458 by setting the custos @code{style} property. Currently supported styles
2459 are @code{vaticana}, @code{medicaea}, @code{hufnagel} and
2466 \consists Custos_engraver;
2467 Custos \override #'style = #'mensural;
2472 The property can also be set locally, for example in a @code{\notes}
2477 \property Staff.Custos \override #'style = #'vaticana
2478 c'1 d' e' d' \break c' d' e' d'
2482 @c . {Tuning output}
2484 @section Tuning output
2486 LilyPond tries to take as much formatting as possible out of your
2487 hands. Nevertheless, there are situations where it needs some help, or
2488 where you want to override its decisions.
2490 Here we discuss how you can do that.
2492 Notational output is specified in so called grobs (graphic
2493 objects). Each grob carries with it a set of properties (grob
2494 properties) specific to that grob. For example, a stem grob has grob
2495 properties that specify its direction, length and thickness.
2497 The most common way of tuning the output is to alter the values of these
2498 properties. There are two ways of doing that: first, you can
2499 specifically select a set of grobs at one point, and set properties as
2500 you wish, or secondly, you can (temporarily) modify the definition of a
2501 grob, thereby affecting an entire group of grobs.
2504 * Tuning groups of grobs ::
2505 * Tuning per grob ::
2510 @node Tuning groups of grobs
2511 @subsection Tuning groups of grobs
2513 @cindex grob description
2515 A grob definition is an association list, that is stored in a context
2516 property. By assigning to that property (using plain @code{\property}),
2517 you can change the resulting grobs.
2518 @lilypond[verbatim, fragment]
2519 c'4 \property Voice.Stem = #'((meta . ((interfaces . ())))) c'4
2521 The @code{\property} statement effectively empties the definition of the
2522 Stem object. One of the effects is that property specifying how it
2523 should be printed is erased, with the effect of rendering it invisible.
2530 This mechanism is fairly crude, since you can only set, but not modify,
2531 the definition of a grob. For this reason, there is a more advanced
2532 mechanism: you can add a property on top of an existing definition, or
2533 remove a property: @code{\override} adds a settings, @code{\revert}
2534 removes that setting.
2536 c'4 \property Voice.Stem \override #'thickness = #4.0
2537 c'4 \property Voice.Stem \revert #'thickness
2541 For the digirati, the grob description is an Scheme association
2542 list. Since it is singly linked, we can treat it as a stack, and
2543 @code{\override} and @code{\revert} are just push and pop
2544 operations. This pushing and popping is also used in the
2545 @code{autoBeamSettings} property.
2547 If you revert a setting which was not set in the first place, then it
2548 has no effect. However, if the setting was set as a system default, it
2549 may remove the default value, and this may give surprising results,
2550 including crashes. In other words, if you use @code{\override} and
2551 @code{\revert}, be sure to balance the overrides and reverts.
2553 If balancing them is too much work, use the following shorthand:
2554 @code{\set} performs a revert followed by an override:
2556 \property Voice.Stem \set #'thickness = #2.0
2559 Formally the syntax for these constructions is
2561 \property @var{context}.@var{grobname} \override @var{symbol} = @var{value}
2562 \property @var{context}.@var{grobname} \set @var{symbol} = @var{value}
2563 \property @var{context}.@var{grobname} \revert @var{symbol}
2565 Here @var{symbol} is a Scheme expression of symbol type, @var{context}
2566 and @var{grobname} are strings and @var{value} is a Scheme expression.
2568 LilyPond will hang or crash if @var{value} contains cyclic references.
2572 @node Tuning per grob
2573 @subsection Tuning per grob
2575 @cindex \outputproperty
2577 A second way of tuning grobs is the more arcane @code{\outputproperty}
2579 Syntax is as follows
2581 \outputproperty @var{predicate} @var{symbol} = @var{value}
2583 Here @code{predicate} is a Scheme functoin taking a grob a argument
2584 argument, and returning a boolean. This statement is processed by the
2585 @code{Output_property_engraver}. It instructs the engraver to feed all
2586 grobs that it sees to @var{predicate}. Whenever the predicate returns
2587 true, the grob property @var{symbol} will be set to @var{value}.
2589 You will need to combine this statement with @code{\context} to select
2590 the appropriate context to apply this to.
2592 If possible, avoid this feature: the semantics are not very clean, and
2593 the syntax and semantics are up for rewrite.
2595 Here are some random examples:
2597 @lilypond[fragment,verbatim,singleline]
2599 \context Staff \outputproperty
2600 #(make-type-checker 'note-head-interface)
2601 #'extra-offset = #'(0.5 . 0.75)
2605 @cindex @code{extra-offset}
2607 This selects all note heads occurring at current staff level, and sets
2608 the @code{extra-offset} of those heads to @code{(0.5,0.75)}, shifting
2611 Move the text "m.d.", but not the fingering instruction "2".
2612 @lilypond[verbatim,singleline]
2613 #(define (make-text-checker text)
2614 (lambda (grob) (equal? text (ly-get-elt-property grob 'text))))
2617 \notes\relative c''' {
2618 \property Voice.Stem \set #'direction = #1
2619 \outputproperty #(make-text-checker "m.d.")
2620 #'extra-offset = #'(-3.5 . -4.5)
2630 @subsection What to tune?
2632 This all tells you how to tune grobs, but what variables are there? The
2633 question is not answered in this manual (although you may encounter
2636 Grob properties are tied directly to the implementation of LilyPond, and
2637 they are thus a moving target. Refer to the automatically generated
2638 documentation of the internals (available from the website).
2640 You need the following information
2644 which grob to modify
2646 which property to modify
2648 which context the grob comes from.
2651 Included with the automatically generated documentation is a master list
2652 of grobs. Each one can be clicked, taking you to a overview of the
2653 available properties.
2655 There is also a master list of contexts. Clicking each takes you to an
2656 overview of the context, listing which grob types are created there.
2661 @subsection Text markup
2665 LilyPond has an internal mechanism to typeset texts. You can
2666 form text markup expressions by composing scheme expressions
2667 in the following way.
2670 \score { \notes \relative c' {
2673 d-#'(lines "one" (bold "text"))
2674 e-#'(music (named "noteheads-2" "flags-u3"))
2676 \paper { linewidth = 10.\cm; } }
2679 Normally, the Scheme markup text is stored in the @code{text} property
2680 of a grob. Formally, it is defined as follows:
2683 text: string | (head? text+)
2684 head: markup | (markup+)
2685 markup-item: property | abbrev | @var{fontstyle}
2686 property: (@var{key} . @var{value})
2687 abbrev: @code{rows lines roman music bold italic named super sub text}
2690 The markup is broken down and converted into a list of grob properties,
2691 which are prepended to the grop's property list. The
2692 @var{key}-@var{value} pair is a grob property.
2694 The following abbreviations are currently
2699 horizontal mode: set all text on one line (default)
2701 vertical mode: set every text on new line
2711 lookup by character name
2713 plain text lookup (by character value)
2720 @var{fontstyle} may be any of @code{finger volta timesig mmrest mark
2721 script large Large dynamic}
2726 @section Page layout
2740 @subsection Paper block
2743 The most important output definition is the @code{\paper} block, for
2744 music notation. The syntax is
2747 @code{\paper @{} [@var{paperidentifier}] @var{items} @code{@}}
2750 where each of the items is one of
2753 @item An assignment. The assignment must be terminated by a
2756 @item A context definition. See Section @ref{Notation contexts} for
2757 more information on context definitions.
2759 @item \stylesheet declaration. Its syntax is
2761 \stylesheet @var{alist}
2764 See @file{font.scm} for details of @var{alist}.
2767 @c . {Paper variables}
2768 @node Paper variables
2769 @subsection Paper variables
2770 @cindex Paper variables
2772 The paper block has some variables you may want to use or change:
2775 @cindex @code{indent}
2777 The indentation of the first line of music.
2778 @cindex @code{staffspace}
2780 @item @code{staffspace}
2781 The distance between two staff lines, calculated from the center
2782 of the lines. You should use either this or @code{stafflinethickness}
2783 as a unit for distances you modify.
2785 @cindex @code{linewidth}
2786 @item @code{linewidth}
2787 Sets the width of the lines.
2789 If set to a negative value, a single
2790 unjustified line is produced.
2792 @cindex @code{textheight}
2794 @item @code{textheight}
2795 Sets the total height of the music on each page. Only used by
2797 @cindex @code{interscoreline}
2799 @item @code{interscoreline}
2800 Sets the spacing between the score lines. Defaults to 16 pt.
2801 @cindex @code{interscorelinefill}
2803 @item @code{interscorelinefill}
2804 If set to a positive number, the distance between the score
2805 lines will stretch in order to fill the full page. In that
2806 case @code{interscoreline} specifies the minimum spacing.
2808 @cindex @code{stafflinethickness}
2810 @item @code{stafflinethickness}
2811 Determines the thickness of staff lines, and also acts as a scaling
2812 parameter for other line thicknesses.
2819 @subsection Font size
2822 The Feta font provides musical symbols at six different sizes. These
2823 fonts are 11 point, 13 point, 16 point, 20 point,
2824 23 point, and 26 point. The point size of a font is the
2825 height of the five lines in a staff when displayed in the font.
2827 Definitions for these sizes are the files @file{paperSZ.ly}, where
2828 @code{SZ} is one of 11, 13, 16, 20, 23 and 26. If you include any of
2829 these files, the identifiers @code{paperEleven}, @code{paperThirteen},
2830 @code{paperSixteen}, @code{paperTwenty}, @code{paperTwentythree}, and
2831 @code{paperTwentysix} are defined respectively. The default
2832 @code{\paper} block is also set.
2834 The font definitions are generated using a Scheme function. For more
2835 details, see the file @file{font.scm}.
2841 @subsection Paper size
2846 @cindex @code{papersize}
2848 To change the paper size, you must first set the
2849 @code{papersize} variable at top level. Set it to
2850 the strings @code{a4}, @code{letter}, or @code{legal}. After this
2851 specification, you must set the font as described above. If you want
2852 the default font, then use the 20 point font. The new paper size will
2853 not take effect if the font is not loaded and selected afterwards.
2857 \include "paper16.ly"
2861 \paper @{ \paperSixteen @}
2865 The file "paper16.ly" will now include a file named @file{a4.ly}, which
2866 will set the paper variables @code{hsize} and @code{vsize} (used by
2877 @subsection Line break
2880 @cindex breaking lines
2882 Line breaks are normally computed automatically. They are chosen such
2883 that the resulting spacing has low variation, and looks neither cramped
2886 Occasionally you might want to override the automatic breaks; you can do
2887 this by specifying @code{\break}. This will force a line break at this
2888 point. Do remember that line breaks can only occur at places where there
2889 are barlines. If you want to have a line break where there is no
2890 barline, you can force a barline by entering @code{\bar "";}.
2892 Similarly, @code{\noBreak} forbids a line break at a certain point.
2894 @cindex @code{\penalty}
2896 The @code{\break} and @code{\noBreak} commands are defined in terms of
2897 the penalty command:
2899 \penalty @var{int} @code{;}
2902 This imposes encourages or discourages LilyPond to make a line break
2905 @strong{Warning} do not use @code{\penalty} directly. It is rather
2906 kludgy, and slated for rewriting.
2910 @subsection Page break
2913 @cindex breaking pages
2916 Page breaks are normally computed by @TeX{}, so they are not under direct
2917 control. However, you can insert a commands into the @file{.tex} output to
2918 instruct @TeX{} where to break pages. For more details, see the
2919 example file @file{input/test/between-systems.ly}
2933 LilyPond allows MIDI output, with the purpose of proof-hearing the music
2934 you enter. The performance lacks lots of interesting effects, such as
2935 swing, articulation, slurring, tieing, etc.
2937 Also note that it is not possible to use the percussion channel
2938 (generally channel 10 of a MIDI file).
2942 * MIDI instrument names::
2948 @subsection MIDI block
2952 The MIDI block is analogous to the paper block, but it is somewhat
2953 simpler. The @code{\midi} block can contain:
2957 @item a @code{\tempo} definition
2958 @item context definitions
2961 Assignments in the @code{\midi} block are not allowed.
2965 @cindex context definition
2967 Context definitions follow precisely the same syntax as within the
2968 \paper block. Translation modules for sound are called performers.
2969 The contexts for MIDI output are defined in @file{ly/performer.ly}.
2972 @c . {MIDI instrument names}
2973 @node MIDI instrument names
2974 @subsection MIDI instrument names
2975 @cindex instrument names
2976 @cindex @code{Staff.midiInstrument}
2977 @cindex @code{Staff.instrument}
2979 The MIDI instrument name is set by the @code{Staff.midiInstrument}
2980 property or, if that property is not set, the @code{Staff.instrument}
2981 property. The instrument name should be chosen from the following list.
2982 If the selected string does not exactly match, then LilyPond uses the
2985 [FIXME: to appendix ]
2989 "acoustic grand" "contrabass" "lead 7 (fifths)"
2990 "bright acoustic" "tremolo strings" "lead 8 (bass+lead)"
2991 "electric grand" "pizzicato strings" "pad 1 (new age)"
2992 "honky-tonk" "orchestral strings" "pad 2 (warm)"
2993 "electric piano 1" "timpani" "pad 3 (polysynth)"
2994 "electric piano 2" "string ensemble 1" "pad 4 (choir)"
2995 "harpsichord" "string ensemble 2" "pad 5 (bowed)"
2996 "clav" "synthstrings 1" "pad 6 (metallic)"
2997 "celesta" "synthstrings 2" "pad 7 (halo)"
2998 "glockenspiel" "choir aahs" "pad 8 (sweep)"
2999 "music box" "voice oohs" "fx 1 (rain)"
3000 "vibraphone" "synth voice" "fx 2 (soundtrack)"
3001 "marimba" "orchestra hit" "fx 3 (crystal)"
3002 "xylophone" "trumpet" "fx 4 (atmosphere)"
3003 "tubular bells" "trombone" "fx 5 (brightness)"
3004 "dulcimer" "tuba" "fx 6 (goblins)"
3005 "drawbar organ" "muted trumpet" "fx 7 (echoes)"
3006 "percussive organ" "french horn" "fx 8 (sci-fi)"
3007 "rock organ" "brass section" "sitar"
3008 "church organ" "synthbrass 1" "banjo"
3009 "reed organ" "synthbrass 2" "shamisen"
3010 "accordion" "soprano sax" "koto"
3011 "harmonica" "alto sax" "kalimba"
3012 "concertina" "tenor sax" "bagpipe"
3013 "acoustic guitar (nylon)" "baritone sax" "fiddle"
3014 "acoustic guitar (steel)" "oboe" "shanai"
3015 "electric guitar (jazz)" "english horn" "tinkle bell"
3016 "electric guitar (clean)" "bassoon" "agogo"
3017 "electric guitar (muted)" "clarinet" "steel drums"
3018 "overdriven guitar" "piccolo" "woodblock"
3019 "distorted guitar" "flute" "taiko drum"
3020 "guitar harmonics" "recorder" "melodic tom"
3021 "acoustic bass" "pan flute" "synth drum"
3022 "electric bass (finger)" "blown bottle" "reverse cymbal"
3023 "electric bass (pick)" "skakuhachi" "guitar fret noise"
3024 "fretless bass" "whistle" "breath noise"
3025 "slap bass 1" "ocarina" "seashore"
3026 "slap bass 2" "lead 1 (square)" "bird tweet"
3027 "synth bass 1" "lead 2 (sawtooth)" "telephone ring"
3028 "synth bass 2" "lead 3 (calliope)" "helicopter"
3029 "violin" "lead 4 (chiff)" "applause"
3030 "viola" "lead 5 (charang)" "gunshot"
3031 "cello" "lead 6 (voice)"
3042 @cindex beats per minute
3043 @cindex metronome marking
3045 @cindex @code{\tempo}
3047 \tempo @var{duration} = @var{perminute} @code{;}
3050 Used to specify the tempo. For example, @code{\tempo 4 = 76;} requests
3051 output with 76 quarter notes per minute.
3059 @section Music entry
3070 @subsection Relative
3072 @cindex relative octave specification
3074 Octaves are specified by adding @code{'} and @code{,} to pitch names.
3075 When you copy existing music, it is easy to accidentally put a pitch in
3076 the wrong octave and hard to find such an error. To prevent these
3077 errors, LilyPond features octave entry.
3079 @cindex @code{\relative}
3081 \relative @var{startpitch} @var{musicexpr}
3084 The octave of notes that appear in @var{musicexpr} are calculated as
3085 follows: If no octave changing marks are used, the basic interval
3086 between this and the last note is always taken to be a fourth or less.
3087 The octave changing marks @code{'} and @code{,} can then
3088 be added to raise or lower the pitch by an extra octave. Upon entering
3089 relative mode, an absolute starting pitch must be specified that will
3090 act as the predecessor of the first note of @var{musicexpr}.
3092 This distance is determined without regarding accidentals: a
3093 @code{fisis} following a @code{ceses} will be put above the
3096 Entering scales is straightforward in relative mode.
3098 @lilypond[fragment,verbatim,center]
3100 g a b c d e f g g, g
3104 And octave changing marks are used for intervals greater than a fourth.
3106 @lilypond[fragment,verbatim,center]
3108 c g c f, c' a, e'' }
3111 If the preceding item is a chord, the first note of the chord is used
3112 to determine the first note of the next chord. But other notes
3113 within the second chord are determined by looking at the immediately
3116 @lilypond[fragment,verbatim,center]
3123 @cindex @code{\notes}
3125 The pitch after the @code{\relative} contains a notename. To parse
3126 the pitch as a notename, you have to be in note mode, so there must
3127 be a surrounding @code{\notes} keyword (which is not
3130 The relative conversion will not affect @code{\transpose} or
3131 @code{\relative} sections in its argument. If you want to use
3132 relative within transposed music, you must place an additional
3133 @code{\relative} inside the @code{\transpose}.
3136 @c . {Point and click}
3137 @node Point and click
3138 @subsection Point and click
3147 * Notation Contexts::
3148 * Creating contexts::
3149 * Default contexts::
3150 * Context properties::
3151 * Changing context definitions::
3152 * Defining new contexts::
3155 @c . {Music expressions}
3159 @c . {Notation Contexts}
3160 @node Notation Contexts
3161 @subsection Notation Contexts
3163 @cindex notation contexts
3165 Notation contexts are objects that only exist during a run of LilyPond.
3166 During the interpretation phase of LilyPond (when lily prints
3167 "interpreting music"), music a @code{\score} block is interpreted in
3168 time order, i.e. in much the same order that humans read, play, and
3171 During this reading, the notation context is holds the state
3172 for the current point within the music. It contains information like
3175 @item What notes are playing at this point?
3176 @item What symbols will be printed at this point?
3177 @item What is the current key signature, time signature, point within
3181 Contexts are grouped hierarchically: A @code{Voice} context is
3182 contained in a @code{Staff} context (because a staff can contain
3183 multiple voices at any point), a @code{Staff} context is contained in
3184 a @code{Score}, @code{StaffGroup}, or @code{ChoirStaff} context (because
3185 these can all contain multiple staffs).
3188 Contexts associated with sheet music output are called @emph{notation
3189 contexts}, those for sound output are called performance contexts.
3192 @node Creating contexts
3193 @subsection Creating contexts
3195 @cindex @code{\context}
3196 @cindex context selection
3198 Contexts for a music expression can be selected manually, using the
3199 following music expression.
3202 \context @var{contexttype} [= @var{contextname}] @var{musicexpr}
3205 This instructs lilypond to interpret @var{musicexpr} within the context
3206 of type @var{contexttype} and with name @var{contextname}. If this
3207 context does not exist, it will be created.
3211 @lilypond[verbatim,singleline]
3213 \notes \relative c'' {
3214 c4 <d4 \context Staff = "another" e4> f
3221 In this example, the @code{c} and @code{d} are printed on the
3222 default staff. For the @code{e}, a context Staff called
3223 @code{another} is specified; since that does not exist, a new
3224 context is created. Within @code{another}, a (default) Voice context
3225 is created for the @code{e4}. When all music referring to a
3226 context is finished, the context is ended as well. So after the
3227 third quarter, @code{another} is removed.
3231 @node Default contexts
3232 @subsection Default contexts
3234 Most music expressions don't need @code{\context}: they inherit the
3235 notation context from their parent. Each note is a music expression, and
3236 as you can see in the following example, only the sequential music
3237 enclosing the three notes has an explicit context.
3239 @lilypond[verbatim,singleline]
3240 \score { \notes \context Voice = goUp { c'4 d' e' } }
3243 There are some quirks that you must keep in mind when dealing with
3246 Every top-level music is interpreted by the Score context, in other
3247 words, you may think of @code{\score} working like
3250 \context Score @var{music}
3254 Sequential music follows the contexts of its "children". Take this example
3255 @lilypond[verbatim, singleline]
3256 \score { \context Score \notes { c'4 ( d' )e' } }
3259 The sequential music is interpreted by the Score context initially
3260 (notice that the @code{\context} specification is redundant), but when a
3261 note is encountered, contexts are setup to accept that note. In this
3262 case, a Thread, Voice and Staff are created. The rest of the sequential
3263 music is also interpreted with the same Thread, Voice and Staff context,
3264 putting the notes on the same staff, in the same voice.
3266 This is a convenient mechanism, but do not expect opening chords to work
3267 without @code{\context}. For every note, a separate staff is
3270 @lilypond[verbatim, singleline]
3271 \score { \notes <c'4 es'> }
3274 Of course, if the chord is preceded by a normal note in sequential
3275 music, the chord will be interpreted by the Thread of the preceding
3277 @lilypond[verbatim,singleline]
3278 \score { \notes { c'4 <c'4 es'> } }
3283 @node Context properties
3284 @subsection Context properties
3286 Notation contexts can be modified from within the @file{.ly} file. The
3287 following music expression does that job:
3289 @cindex @code{\property}
3291 \property @var{contextname}.@var{propname} = @var{value}
3294 Sets the @var{propname} property of the context @var{contextname} to the
3295 specified Scheme expression @var{value}. All @var{propname} and
3296 @var{contextname} are strings, which are typically unquoted.
3298 Properties that are set in one context are inherited by all of the
3299 contained contexts. This means that a property valid for the
3300 @code{Voice} context can be set in the @code{Score} context (for
3301 example) and thus take effect in all @code{Voice} contexts.
3306 @c . {Context definitions}
3307 @node Changing context definitions
3308 @subsection Changing context definitions
3310 @cindex context definition
3311 @cindex translator definition
3313 The most common way to define a context is by extending an existing
3314 context. You can change an existing context from the paper block, by
3315 first initializing a translator with an existing context identifier:
3319 @var{context-identifier}
3322 Then you can add engravers, remove engravers and set context
3323 properties. The syntax for these operations are respectively
3325 \remove @var{engravername}
3326 \consists @var{engravername}
3327 @var{propname} = @var{value}
3330 Here @var{engravername} is a string, the name of an engraver in the
3331 system. @var{propname} is a string and @var{value} is a Scheme
3334 @lilypond[verbatim,singleline]
3338 \translator { \StaffContext
3339 \consists Instrument_name_engraver;
3341 \remove Clef_engraver;
3347 These type of property assignments happen before interpretation starts,
3348 so a @code{\property} expression will override any predefined settings.
3350 Engravers are the actual C++ modules that do the work in the
3351 interpretation phase.
3354 There are some pre-defined identifiers to simplify editing translators,
3355 they are defined in @file{ly/engraver.ly}. These pre-defined
3359 @cindex @code{StaffContext}
3360 @item @code{StaffContext}
3361 Default Staff context.
3362 @cindex @code{RhythmicStaffContext}
3364 @item @code{RhythmicStaffContext}
3365 Default RhythmicStaff context.
3366 @cindex @code{VoiceContext}
3368 @item @code{VoiceContext}
3369 Default Voice context.
3370 @cindex @code{ScoreContext}
3372 @item @code{ScoreContext}
3373 Default Score context.
3375 @cindex @code{HaraKiriStaffContext}
3377 @item @code{HaraKiriStaffContext}
3378 Staff context that does not print if it only contains rests.
3379 Useful for orchestral scores.@footnote{Harakiri, also called
3380 Seppuku, is the ritual suicide of the Japanese Samourai warriors.}
3383 @node Defining new contexts
3384 @subsection Defining new contexts
3386 If you want to build a context from scratch, you must also supply the
3387 following extra information:
3389 @item A name, specified by @code{\name @var{contextname};}.
3391 @item A cooperation engraver. This is specified by @code{\type
3396 A context definition has this syntax:
3400 \translator @code{@{}
3401 @var{translatorinit} @var{translatormodifierlist}
3405 @var{translatorinit} can be an identifier or
3409 where @var{typename} is one of
3411 The cooperation engraver groups other engravers, and specifies how they
3412 should cooperate. Choices are:
3415 @cindex @code{Engraver_group_engraver}
3416 @item @code{Engraver_group_engraver}
3417 The standard cooperation engraver.
3419 @cindex @code{Score_engraver}
3421 @item @code{Score_engraver}
3422 This is cooperation module that should be in the top level context,
3423 and only the toplevel context.
3425 @cindex @code{Grace_engraver_group}
3427 @item @code{Grace_engraver_group}
3428 This is a special cooperation module (resembling
3429 @code{Score_engraver}) that is used to created an embedded
3433 @var{translatormodifierlist} is a list of items where each item is
3437 @item @code{\consists} @var{engravername} @code{;}
3438 Add @var{engravername} to the list of modules in this context.
3439 The order of engravers added with @code{\consists} is
3442 @item @code{\consistsend} @var{engravername} @code{;}
3443 Analogous to @code{\consists}, but makes sure that
3444 @var{engravername} is always added to the end of the list of
3447 Some engraver types need to be at the end of the list; this
3448 insures they are put there, and stay there, if a user adds or
3449 removes engravers. This command is usually not needed for
3452 @item @code{\accepts} @var{contextname} @code{;}
3453 Add @var{contextname} to the list of context this context can
3454 contain. The first listed context is the context to create by
3457 @item @code{\denies}. The opposite of @code{\accepts}. Added for
3458 completeness, but is never used in practice.
3461 @item @code{\remove} @var{engravername} @code{;}
3462 Remove a previously added (with @code{\consists}) engraver.
3464 @item @code{\name} @var{contextname} @code{;}
3465 This sets name of the context, e.g. @code{Staff}, @code{Voice}. If
3466 the name is not specified, the translator won't do anything.
3468 @item @var{propname} @code{=} @var{value} @code{;}
3469 A property assignment.
3472 In the @code{\paper} block, it is also possible to define translator
3473 identifiers. Like other block identifiers, the identifier can only
3474 be used as the very first item of a translator. In order to define
3475 such an identifier outside of @code{\score}, you must do
3481 foo = \translator @{ @dots{} @}
3488 \translator @{ \foo @dots{} @}
3496 @cindex paper types, engravers, and pre-defined translators
3501 Properties can be preset within the @code{\translator} block
3502 corresponding to the appropriate context. In this case, the syntax
3506 @var{propname} @code{=} @var{value}
3509 The property settings are used during the interpretation phase. They
3510 are read by the LilyPond modules where interpretation contexts are
3511 built of. These modules are called @emph{translators}. Translators for
3512 notation are called @emph{engravers}, and translators for sound are
3513 called @emph{performers}.
3518 @c . {Syntactic details}
3519 @node Syntactic details
3520 @section Syntactic details
3521 @cindex Syntactic details
3525 * Music expressions::
3526 * Manipulating music expressions::
3535 @subsection Top level
3538 This section describes what you may enter at top level.
3542 @subsubsection Score
3545 @cindex score definition
3547 The output is generated combining a music expression with an output
3548 definition. A score block has the following syntax:
3551 \score @{ @var{musicexpr} @var{outputdefs} @}
3554 @var{outputdefs} are zero or more output definitions. If no output
3555 definition is supplied, the default @code{\paper} block will be added.
3559 @c . {Default output}
3560 @subsubsection Default output
3562 Default values for the @code{\paper} and @code{\midi} block are set by
3563 entering such a block at top-level.
3566 @subsubsection Header
3568 @cindex @code{\header}
3573 \header @{ @var{key1} = @var{val1};
3574 @cindex @code{ly2dvi}
3575 @var{key2} = @var{val2}; @dots{} @}
3579 A header describes the file's contents. It can also appear in a
3580 @code{\score} block. Tools like @code{ly2dvi} can use this
3581 information for generating titles. Key values that are used by
3582 @code{ly2dvi} are: title, subtitle, composer, opus, poet, instrument,
3583 metre, arranger, piece and tagline.
3585 It is customary to put the @code{\header} at the top of the file.
3587 @subsubsection Default output
3589 A @code{\midi} or @code{\paper} block at top-level sets the default
3591 paper block for all scores that lack an explicit paper block.
3595 @subsection Identifiers
3598 All of the information in a LilyPond input file, is represented as a
3599 Scheme value. In addition to normal Scheme data types (such as pair,
3600 number, boolean, etc.), LilyPond has a number of specialized data types,
3607 @item Translator_def
3611 @item Music_output_def
3612 @item Moment (rational number)
3615 LilyPond also includes some transient object types. Objects of these
3616 types are built during a LilyPond run, and do not `exist' per se within
3617 your input file. These objects are created as a result of your input
3618 file, so you can include commands in the input to manipulate them,
3619 during a lilypond run.
3622 @item Grob: short for Graphical object. See @ref{Grobs}.
3623 @item Molecule: device-independent page output object,
3624 including dimensions. Produced by some Grob functions
3626 @item Translator: object that produces audio objects or Grobs. This is
3627 not yet user accessible.
3628 @item Font_metric: object representing a font. (See @ref{Font metrics})
3633 @node Music expressions
3634 @subsection Music expressions
3636 @cindex music expressions
3638 Music in LilyPond is entered as a music expression. Notes, rests, lyric
3639 syllables are music expressions, and you can combine music expressions
3640 to form new ones, for example by enclosing a list of expressions in
3641 @code{\sequential @{ @}} or @code{< >}. In this example, a compound
3642 expression is formed out of the quarter note @code{c} and a quarter note
3646 \sequential @{ c4 d4 @}
3649 @cindex Sequential music
3650 @cindex @code{\sequential}
3651 @cindex sequential music
3654 @cindex Simultaneous music
3655 @cindex @code{\simultaneous}
3657 The two basic compound music expressions are simultaneous and
3661 \sequential @code{@{} @var{musicexprlist} @code{@}}
3662 \simultaneous @code{@{} @var{musicexprlist} @code{@}}
3664 For both, there is a shorthand:
3666 @code{@{} @var{musicexprlist} @code{@}}
3670 @code{<} @var{musicexprlist} @code{>}
3672 for simultaneous music.
3673 Other compound music expressions include
3676 \transpose @var{pitch} @var{expr}
3677 \apply @var{func} @var{expr}
3678 \context @var{type} = @var{id} @var{expr}
3679 \times @var{fraction} @var{expr}
3682 In principle, the way in which you nest sequential and simultaneous to
3683 produce music is not relevant. In the following example, three chords
3684 are expressed in two different ways:
3686 @lilypond[fragment,verbatim,center]
3687 \notes \context Voice {
3688 <a c'> <b d' > <c' e'>
3689 < { a b c' } { c' d' e' } >
3693 However, in some cases, LilyPond will also try to choose contexts, and
3694 use the structure of the music expression to do so. This can have
3695 undesired effects: for example, LilyPond will create a separate staff
3696 for each note if you start a @code{\score} with a chord:
3697 @lilypond[verbatim,center,singleline]
3702 The solution is to explicitly instantiate the context you desire.
3703 In this case this is typically a Voice context
3704 @lilypond[verbatim,center,singleline]
3706 \notes\context Voice <c''4 e''>
3709 If you use @code{\context Staff} you will get separate stems for each
3710 note head, leading to collisions, so don't use that.
3714 @c . {Manipulating music expressions}
3715 @node Manipulating music expressions
3716 @subsection Manipulating music expressions
3718 The @code{\apply} mechanism gives you access to the internal
3719 representation of music. You can write Scheme-functions that operate
3720 directly on it. The syntax is
3722 \apply #@var{func} @var{music}
3724 This means that @var{func} is applied to @var{music}. The function
3725 @var{func} should return a music expression.
3727 This example replaces the text string of a script. It also shows a dump
3728 of the music it processes, which is useful if you want to know more
3729 about how music is stored.
3731 #(define (testfunc x)
3732 (if (equal? (ly-get-mus-property x 'text) "foo")
3733 (ly-set-mus-property x 'text "bar"))
3735 (ly-set-mus-property x 'elements
3736 (map testfunc (ly-get-mus-property x 'elements)))
3741 \apply #testfunc { c4_"foo" }
3745 For more information on what is possible, see the @ref{Tricks} and the
3746 automatically generated documentation.
3748 As always: directly accessing internal representations is dangerous: the
3749 implementation is subject to changes, so you should not use this if
3755 @subsection Assignments
3758 Identifiers allow objects to be assigned to names during the parse
3759 stage. To assign an identifier, you use @var{name}@code{=}@var{value}
3760 and to refer to an identifier, you preceed its name with a backslash:
3761 `@code{\}@var{name}'. @var{value} is any valid Scheme value or any of
3762 the input-types listed above. Identifier assignments can appear at top
3763 level in the LilyPond file, but also in @code{\paper} blocks.
3765 Semicolons are forbidden after top level assignments, but mandatory in
3766 other places. The rules about semicolons and assignments are very
3767 confusing, but when LilyPond input evolves more towards Scheme, we hope
3768 that this problem will grow smaller.
3770 An identifier can be created with any string for its name, but you will
3771 only be able to refer to identifiers whose names begin with a letter,
3772 being entirely alphabetical. It is impossible to refer to an identifier
3773 whose name is the same as the name of a keyword.
3775 The right hand side of an identifier assignment is parsed completely
3776 before the assignment is done, so it is allowed to redefine an
3777 identifier in terms of its old value, e.g.
3783 When an identifier is referenced, the information it points to is
3784 copied. For this reason, an identifier reference must always be the
3785 first item in a block.
3789 \paperIdent % wrong and invalid
3793 \paperIdent % correct
3797 @c . {Lexical details}
3798 @node Lexical details
3799 @subsection Lexical details
3800 @cindex Lexical details
3805 @subsubsection Comments
3811 A one line comment is introduced by a @code{%} character.
3812 Block comments are started by @code{%@{} and ended by @code{%@}}.
3813 They cannot be nested.
3815 @c . {Direct Scheme}
3816 @subsubsection Direct Scheme
3819 @cindex Scheme, in-line code
3822 LilyPond contains a Scheme interpreter (the GUILE library) for
3823 internal use. In some places Scheme expressions also form valid syntax:
3824 whereever it is allowed,
3828 evaluates the specified Scheme code. If this is used at toplevel, then
3829 the result is discarded. Example:
3831 \property Staff.TestObject \override #'foobar = #(+ 1 2)
3834 @code{\override} expects two Scheme expressions, so there are two Scheme
3835 expressions. The first one is a symbol (@code{foobar}), the second one
3836 an integer (namely, 3).
3838 Scheme is a full-blown programming language, and a full discussion is
3839 outside the scope of this document. Interested readers are referred to
3840 the website @uref{http://www.schemers.org/} for more information on
3845 @subsubsection Keywords
3849 Keywords start with a backslash, followed by a number of lower case
3850 alphabetic characters. These are all the keywords.
3853 apply arpeggio autochange spanrequest commandspanrequest
3854 simultaneous sequential accepts alternative bar breathe
3855 char chordmodifiers chords clef cm consists consistsend
3856 context denies duration dynamicscript elementdescriptions
3857 font grace header in lyrics key mark pitch
3858 time times midi mm name pitchnames notes outputproperty
3859 override set revert partial paper penalty property pt
3860 relative remove repeat addlyrics partcombine score
3861 script stylesheet skip textscript tempo translator
3866 @subsubsection Integers
3874 Formed from an optional minus sign followed by digits. Arithmetic
3875 operations cannot be done with integers, and integers cannot be mixed
3879 @subsubsection Reals
3880 @cindex real numbers
3886 Formed from an optional minus sign and a sequence of digits followed
3887 by a @emph{required} decimal point and an optional exponent such as
3888 @code{-1.2e3}. Reals can be built up using the usual operations:
3889 `@code{+}', `@code{-}', `@code{*}', and
3890 `@code{/}', with parentheses for grouping.
3898 A real constant can be followed by one of the dimension keywords:
3899 @code{\mm} @code{\pt}, @code{\in}, or @code{\cm}, for millimeters,
3900 points, inches and centimeters, respectively. This converts the number
3901 to a real that is the internal representation of dimensions.
3905 @subsubsection Strings
3909 Begins and ends with the @code{"} character. To include a @code{"}
3910 character in a string write @code{\"}. Various other backslash
3911 sequences have special interpretations as in the C language. A string
3912 that contains no spaces can be written without the quotes. See
3913 @ref{Lexical modes} for details on unquoted strings; their
3914 interpretation varies depending on the situation. Strings can be
3915 concatenated with the @code{+} operator.
3917 The tokenizer accepts the following commands. They have no grammatical
3918 function, hence they can appear anywhere in the input.
3922 @subsubsection Main input
3925 @cindex @code{\maininput}
3927 The @code{\maininput} command is used in init files to signal that the
3928 user file must be read. This command cannot be used in a user file.
3930 @c . {File inclusion}
3931 @subsubsection Main input
3934 @subsubsection File inclusion
3935 @cindex @code{\include}
3937 \include @var{filename}
3940 Include @var{filename}. The argument @var{filename} may be a quoted string (an
3941 unquoted string will not work here!) or a string identifier. The full
3942 filename including the @file{.ly} extension must be given,
3944 @subsubsection Version information
3945 @cindex @code{\version}
3947 \version @var{string} ;
3950 Specify the version of LilyPond that a file was written for. The
3951 argument is a version string in quotes, for example @code{"1.2.0"}.
3952 This is used to detect invalid input, and to aid
3953 @code{convert-ly} a tool that automatically upgrades input files. See
3954 See @ref{convert-ly} for more information on @code{convert-ly}.
3960 @subsubsection Defining pitch names
3961 @cindex Lexical modes
3962 @cindex definining pitch names
3963 @cindex pitch names, definining
3965 @cindex chord modifier names
3967 A @code{\paper} block at top level sets the default paper block. A
3968 @code{\midi} block at top level works similarly.
3971 @subsubsection Assignments
3975 Identifier assignments may appear at top level. @ref{Assignments}
3979 @c . {Direct scheme}
3980 @subsubsection Direct scheme
3981 @cindex Direct scheme
3983 Scheme statements maybe issued to produce interesting side-effects.
3986 @c . {Lexical modes}
3988 @subsection Lexical modes
3989 @cindex Lexical modes
3992 @cindex @code{\notes}
3993 @cindex @code{\chords}
3994 @cindex @code{\lyrics}
3996 To simplify entering notes, lyrics, and chords, LilyPond has three
3997 special input modes on top of the default mode: note, lyrics and chords
3998 mode. These input modes change the way that normal, unquoted words are
3999 interpreted: for example, the word @code{cis} may be interpreted as a
4000 C-sharp, as a lyric syllable `cis' or as a C-sharp major triad
4003 A mode switch is entered as a compound music expressions
4005 @code{\notes} @var{musicexpr}
4006 @code{\chords} @var{musicexpr}
4007 @code{\lyrics} @var{musicexpr}.
4010 In each of these cases, these expressions do not add anything to the
4011 meaning of their arguments. They are just a way to indicate that the
4012 arguments should be parsed in indicated mode. The modes are treated in
4013 more detail in the sections @ref{Note entry}, @ref{Lyrics} and
4016 You may nest different input modes.
4020 @subsection Ambiguities
4025 The grammar contains a number of ambiguities. We hope to resolve them at
4029 @item The assignment
4035 can be interpreted as making a string identifier @code{\foo}
4036 containing @code{"bar"}, or a music identifier @code{\foo}
4037 containing the syllable `bar'.
4039 @item The assignment
4045 can be interpreted as making an integer identifier
4046 containing -6, or a Request identifier containing the
4047 fingering `6' (with neutral direction).
4049 @item If you do a nested repeat like
4061 then it is ambiguous to which @code{\repeat} the
4062 @code{\alternative} belongs. This is the classic if-then-else
4063 dilemma. It may be solved by using braces.
4065 @item (an as yet unidentified ambiguity :-)
4072 @c .{Local emacs vars}
4075 @c minor-mode: font-lock
4076 @c minor-mode: outline
4077 @c outline-layout: (-1 : 0)
4078 @c outline-use-mode-specific-leader: "@c \."
4079 @c outline-primary-bullet: "{"
4080 @c outline-stylish-prefixes: nil
4081 @c outline-override-protect: t