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. The last
26 revision of this document was for LilyPond 1.3.136.
56 The purpose of LilyPond is explained informally by the term `music
57 typesetter'. This is not a fully correct name: not only does the
58 program print musical symbols, it also makes esthetic decisions.
59 Symbols and their placements are @emph{generated} from a high-level
60 musical description. In other words, LilyPond would be best described
61 by `music compiler' or `music to notation compiler'.
63 LilyPond is linked to GUILE, GNU's Scheme library for extension. The
64 Scheme library provides the glue that holds together the low-level
65 routines and separate modules general, which are C++
67 When lilypond is run to typeset sheet music, the following happens:
69 @item GUILE Initialization: various scheme files are read
70 @item parsing: first standard @code{ly} initialization files are read, and
71 then the user @file{ly} file is read.
72 @item interpretation: the music in the file is processed ``in playing
73 order'', i.e. the order that you use to read sheet music, or the
74 order in which notes are played.
77 in this step, the results of the interpretation, a typesetting
78 specification, is solved.
80 @item the visible results ("virtual ink") is written to the output file.
83 During these stages different types of data play the the main role:
84 during parsing, @strong{Music} objects are created. During the
85 interpretation, @strong{context} is constructed, and with this context
86 af network of @strong{graphical objects} (``grobs'') is created. The
87 grobs contain unknown variables, and the network forms a set of
88 equations. After solving the equations and filling in these variables,
89 the printed output (in the form of @strong{molecules}) is written to an
92 These threemanship of tasks (parsing, translating, typesetting) and
93 data-structures (music, context, graphical objects) permeates the entire
94 design of the program. This manual is ordered in terms of user
95 tasks. With each concept will be explained to which of the three parts
104 The most basic forms of music are notes. We discuss how you enter them
105 here. Notes on their own don't form valid input, but for the sake of
106 brevity we omit obligotary lint such as @code{\score} blocks and
107 @code{\paper} declarations.
112 * Defining pitch names::
115 * Easy Notation note heads ::
127 @cindex Note specification
129 @cindex entering notes
131 The verbose syntax for pitch specification is
133 @cindex @code{\pitch}
135 \pitch @var{scmpitch}
138 @var{scmpitch} is a pitch scheme object, see @ref{Pitch data type}.
140 In Note and Chord mode, pitches may be designated by names. The default
141 names are the Dutch note names. The notes are specified by the letters
142 @code{a} through @code{g} (where the octave is formed by notes ranging
143 from @code{c}, to @code{b}). The pitch @code{c} is an octave below
144 middle C and the letters span the octave above that C.
146 @cindex note names, Dutch
148 In Dutch, a sharp is formed by adding @code{-is} to the end of a pitch
149 name. A flat is formed by adding @code{-es}. Double sharps and double
150 flats are obtained by adding @code{-isis} or @code{-eses}. @code{aes}
151 and @code{ees} are contracted to @code{as} and @code{es} in Dutch, but
152 both forms are accepted.
154 LilyPond has predefined sets of notenames for various other languages.
155 To use them, simply include the language specific init file. For
156 example: @code{\include "english.ly"}. The available language files and
157 the names they define are:
160 Note Names sharp flat
161 nederlands.ly c d e f g a bes b -is -es
162 english.ly c d e f g a bf b -s/-sharp -f/-flat
163 deutsch.ly c d e f g a b h -is -es
164 norsk.ly c d e f g a b h -iss/-is -ess/-es
165 svenska.ly c d e f g a b h -iss -ess
166 italiano.ly do re mi fa sol la sib si -d -b
167 catalan.ly do re mi fa sol la sib si -d/-s -b
175 The optional octave specification takes the form of a series of
176 single quote (`@code{'}') characters or a series of comma
177 (`@code{,}') characters. Each @code{'} raises the pitch by one
178 octave; each @code{,} lowers the pitch by an octave.
180 @lilypond[fragment,verbatim,center]
181 c' c'' es' g' as' gisis' ais'
184 @c . {Defining pitch names}
185 @node Defining pitch names
186 @subsection Defining pitch names
188 @cindex defining pitch names
189 @cindex pitch names, defining
191 Note names and chord modifiers can be customised for nationalities. The
192 syntax is as follows.
194 @cindex @code{\pitchnames}
195 @cindex @code{\chordmodifiers}
197 \pitchnames @var{scheme-alist}
198 \chordmodifiers @var{scheme-alist}
201 See @file{ly/nederlands.ly} and @file{ly/chord-modifiers.ly} for
202 specific examples how to do this.
208 @subsection Durations
212 @cindex @code{\duration}
214 The syntax for a verbose duration specification is
216 \duration @var{scmduration}
218 Here, @var{scmduration} is a Scheme object of type Duration. See
219 @ref{Duration} for more information.
222 In Note, Chord, and Lyrics mode, durations may be designated by numbers
223 and dots: durations are entered as their reciprocal values. For notes
224 longer than a whole note, use identifiers.
230 c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64
232 r1 r2 r4 r8 r16 r32 r64 r64
238 \notes \relative c'' {
239 a\longa a\breve \autoBeamOff
240 a1 a2 a4 a8 a16 a32 a64 a64
242 r1 r2 r4 r8 r16 r32 r64 r64
247 \remove "Clef_engraver";
248 \remove "Staff_symbol_engraver";
249 \remove "Time_signature_engraver";
250 \consists "Pitch_squash_engraver";
257 As you can see, the longa is not printed. To get a longa note head, you
258 have to use a mensural note heads. This is done accomplished by setting
259 the @code{style} property of the NoteHead grob to @code{mensural}.
261 If the duration is omitted then it is set to the previous duration
262 entered. At the start of parsing a quarter note is assumed. The
263 duration can be followed by a dot (`@code{.}') to obtain dotted note
267 @lilypond[fragment,verbatim,center]
273 You can alter the length of duration by appending
274 `@code{*}@var{fraction}'. This will not affect the appearance of the
275 notes or rests produced.
281 A note specification has the form
284 @var{pitch}[@var{octavespec}][!][?][@var{duration}]
287 LilyPond will determine what accidentals to typeset depending on the key
288 and context. The alteration refers to what note is heard, not to whether
289 an accidental is printed. A reminder accidental
290 @cindex reminder accidental
292 can be forced by adding an exclamation mark @code{!} after the pitch. A
293 cautionary accidental,
294 @cindex cautionary accidental
295 i.e., an accidental within parentheses can be obtained by adding the
296 question mark `@code{?}' after the pitch.
298 @lilypond[fragment,verbatim,center]
299 cis' d' e' cis' c'? d' e' c'!
303 @node Easy Notation note heads
304 @subsection Easy Notation note heads
306 @cindex easy notation
309 A entirely different type of note head is the "easyplay" note head: a
310 note head that includes a note name. It is used in some publications by
311 Hal-Leonard Inc. music publishers.
313 @lilypond[singleline,verbatim]
314 \include "paper26.ly"
316 \notes { c'2 e'4 f' | g'1 }
317 \paper { \translator { \EasyNotation } }
321 Note that @code{EasyNotation} overrides a @code{Score} context. You
322 probably will want to print it with magnification to make it better
328 If you view the result with Xdvi, then staff lines will show through the
329 letters. Printing the postscript file obtained either by using dvips or
330 the @code{-f ps} option of lilypond will produce the desired result.
340 A tie connects two adjacent note heads of the same pitch. When used
341 with chords, it connects all of the note heads whose pitches match.
342 Ties are indicated using the tilde symbol `@code{~}'.
343 If you try to tie together chords which have no common pitches, a
344 warning message will appear and no ties will be created.
346 @lilypond[fragment,verbatim,center]
347 e' ~ e' <c' e' g'> ~ <c' e' g'>
350 If you dislike the amount of ties created for a chord, you set
351 @code{Thread.sparseTies} to true, resulting in a smaller number of
353 @lilypond[fragment,verbatim,center]
354 \property Thread.sparseTies = ##t
355 <c' e' g'> ~ <c' e' g'>
358 In its meaning a tie is just a way of extending a note duration, similar
359 to the augmentation dot: the following example are three ways of notating
360 exactly the same concept.
361 @lilypond[fragment, singleline]
364 At present, the tie is implemented as a separate thing, temporally
365 located in between the notes. There is also no way to convert
366 between tied notes, dotted notes and plain notes.
374 @subsubsection Tuplets
378 Tuplets are made out of a music expression by multiplying their duration
381 @cindex @code{\times}
383 \times @var{fraction} @var{musicexpr}
386 The duration of @var{musicexpr} will be multiplied by the fraction.
387 In print, the fraction's denominator will be printed over the notes,
388 optionally with a bracket. The most common tuplet is the triplet in
389 which 3 notes have the length of 2, so the notes are 2/3 of
390 their written length:
392 @lilypond[fragment,verbatim,center]
393 g'4 \times 2/3 {c'4 c' c'} d'4 d'4
396 [todo: document tupletSpannerDuration]
406 Rests are entered like notes, with note name `@code{r}'.
416 \skip @var{duration} @code{;}
421 Skips the amount of time specified by @var{duration}. If no other music
422 is played, a gap will be left for the skipped time with no notes
423 printed. The short hand is only available in Note and Chord mode.
428 @subsection Note mode
433 @cindex @code{\notes}
435 Note mode is the lexical mode generally used for inputting notes. The
441 This instructs the tokenizer to interpret @var{expr} in note mode. If a
442 a sequence of alfabetical characters, like @code{foobar}, LilyPond first
443 checks if @code{foobar} is a pitch name. If it is not a pitch name,
444 then it is treated as a string.
446 Numbers and dots indicate durations, so you can enter floating point
447 numbers in this mode.
451 @section Staff notation
453 @cindex Staff notation
463 @subsection Key signature
468 Changing the key signature is done with the @code{\key} command.
470 @code{\key} @var{pitch} @var{type} @code{;}
473 @cindex @code{\minor}
474 @cindex @code{\major}
475 @cindex @code{\minor}
476 @cindex @code{\ionian}
477 @cindex @code{\locrian}
478 @cindex @code{\aeolian}
479 @cindex @code{\mixolydian}
480 @cindex @code{\lydian}
481 @cindex @code{\phrygian}
482 @cindex @code{\dorian}
484 Here, @var{type} should be @code{\major} or @code{\minor} to get
485 @var{pitch}-major or @var{pitch}-minor, respectively. The second
486 argument is optional; the default is major keys. The @var{\context}
487 argument can also be given as an integer, which tells the number of
488 semitones that should be added to the pitch given in the subsequent
489 @code{\key} commands to get the corresponding major key, e.g.,
490 @code{\minor} is defined as 3. The standard mode names @code{\ionian},
491 @code{\locrian}, @code{\aeolian}, @code{\mixolydian}, @code{\lydian},
492 @code{\phrygian}, and @code{\dorian} are also defined.
494 This command sets context property @code{Staff.keySignature}.
496 @cindex @code{keySignature}
499 @subsection Clef changes
502 \clef @var{clefname} @code{;}
508 \property Staff.clefGlyph = @var{glyph associated with clefname}
509 \property Staff.clefPosition = @var{clef Y-position for clefname}
510 \property Staff.clefOctavation = @var{extra pitch of clefname}
513 Supported clef-names include
516 @item treble, violin, G, G2: G clef on 2nd line
517 @item french: G clef on 1st line
518 @item soprano: C clef on 1st line
519 @item mezzosoprano: C clef on 2nd line
520 @item alto: C clef on 3rd line
521 @item tenor: C clef on 4th line
522 @item baritone: C clef on 5th line
523 @item varbaritone: F clef on 3rd line
524 @item bass, F: F clef on 4th line
525 @item subbass: F clef on 5th line
526 @item percussion: percussion clef
529 Supported associated glyphs (for @code{Staff.clefGlyph}) are:
532 @item clefs-C: modern style C clef
533 @item clefs-F: modern style F clef
534 @item clefs-G: modern style G clef
535 @item clefs-vaticana_do: Editio Vaticana style do clef
536 @item clefs-vaticana_fa: Editio Vaticana style fa clef
537 @item clefs-medicaea_do: Editio Medicaea style do clef
538 @item clefs-medicaea_fa: Editio Medicaea style fa clef
539 @item clefs-mensural1_c: modern style mensural C clef
540 @item clefs-mensural2_c: historic style small mensural C clef
541 @item clefs-mensural3_c: historic style big mensural C clef
542 @item clefs-mensural1_f: historic style traditional mensural F clef
543 @item clefs-mensural2_f: historic style new mensural F clef
544 @item clefs-mensural_g: historic style mensural G clef
545 @item clefs-hufnagel_do: historic style hufnagel do clef
546 @item clefs-hufnagel_fa: historic style hufnagel fa clef
547 @item clefs-hufnagel_do_fa: historic style hufnagel combined do/fa clef
548 @item clefs-percussion: modern style percussion clef
551 @emph{Modern style} means ``as is typeset in current editions.''
552 @emph{Historic style} means ``as was typeset or written in contemporary
553 historic editions''. @emph{Editio XXX style} means ``as is/was printed in
556 @cindex Vaticana, Editio
557 @cindex Medicaea, Editio
558 @cindex hufnagel clefs
561 @c . {Time signature}
563 @subsection Time signature
564 @cindex Time signature
568 The time signature is changed by the @code{\time} command. Syntax:
570 \time @var{numerator}@code{/}@var{denominator} @code{;}
572 Internally, this is a short-cut for doing
574 \property Score.timeSignatureFraction = #'(@var{numerator} . @var{denominator})
577 [TODO: discuss options for layout]
581 @subsubsection Partial
585 @cindex partial measure
586 @cindex measure, partial
587 @cindex shorten measures
588 @cindex @code{\partial}
590 Partial measures are entered using the @code{\partial} command:
592 \partial @var{duration} @code{;}
595 Internally, this is a short cut for
598 \property Score.measurePosition = -@var{length of duration}
604 @subsection Bar lines
608 @cindex measure lines
615 This is a short-cut for doing
617 \property Score.whichBar = @var{bartype}
620 You are encouraged to use @code{\repeat} for repetitions. See
621 @ref{Repeats}, and the documentation of @code{whichBar} in the generated
630 [TODO: collisions, rest-collisinos, voiceX identifiers, how to
631 which contexts to instantiate.]
635 @cindex @code{\shiftOff}
636 @item @code{\shiftOff}
637 Disable horizontal shifting of note heads that collide.
639 @cindex @code{\shiftOn}
640 @item @code{\shiftOn}
641 Enable note heads that collide with other note heads to be
642 shifted horiztonally. Also @code{\shiftOnn} and @code{\shiftOnnn}
643 set different shift values.
645 @cindex @code{\stemBoth}
646 @item @code{\stemBoth}
647 Allow stems and beams to point either upwards or
648 downwards, decided automatically by LilyPond.
650 @cindex @code{\stemDown}
651 @item @code{\stemDown}
652 Force stems and beams to point down.
654 @cindex @code{\stemUp}
656 Force stems and beams to point up.
659 @cindex @code{\slurBoth}
660 @cindex @code{\slurDown}
661 @cindex @code{\slurUp}
662 Similarly, for slurs use
666 @cindex @code{\slurBoth}
667 @cindex @code{\slurDown}
668 @cindex @code{\slurUp}
678 Beams are used to group short notes into chunks that are aligned with
679 the metrum. LilyPond guesses where beams should be inserted, but if
680 you're not satisfied with the automatic beaming, you can either instruct
681 lilypond which patterns to beam automatically. In specific cases, you
682 can also specify explicitly what to beam and what not.
685 @c . {Automatic beams}
686 @subsection Automatic beams
688 @cindex @code{Voice.autoBeamSettings}
689 @cindex @code{(end * * * *)}
690 @cindex @code{(begin * * * *)}
692 A large number of Voice properties are used to decide how to generate
693 beams. Their default values appear in @file{scm/auto-beam.scm}.
695 By default, automatic beams can start on any note@footnote{In exotic
696 time signatures such as 1/8 and 1/16 this is not true} but can only end
697 in a few positions within the measure: they can end on a beat, or at
698 durations specified by the properties in
699 @code{Voice.autoBeamSettings}. The defaults for @code{autoBeamSettings}
700 are defined in @file{scm/auto-beam.scm}.
702 The syntax for changing the value @code{autoBeamSettings} is set using
703 @code{\override} and unset using @code{\revert}:
705 \property Voice.autoBeamSettings \override #'(@var{BE} @var{N} @var{M} @var{P} @var{Q}) = @var{dur}
706 \property Voice.autoBeamSettings \revert #'(@var{BE} @var{N} @var{M} @var{P} @var{Q})
708 Here, @var{BE} is the symbol @code{begin} or @code{end}. It determines
709 whether the rule applies to begin or end-points. The quantity
710 @var{N}/@var{M} refers to a time signature (@code{* *} may be entered to
711 designate all time signatures), @var{P}/@var{Q} refers to the length of
712 the beamed notes (@code{* *} designate notes of any length).
714 If you want automatic beams to end on every quarter note, you can
717 \property Voice.autoBeamSettings \override
718 #'(end * * * *) = #(make-moment 1 4)
720 The duration a quarter note is 1/4 of a whole note. It is entered as
721 @code{(make-moment 1 4)}.
723 The same syntax can be used to specify beam starting points. In this
724 example, you automatic beams can only end on a dotted quarter note.
726 \property Voice.autoBeamSettings \override
727 #'(begin * * * *) = #(make-moment 3 8)
729 In 4/4 time signature, this means that automatic beams could end only on
730 3/8 and on the fourth beat of the measure (after 3/4, that is 2 times
731 3/8 has passed within the measure).
733 You can also restrict rules to specific time signatures. A rule that
734 should only be applied in @var{N}/@var{M} time signature is formed by
735 replacing the first asterisks by @var{N} and @var{M}. For example, a
736 rule for 6/8 time exclusively looks like
738 \property Voice.autoBeamSettings \override
739 #'(begin 6 8 * *) = ...
742 If you want a rule to apply to certain types of beams, you can use the
743 second pair of asterisks. Beams are classified according to the shortest
744 note they contain. For a beam ending rule that only applies to beams
745 with 32nd notes (and no shorter notes), you would use @code{(end * * 1
748 [say something about irregular meters. eg 5/8 = 2+3/8, 3+2/8]
750 Automatic beams can not be put on the last note in a score.
752 @cindex automatic beam generation
754 @cindex @code{Voice.noAutoBeaming}
756 Automatic beaming is on by default, but it can switched off by setting
757 @code{Voice.noAutoBeaming} to true. You you may find this necessary for
758 a melody that goes with lyrics.
761 @cindex Automatic beams
762 @subsubsection Manual beams
763 @cindex beams, manual
767 In some cases it may be necessary to override LilyPond's automatic
768 beaming algorithm. For example, the auto beamer will not beam over
769 rests or bar lines, so if you want that, specify the begin and end point
770 manually using @code{[} and @code{]}:
773 @lilypond[fragment,relative,verbatim]
775 r4 [r8 g'' a r8] r8 [g | a] r8
778 Whenever an manual beam is busy, the auto beam will not produce
781 @cindex @code{stemLeftBeamCount}
783 If you have specific wishes for the number of beams, you can fully
784 control the number of beams through the properties
785 @code{Voice.stemLeftBeamCount} and @code{Voice.stemRightBeamCount}.
787 @lilypond[fragment,relative,verbatim]
790 [f8 r16 \property Voice.stemLeftBeamCount = #1 f g a]
794 @cindex @code{stemRightBeamCount}
797 [FIXME: explain common tweaks.]
800 @node Expressive marks
801 @section Expressive marks
814 A slur indicates that notes are to be played bound or @emph{legato}. In
815 lilypond, they are entered using parentheses:
816 @lilypond[fragment,verbatim,center]
817 f'()g'()a' [a'8 b'(] a'4 g'2 )f'4
821 Slurs avoid crossing stems, and are attached to note heads whenever
822 possible. In some instances involving beams slurs may be attached to a
823 stem end. If you want to override this layout you can do this through
824 @code{Voice.Slur}'s grob-property @code{attachment}:
826 [TODO: remove this section]
827 Maybe reinclude other slur features and move back to tricks? Esp. the
828 second example, how to fix, can be very helpful.
831 @lilypond[fragment,relative,verbatim]
832 \property Voice.Slur \set #'direction = #1
833 \property Voice.Stem \set #'length = #5.5
835 \property Voice.Slur \set #'attachment = #'(stem . stem)
840 If a slur would strike through a stem or beam, the slur will be moved
841 away upward or downward. If this happens, attaching the slur to the
842 stems might look better:
845 @lilypond[fragment,relative,verbatim]
846 \property Voice.Stem \set #'direction = #1
847 \property Voice.Slur \set #'direction = #1
849 \property Voice.Slur \set #'attachment = #'(stem . stem)
854 Similarly, the curvature of a slur is adjusted to stay clear of note
855 heads and stems. When that would increase the curvature too much, the
856 slur is reverted to its default shape. The threshold for this decision
857 is in @code{Voice.Slur}'s grob-property @code{beautiful}. In some
858 cases, you may prefer curved slurs to vertically moved ones. You can
859 express this by increasing the @code{beautiful} value:
861 [hoe gedefd?? wat betekent beautiful = X?]
863 [dit voorbeeld is te lang: junken, of inkorten]
868 \notes \context PianoStaff <
870 \context Staff=up { s1 * 6/4 }
871 \context Staff=down <
873 \autochange Staff \context Voice
875 d,8( a' d f a d f d a f d )a
883 Slur \override #'beautiful = #5.0
884 Slur \override #'direction = #1
885 Stem \override #'direction = #-1
886 autoBeamSettings \override #'(end * * * *)
891 VerticalAlignment \override #'threshold = #'(5 . 5)
898 @cindex Adusting slurs
901 @subsection Phrasing slur
903 @cindex phrasing slur
904 @cindex phrasing mark
906 A phrasing slur (or phrasing mark) connects chords and is used to
907 indicate a musical sentence. It is entered using @code{\(} and @code{\)}.
908 @lilypond[fragment,verbatim,center,relative]
909 \time 6/4; c''\((d)e f(e)\)d
912 Typographically, the phrasing slur behaves almost exactly like a normal
913 slur. The grob associated with it is @code{Voice.PhrasingSlur}.
916 @subsection Breath marks
918 Breath marks are entered using @code{\breathe}:
920 @lilypond[fragment,relative]
924 Currently, only tick marks are supported, comma style breath marks are
925 not. The grob for this object is called @code{Voice.BreathingSign}.
935 @subsubsection Text spanner
938 Some textual indications, e.g. rallentando, accelerando, often extend
939 over a many measures. This is indicated by following the text with a
940 dotted line. You can create such texts in LilyPond using
941 text spanners. The syntax is as follows:
943 \spanrequest \start "text"
944 \spanrequest \stop "text"
946 LilyPond will respond by creating a @code{Voice.TextSpanner} grob. The
947 string to be printed, as well as the style is set through grob
950 An application ---or rather, a hack---is to fake octavation indications.
951 @lilypond[fragment,relative,verbatim]
952 \relative c' { a'''' b c a
953 \property Voice.TextSpanner \set #'type = #'dotted-line
954 \property Voice.TextSpanner \set #'edge-height = #'(0 . 1.5)
955 \property Voice.TextSpanner \set #'edge-text = #'("8va " . "")
956 \property Staff.centralCPosition = #-13
957 a\spanrequest \start "text" b c a \spanrequest \stop "text" }
973 @subsection Articulation
976 @cindex articulations
980 A variety of symbols can appear above and below notes to indicate
981 different characteristics of the performance. These symbols can be
982 added to a note with `@var{note}@code{-\}@var{name}'. Numerous symbols
983 are defined in @file{script.ly} and @file{script.scm}. Symbols can be
984 forced to appear above or below the note by writing
985 `@var{note}@code{^\}@var{name}' and `@var{note}@code{_\}@var{name}'
986 respectively. Here is a chart showing symbols above notes, with the
987 name of the corresponding symbol appearing underneath.
992 \property Score.LyricSyllable \override #'font-family =
994 \property Score.LyricSyllable \override #'font-shape = #'upright
995 c''-\accent c''-\marcato c''-\staccatissimo c''-\fermata
996 c''-\stopped c''-\staccato c''-\tenuto c''-\upbow
997 c''-\downbow c''^\lheel c''-\rheel c''^\ltoe
998 c''-\rtoe c''-\turn c''-\open c''-\flageolet
999 c''-\reverseturn c''-\trill c''-\prall c''-\mordent
1000 c''-\prallprall c''-\prallmordent c''-\upprall c''-\downprall
1001 c''-\thumb c''-\segno c''-\coda
1003 \context Lyrics \lyrics {
1004 accent__ marcato__ staccatissimo__ fermata
1005 stopped__ staccato__ tenuto__ upbow
1006 downbow__ lheel__ rheel__ ltoe
1007 rtoe__ turn__ open__ flageolet
1008 reverseturn__ trill__ prall__ mordent
1009 prallprall__ prallmordent__ uprall__ downprall
1010 thumb__ segno__ coda
1014 linewidth = 5.875\in;
1019 All of these note ornaments appear in the printed output but have no
1020 effect on the MIDI rendering of the music.
1022 To save typing work, some shorthands are available:
1023 @lilypond[singleline]
1025 \notes \context Voice {
1026 \property Voice.TextScript \set #'font-family = #'typewriter
1027 \property Voice.TextScript \set #'font-shape = #'upright
1033 c''4-^_"c-\\^{ }" s4
1040 Fingering instructions can also be entered in this shorthand.
1041 @lilypond[verbatim, singleline, fragment]
1042 c'4-1 c'4-2 c'4-3 c'4-4
1045 Unfortunately, there is no support adding fingering instructions to
1046 individual note heads. Some hacks exist, though. See
1047 @file{input/test/script-horizontal.ly}.
1050 @cindex @code{\script}
1059 Defines a script printing request. The argument is a string which
1060 points into the script-alias table defined in @file{scm/script.scm}.
1061 Usually the @code{\script} keyword is not used directly. Various
1062 helpful identifier definitions appear in @file{script.ly}.
1064 For information on how to add scripts, consult @file{scm/script.scm}.
1070 @subsection Text scripts
1071 @cindex Text scripts
1073 In addition, it is possible to place arbitrary strings of text or markup
1074 text (see @ref{Text markup}) above or below notes by using a string:
1075 @code{c^"text"}. The text is typeset in italic by default.
1077 The amount of space taken by these indications by default does not
1078 influence, spacing, but setting @code{Voice.textNonEmpty} to true will
1079 take the widths into account. The identifier @code{\fattext} is defined
1080 in the standard includes.
1081 @lilypond[fragment,singleline]
1082 \relative c' { c4^"longtext" \fatText c4_"longlongtext" c4 }
1085 Text scripts are created in form of @code{Voice.TextScript} grobs.
1087 For purposes of defining identifiers, a more verbose form also exists:
1090 \textscript @var{text}
1093 Defines a text to be printed over or under a note. @var{text} is a
1094 string or a markup text.
1098 foo = \textscript #'(finger "6")
1105 This is equivalent to @code{c4-6 c4-"foo"}.
1110 @subsection Grace notes
1119 @cindex @code{\grace}
1122 @cindex @code{graceAlignPosition}
1124 Grace notes are ornaments that are written out, but do not take up any
1125 logical time in a measure. LilyPond has limited support for grace notes.
1126 The syntax is as follows.
1128 \grace @var{musicexpr}
1131 When grace music is interpreted, a score-within-a-score is set up:
1132 @var{musicexpr} has its own time bookkeeping, and you could (for
1133 example) have a separate time signature within grace notes. While in
1134 this score-within-a-score, you can create notes, beams, slurs, etc.
1135 Unbeamed eighth notes and shorter by default have a slash through the
1136 stem. This behavior can be controlled with the
1137 @code{Stem}.@code{flag-style} property.
1140 @lilypond[fragment,verbatim]
1142 \grace c8 c4 \grace { [c16 c16] } c4
1143 \grace { \property Grace.Stem \override #'flag-style = ##f c16 } c4
1150 At present, nesting @code{\grace} notes is not supported. The following
1151 may cause run-time errors:
1153 @code{\grace @{ \grace c32 c16 @} c4}
1155 Since the meaning of such a construct is unclear, we don't consider this
1156 a loss. Similarly, juxtaposing two @code{\grace} sections is
1157 syntactically valid, but makes no sense and may cause runtime errors.
1158 Ending a staff or score with grace notes may also generate a run-time
1159 error, since there will be no main note to attach the grace notes to.
1162 A grace note expression has duration 0; the next real note is assumed to
1163 be the main note. If you want the note to appear after the main note,
1164 set @code{Voice.graceAlignPosition} to @code{1}.
1166 The present implementation of grace notes is not robust and generally
1167 kludgy. We expect it to change after LilyPond 1.4. Syntax changes might
1168 also be implemented.
1181 @subsubsection Glissando
1184 @cindex @code{\glissando}
1186 A glissando line can be requested by attaching a @code{\glissando} to a
1190 @lilypond[fragment,relative,verbatim]
1195 Printing of an additional text (such as @emph{gliss.}) must be done
1202 @subsubsection Dynamics
1215 @cindex @code{\ffff}
1225 Absolute dynamic marks are specified by using an identifier after a
1226 note: @code{c4-\ff}. The available dynamic marks are: @code{\ppp},
1227 @code{\pp}, @code{\p}, @code{\mp}, @code{\mf}, @code{\f}, @code{\ff},
1228 @code{\fff}, @code{\fff}, @code{\fp}, @code{\sf}, @code{\sff},
1229 @code{\sp}, @code{\spp}, @code{\sfz}, and @code{\rfz}.
1232 @cindex Crescendo and Decrescendo
1236 @cindex @code{\decr}
1237 @cindex @code{\rced}
1243 A crescendo mark is started with @code{\cr} and terminated with
1244 @code{\rc} (the textual reverse of @code{cr}). A decrescendo mark is
1245 started with @code{\decr} and terminated with @code{\rced}. There are
1246 also shorthands for these marks. A crescendo can be started with
1247 @code{\<} and a decrescendo can be started with @code{\>}. Either one
1248 can be terminated with @code{\!}. Note that @code{\!} must go before
1249 the last note of the dynamic mark whereas @code{\rc} and @code{\rced} go
1250 after the last note. Because these marks are bound to notes, if you
1251 want to get several marks during one note, you must use spacer notes.
1253 @lilypond[fragment,verbatim,center]
1254 c'' \< \! c'' d'' \decr e'' \rced
1255 < f''1 { s4 \< \! s2 \> \! s4 } >
1260 You can also use a text saying @emph{cresc.} instead of hairpins. Here
1261 is an example how to do it:
1263 @lilypond[fragment,relative,verbatim]
1265 \property Voice.crescendoText = "cresc."
1266 \property Voice.crescendoSpanner = #'dashed-line
1282 @cindex @code{\repeat}
1284 To specify repeats, use the @code{\repeat} keyword. Since repeats
1285 should work differently when played or printed, there are a few
1286 different variants of repeats.
1290 Repeated music is fully written (played) out. Useful for MIDI
1294 This is the normal notation: Repeats are not written out, but
1295 alternative endings (voltas) are printed, left to right.
1298 Alternative endings are written stacked. Which is unfortunately not
1299 practical for anything right now.
1305 Make measure repeats. These look like percent signs.
1311 * Manual repeat commands::
1313 * Tremolo subdivision::
1318 @subsection Repeat syntax
1320 The syntax for repeats is
1323 \repeat @var{variant} @var{repeatcount} @var{repeatbody}
1326 If you have alternative endings, you may add
1327 @cindex @code{\alternative}
1329 \alternative @code{@{} @var{alternative1}
1331 @var{alternative3} @dots{} @code{@}}
1333 where each @var{alternative} is a music expression.
1335 Normal notation repeats are used like this:
1336 @lilypond[fragment,verbatim]
1338 \repeat volta 2 { c'4 d' e' f' }
1339 \repeat volta 2 { f' e' d' c' }
1342 With alternative endings:
1344 @lilypond[fragment,verbatim]
1346 \repeat volta 2 {c'4 d' e' f'}
1347 \alternative { {d'2 d'} {f' f} }
1351 Folded repeats look like this:@footnote{Folded repeats offer little
1352 more over simultaneous music. However, it is to be expected that
1353 more functionality -- especially for the MIDI backend -- will be
1354 implemented at some point in the future.}
1357 @lilypond[fragment,verbatim]
1359 \repeat fold 2 {c'4 d' e' f'}
1360 \alternative { {d'2 d'} {f' f} }
1366 If you don't give enough alternatives for all of the repeats, then
1367 the first alternative is assumed to be repeated often enough to equal
1368 the specified number of repeats.
1371 @lilypond[fragment,verbatim]
1375 \repeat volta 3 { e | c2 d2 | e2 f2 | }
1376 \alternative { { g4 g g } { a | a a a a | b2. } }
1382 As you can see, LilyPond doesn't remember the timing information, nor
1383 are slurs or ties repeated, so you have to reset timing information
1384 after a repeat, e.g. using a bar-check (See @ref{Bar check}),
1385 @code{Score.measurePosition} or @code{\partial}. We hope to fix this
1388 It is possible to nest @code{\repeat}, although it probably is only
1389 meaningful for unfolded repeats.
1391 @node Manual repeat commands
1392 @subsection Manual repeat commands
1394 @cindex @code{repeatCommands}
1396 The property @code{repeatCommands} can be used to control the layout of
1397 repeats. Its value is a Scheme list of repeat commands, where each repeat
1405 @item (volta . @var{text})
1406 Print a volta bracket saying @var{text}.
1408 Stop a running volta bracket
1411 @lilypond[verbatim, fragment]
1413 \property Score.repeatCommands = #'((volta "93") end-repeat)
1415 \property Score.repeatCommands = #'((volta #f))
1420 [explain precendence: \bar, repeatCommands, whichBar, defaultBarType]
1422 @node Tremolo repeats
1423 @subsection Tremolo repeats
1424 @cindex tremolo beams
1426 To place tremolo marks between notes, use @code{\repeat} with tremolo
1428 @lilypond[verbatim,center,singleline]
1430 \context Voice \notes\relative c' {
1431 \repeat "tremolo" 8 { c16 d16 }
1432 \repeat "tremolo" 4 { c16 d16 }
1433 \repeat "tremolo" 2 { c16 d16 }
1434 \repeat "tremolo" 4 c16
1439 At present, the spacing between tremolo beams is not regular, since the
1440 spacing engine does not notice that not all notes are printed.
1442 @node Tremolo subdivision
1443 @subsection Tremolo subdivision
1444 @cindex tremolo marks
1445 @cindex @code{tremoloFlags}
1447 Tremolo marks can be printed on a single note by adding
1448 `@code{:}[@var{length}]' after the note. The length must be at least 8.
1449 A @var{length} value of 8 gives one line across the note stem. If the
1450 length is omitted, then then the last value (stored in
1451 @code{Voice.tremoloFlags}) is used.
1453 @lilypond[verbatim,fragment,center]
1456 Using this mechanism pays off when you entering many tremolos, since the
1457 default argument saves a lot of typing.
1459 Tremolos in this style do not carry over into the MIDI output.
1462 @node Measure repeats
1463 @subsection Measure repeats
1465 @cindex percent repeats
1466 @cindex measure repeats
1468 In the @code{percent} style, a note pattern can be repeated. It is
1469 printed once, and then the pattern is replaced with a special sign.
1471 @lilypond[verbatim,singleline]
1472 \context Voice { \repeat "percent" 5 { c'1 } }
1475 At present, only repeats of whole measures are supported.
1479 @section Piano music
1481 Piano music is an odd type of notation: two staffs are largely
1482 independent, but sometimes voices can cross between the two staffs. The
1483 @code{PianoStaff} is especially built to handle this cross-staffing
1484 behavior. In this section we discuss the @code{PianoStaff} and some
1485 other pianistic peculiarities.
1488 * Automatic staff changes::
1489 * Manual staff switches::
1496 @c . {Automatic staff changes}
1497 @node Automatic staff changes
1498 @subsection Automatic staff changes
1499 @cindex Automatic staff changes
1501 Voices can be switched from top to bottom staff automatically. The
1504 \autochange @var{contexttype} @var{musicexp}
1506 This will switch notation context of @var{musicexp} between a
1507 @var{contexttype} named @code{up} and @code{down}. Typically, you use
1508 @code{Staff} for @var{contexttype}. The autochanger switches on basis
1509 of pitch (central C is the turning point), and it looks ahead skipping
1510 over rests to switch rests in advance.
1512 @lilypond[verbatim,singleline]
1513 \score { \notes \context PianoStaff <
1514 \context Staff = "up" {
1515 \autochange Staff \context Voice = VA < \relative c' {
1516 g4 a b c d r4 a g } > }
1517 \context Staff = "down" {
1523 Note how spacer rests are used to prevent the bottom staff from
1524 terminating too soon.
1527 @node Manual staff switches
1528 @subsection Manual staff switches
1530 @cindex manual staff switches
1531 @cindex staff switch, manual
1533 Voices can be switched between staffs manually, using the following command:
1535 \translator Staff = @var{which} @var{music}
1537 The string @var{which} is the name of the staff. Typically it is
1538 @code{"up"} or @code{"down"}.
1540 Formally, this construct is a music expression indicating that the
1541 context which is a direct child of the a context of type
1542 @var{contexttype} should be shifted to a context of type
1543 @var{contexttype} and the specified name.
1545 @cindex @code{\translator}
1547 \translator @var{contexttype} = @var{name}
1556 Piano pedals can be entered using the span requests (See @ref{Span
1557 requests}) of the types @code{Sustain}, @code{UnaChorda} and
1560 @lilypond[fragment,verbatim]
1561 c''4 \spanrequest \start "Sustain" c4 c4 \spanrequest \stop "Sustain"
1564 For these verbose expressions, standard shorthands have been defined:
1565 @code{sustainDown}, @code{sustainUp}, @code{unaChorda},
1566 @code{treChorde}, @code{sostenutoDown} and @code{sostenutoUp}. The
1567 symbols that are printed can be modified by setting
1568 @code{pedal@var{X}Strings}, where @var{X} is one of the pedal
1569 types. Refer to the generated documentation for more information.
1571 Currently, brackets are not supported, only text markings (ie. *Ped
1577 @subsection Arpeggio
1580 @cindex broken arpeggio
1581 @cindex @code{\arpeggio}
1583 You can specify an arpeggio sign on a chord by attaching an
1584 @code{\arpeggio} to a note of the chord.
1588 @lilypond[fragment,relative,verbatim]
1589 \context Voice <c'\arpeggio e g c>
1593 When an arpeggio crosses staffs in piano music, you attach an arpeggio
1594 to the chords in both staffs, and set
1595 @code{PianoStaff.connectArpeggios}.
1598 @lilypond[fragment,relative,verbatim]
1599 \context PianoStaff <
1600 \property PianoStaff.connectArpeggios = ##t
1601 \context Voice = one { <c''\arpeggio e g c> }
1602 \context Voice = other { \clef bass; <c,,\arpeggio e g>}
1607 This command creates @code{Arpeggio} grobs. It is not possible to mix
1608 connected arpeggios and unconnected arpeggios at the same time.
1611 @c . {Follow Thread}
1613 @subsection Follow Thread
1614 @cindex follow thread
1615 @cindex staff switching
1618 [todo: different name, eg. voice line ? ]
1620 @cindex @code{followThread}
1622 Whenever a voice switches to another staff a line connecting the notes
1623 can be printed automatically. This is enabled if the property
1624 @code{PianoStaff.followThread} is set to true:
1627 @lilypond[fragment,relative,verbatim]
1628 \context PianoStaff <
1629 \property PianoStaff.followThread = ##t
1630 \context Staff \context Voice {
1632 \translator Staff=two
1635 \context Staff=two {\clef bass; \skip 1*2;}
1649 * Automatic syllable durations::
1655 @subsection Lyrics mode
1659 @cindex @code{\lyrics}
1661 Lyrics mode is introduced by the keyword @code{\lyrics}. This mode has
1662 rules that make it easy to include punctuation and diacritical marks in
1663 words: The purpose of Lyrics mode is that you can enter lyrics in @TeX{}
1664 format or a standard encoding without needing quotes. The precise
1665 definition of this mode is ludicrous, and this will remain so until the
1666 authors of LilyPond acquire a deeper understanding of character
1667 encoding, or someone else steps up to fix this.
1669 A word in Lyrics mode begins with: an alphabetic character, @code{_},
1670 @code{?}, @code{!}, @code{:}, @code{'}, the control characters @code{^A}
1671 through @code{^F}, @code{^Q} through @code{^W}, @code{^Y}, @code{^^},
1672 any 8-bit character with ASCII code over 127, or a two-character
1673 combination of a backslash followed by one of @code{`}, @code{'},
1674 @code{"}, or @code{^}.
1676 Subsequent characters of a word can be any character that is not a digit
1677 and not white space. One important consequence of this is that a word
1678 can end with `@code{@}}', which may be confusing. However, LilyPond will
1679 issue a warning. Any @code{_} character which appears in an unquoted
1680 word is converted to a space. This provides a mechanism for introducing
1681 spaces into words without using quotes. Quoted words can also be used
1682 in Lyrics mode to specify words that cannot be written with the above
1683 rules. Here are some examples. Not all of these words are printable by
1688 2B_||_!2B % not a word because it starts with a digit
1689 ``Hello'' % not a word because it starts with `
1690 _ _ _ _ % 4 words, each one a space
1693 Since combinations of numbers and dots are used for indicating
1694 durations, you can not enter real numbers in this mode.
1696 @cindex lyrics expressions
1698 Syllables are entered like notes, with pitches replaced by text. For
1699 example, @code{Twin-4 kle4 twin-4 kle4} enters four syllables, each
1700 with quarter note duration. Note that the hyphen has no special
1701 meaning for lyrics, and does not introduce special symbols. See
1702 @ref{Lexical modes} for a description of what is interpreted as
1705 Spaces can be introduced into a lyric either by using quotes
1706 (@code{"}) or by using an underscore without quotes: @code{He_could4
1707 not4}. All unquoted underscores are converted to spaces. Printing
1708 lyrics is discussed in the next section.
1711 @c . {Printing lyrics}
1712 @node Printing lyrics
1713 @subsection Printing lyrics
1717 Lyric syllables must be interpreted within a @code{Lyrics} context for
1718 printing them. Here is a full example:
1724 \notes \transpose c'' {
1726 e f g2 | e4 f g2 \bar "|.";
1728 \context Lyrics \lyrics {
1729 Va-4 der Ja- cob Va- der Ja- cob
1730 Slaapt gij nog?2 Slaapt4 gij nog?2
1742 @cindex lyric extender
1744 You may want a continuous line after the syllables to show melismata.
1745 To achieve this effect, add a @code{__} lyric as a separate word
1746 after the lyric to be extended. This will create an extender, a line
1747 that extends over the entire duration of the lyric. This line will
1748 run all the way to the start of the next lyric, so you may want to
1749 shorten it by using a blank lyric (using @code{_}).
1756 \notes \relative c'' {
1757 a4 () b () c () d | c () d () b () a | c () d () b () a
1759 \context Lyrics \lyrics {
1760 foo1 __ | bar2. __ _4 | baz1 __
1768 @cindex Lyric hyphen
1770 If you want to have hyphens centered between syllables (rather than
1771 attached to the end of the first syllable) you can use the special
1772 `@code{-}@code{-}' lyric as a separate word between syllables. This
1773 will result in a hyphen which length varies depending on the space
1774 between syllables, and which will be centered between the syllables.
1782 \notes \transpose c'' {
1784 e f g2 | e4 f g2 \bar "|.";
1786 \context Lyrics \lyrics {
1787 Va4 -- der Ja -- cob | Va -- der Ja -- cob |
1788 Slaapt gij nog?2 | Slaapt4 gij nog?2
1797 @c . {Automatic syllable durations}
1798 @node Automatic syllable durations
1799 @subsection Automatic syllable durations
1800 @cindex Automatic syllable durations
1803 @cindex automatic lyric durations
1804 @cindex @code{\addlyrics}
1806 If you have lyrics that are set to a melody, you can import the rhythm
1807 of that melody into the lyrics using @code{\addlyrics}. The syntax for
1810 \addlyrics @var{musicexpr1 musicexpr2}
1813 This means that both @var{musicexpr1} and @var{musicexpr2} are
1814 interpreted, but that every non-command atomic music expression
1815 (``every syllable'') in @var{musicexpr2} is interpreted using timing
1816 of @var{musicexpr1}.
1817 @cindex @code{automaticMelismata}
1819 If the property @code{automaticMelismata} is set in the
1820 context of @var{musicexpr1}, no lyrics will be put on slurred or tied
1824 @lilypond[verbatim,fragment]
1827 \property Voice.automaticMelismata = ##t
1828 c8 () cis d8. e16 f2
1830 \context Lyrics \lyrics {
1835 You should use a single rhythm melody, and single rhythm lyrics (a
1836 constant duration is the obvious choice). If you do not, you will get
1837 undesired effects when using multiple stanzas:
1840 @lilypond[verbatim,fragment]
1843 c8 () cis d8. e16 f2
1845 \context Lyrics \lyrics
1852 It is valid (but probably not very useful) to use notes instead of
1853 lyrics for @var{musicexpr2}.
1856 @subsection More stanzas
1860 If you have multiple stanzas printed underneath each other, the separate
1861 syllables should be aligned around punctuation. LilyPond can do this if
1862 you explain it which lyric lines belong to which melody.
1864 To this end, give the Voice context an identity, and set the LyricsVoice
1865 to name starting with that identity. In the following example, the Voice
1866 identity is @code{duet}, and the identities of the LyricsVoices are
1867 @code{duet-1} and @code{duet-2}.
1870 @lilypond[singleline,verbatim]
1873 \notes \relative c'' \context Voice = duet { \time 3/4; g2 e4 a2 f4 g2. }
1874 \lyrics \context Lyrics <
1875 \context LyricsVoice = "duet-1" {
1876 \property LyricsVoice . stanza = "Bert"
1877 Hi, my name is bert. }
1878 \context LyricsVoice = "duet-2" {
1879 \property LyricsVoice . stanza = "Ernie"
1880 Ooooo, ch\'e -- ri, je t'aime. }
1885 You can add stanza numbers by setting @code{LyricsVoice.Stanza} (for the
1886 first system) and @code{LyricsVoice.stz} for the following systems.
1888 @cindex stanza numbering
1896 [chords vs. simultaneous music]
1900 * Entering named chords::
1901 * Printing named chords::
1906 @subsection Chords mode
1909 Chord mode is introduced by the keyword
1910 @code{\chords}. It is similar to Note mode, but
1911 words are also looked up in a chord modifier table (containing
1912 @code{maj}, @code{dim}, etc).
1914 Since combinations of numbers and dots are used for indicating
1915 durations, you can not enter real numbers in this mode. Dashes
1916 and carets are used to indicate chord additions and subtractions,
1917 so scripts can not be entered in Chord mode.
1919 @c . {Entering named chords}
1920 @node Entering named chords
1921 @subsection Entering named chords
1922 @cindex Chords names
1924 Chord names are a way to generate simultaneous music expressions that
1925 correspond with traditional chord names. It can only be used in
1926 Chord mode (see @ref{Lexical modes}).
1930 @var{tonic}[@var{duration}][@code{-}@var{modifiers}][@code{^}@var{subtractions}][@code{/}@var{inversion}][@code{/+}@var{bass}].
1933 @var{tonic} should be the tonic note of the chord, and @var{duration}
1934 is the chord duration in the usual notation. There are two kinds of
1935 modifiers. One type is @emph{chord additions}, which are obtained by
1936 listing intervals separated by dots. An interval is written by its
1937 number with an optional @code{+} or @code{-} to indicate raising or
1938 lowering by half a step. Chord additions has two effects: It adds
1939 the specified interval and all lower odd numbered intervals to the
1940 chord, and it may lower or raise the specified interval. Intervals
1941 must be separated by a dot (@code{.}).
1944 Throughout these examples, chords have been shifted around the staff
1945 using @code{\transpose}.
1950 @lilypond[fragment,verbatim]
1954 c:9 c:9-.5+.7+ c:3-.5- c:4.6.8
1966 The second type of modifier that may appear after the @code{:} is a
1967 named modifier. Named modifiers are listed in the file
1968 @file{chord-modifiers.ly}. The available modifiers are @code{m} and
1969 @code{min} which lower the 3rd half a step, `@code{aug}' which
1970 raises the 5th, `@code{dim}' which lowers the 5th,
1971 `@code{maj}' which adds a raised 7th, and `@code{sus}'
1972 which replaces the 5th with a 4th.
1976 @lilypond[fragment,verbatim]
1979 c1:m c:min7 c:maj c:aug c:dim c:sus
1987 Chord subtractions are used to eliminate notes from a chord. The
1988 notes to be subtracted are listed after a @code{^} character,
1991 @lilypond[fragment,verbatim,center]
2000 Chord inversions can be specified by appending `@code{/}' and
2001 the name of a single note to a chord. This has the effect of
2002 lowering the specified note by an octave so it becomes the lowest
2003 note in the chord. If the specified note is not in the chord, a
2004 warning will be printed.
2006 @lilypond[fragment,verbatim,center]
2016 Bass notes can be added by `@code{/+}' and
2017 the name of a single note to a chord. This has the effect of
2018 adding the specified note to the chord, lowered by an octave,
2019 so it becomes the lowest note in the chord.
2021 @lilypond[fragment,verbatim,center]
2030 The most interesting application is printing chord names, which is
2031 explained in the next subsection.
2033 You should not combine @code{\relative} with named chords. [FIXME]
2035 @c . {Printing named chords}
2036 @node Printing named chords
2037 @subsection Printing named chords
2043 @cindex printing chord names
2046 @cindex @code{ChordNames}
2047 @cindex @code{ChordNameVoice}
2049 For displaying printed chord names, use the @code{ChordNames} and
2050 @code{ChordNameVoice} contexts. The chords may be entered either using
2051 the notation described above, or directly using simultaneous music.
2054 @lilypond[verbatim,singleline]
2056 \chords {a1 b c} <d f g> <e g b>
2060 \context ChordNamesVoice \scheme
2061 \context Staff \transpose c'' \scheme
2067 You can make the chord changes stand out more by setting property
2068 @code{ChordNames.chordChanges} to true. This will only display chord
2069 names when there's a change in the chords scheme, but always display the
2070 chord name after a line break:
2076 c1:m \break c:m c:m c:m d
2081 \context ChordNames \scheme
2082 \context Staff \transpose c'' \scheme
2085 linewidth = 40 * \staffspace;
2097 LilyPond examines chords specified as lists of notes to determine a
2098 name to give the chord. LilyPond will not try to
2099 identify chord inversions or added base, which may result in strange
2100 chord names when chords are entered as a list of pitches:
2103 @lilypond[verbatim,center,singleline]
2112 \context ChordNamesVoice \scheme
2113 \context Staff \scheme
2119 To specify chord inversions, append @code{/<notename>}. To specify an
2120 added bass note, append @code{/+<notename}:
2123 @lilypond[verbatim,center,singleline]
2130 \context ChordNames \scheme
2131 \context Staff \transpose c'' \scheme
2137 The chord names that LilyPond should print are fully customizable. The
2138 code to print chord names is written in Scheme. It can be found in
2139 @file{scm/chord-name.scm}. Chord names are based on Banter style
2140 naming, which is unambiguous and has a logical structure. Typical
2141 American style chord names are implemented as a variation on Banter
2142 names, they can be selected by setting property @code{ChordName.style}
2147 \include "english.ly"
2152 df:m5- % Diminished triad
2153 c:5^3 % Root-fifth chord
2154 c:4^3 % Suspended fourth triad
2155 c:5+ % Augmented triad
2157 c:m5-.7- % Diminished seventh
2158 c:7+ % Major seventh
2159 c:7.4^3 % Dominant seventh suspended fourth
2160 c:5+.7 % Augmented dominant seventh
2161 c:m5-.7 % "Half" diminished seventh
2162 c:5-.7 % Dominant seventh flat fifth
2163 c:5-.7+ % Major seventh flat fifth
2164 c:m7+ % Minor-major seventh
2165 c:m7 % Minor seventh
2166 c:7 % Dominant seventh
2169 c:9^7 % Major triad w/added ninth
2170 c:6.9^7 % Six/Nine chord
2171 c:9 % Dominant ninth
2172 c:7+.9 % Major ninth
2173 c:m7.9 % Minor ninth
2178 \context ChordNames \scheme
2179 \context Staff \transpose c'' \scheme
2184 ChordName \override #'word-space = #1
2185 ChordName \override #'style = #'american
2192 Similarly, Jazz style chord names are implemented as a variation on
2193 American style names:
2199 c:6 % 6 = major triad with added sixth
2200 c:maj % triangle = maj
2205 c:m % m = minor triad
2206 c:m.6 % m6 = minor triad with added sixth
2207 c:m.7+ % m triangle = minor major seventh chord
2215 c:7.5+ % +7 = augmented dominant
2216 c:7.5- % 7b5 = hard diminished dominant
2223 c:13.9-^11 % 7(b9,13)
2224 c:13.9+^11 % 7(#9,13)
2226 c:13-.9-^11 % 7(b9,b13)
2227 c:13-.9+^11 % 7(#9,b13)
2229 % half diminished chords
2230 c:m5-.7 % slashed o = m7b5
2231 c:9.3-.5- % o/7(pure 9)
2234 c:m5-.7- % o = diminished seventh chord
2239 \context ChordNames \scheme
2240 \context Staff \transpose c'' \scheme
2245 ChordName \override #'word-space = #1
2246 ChordName \override #'style = #'jazz
2254 @section Writing parts
2259 * Instrument names::
2261 * Sound output for transposing instruments::
2262 * Multi measure rests::
2263 * Automatic part combining::
2266 @c . {Rehearsal marks}
2267 @node Rehearsal marks
2268 @subsection Rehearsal marks
2269 @cindex Rehearsal marks
2271 @cindex @code{\mark}
2272 @cindex @code{Mark_engraver}
2275 \mark @var{unsigned};
2280 With this command, you can print a rehearsal mark above the system. You
2281 can provide a number, a string or a markup text as argument. If there is
2282 no argument, the property @code{rehearsalMark} is used and automatically
2285 @lilypond[fragment,verbatim]
2291 c1 \mark #'(music "scripts-segno") ;
2296 @node Instrument names
2297 @subsection Instrument names
2299 You can specify an instrument name for a staff by setting
2300 @code{Staff.instrument} and @code{Staff.instr}. This will print a string
2301 before the start of the staff. For the first start, @code{instrument} is
2302 used, for the next ones @code{instr} is used.
2304 @lilypond[verbatim,singleline]
2306 \property Staff.instrument = "instr " { c''4 } }
2308 \translator { \StaffContext
2309 \consists "Instrument_name_engraver"; } } }
2312 This requires that you add the @code{Instrument_name_engraver} to the
2317 @subsection Transpose
2319 @cindex transposition of pitches
2320 @cindex @code{\transpose}
2322 A music expression can be transposed with @code{\transpose}. The syntax
2325 \transpose @var{pitch} @var{musicexpr}
2328 This means that middle C in @var{musicexpr} is transposed to
2331 @code{\transpose} distinguishes between enharmonic pitches: both
2332 @code{\transpose cis'} or @code{\transpose des'} will transpose up half
2333 a tone. The first version will print sharps and the second version
2337 @lilypond[fragment,verbatim]
2340 { \key e \major; c d e f }
2342 \transpose des'' { \key e \major; c d e f }
2343 \transpose cis'' { \key e \major; c d e f }
2349 If you want to use both @code{\transpose} and @code{\relative}, then
2350 you must use @code{\transpose} first. @code{\relative} will have no
2351 effect music that appears inside a @code{\transpose}.
2353 @node Sound output for transposing instruments
2354 @subsection Sound output transposing instruments
2356 When you want to play a score containing transposed and untransposed
2357 instruments, you have to instruct LilyPond the pitch offset (in
2358 semitones) for the transposed instruments. This is done using
2361 @cindex @code{transposing}
2364 \property Staff.instrument = #"Cl. in B-flat"
2365 \property Staff.transposing = #-2
2369 @c . {Multi measure rests}
2370 @node Multi measure rests
2371 @subsection Multi measure rests
2372 @cindex Multi measure rests
2376 Multi measure rests are entered using `@code{R}'. It is specifically
2377 meant for entering parts: the rest can expand to fill a score with
2378 rests, or it can be printed as a single multimeasure rest This expansion
2379 is controlled by the property @code{Score.skipBars}. If this is set to true,
2380 Lily will not expand empty measures, and the appropriate number is added
2383 @lilypond[fragment,verbatim]
2384 \time 3/4; R2.*2 \property Score.skipBars = ##t R2.*17 R2.*4
2387 Currently, there is no way to condense multiple rests into a single
2390 @cindex condensing rests
2392 @node Automatic part combining
2393 @subsection Automatic part combining
2394 @cindex automatic part combining
2395 @cindex part combiner
2397 Automatic part combining is used to merge two parts of music onto on
2398 staff in an intelligent way. It is aimed primarily at typesetting Hymns
2399 and orchestral scores. When the two parts are identical for a period of
2400 time, only will be shown. In places where the two parts differ, stem
2401 directions are set automatically. Also, soli and @`{a} due parts can be
2402 identified and marke.
2405 @subsubsection Part combine syntax
2407 The syntax for part combining is
2410 \partcombine @var{context} @var{musicexpr1} @var{musicexpr2}
2413 where the pieces of music @var{musicexpr1} and @var{musicexpr2} will be
2414 combined into one context @var{context}. The names of the music
2415 expressions must start with the prefixes @code{one} and @code{two}.
2417 @subsubsection Part combine usage
2419 @cindex @code{Thread_devnull_engraver}
2420 @cindex @code{Voice_engraver}
2421 @cindex @code{A2_engraver}
2423 The most useful function of the part combiner to combining threads into
2424 one voice, as common for wind parts in orchestral scores:
2426 @lilypond[verbatim,singleline,fragment]
2428 \context Voice=one \partcombine Voice
2429 \context Thread=one \notes\relative c'' {
2432 \context Thread=two \notes\relative c'' {
2438 If you have developed a bit of a feel for LilyPond's functioning, you
2439 will notice that what you see above is quite unusual. The first
2440 @code{g} appears only once, although it was specified twice (once in
2441 each Thread). That is the work of the
2442 @code{Thread_devnull_engraver}@footnote{On unix systems, the file
2443 @file{/dev/null} is special device: anything written to it is
2444 discarded.}, that works closely together with the part combiner. When
2445 the part combiner notices that two threads are identical, it tells the
2446 @code{Thread_devnull_engraver} to discard everything in the second
2449 Similarly, the markings @emph{@`{a}2}, @emph{Solo} and @emph{Solo II},
2450 are created by the @code{A2_engraver}. The @code{A2_engraver} also acts
2451 upon instructions of the part combiner. Another thing that the
2452 @code{A2_engraver} does, is forcing of stem, slur and tie directions,
2453 always when both threads are not identical; up for the musicexpr called
2454 @code{one}, down for the musicexpr called @code{two}.
2456 There is actually a third engraver involved in part combining; the
2457 @code{Voice_devnull_engraver}. This one takes care of removing
2458 redundant spanners such as beams, slurs, ties, crescendi, etc.
2460 If you just want the splitting of Threads and setting of directions, and
2461 not the textual markings, you may set the property @var{soloADue} to false:
2463 @lilypond[verbatim,singleline]
2465 \notes \context Staff <
2466 \context Voice=one \partcombine Voice
2467 \context Thread=one\relative c'' {
2470 \context Thread=two\relative c'' {
2483 There are a number of other properties that you can use to tweak the
2484 behavior of part combining, refer to the automatically generated
2485 documentation of the involved engravers and the examples in the tutorial.
2494 A @emph{custos} (plural: @emph{custodes}; latin word for "guard") is a
2495 staff context symbol that appears at the end of a staff line. It
2496 anticipates the pitch of the first note(s) of the following line and
2497 thus helps the player or singer to manage line breaks during
2498 performance, thus enhancing readability of a score.
2503 \notes { c'1 d' e' d' \break c' d' e' d' }
2507 \consists Custos_engraver;
2508 Custos \override #'style = #'mensural;
2515 Custodes were frequently used in music notation until the 16th century.
2516 There were different appearences for different notation styles.
2517 Nowadays, they have survived only in special forms of musical notation
2518 such as via the editio vaticana dating back to the beginning of the 20th
2521 For typesetting custodes, just put a @code{Custos_engraver} into the
2522 @code{StaffContext} when declaring the @code{\paper} block. In this
2523 block, you can also globally control the appearance of the custos symbol
2524 by setting the custos @code{style} property. Currently supported styles
2525 are @code{vaticana}, @code{medicaea}, @code{hufnagel} and
2532 \consists Custos_engraver;
2533 Custos \override #'style = #'mensural;
2538 The property can also be set locally, for example in a @code{\notes}
2543 \property Staff.Custos \override #'style = #'vaticana
2544 c'1 d' e' d' \break c' d' e' d'
2548 @c . {Tuning output}
2550 @section Tuning output
2552 LilyPond tries to take as much formatting as possible out of your
2553 hands. Nevertheless, there are situations where it needs some help, or
2554 where you want to override its decisions.
2556 Here we discuss how you can do that.
2558 Notational output is specified in so called grobs (graphic
2559 objects). Each grob carries with it a set of properties (grob
2560 properties) specific to that grob. For example, a stem grob has grob
2561 properties that specify its direction, length and thickness.
2563 The most common way of tuning the output is to alter the values of these
2564 properties. There are two ways of doing that: first, you can
2565 specifically select a set of grobs at one point, and set properties as
2566 you wish, or secondly, you can (temporarily) modify the definition of a
2567 grob, thereby affecting an entire group of grobs.
2570 * Tuning groups of grobs ::
2571 * Tuning per grob ::
2576 @node Tuning groups of grobs
2577 @subsection Tuning groups of grobs
2579 @cindex grob description
2581 A grob definition is an association list, that is stored in a context
2582 property. By assigning to that property (using plain @code{\property}),
2583 you can change the resulting grobs.
2584 @lilypond[verbatim, fragment]
2585 c'4 \property Voice.Stem \override #'meta = #'((interfaces . ())) c'4
2587 The @code{\property} statement effectively empties the definition of the
2588 Stem object. One of the effects is that property specifying how it
2589 should be printed is erased, with the effect of rendering it invisible.
2596 This mechanism is fairly crude, since you can only set, but not modify,
2597 the definition of a grob. For this reason, there is a more advanced
2598 mechanism: you can add a property on top of an existing definition, or
2599 remove a property: @code{\override} adds a settings, @code{\revert}
2600 removes that setting.
2602 c'4 \property Voice.Stem \override #'thickness = #4.0
2603 c'4 \property Voice.Stem \revert #'thickness
2607 For the digirati, the grob description is an Scheme association
2608 list. Since it is singly linked, we can treat it as a stack, and
2609 @code{\override} and @code{\revert} are just push and pop
2610 operations. This pushing and popping is also used in the
2611 @code{autoBeamSettings} property.
2613 If you revert a setting which was not set in the first place, then it
2614 has no effect. However, if the setting was set as a system default, it
2615 may remove the default value, and this may give surprising results,
2616 including crashes. In other words, if you use @code{\override} and
2617 @code{\revert}, be sure to balance the overrides and reverts.
2619 If balancing them is too much work, use the following shorthand:
2620 @code{\set} performs a revert followed by an override:
2622 \property Voice.Stem \set #'thickness = #2.0
2625 Formally the syntax for these constructions is
2627 \property @var{context}.@var{grobname} \override @var{symbol} = @var{value}
2628 \property @var{context}.@var{grobname} \set @var{symbol} = @var{value}
2629 \property @var{context}.@var{grobname} \revert @var{symbol}
2631 Here @var{symbol} is a Scheme expression of symbol type, @var{context}
2632 and @var{grobname} are strings and @var{value} is a Scheme expression.
2634 LilyPond will hang or crash if @var{value} contains cyclic references.
2638 @node Tuning per grob
2639 @subsection Tuning per grob
2641 @cindex \outputproperty
2643 A second way of tuning grobs is the more arcane @code{\outputproperty}
2645 Syntax is as follows
2647 \outputproperty @var{predicate} @var{symbol} = @var{value}
2649 Here @code{predicate} is a Scheme functoin taking a grob a argument
2650 argument, and returning a boolean. This statement is processed by the
2651 @code{Output_property_engraver}. It instructs the engraver to feed all
2652 grobs that it sees to @var{predicate}. Whenever the predicate returns
2653 true, the grob property @var{symbol} will be set to @var{value}.
2655 You will need to combine this statement with @code{\context} to select
2656 the appropriate context to apply this to.
2658 If possible, avoid this feature: the semantics are not very clean, and
2659 the syntax and semantics are up for rewrite.
2661 Here are some random examples:
2663 @lilypond[fragment,verbatim,singleline]
2665 \context Staff \outputproperty
2666 #(make-type-checker 'note-head-interface)
2667 #'extra-offset = #'(0.5 . 0.75)
2671 @cindex @code{extra-offset}
2673 This selects all note heads occurring at current staff level, and sets
2674 the @code{extra-offset} of those heads to @code{(0.5,0.75)}, shifting
2677 Move the text "m.d.", but not the fingering instruction "2".
2678 @lilypond[verbatim,singleline]
2679 #(define (make-text-checker text)
2680 (lambda (grob) (equal? text (ly-get-elt-property grob 'text))))
2683 \notes\relative c''' {
2684 \property Voice.Stem \set #'direction = #1
2685 \outputproperty #(make-text-checker "m.d.")
2686 #'extra-offset = #'(-3.5 . -4.5)
2696 @subsection What to tune?
2698 This all tells you how to tune grobs, but what variables are there? The
2699 question is not answered in this manual (although you may encounter
2702 Grob properties are tied directly to the implementation of LilyPond, and
2703 they are thus a moving target. Refer to the automatically generated
2704 documentation of the internals (available from the website).
2706 You need the following information
2710 which grob to modify
2712 which property to modify
2714 which context the grob comes from.
2717 Included with the automatically generated documentation is a master list
2718 of grobs. Each one can be clicked, taking you to a overview of the
2719 available properties.
2721 There is also a master list of contexts. Clicking each takes you to an
2722 overview of the context, listing which grob types are created there.
2727 @subsection Text markup
2731 LilyPond has an internal mechanism to typeset texts. You can
2732 form text markup expressions by composing scheme expressions
2733 in the following way.
2737 \notes \relative c' {
2739 c-#'(upright "upright")
2740 c-#'((bold upright) "bold")
2741 d-#'(lines "one" ((bold upright) "two"))
2742 e-#'(music (named "noteheads-2" "flags-u3"))
2744 \paper { linewidth = 10.\cm; }
2748 Normally, the Scheme markup text is stored in the @code{text} property
2749 of a grob. Formally, it is defined as follows:
2752 text: string | (head? text+)
2753 head: markup | (markup+)
2754 markup-item: property | abbrev | @var{fontstyle}
2755 property: (@var{key} . @var{value})
2756 abbrev: @code{rows lines roman music bold italic named super sub text}
2759 The markup is broken down and converted into a list of grob properties,
2760 which are prepended to the grop's property list. The
2761 @var{key}-@var{value} pair is a grob property.
2763 The following abbreviations are currently
2768 horizontal mode: set all text on one line (default)
2770 vertical mode: set every text on new line
2780 lookup by character name
2782 plain text lookup (by character value)
2789 @var{fontstyle} may be any of @code{finger volta timesig mmrest mark
2790 script large Large dynamic}
2793 It is possible to use @TeX{} commands in the strings, but this should be
2794 avoided because this makes it impossible for LilyPond to compute the
2795 exact length of the string, which may lead to collisions. Also, @TeX{}
2796 commands won't work with direct postscript output.
2800 @section Page layout
2814 @subsection Paper block
2817 The most important output definition is the @code{\paper} block, for
2818 music notation. The syntax is
2821 @code{\paper @{} [@var{paperidentifier}] @var{items} @code{@}}
2824 where each of the items is one of
2827 @item An assignment. The assignment must be terminated by a
2830 @item A context definition. See @ref{Notation Contexts} for
2831 more information on context definitions.
2833 @item \stylesheet declaration. Its syntax is
2835 \stylesheet @var{alist}
2838 See @file{font.scm} for details of @var{alist}.
2841 @c . {Paper variables}
2842 @node Paper variables
2843 @subsection Paper variables
2844 @cindex Paper variables
2846 The paper block has some variables you may want to use or change:
2849 @cindex @code{indent}
2851 The indentation of the first line of music.
2852 @cindex @code{staffspace}
2854 @item @code{staffspace}
2855 The distance between two staff lines, calculated from the center
2856 of the lines. You should use either this or @code{stafflinethickness}
2857 as a unit for distances you modify.
2859 @cindex @code{linewidth}
2860 @item @code{linewidth}
2861 Sets the width of the lines.
2863 If set to a negative value, a single
2864 unjustified line is produced.
2866 @cindex @code{textheight}
2868 @item @code{textheight}
2869 Sets the total height of the music on each page. Only used by
2871 @cindex @code{interscoreline}
2873 @item @code{interscoreline}
2874 Sets the spacing between the score lines. Defaults to 16 pt.
2875 @cindex @code{interscorelinefill}
2877 @item @code{interscorelinefill}
2878 If set to a positive number, the distance between the score
2879 lines will stretch in order to fill the full page. In that
2880 case @code{interscoreline} specifies the minimum spacing.
2882 @cindex @code{stafflinethickness}
2884 @item @code{stafflinethickness}
2885 Determines the thickness of staff lines, and also acts as a scaling
2886 parameter for other line thicknesses.
2893 @subsection Font size
2896 The Feta font provides musical symbols at six different sizes. These
2897 fonts are 11 point, 13 point, 16 point, 20 point,
2898 23 point, and 26 point. The point size of a font is the
2899 height of the five lines in a staff when displayed in the font.
2901 Definitions for these sizes are the files @file{paperSZ.ly}, where
2902 @code{SZ} is one of 11, 13, 16, 20, 23 and 26. If you include any of
2903 these files, the identifiers @code{paperEleven}, @code{paperThirteen},
2904 @code{paperSixteen}, @code{paperTwenty}, @code{paperTwentythree}, and
2905 @code{paperTwentysix} are defined respectively. The default
2906 @code{\paper} block is also set.
2908 The font definitions are generated using a Scheme function. For more
2909 details, see the file @file{font.scm}.
2915 @subsection Paper size
2920 @cindex @code{papersize}
2922 To change the paper size, you must first set the
2923 @code{papersize} variable at top level. Set it to
2924 the strings @code{a4}, @code{letter}, or @code{legal}. After this
2925 specification, you must set the font as described above. If you want
2926 the default font, then use the 20 point font. The new paper size will
2927 not take effect if the font is not loaded and selected afterwards.
2931 \include "paper16.ly"
2935 \paper @{ \paperSixteen @}
2939 The file "paper16.ly" will now include a file named @file{a4.ly}, which
2940 will set the paper variables @code{hsize} and @code{vsize} (used by
2951 @subsection Line break
2954 @cindex breaking lines
2956 Line breaks are normally computed automatically. They are chosen such
2957 that the resulting spacing has low variation, and looks neither cramped
2960 Occasionally you might want to override the automatic breaks; you can do
2961 this by specifying @code{\break}. This will force a line break at this
2962 point. Do remember that line breaks can only occur at places where there
2963 are barlines. If you want to have a line break where there is no
2964 barline, you can force a barline by entering @code{\bar "";}.
2966 Similarly, @code{\noBreak} forbids a line break at a certain point.
2968 @cindex @code{\penalty}
2970 The @code{\break} and @code{\noBreak} commands are defined in terms of
2971 the penalty command:
2973 \penalty @var{int} @code{;}
2976 This imposes encourages or discourages LilyPond to make a line break
2979 @strong{Warning} do not use @code{\penalty} directly. It is rather
2980 kludgy, and slated for rewriting.
2984 @subsection Page break
2987 @cindex breaking pages
2990 Page breaks are normally computed by @TeX{}, so they are not under direct
2991 control. However, you can insert a commands into the @file{.tex} output to
2992 instruct @TeX{} where to break pages. For more details, see the
2993 example file @file{input/test/between-systems.ly}
3007 LilyPond allows MIDI output, with the purpose of proof-hearing the music
3008 you enter. The performance lacks lots of interesting effects, such as
3009 swing, articulation, slurring, tieing, etc.
3011 Also note that it is not possible to use the percussion channel
3012 (generally channel 10 of a MIDI file).
3016 * MIDI instrument names::
3022 @subsection MIDI block
3026 The MIDI block is analogous to the paper block, but it is somewhat
3027 simpler. The @code{\midi} block can contain:
3031 @item a @code{\tempo} definition
3032 @item context definitions
3035 Assignments in the @code{\midi} block are not allowed.
3039 @cindex context definition
3041 Context definitions follow precisely the same syntax as within the
3042 \paper block. Translation modules for sound are called performers.
3043 The contexts for MIDI output are defined in @file{ly/performer.ly}.
3046 [Instrument Equaliser]
3048 FIXME: would it be useful to refer to files like scm/midi.scm,
3049 or to give examples of how to tweak MIDI output volume?
3052 @c . {MIDI instrument names}
3053 @node MIDI instrument names
3054 @subsection MIDI instrument names
3055 @cindex instrument names
3056 @cindex @code{Staff.midiInstrument}
3057 @cindex @code{Staff.instrument}
3059 The MIDI instrument name is set by the @code{Staff.midiInstrument}
3060 property or, if that property is not set, the @code{Staff.instrument}
3061 property. The instrument name should be chosen from the following list.
3062 If the selected string does not exactly match, then LilyPond uses the
3065 [FIXME: to appendix ]
3069 "acoustic grand" "contrabass" "lead 7 (fifths)"
3070 "bright acoustic" "tremolo strings" "lead 8 (bass+lead)"
3071 "electric grand" "pizzicato strings" "pad 1 (new age)"
3072 "honky-tonk" "orchestral strings" "pad 2 (warm)"
3073 "electric piano 1" "timpani" "pad 3 (polysynth)"
3074 "electric piano 2" "string ensemble 1" "pad 4 (choir)"
3075 "harpsichord" "string ensemble 2" "pad 5 (bowed)"
3076 "clav" "synthstrings 1" "pad 6 (metallic)"
3077 "celesta" "synthstrings 2" "pad 7 (halo)"
3078 "glockenspiel" "choir aahs" "pad 8 (sweep)"
3079 "music box" "voice oohs" "fx 1 (rain)"
3080 "vibraphone" "synth voice" "fx 2 (soundtrack)"
3081 "marimba" "orchestra hit" "fx 3 (crystal)"
3082 "xylophone" "trumpet" "fx 4 (atmosphere)"
3083 "tubular bells" "trombone" "fx 5 (brightness)"
3084 "dulcimer" "tuba" "fx 6 (goblins)"
3085 "drawbar organ" "muted trumpet" "fx 7 (echoes)"
3086 "percussive organ" "french horn" "fx 8 (sci-fi)"
3087 "rock organ" "brass section" "sitar"
3088 "church organ" "synthbrass 1" "banjo"
3089 "reed organ" "synthbrass 2" "shamisen"
3090 "accordion" "soprano sax" "koto"
3091 "harmonica" "alto sax" "kalimba"
3092 "concertina" "tenor sax" "bagpipe"
3093 "acoustic guitar (nylon)" "baritone sax" "fiddle"
3094 "acoustic guitar (steel)" "oboe" "shanai"
3095 "electric guitar (jazz)" "english horn" "tinkle bell"
3096 "electric guitar (clean)" "bassoon" "agogo"
3097 "electric guitar (muted)" "clarinet" "steel drums"
3098 "overdriven guitar" "piccolo" "woodblock"
3099 "distorted guitar" "flute" "taiko drum"
3100 "guitar harmonics" "recorder" "melodic tom"
3101 "acoustic bass" "pan flute" "synth drum"
3102 "electric bass (finger)" "blown bottle" "reverse cymbal"
3103 "electric bass (pick)" "skakuhachi" "guitar fret noise"
3104 "fretless bass" "whistle" "breath noise"
3105 "slap bass 1" "ocarina" "seashore"
3106 "slap bass 2" "lead 1 (square)" "bird tweet"
3107 "synth bass 1" "lead 2 (sawtooth)" "telephone ring"
3108 "synth bass 2" "lead 3 (calliope)" "helicopter"
3109 "violin" "lead 4 (chiff)" "applause"
3110 "viola" "lead 5 (charang)" "gunshot"
3111 "cello" "lead 6 (voice)"
3122 @cindex beats per minute
3123 @cindex metronome marking
3125 @cindex @code{\tempo}
3127 \tempo @var{duration} = @var{perminute} @code{;}
3130 Used to specify the tempo. For example, @code{\tempo 4 = 76;} requests
3131 output with 76 quarter notes per minute.
3139 @section Music entry
3151 @subsection Relative
3153 @cindex relative octave specification
3155 Octaves are specified by adding @code{'} and @code{,} to pitch names.
3156 When you copy existing music, it is easy to accidentally put a pitch in
3157 the wrong octave and hard to find such an error. To prevent these
3158 errors, LilyPond features octave entry.
3160 @cindex @code{\relative}
3162 \relative @var{startpitch} @var{musicexpr}
3165 The octave of notes that appear in @var{musicexpr} are calculated as
3166 follows: If no octave changing marks are used, the basic interval
3167 between this and the last note is always taken to be a fourth or less.
3168 The octave changing marks @code{'} and @code{,} can then
3169 be added to raise or lower the pitch by an extra octave. Upon entering
3170 relative mode, an absolute starting pitch must be specified that will
3171 act as the predecessor of the first note of @var{musicexpr}.
3173 This distance is determined without regarding accidentals: a
3174 @code{fisis} following a @code{ceses} will be put above the
3177 Entering scales is straightforward in relative mode.
3179 @lilypond[fragment,verbatim,center]
3181 g a b c d e f g g, g
3185 And octave changing marks are used for intervals greater than a fourth.
3187 @lilypond[fragment,verbatim,center]
3189 c g c f, c' a, e'' }
3192 If the preceding item is a chord, the first note of the chord is used
3193 to determine the first note of the next chord. But other notes
3194 within the second chord are determined by looking at the immediately
3197 @lilypond[fragment,verbatim,center]
3204 @cindex @code{\notes}
3206 The pitch after the @code{\relative} contains a notename. To parse
3207 the pitch as a notename, you have to be in note mode, so there must
3208 be a surrounding @code{\notes} keyword (which is not
3211 The relative conversion will not affect @code{\transpose} or
3212 @code{\relative} sections in its argument. If you want to use
3213 relative within transposed music, you must place an additional
3214 @code{\relative} inside the @code{\transpose}.
3219 @subsection Bar check
3223 @cindex @code{barCheckNoSynchronize}
3227 Whenever a bar check is encountered during interpretation, a warning
3228 message is issued if it doesn't fall at a measure boundary. This can
3229 help you find errors in the input. Depending on the value of
3230 @code{barCheckNoSynchronize}, the beginning of the measure will be
3231 relocated, so this can also be used to shorten measures.
3233 A bar check is entered using the bar symbol, @code{|}
3237 @c . {Point and click}
3238 @node Point and click
3239 @subsection Point and click
3248 * Notation Contexts::
3249 * Creating contexts::
3250 * Default contexts::
3251 * Context properties::
3252 * Changing context definitions::
3253 * Defining new contexts::
3256 @c . {Music expressions}
3260 @c . {Notation Contexts}
3261 @node Notation Contexts
3262 @subsection Notation Contexts
3264 @cindex notation contexts
3266 Notation contexts are objects that only exist during a run of LilyPond.
3267 During the interpretation phase of LilyPond (when lily prints
3268 "interpreting music"), music a @code{\score} block is interpreted in
3269 time order, i.e. in much the same order that humans read, play, and
3272 During this reading, the notation context is holds the state
3273 for the current point within the music. It contains information like
3276 @item What notes are playing at this point?
3277 @item What symbols will be printed at this point?
3278 @item What is the current key signature, time signature, point within
3282 Contexts are grouped hierarchically: A @code{Voice} context is
3283 contained in a @code{Staff} context (because a staff can contain
3284 multiple voices at any point), a @code{Staff} context is contained in
3285 a @code{Score}, @code{StaffGroup}, or @code{ChoirStaff} context (because
3286 these can all contain multiple staffs).
3289 Contexts associated with sheet music output are called @emph{notation
3290 contexts}, those for sound output are called performance contexts.
3293 @node Creating contexts
3294 @subsection Creating contexts
3296 @cindex @code{\context}
3297 @cindex context selection
3299 Contexts for a music expression can be selected manually, using the
3300 following music expression.
3303 \context @var{contexttype} [= @var{contextname}] @var{musicexpr}
3306 This instructs lilypond to interpret @var{musicexpr} within the context
3307 of type @var{contexttype} and with name @var{contextname}. If this
3308 context does not exist, it will be created.
3312 @lilypond[verbatim,singleline]
3314 \notes \relative c'' {
3315 c4 <d4 \context Staff = "another" e4> f
3322 In this example, the @code{c} and @code{d} are printed on the
3323 default staff. For the @code{e}, a context Staff called
3324 @code{another} is specified; since that does not exist, a new
3325 context is created. Within @code{another}, a (default) Voice context
3326 is created for the @code{e4}. When all music referring to a
3327 context is finished, the context is ended as well. So after the
3328 third quarter, @code{another} is removed.
3332 @node Default contexts
3333 @subsection Default contexts
3335 Most music expressions don't need @code{\context}: they inherit the
3336 notation context from their parent. Each note is a music expression, and
3337 as you can see in the following example, only the sequential music
3338 enclosing the three notes has an explicit context.
3340 @lilypond[verbatim,singleline]
3341 \score { \notes \context Voice = goUp { c'4 d' e' } }
3344 There are some quirks that you must keep in mind when dealing with
3347 Every top-level music is interpreted by the Score context, in other
3348 words, you may think of @code{\score} working like
3351 \context Score @var{music}
3355 Sequential music follows the contexts of its "children". Take this example
3356 @lilypond[verbatim, singleline]
3357 \score { \context Score \notes { c'4 ( d' )e' } }
3360 The sequential music is interpreted by the Score context initially
3361 (notice that the @code{\context} specification is redundant), but when a
3362 note is encountered, contexts are setup to accept that note. In this
3363 case, a Thread, Voice and Staff are created. The rest of the sequential
3364 music is also interpreted with the same Thread, Voice and Staff context,
3365 putting the notes on the same staff, in the same voice.
3367 This is a convenient mechanism, but do not expect opening chords to work
3368 without @code{\context}. For every note, a separate staff is
3371 @lilypond[verbatim, singleline]
3372 \score { \notes <c'4 es'> }
3375 Of course, if the chord is preceded by a normal note in sequential
3376 music, the chord will be interpreted by the Thread of the preceding
3378 @lilypond[verbatim,singleline]
3379 \score { \notes { c'4 <c'4 es'> } }
3384 @node Context properties
3385 @subsection Context properties
3387 Notation contexts can be modified from within the @file{.ly} file. The
3388 following music expression does that job:
3390 @cindex @code{\property}
3392 \property @var{contextname}.@var{propname} = @var{value}
3395 Sets the @var{propname} property of the context @var{contextname} to the
3396 specified Scheme expression @var{value}. All @var{propname} and
3397 @var{contextname} are strings, which are typically unquoted.
3399 Properties that are set in one context are inherited by all of the
3400 contained contexts. This means that a property valid for the
3401 @code{Voice} context can be set in the @code{Score} context (for
3402 example) and thus take effect in all @code{Voice} contexts.
3407 @c . {Context definitions}
3408 @node Changing context definitions
3409 @subsection Changing context definitions
3411 @cindex context definition
3412 @cindex translator definition
3414 The most common way to define a context is by extending an existing
3415 context. You can change an existing context from the paper block, by
3416 first initializing a translator with an existing context identifier:
3420 @var{context-identifier}
3423 Then you can add engravers, remove engravers and set context
3424 properties. The syntax for these operations are respectively
3426 \remove @var{engravername}
3427 \consists @var{engravername}
3428 @var{propname} = @var{value}
3431 Here @var{engravername} is a string, the name of an engraver in the
3432 system. @var{propname} is a string and @var{value} is a Scheme
3435 @lilypond[verbatim,singleline]
3439 \translator { \StaffContext
3440 \consists Instrument_name_engraver;
3442 \remove Clef_engraver;
3448 These type of property assignments happen before interpretation starts,
3449 so a @code{\property} expression will override any predefined settings.
3451 Engravers are the actual C++ modules that do the work in the
3452 interpretation phase.
3455 There are some pre-defined identifiers to simplify editing translators,
3456 they are defined in @file{ly/engraver.ly}. These pre-defined
3460 @cindex @code{StaffContext}
3461 @item @code{StaffContext}
3462 Default Staff context.
3463 @cindex @code{RhythmicStaffContext}
3465 @item @code{RhythmicStaffContext}
3466 Default RhythmicStaff context.
3467 @cindex @code{VoiceContext}
3469 @item @code{VoiceContext}
3470 Default Voice context.
3471 @cindex @code{ScoreContext}
3473 @item @code{ScoreContext}
3474 Default Score context.
3476 @cindex @code{HaraKiriStaffContext}
3478 @item @code{HaraKiriStaffContext}
3479 Staff context that does not print if it only contains rests.
3480 Useful for orchestral scores.@footnote{Harakiri, also called
3481 Seppuku, is the ritual suicide of the Japanese Samourai warriors.}
3484 @node Defining new contexts
3485 @subsection Defining new contexts
3487 If you want to build a context from scratch, you must also supply the
3488 following extra information:
3490 @item A name, specified by @code{\name @var{contextname};}.
3492 @item A cooperation engraver. This is specified by @code{\type
3497 A context definition has this syntax:
3501 \translator @code{@{}
3502 @var{translatorinit} @var{translatormodifierlist}
3506 @var{translatorinit} can be an identifier or
3510 where @var{typename} is one of
3512 The cooperation engraver groups other engravers, and specifies how they
3513 should cooperate. Choices are:
3516 @cindex @code{Engraver_group_engraver}
3517 @item @code{Engraver_group_engraver}
3518 The standard cooperation engraver.
3520 @cindex @code{Score_engraver}
3522 @item @code{Score_engraver}
3523 This is cooperation module that should be in the top level context,
3524 and only the toplevel context.
3526 @cindex @code{Grace_engraver_group}
3528 @item @code{Grace_engraver_group}
3529 This is a special cooperation module (resembling
3530 @code{Score_engraver}) that is used to created an embedded
3534 @var{translatormodifierlist} is a list of items where each item is
3538 @item @code{\consists} @var{engravername} @code{;}
3539 Add @var{engravername} to the list of modules in this context.
3540 The order of engravers added with @code{\consists} is
3543 @item @code{\consistsend} @var{engravername} @code{;}
3544 Analogous to @code{\consists}, but makes sure that
3545 @var{engravername} is always added to the end of the list of
3548 Some engraver types need to be at the end of the list; this
3549 insures they are put there, and stay there, if a user adds or
3550 removes engravers. This command is usually not needed for
3553 @item @code{\accepts} @var{contextname} @code{;}
3554 Add @var{contextname} to the list of context this context can
3555 contain. The first listed context is the context to create by
3558 @item @code{\denies}. The opposite of @code{\accepts}. Added for
3559 completeness, but is never used in practice.
3562 @item @code{\remove} @var{engravername} @code{;}
3563 Remove a previously added (with @code{\consists}) engraver.
3565 @item @code{\name} @var{contextname} @code{;}
3566 This sets name of the context, e.g. @code{Staff}, @code{Voice}. If
3567 the name is not specified, the translator won't do anything.
3569 @item @var{propname} @code{=} @var{value} @code{;}
3570 A property assignment.
3573 In the @code{\paper} block, it is also possible to define translator
3574 identifiers. Like other block identifiers, the identifier can only
3575 be used as the very first item of a translator. In order to define
3576 such an identifier outside of @code{\score}, you must do
3582 foo = \translator @{ @dots{} @}
3589 \translator @{ \foo @dots{} @}
3597 @cindex paper types, engravers, and pre-defined translators
3602 Properties can be preset within the @code{\translator} block
3603 corresponding to the appropriate context. In this case, the syntax
3607 @var{propname} @code{=} @var{value}
3610 The property settings are used during the interpretation phase. They
3611 are read by the LilyPond modules where interpretation contexts are
3612 built of. These modules are called @emph{translators}. Translators for
3613 notation are called @emph{engravers}, and translators for sound are
3614 called @emph{performers}.
3619 @c . {Syntactic details}
3620 @node Syntactic details
3621 @section Syntactic details
3622 @cindex Syntactic details
3626 * Music expressions::
3627 * Manipulating music expressions::
3636 @subsection Top level
3639 This section describes what you may enter at top level.
3643 @subsubsection Score
3646 @cindex score definition
3648 The output is generated combining a music expression with an output
3649 definition. A score block has the following syntax:
3652 \score @{ @var{musicexpr} @var{outputdefs} @}
3655 @var{outputdefs} are zero or more output definitions. If no output
3656 definition is supplied, the default @code{\paper} block will be added.
3660 @c . {Default output}
3661 @subsubsection Default output
3663 Default values for the @code{\paper} and @code{\midi} block are set by
3664 entering such a block at top-level.
3667 @subsubsection Header
3669 @cindex @code{\header}
3674 \header @{ @var{key1} = @var{val1};
3675 @cindex @code{ly2dvi}
3676 @var{key2} = @var{val2}; @dots{} @}
3680 A header describes the file's contents. It can also appear in a
3681 @code{\score} block. Tools like @code{ly2dvi} can use this
3682 information for generating titles. Key values that are used by
3683 @code{ly2dvi} are: title, subtitle, composer, opus, poet, instrument,
3684 metre, arranger, piece and tagline.
3686 It is customary to put the @code{\header} at the top of the file.
3688 @subsubsection Default output
3690 A @code{\midi} or @code{\paper} block at top-level sets the default
3692 paper block for all scores that lack an explicit paper block.
3696 @subsection Identifiers
3699 All of the information in a LilyPond input file, is represented as a
3700 Scheme value. In addition to normal Scheme data types (such as pair,
3701 number, boolean, etc.), LilyPond has a number of specialized data types,
3708 @item Translator_def
3712 @item Music_output_def
3713 @item Moment (rational number)
3716 LilyPond also includes some transient object types. Objects of these
3717 types are built during a LilyPond run, and do not `exist' per se within
3718 your input file. These objects are created as a result of your input
3719 file, so you can include commands in the input to manipulate them,
3720 during a lilypond run.
3723 @item Grob: short for Graphical object. See @ref{Grobs}.
3724 @item Molecule: device-independent page output object,
3725 including dimensions. Produced by some Grob functions
3727 @item Translator: object that produces audio objects or Grobs. This is
3728 not yet user accessible.
3729 @item Font_metric: object representing a font. (See @ref{Font metrics})
3734 @node Music expressions
3735 @subsection Music expressions
3737 @cindex music expressions
3739 Music in LilyPond is entered as a music expression. Notes, rests, lyric
3740 syllables are music expressions, and you can combine music expressions
3741 to form new ones, for example by enclosing a list of expressions in
3742 @code{\sequential @{ @}} or @code{< >}. In this example, a compound
3743 expression is formed out of the quarter note @code{c} and a quarter note
3747 \sequential @{ c4 d4 @}
3750 @cindex Sequential music
3751 @cindex @code{\sequential}
3752 @cindex sequential music
3755 @cindex Simultaneous music
3756 @cindex @code{\simultaneous}
3758 The two basic compound music expressions are simultaneous and
3762 \sequential @code{@{} @var{musicexprlist} @code{@}}
3763 \simultaneous @code{@{} @var{musicexprlist} @code{@}}
3765 For both, there is a shorthand:
3767 @code{@{} @var{musicexprlist} @code{@}}
3771 @code{<} @var{musicexprlist} @code{>}
3773 for simultaneous music.
3774 Other compound music expressions include
3777 \transpose @var{pitch} @var{expr}
3778 \apply @var{func} @var{expr}
3779 \context @var{type} = @var{id} @var{expr}
3780 \times @var{fraction} @var{expr}
3783 In principle, the way in which you nest sequential and simultaneous to
3784 produce music is not relevant. In the following example, three chords
3785 are expressed in two different ways:
3787 @lilypond[fragment,verbatim,center]
3788 \notes \context Voice {
3789 <a c'> <b d' > <c' e'>
3790 < { a b c' } { c' d' e' } >
3794 However, in some cases, LilyPond will also try to choose contexts, and
3795 use the structure of the music expression to do so. This can have
3796 undesired effects: for example, LilyPond will create a separate staff
3797 for each note if you start a @code{\score} with a chord:
3798 @lilypond[verbatim,center,singleline]
3803 The solution is to explicitly instantiate the context you desire.
3804 In this case this is typically a Voice context
3805 @lilypond[verbatim,center,singleline]
3807 \notes\context Voice <c''4 e''>
3810 If you use @code{\context Staff} you will get separate stems for each
3811 note head, leading to collisions, so don't use that.
3815 @c . {Manipulating music expressions}
3816 @node Manipulating music expressions
3817 @subsection Manipulating music expressions
3819 The @code{\apply} mechanism gives you access to the internal
3820 representation of music. You can write Scheme-functions that operate
3821 directly on it. The syntax is
3823 \apply #@var{func} @var{music}
3825 This means that @var{func} is applied to @var{music}. The function
3826 @var{func} should return a music expression.
3828 This example replaces the text string of a script. It also shows a dump
3829 of the music it processes, which is useful if you want to know more
3830 about how music is stored.
3832 #(define (testfunc x)
3833 (if (equal? (ly-get-mus-property x 'text) "foo")
3834 (ly-set-mus-property x 'text "bar"))
3836 (ly-set-mus-property x 'elements
3837 (map testfunc (ly-get-mus-property x 'elements)))
3842 \apply #testfunc { c4_"foo" }
3846 For more information on what is possible, see the @ref{Tricks} and the
3847 automatically generated documentation.
3849 As always: directly accessing internal representations is dangerous: the
3850 implementation is subject to changes, so you should not use this if
3854 @c . {Span requests}
3860 @subsubsection Span requests
3861 @cindex Span requests
3863 Notational constructs that start and end on different notes can be
3864 entered using span requests. The syntax is as follows:
3868 \spanrequest @var{startstop} @var{type}
3872 @cindex @code{\start}
3873 @cindex @code{\stop}
3875 This defines a spanning request. The @var{startstop} parameter is either
3876 -1 (@code{\start}) or 1 (@code{\stop}) and @var{type} is a string that
3877 describes what should be started. Much of the syntactic sugar is a
3878 shorthand for @code{\spanrequest}, for example,
3880 @lilypond[fragment,verbatim,center]
3881 c'4-\spanrequest \start "slur"
3882 c'4-\spanrequest \stop "slur"
3885 Among the supported types are @code{crescendo}, @code{decrescendo},
3886 @code{beam}, @code{slur}. This is an internal command. Users are
3887 encouraged to use the shorthands which are defined in the initialization
3888 file @file{spanners.ly}.
3893 @subsection Assignments
3896 Identifiers allow objects to be assigned to names during the parse
3897 stage. To assign an identifier, you use @var{name}@code{=}@var{value}
3898 and to refer to an identifier, you preceed its name with a backslash:
3899 `@code{\}@var{name}'. @var{value} is any valid Scheme value or any of
3900 the input-types listed above. Identifier assignments can appear at top
3901 level in the LilyPond file, but also in @code{\paper} blocks.
3903 Semicolons are forbidden after top level assignments, but mandatory in
3904 other places. The rules about semicolons and assignments are very
3905 confusing, but when LilyPond input evolves more towards Scheme, we hope
3906 that this problem will grow smaller.
3908 An identifier can be created with any string for its name, but you will
3909 only be able to refer to identifiers whose names begin with a letter,
3910 being entirely alphabetical. It is impossible to refer to an identifier
3911 whose name is the same as the name of a keyword.
3913 The right hand side of an identifier assignment is parsed completely
3914 before the assignment is done, so it is allowed to redefine an
3915 identifier in terms of its old value, e.g.
3921 When an identifier is referenced, the information it points to is
3922 copied. For this reason, an identifier reference must always be the
3923 first item in a block.
3927 \paperIdent % wrong and invalid
3931 \paperIdent % correct
3935 @c . {Lexical details}
3936 @node Lexical details
3937 @subsection Lexical details
3938 @cindex Lexical details
3943 @subsubsection Comments
3949 A one line comment is introduced by a @code{%} character.
3950 Block comments are started by @code{%@{} and ended by @code{%@}}.
3951 They cannot be nested.
3953 @c . {Direct Scheme}
3954 @subsubsection Direct Scheme
3957 @cindex Scheme, in-line code
3960 LilyPond contains a Scheme interpreter (the GUILE library) for
3961 internal use. In some places Scheme expressions also form valid syntax:
3962 whereever it is allowed,
3966 evaluates the specified Scheme code. If this is used at toplevel, then
3967 the result is discarded. Example:
3969 \property Staff.TestObject \override #'foobar = #(+ 1 2)
3972 @code{\override} expects two Scheme expressions, so there are two Scheme
3973 expressions. The first one is a symbol (@code{foobar}), the second one
3974 an integer (namely, 3).
3976 Scheme is a full-blown programming language, and a full discussion is
3977 outside the scope of this document. Interested readers are referred to
3978 the website @uref{http://www.schemers.org/} for more information on
3983 @subsubsection Keywords
3987 Keywords start with a backslash, followed by a number of lower case
3988 alphabetic characters. These are all the keywords.
3991 apply arpeggio autochange spanrequest commandspanrequest
3992 simultaneous sequential accepts alternative bar breathe
3993 char chordmodifiers chords clef cm consists consistsend
3994 context denies duration dynamicscript elementdescriptions
3995 font grace header in lyrics key mark pitch
3996 time times midi mm name pitchnames notes outputproperty
3997 override set revert partial paper penalty property pt
3998 relative remove repeat addlyrics partcombine score
3999 script stylesheet skip textscript tempo translator
4004 @subsubsection Integers
4012 Formed from an optional minus sign followed by digits. Arithmetic
4013 operations cannot be done with integers, and integers cannot be mixed
4017 @subsubsection Reals
4018 @cindex real numbers
4024 Formed from an optional minus sign and a sequence of digits followed
4025 by a @emph{required} decimal point and an optional exponent such as
4026 @code{-1.2e3}. Reals can be built up using the usual operations:
4027 `@code{+}', `@code{-}', `@code{*}', and
4028 `@code{/}', with parentheses for grouping.
4036 A real constant can be followed by one of the dimension keywords:
4037 @code{\mm} @code{\pt}, @code{\in}, or @code{\cm}, for millimeters,
4038 points, inches and centimeters, respectively. This converts the number
4039 to a real that is the internal representation of dimensions.
4043 @subsubsection Strings
4047 Begins and ends with the @code{"} character. To include a @code{"}
4048 character in a string write @code{\"}. Various other backslash
4049 sequences have special interpretations as in the C language. A string
4050 that contains no spaces can be written without the quotes. See
4051 @ref{Lexical modes} for details on unquoted strings; their
4052 interpretation varies depending on the situation. Strings can be
4053 concatenated with the @code{+} operator.
4055 The tokenizer accepts the following commands. They have no grammatical
4056 function, hence they can appear anywhere in the input.
4060 @subsubsection Main input
4063 @cindex @code{\maininput}
4065 The @code{\maininput} command is used in init files to signal that the
4066 user file must be read. This command cannot be used in a user file.
4068 @c . {File inclusion}
4069 @subsubsection Main input
4072 @subsubsection File inclusion
4073 @cindex @code{\include}
4075 \include @var{filename}
4078 Include @var{filename}. The argument @var{filename} may be a quoted string (an
4079 unquoted string will not work here!) or a string identifier. The full
4080 filename including the @file{.ly} extension must be given,
4082 @subsubsection Version information
4083 @cindex @code{\version}
4085 \version @var{string} ;
4088 Specify the version of LilyPond that a file was written for. The
4089 argument is a version string in quotes, for example @code{"1.2.0"}.
4090 This is used to detect invalid input, and to aid
4091 @code{convert-ly} a tool that automatically upgrades input files. See
4092 See @ref{convert-ly} for more information on @code{convert-ly}.
4098 @subsubsection Defining pitch names
4099 @cindex Lexical modes
4100 @cindex definining pitch names
4101 @cindex pitch names, definining
4103 @cindex chord modifier names
4105 A @code{\paper} block at top level sets the default paper block. A
4106 @code{\midi} block at top level works similarly.
4109 @subsubsection Assignments
4113 Identifier assignments may appear at top level. @ref{Assignments}
4117 @c . {Direct scheme}
4118 @subsubsection Direct scheme
4119 @cindex Direct scheme
4121 Scheme statements maybe issued to produce interesting side-effects.
4124 @c . {Lexical modes}
4126 @subsection Lexical modes
4127 @cindex Lexical modes
4130 @cindex @code{\notes}
4131 @cindex @code{\chords}
4132 @cindex @code{\lyrics}
4134 To simplify entering notes, lyrics, and chords, LilyPond has three
4135 special input modes on top of the default mode: note, lyrics and chords
4136 mode. These input modes change the way that normal, unquoted words are
4137 interpreted: for example, the word @code{cis} may be interpreted as a
4138 C-sharp, as a lyric syllable `cis' or as a C-sharp major triad
4141 A mode switch is entered as a compound music expressions
4143 @code{\notes} @var{musicexpr}
4144 @code{\chords} @var{musicexpr}
4145 @code{\lyrics} @var{musicexpr}.
4148 In each of these cases, these expressions do not add anything to the
4149 meaning of their arguments. They are just a way to indicate that the
4150 arguments should be parsed in indicated mode. The modes are treated in
4151 more detail in the @ref{Note entry}, @ref{Lyrics} and
4154 You may nest different input modes.
4158 @subsection Ambiguities
4163 The grammar contains a number of ambiguities. We hope to resolve them at
4167 @item The assignment
4173 can be interpreted as making a string identifier @code{\foo}
4174 containing @code{"bar"}, or a music identifier @code{\foo}
4175 containing the syllable `bar'.
4177 @item The assignment
4183 can be interpreted as making an integer identifier
4184 containing -6, or a Request identifier containing the
4185 fingering `6' (with neutral direction).
4187 @item If you do a nested repeat like
4199 then it is ambiguous to which @code{\repeat} the
4200 @code{\alternative} belongs. This is the classic if-then-else
4201 dilemma. It may be solved by using braces.
4203 @item (an as yet unidentified ambiguity :-)
4210 @c .{Local emacs vars}
4213 @c minor-mode: font-lock
4214 @c minor-mode: outline
4215 @c outline-layout: (-1 : 0)
4216 @c outline-use-mode-specific-leader: "@c \."
4217 @c outline-primary-bullet: "{"
4218 @c outline-stylish-prefixes: nil
4219 @c outline-override-protect: t