4 @c A menu is needed before every deeper *section nesting of @nodes
5 @c Run M-x texinfo-all-menus-update
6 @c to automagically fill in these menus
7 @c before saving changes
11 @unnumberedsubsec Bugs
16 @c .{Reference Manual}
18 @node Reference Manual
19 @chapter Reference Manual
21 This document describes GNU LilyPond and its input format. The last
22 revision of this document was for LilyPond 1.3.138.
44 * Interpretation context::
54 The purpose of LilyPond is explained informally by the term `music
55 typesetter'. This is not a fully correct name: not only does the
56 program print musical symbols, it also makes esthetic decisions.
57 Symbols and their placements are @emph{generated} from a high-level
58 musical description. In other words, LilyPond would be best described
59 by `music compiler' or `music to notation compiler'.
61 LilyPond is linked to GUILE, GNU's Scheme library for extension. The
62 Scheme library provides the glue that holds together the low-level
63 routines and separate modules general, which are C++
65 When lilypond is run to typeset sheet music, the following happens:
67 @item GUILE Initialization: various scheme files are read
68 @item parsing: first standard @code{ly} initialization files are read, and
69 then the user @file{ly} file is read.
70 @item interpretation: the music in the file is processed ``in playing
71 order'', i.e. the order that you use to read sheet music, or the
72 order in which notes are played.
75 in this step, the results of the interpretation, a typesetting
76 specification, is solved.
78 @item the visible results ("virtual ink") is written to the output file.
81 During these stages different types of data play the the main role:
82 during parsing, @strong{Music} objects are created. During the
83 interpretation, @strong{context} is constructed, and with this context
84 af network of @strong{graphical objects} (``grobs'') is created. The
85 grobs contain unknown variables, and the network forms a set of
86 equations. After solving the equations and filling in these variables,
87 the printed output (in the form of @strong{molecules}) is written to an
90 These threemanship of tasks (parsing, translating, typesetting) and
91 data-structures (music, context, graphical objects) permeates the entire
92 design of the program. This manual is ordered in terms of user
93 tasks. With each concept will be explained to which of the three parts
102 The most basic forms of music are notes. We discuss how you enter them
103 here. Notes on their own don't form valid input, but for the sake of
104 brevity we omit obligotary lint such as @code{\score} blocks and
105 @code{\paper} declarations.
110 * Defining pitch names::
113 * Easy Notation note heads ::
126 @cindex Note specification
128 @cindex entering notes
130 The verbose syntax for pitch specification is
132 @cindex @code{\pitch}
134 \pitch @var{scmpitch}
137 @var{scmpitch} is a pitch scheme object, see @ref{Pitch data type}.
139 In Note and Chord mode, pitches may be designated by names. The default
140 names are the Dutch note names. The notes are specified by the letters
141 @code{a} through @code{g} (where the octave is formed by notes ranging
142 from @code{c}, to @code{b}). The pitch @code{c} is an octave below
143 middle C and the letters span the octave above that C.
145 @cindex note names, Dutch
147 In Dutch, a sharp is formed by adding @code{-is} to the end of a pitch
148 name. A flat is formed by adding @code{-es}. Double sharps and double
149 flats are obtained by adding @code{-isis} or @code{-eses}. @code{aes}
150 and @code{ees} are contracted to @code{as} and @code{es} in Dutch, but
151 both forms are accepted.
153 LilyPond has predefined sets of notenames for various other languages.
154 To use them, simply include the language specific init file. For
155 example: @code{\include "english.ly"}. The available language files and
156 the names they define are:
159 Note Names sharp flat
160 nederlands.ly c d e f g a bes b -is -es
161 english.ly c d e f g a bf b -s/-sharp -f/-flat
162 deutsch.ly c d e f g a b h -is -es
163 norsk.ly c d e f g a b h -iss/-is -ess/-es
164 svenska.ly c d e f g a b h -iss -ess
165 italiano.ly do re mi fa sol la sib si -d -b
166 catalan.ly do re mi fa sol la sib si -d/-s -b
174 The optional octave specification takes the form of a series of
175 single quote (`@code{'}') characters or a series of comma
176 (`@code{,}') characters. Each @code{'} raises the pitch by one
177 octave; each @code{,} lowers the pitch by an octave.
179 @lilypond[fragment,verbatim,center]
180 c' c'' es' g' as' gisis' ais'
183 @c . {Defining pitch names}
184 @node Defining pitch names
185 @subsection Defining pitch names
187 @cindex defining pitch names
188 @cindex pitch names, defining
190 Note names and chord modifiers can be customised for nationalities. The
191 syntax is as follows.
193 @cindex @code{\pitchnames}
194 @cindex @code{\chordmodifiers}
196 \pitchnames @var{scheme-alist}
197 \chordmodifiers @var{scheme-alist}
200 See @file{ly/nederlands.ly} and @file{ly/chord-modifiers.ly} for
201 specific examples how to do this.
207 @subsection Durations
211 @cindex @code{\duration}
213 The syntax for a verbose duration specification is
215 \duration @var{scmduration}
217 Here, @var{scmduration} is a Scheme object of type Duration. See
218 @ref{Duration} for more information.
221 In Note, Chord, and Lyrics mode, durations may be designated by numbers
222 and dots: durations are entered as their reciprocal values. For notes
223 longer than a whole note, use identifiers.
229 c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64
231 r1 r2 r4 r8 r16 r32 r64 r64
237 \notes \relative c'' {
238 a\longa a\breve \autoBeamOff
239 a1 a2 a4 a8 a16 a32 a64 a64
241 r1 r2 r4 r8 r16 r32 r64 r64
246 \remove "Clef_engraver";
247 \remove "Staff_symbol_engraver";
248 \remove "Time_signature_engraver";
249 \consists "Pitch_squash_engraver";
256 As you can see, the longa is not printed. To get a longa note head, you
257 have to use a mensural note heads. This is done accomplished by setting
258 the @code{style} property of the NoteHead grob to @code{mensural}.
260 If the duration is omitted then it is set to the previous duration
261 entered. At the start of parsing a quarter note is assumed. The
262 duration can be followed by a dot (`@code{.}') to obtain dotted note
266 @lilypond[fragment,verbatim,center]
272 You can alter the length of duration by appending
273 `@code{*}@var{fraction}'. This will not affect the appearance of the
274 notes or rests produced.
280 A note specification has the form
283 @var{pitch}[@var{octavespec}][!][?][@var{duration}]
286 LilyPond will determine what accidentals to typeset depending on the key
287 and context. The alteration refers to what note is heard, not to whether
288 an accidental is printed. A reminder accidental
289 @cindex reminder accidental
291 can be forced by adding an exclamation mark @code{!} after the pitch. A
292 cautionary accidental,
293 @cindex cautionary accidental
294 i.e., an accidental within parentheses can be obtained by adding the
295 question mark `@code{?}' after the pitch.
297 @lilypond[fragment,verbatim,center]
298 cis' d' e' cis' c'? d' e' c'!
302 @node Easy Notation note heads
303 @subsection Easy Notation note heads
305 @cindex easy notation
308 A entirely different type of note head is the "easyplay" note head: a
309 note head that includes a note name. It is used in some publications by
310 Hal-Leonard Inc. music publishers.
312 @lilypond[singleline,verbatim]
313 \include "paper26.ly"
315 \notes { c'2 e'4 f' | g'1 }
316 \paper { \translator { \EasyNotation } }
320 Note that @code{EasyNotation} overrides a @code{Score} context. You
321 probably will want to print it with magnification to make it better
327 If you view the result with Xdvi, then staff lines will show through the
328 letters. Printing the postscript file obtained either by using dvips or
329 the @code{-f ps} option of lilypond will produce the desired result.
339 A tie connects two adjacent note heads of the same pitch. When used
340 with chords, it connects all of the note heads whose pitches match.
341 Ties are indicated using the tilde symbol `@code{~}'.
342 If you try to tie together chords which have no common pitches, a
343 warning message will appear and no ties will be created.
345 @lilypond[fragment,verbatim,center]
346 e' ~ e' <c' e' g'> ~ <c' e' g'>
349 If you dislike the amount of ties created for a chord, you set
350 @code{Voice.sparseTies} to true, resulting in a smaller number of
352 @lilypond[fragment,verbatim,center]
353 \property Voice.sparseTies = ##t
354 <c' e' g'> ~ <c' e' g'>
357 In its meaning a tie is just a way of extending a note duration, similar
358 to the augmentation dot: the following example are three ways of notating
359 exactly the same concept.
360 @lilypond[fragment, singleline]
366 At present, the tie is implemented as a separate thing, temporally
367 located in between the notes. There is also no way to convert
368 between tied notes, dotted notes and plain notes.
370 Tieing only a subset of the note heads of a chord is not supported in a
371 simple way. It can be achieved by moving the tie-engraver into Thread
372 context and turning off ties per Thread.
380 @cindex @code{\times}
382 Tuplets are made out of a music expression by multiplying their duration
385 @cindex @code{\times}
387 \times @var{fraction} @var{musicexpr}
390 The duration of @var{musicexpr} will be multiplied by the fraction.
391 In print, the fraction's denominator will be printed over the notes,
392 optionally with a bracket. The most common tuplet is the triplet in
393 which 3 notes have the length of 2, so the notes are 2/3 of
394 their written length:
396 @lilypond[fragment,verbatim,center]
397 g'4 \times 2/3 {c'4 c' c'} d'4 d'4
400 The property @code{tupletSpannerDuration} specifies how long brackets
401 should last. With this, you can make lots of tuplets while typing
402 @code{\times} only once. This saves typing work when you must make lots
405 @lilypond[fragment, relative, singleline, verbatim]
406 \property Voice.tupletSpannerDuration = #(make-moment 1 4)
407 \times 2/3 { c''8 c c c c c }
415 Rests are entered like notes, with note name `@code{r}'.
425 \skip @var{duration} @code{;}
430 Skips the amount of time specified by @var{duration}. If no other music
431 is played, a gap will be left for the skipped time with no notes
432 printed. The short hand is only available in Note and Chord mode.
437 @subsection Note mode
442 @cindex @code{\notes}
444 Note mode is the lexical mode generally used for inputting notes. The
450 This instructs the tokenizer to interpret @var{expr} in note mode. If a
451 a sequence of alfabetical characters, like @code{foobar}, LilyPond first
452 checks if @code{foobar} is a pitch name. If it is not a pitch name,
453 then it is treated as a string.
455 Numbers and dots indicate durations, so you can enter floating point
456 numbers in this mode.
460 @section Staff notation
462 @cindex Staff notation
474 @subsection Key signature
479 Changing the key signature is done with the @code{\key} command.
481 @code{\key} @var{pitch} @var{type} @code{;}
484 @cindex @code{\minor}
485 @cindex @code{\major}
486 @cindex @code{\minor}
487 @cindex @code{\ionian}
488 @cindex @code{\locrian}
489 @cindex @code{\aeolian}
490 @cindex @code{\mixolydian}
491 @cindex @code{\lydian}
492 @cindex @code{\phrygian}
493 @cindex @code{\dorian}
495 Here, @var{type} should be @code{\major} or @code{\minor} to get
496 @var{pitch}-major or @var{pitch}-minor, respectively. The second
497 argument is optional; the default is major keys. The @var{\context}
498 argument can also be given as an integer, which tells the number of
499 semitones that should be added to the pitch given in the subsequent
500 @code{\key} commands to get the corresponding major key, e.g.,
501 @code{\minor} is defined as 3. The standard mode names @code{\ionian},
502 @code{\locrian}, @code{\aeolian}, @code{\mixolydian}, @code{\lydian},
503 @code{\phrygian}, and @code{\dorian} are also defined.
505 This command sets context property @code{Staff.keySignature}.
507 @cindex @code{keySignature}
514 \clef @var{clefname} @code{;}
520 \property Staff.clefGlyph = @var{glyph associated with clefname}
521 \property Staff.clefPosition = @var{clef Y-position for clefname}
522 \property Staff.clefOctavation = @var{extra pitch of clefname}
525 Supported clef-names include
528 @item treble, violin, G, G2: G clef on 2nd line
529 @item french: G clef on 1st line
530 @item soprano: C clef on 1st line
531 @item mezzosoprano: C clef on 2nd line
532 @item alto: C clef on 3rd line
533 @item tenor: C clef on 4th line
534 @item baritone: C clef on 5th line
535 @item varbaritone: F clef on 3rd line
536 @item bass, F: F clef on 4th line
537 @item subbass: F clef on 5th line
538 @item percussion: percussion clef
541 Supported associated glyphs (for @code{Staff.clefGlyph}) are:
544 @item clefs-C: modern style C clef
545 @item clefs-F: modern style F clef
546 @item clefs-G: modern style G clef
547 @item clefs-vaticana_do: Editio Vaticana style do clef
548 @item clefs-vaticana_fa: Editio Vaticana style fa clef
549 @item clefs-medicaea_do: Editio Medicaea style do clef
550 @item clefs-medicaea_fa: Editio Medicaea style fa clef
551 @item clefs-mensural1_c: modern style mensural C clef
552 @item clefs-mensural2_c: historic style small mensural C clef
553 @item clefs-mensural3_c: historic style big mensural C clef
554 @item clefs-mensural1_f: historic style traditional mensural F clef
555 @item clefs-mensural2_f: historic style new mensural F clef
556 @item clefs-mensural_g: historic style mensural G clef
557 @item clefs-hufnagel_do: historic style hufnagel do clef
558 @item clefs-hufnagel_fa: historic style hufnagel fa clef
559 @item clefs-hufnagel_do_fa: historic style hufnagel combined do/fa clef
560 @item clefs-percussion: modern style percussion clef
563 @emph{Modern style} means ``as is typeset in current editions.''
564 @emph{Historic style} means ``as was typeset or written in contemporary
565 historic editions''. @emph{Editio XXX style} means ``as is/was printed in
568 @cindex Vaticana, Editio
569 @cindex Medicaea, Editio
570 @cindex hufnagel clefs
573 @c . {Time signature}
575 @subsection Time signature
576 @cindex Time signature
580 The time signature is changed by the @code{\time} command. Syntax:
582 \time @var{numerator}@code{/}@var{denominator} @code{;}
584 Internally, this is a shortcut for doing
586 \property Score.timeSignatureFraction = #'(@var{numerator} . @var{denominator})
589 [TODO: discuss options for layout]
596 @cindex partial measure
597 @cindex measure, partial
598 @cindex shorten measures
599 @cindex @code{\partial}
601 Partial measures are entered using the @code{\partial} command:
603 \partial @var{duration} @code{;}
606 Internally, this is a shortcut for
609 \property Score.measurePosition = -@var{length of duration}
614 @node Unmetered music
615 @subsection Unmetered music
617 Bar lines and bar numbers are calculated automatically. For unmetered
618 music (e.g. cadenzas), this is not desirable. The property
619 @code{Score.timing} can be used to switch off this automatic timing
621 @lilypond[fragment,relative,singleline,verbatim]
623 \property Score.timing = ##f
625 \property Score.timing = ##t
629 The identifiers @code{\cadenzaOn} and @code{\cadenzaOff} can be used to
630 achieve the same effect.
636 @subsection Bar lines
640 @cindex measure lines
647 This is a shortcut for doing
649 \property Score.whichBar = @var{bartype}
652 You are encouraged to use @code{\repeat} for repetitions. See
653 @ref{Repeats}, and the documentation of @code{whichBar} in the generated
657 @cindex Bar_line_engraver
659 @cindex repeatCommands
660 @cindex defaultBarType
662 Bar lines are created by the @code{Bar_line_engraver}. That engraver examines
663 @code{whichBar} at every moment. Whenever it is set to a string, it will
664 create a bar with that type. @code{whichBar} is usually set
665 automatically: at the start of a measure it is set to
666 @code{defaultBarType}. The contents of @code{repeatCommands} is used to
667 override default measure bars.
669 @code{whichBar} can also be set directly, using @code{\property} or
670 @code{\bar ; }. These settings take precedence over automatic @code{whichBar}
679 [TODO: collisions, rest-collisinos, voiceX identifiers, how to
680 which contexts to instantiate. some small examples? ]
684 @cindex @code{\shiftOff}
685 @item @code{\shiftOff}
686 Disable horizontal shifting of note heads that collide.
688 @cindex @code{\shiftOn}
689 @item @code{\shiftOn}
690 Enable note heads that collide with other note heads to be
691 shifted horiztonally. Also @code{\shiftOnn} and @code{\shiftOnnn}
692 set different shift values.
694 @cindex @code{\stemBoth}
695 @item @code{\stemBoth}
696 Allow stems and beams to point either upwards or
697 downwards, decided automatically by LilyPond.
699 @cindex @code{\stemDown}
700 @item @code{\stemDown}
701 Force stems and beams to point down.
703 @cindex @code{\stemUp}
705 Force stems and beams to point up.
708 @cindex @code{\slurBoth}
709 @cindex @code{\slurDown}
710 @cindex @code{\slurUp}
711 Similarly, for slurs use
716 @cindex @code{\tieBoth}
717 @cindex @code{\tieDown}
718 @cindex @code{\tieUp}
724 @cindex @code{\dynacmicBoth}
725 @cindex @code{\dynamicDown}
726 @cindex @code{\dynamicUp}
732 @c text scripts? articulation scripts? fingering?
734 @cindex @code{\voiceOne}
735 @cindex @code{\voiceTwo}
736 @cindex @code{\voiceThree}
737 @cindex @code{\voiceFour}
738 @cindex @code{\oneVoice}
739 @cindex @code{\shiftOn}
740 @cindex @code{\shiftOff}
742 If two voices sharing one staff have the same stem directions, their
743 note heads may collide. You can shift the note heads of one voice by
744 setting @code{\shiftOn}. This can be undone by setting
747 For simple polyphonic music, shorthands are available that combine
748 directions and shift settings: @code{\voiceOne}, @code{\voiceTwo},
749 @code{\voiceThree}, @code{\voiceFour} and @code{\oneVoice}.
755 Beams are used to group short notes into chunks that are aligned with
756 the metrum. LilyPond guesses where beams should be inserted, but if
757 you're not satisfied with the automatic beaming, you can either instruct
758 lilypond which patterns to beam automatically. In specific cases, you
759 can also specify explicitly what to beam and what not.
762 @c . {Automatic beams}
763 @subsection Automatic beams
765 @cindex @code{Voice.autoBeamSettings}
766 @cindex @code{(end * * * *)}
767 @cindex @code{(begin * * * *)}
769 A large number of Voice properties are used to decide how to generate
770 beams. Their default values appear in @file{scm/auto-beam.scm}.
772 By default, automatic beams can start on any note@footnote{In exotic
773 time signatures such as 1/8 and 1/16 this is not true} but can only end
774 in a few positions within the measure: they can end on a beat, or at
775 durations specified by the properties in
776 @code{Voice.autoBeamSettings}. The defaults for @code{autoBeamSettings}
777 are defined in @file{scm/auto-beam.scm}.
779 The syntax for changing the value @code{autoBeamSettings} is set using
780 @code{\override} and unset using @code{\revert}:
782 \property Voice.autoBeamSettings \override #'(@var{BE} @var{N} @var{M} @var{P} @var{Q}) = @var{dur}
783 \property Voice.autoBeamSettings \revert #'(@var{BE} @var{N} @var{M} @var{P} @var{Q})
785 Here, @var{BE} is the symbol @code{begin} or @code{end}. It determines
786 whether the rule applies to begin or end-points. The quantity
787 @var{N}/@var{M} refers to a time signature (@code{* *} may be entered to
788 designate all time signatures), @var{P}/@var{Q} refers to the length of
789 the beamed notes (@code{* *} designate notes of any length).
791 If you want automatic beams to end on every quarter note, you can
794 \property Voice.autoBeamSettings \override
795 #'(end * * * *) = #(make-moment 1 4)
797 The duration a quarter note is 1/4 of a whole note. It is entered as
798 @code{(make-moment 1 4)}.
800 The same syntax can be used to specify beam starting points. In this
801 example, you automatic beams can only end on a dotted quarter note.
803 \property Voice.autoBeamSettings \override
804 #'(begin * * * *) = #(make-moment 3 8)
806 In 4/4 time signature, this means that automatic beams could end only on
807 3/8 and on the fourth beat of the measure (after 3/4, that is 2 times
808 3/8 has passed within the measure).
810 You can also restrict rules to specific time signatures. A rule that
811 should only be applied in @var{N}/@var{M} time signature is formed by
812 replacing the first asterisks by @var{N} and @var{M}. For example, a
813 rule for 6/8 time exclusively looks like
815 \property Voice.autoBeamSettings \override
816 #'(begin 6 8 * *) = ...
819 If you want a rule to apply to certain types of beams, you can use the
820 second pair of asterisks. Beams are classified according to the shortest
821 note they contain. For a beam ending rule that only applies to beams
822 with 32nd notes (and no shorter notes), you would use @code{(end * * 1
825 [say something about irregular meters. eg 5/8 = 2+3/8, 3+2/8]
827 Automatic beams can not be put on the last note in a score.
829 @cindex automatic beam generation
831 @cindex @code{Voice.noAutoBeaming}
833 Automatic beaming is on by default, but it can switched off by setting
834 @code{Voice.noAutoBeaming} to true. You you may find this necessary for
835 a melody that goes with lyrics.
838 @cindex Automatic beams
839 @subsection Manual beams
840 @cindex beams, manual
844 In some cases it may be necessary to override LilyPond's automatic
845 beaming algorithm. For example, the auto beamer will not beam over
846 rests or bar lines, so if you want that, specify the begin and end point
847 manually using @code{[} and @code{]}:
850 @lilypond[fragment,relative,verbatim]
852 r4 [r8 g'' a r8] r8 [g | a] r8
855 Whenever an manual beam is busy, the auto beam will not produce
858 @cindex @code{stemLeftBeamCount}
860 If you have specific wishes for the number of beams, you can fully
861 control the number of beams through the properties
862 @code{Voice.stemLeftBeamCount} and @code{Voice.stemRightBeamCount}.
864 @lilypond[fragment,relative,verbatim]
867 [f8 r16 \property Voice.stemLeftBeamCount = #1 f g a]
871 @cindex @code{stemRightBeamCount}
873 The beam symbol can be tweaked through @code{Voice.Beam}'s
874 grob-properties @code{height} and @code{staff-position},
877 Set @code{height} to zero, to get horizontal beams:
880 @lilypond[fragment,relative,verbatim]
881 \property Voice.Beam \set #'direction = #1
882 \property Voice.Beam \set #'height = #0
887 Here's how you'd specify a weird looking beam that instead of being
888 horizontal, falls two staff spaces:
891 @lilypond[fragment,relative,verbatim]
892 \property Voice.Beam \set #'staff-position = #2
893 \property Voice.Beam \set #'height = #-2
897 @cindex @code{default-neutral-direction}
899 @node Expressive marks
900 @section Expressive marks
915 A slur indicates that notes are to be played bound or @emph{legato}. In
916 lilypond, they are entered using parentheses:
917 @lilypond[fragment,verbatim,center]
918 f'()g'()a' [a'8 b'(] a'4 g'2 )f'4
922 Slurs avoid crossing stems, and are attached to note heads whenever
923 possible. In some instances involving beams slurs may be attached to a
924 stem end. If you want to override this layout you can do this through
925 @code{Voice.Slur}'s grob-property @code{attachment}:
927 Maybe reinclude other slur features and move back to tricks? Esp. the
928 second example, how to fix, can be very helpful.
931 @lilypond[fragment,relative,verbatim]
932 \property Voice.Slur \set #'direction = #1
933 \property Voice.Stem \set #'length = #5.5
935 \property Voice.Slur \set #'attachment = #'(stem . stem)
940 If a slur would strike through a stem or beam, the slur will be moved
941 away upward or downward. If this happens, attaching the slur to the
942 stems might look better:
945 @lilypond[fragment,relative,verbatim]
946 \property Voice.Stem \set #'direction = #1
947 \property Voice.Slur \set #'direction = #1
949 \property Voice.Slur \set #'attachment = #'(stem . stem)
955 Similarly, the curvature of a slur is adjusted to stay clear of note
956 heads and stems. When that would increase the curvature too much, the
957 slur is reverted to its default shape. The threshold for this decision
958 is in @code{Voice.Slur}'s grob-property @code{beautiful}. It is loosely
959 related to the enclosed area between the slur and the notes. Usually,
960 the default setting works well, but in some cases you may prefer a
961 curved slur when LilyPond decides for a vertically moved one. You can
962 express this by increasing the @code{beautiful} value:
964 @lilypond[verbatim,singleline,relative]
965 \property Voice.Beam \override #'direction = #-1
966 \property Voice.Slur \override #'direction = #1
967 c'16( a' f' a a f a, )c,
969 \property Voice.Slur \override #'beautiful = #5.0
975 The definition for @code{beautiful} is vague, the default setting is
976 experimental computer science.
978 @cindex Adusting slurs
981 @subsection Phrasing slur
983 @cindex phrasing slur
984 @cindex phrasing mark
986 A phrasing slur (or phrasing mark) connects chords and is used to
987 indicate a musical sentence. It is entered using @code{\(} and
990 @lilypond[fragment,verbatim,center,relative]
991 \time 6/4; c''\((d)e f(e)\)d
994 Typographically, the phrasing slur behaves almost exactly like a normal
995 slur. The grob associated with it is @code{Voice.PhrasingSlur}.
998 @subsection Breath marks
1000 Breath marks are entered using @code{\breathe}:
1002 @lilypond[fragment,relative]
1006 Currently, only tick marks are supported, comma style breath marks are
1007 not. The grob for this object is called @code{Voice.BreathingSign}.
1012 Currently, only tick marks are supported, comma style breath marks are
1020 @cindex beats per minute
1021 @cindex metronome marking
1023 @cindex @code{\tempo}
1025 \tempo @var{duration} = @var{perminute} @code{;}
1028 Used to specify the tempo. For example, @code{\tempo 4 = 76;} requests
1029 output with 76 quarter notes per minute.
1033 The tempo setting is not printed, but is currently only used in the MIDI
1039 @subsection Text spanner
1040 @cindex Text spanner
1042 Some textual indications, e.g. rallentando, accelerando, often extend
1043 over a many measures. This is indicated by following the text with a
1044 dotted line. You can create such texts in LilyPond using
1045 text spanners. The syntax is as follows:
1047 \spanrequest \start "text"
1048 \spanrequest \stop "text"
1050 LilyPond will respond by creating a @code{Voice.TextSpanner} grob. The
1051 string to be printed, as well as the style is set through grob
1054 An application---or rather, a hack---is to fake octavation indications.
1055 @lilypond[fragment,relative,verbatim]
1056 \relative c' { a'''' b c a
1057 \property Voice.TextSpanner \set #'type = #'dotted-line
1058 \property Voice.TextSpanner \set #'edge-height = #'(0 . 1.5)
1059 \property Voice.TextSpanner \set #'edge-text = #'("8va " . "")
1060 \property Staff.centralCPosition = #-13
1061 a\spanrequest \start "text" b c a \spanrequest \stop "text" }
1077 @subsection Articulation
1078 @cindex Articulation
1080 @cindex articulations
1084 A variety of symbols can appear above and below notes to indicate
1085 different characteristics of the performance. These symbols can be
1086 added to a note with `@var{note}@code{-\}@var{name}'. Numerous symbols
1087 are defined in @file{script.ly} and @file{script.scm}. Symbols can be
1088 forced to appear above or below the note by writing
1089 `@var{note}@code{^\}@var{name}' and `@var{note}@code{_\}@var{name}'
1090 respectively. Here is a chart showing symbols above notes, with the
1091 name of the corresponding symbol appearing underneath.
1096 \property Score.LyricSyllable \override #'font-family =
1098 \property Score.LyricSyllable \override #'font-shape = #'upright
1099 c''-\accent c''-\marcato c''-\staccatissimo c''-\fermata
1100 c''-\stopped c''-\staccato c''-\tenuto c''-\upbow
1101 c''-\downbow c''^\lheel c''-\rheel c''^\ltoe
1102 c''-\rtoe c''-\turn c''-\open c''-\flageolet
1103 c''-\reverseturn c''-\trill c''-\prall c''-\mordent
1104 c''-\prallprall c''-\prallmordent c''-\upprall c''-\downprall
1105 c''-\thumb c''-\segno c''-\coda
1107 \context Lyrics \lyrics {
1108 accent__ marcato__ staccatissimo__ fermata
1109 stopped__ staccato__ tenuto__ upbow
1110 downbow__ lheel__ rheel__ ltoe
1111 rtoe__ turn__ open__ flageolet
1112 reverseturn__ trill__ prall__ mordent
1113 prallprall__ prallmordent__ uprall__ downprall
1114 thumb__ segno__ coda
1118 linewidth = 5.875\in;
1124 To save typing work, some shorthands are available:
1125 @lilypond[singleline]
1127 \notes \context Voice {
1128 \property Voice.TextScript \set #'font-family = #'typewriter
1129 \property Voice.TextScript \set #'font-shape = #'upright
1135 c''4-^_"c-\\^{ }" s4
1142 Fingering instructions can also be entered in this shorthand.
1143 @lilypond[verbatim, singleline, fragment]
1144 c'4-1 c'4-2 c'4-3 c'4-4
1148 @cindex @code{\script}
1157 Defines a script printing request. The argument is a string which
1158 points into the script-alias table defined in @file{scm/script.scm}.
1159 Usually the @code{\script} keyword is not used directly. Various
1160 helpful identifier definitions appear in @file{script.ly}.
1162 For information on how to add scripts, consult @file{scm/script.scm}.
1167 All of these note ornaments appear in the printed output but have no
1168 effect on the MIDI rendering of the music.
1170 Unfortunately, there is no support adding fingering instructions or
1171 ornaments to individual note heads. Some hacks exist, though. See
1172 @file{input/test/script-horizontal.ly}.
1177 @subsection Text scripts
1178 @cindex Text scripts
1180 In addition, it is possible to place arbitrary strings of text or markup
1181 text (see @ref{Text markup}) above or below notes by using a string:
1182 @code{c^"text"}. The text is typeset in italic by default.
1184 The amount of space taken by these indications by default does not
1185 influence, spacing, but setting @code{Voice.textNonEmpty} to true will
1186 take the widths into account. The identifier @code{\fattext} is defined
1187 in the standard includes.
1188 @lilypond[fragment,singleline,verbatim]
1189 \relative c' { c4^"longtext" \fatText c4_"longlongtext" c4 }
1192 Text scripts are created in form of @code{Voice.TextScript} grobs.
1194 For purposes of defining identifiers, a more verbose form also exists:
1197 \textscript @var{text}
1200 Defines a text to be printed over or under a note. @var{text} is a
1201 string or a markup text.
1205 foo = \textscript #'(finger "6")
1212 This is equivalent to @code{c4-6 c4-"foo"}.
1217 @subsection Grace notes
1226 @cindex @code{\grace}
1229 @cindex @code{graceAlignPosition}
1231 Grace notes are ornaments that are written out, but do not take up any
1232 logical time in a measure. LilyPond has limited support for grace notes.
1233 The syntax is as follows.
1235 \grace @var{musicexpr}
1238 When grace music is interpreted, a score-within-a-score is set up:
1239 @var{musicexpr} has its own time bookkeeping, and you could (for
1240 example) have a separate time signature within grace notes. While in
1241 this score-within-a-score, you can create notes, beams, slurs, etc.
1242 Unbeamed eighth notes and shorter by default have a slash through the
1243 stem. This behavior can be controlled with the
1244 @code{Stem}.@code{flag-style} property.
1247 @lilypond[fragment,verbatim]
1249 \grace c8 c4 \grace { [c16 c16] } c4
1250 \grace { \property Grace.Stem \override #'flag-style = #'() c16 } c4
1257 At present, nesting @code{\grace} notes is not supported. The following
1258 may cause run-time errors:
1260 @code{\grace @{ \grace c32 c16 @} c4}
1262 Since the meaning of such a construct is unclear, we don't consider this
1263 a loss. Similarly, juxtaposing two @code{\grace} sections is
1264 syntactically valid, but makes no sense and may cause runtime errors.
1265 Ending a staff or score with grace notes may also generate a run-time
1266 error, since there will be no main note to attach the grace notes to.
1269 A grace note expression has duration 0; the next real note is assumed to
1270 be the main note. If you want the note to appear after the main note,
1271 set @code{Voice.graceAlignPosition} to @code{1}.
1275 The present implementation of grace notes is not robust and generally
1276 kludgy. We expect it to change after LilyPond 1.4. Syntax changes might
1277 also be implemented.
1290 @subsubsection Glissando
1293 @cindex @code{\glissando}
1295 A glissando line can be requested by attaching a @code{\glissando} to a
1299 @lilypond[fragment,relative,verbatim]
1306 Printing of an additional text (such as @emph{gliss.}) must be done
1313 @subsubsection Dynamics
1326 @cindex @code{\ffff}
1336 Absolute dynamic marks are specified by using an identifier after a
1337 note: @code{c4-\ff}. The available dynamic marks are: @code{\ppp},
1338 @code{\pp}, @code{\p}, @code{\mp}, @code{\mf}, @code{\f}, @code{\ff},
1339 @code{\fff}, @code{\fff}, @code{\fp}, @code{\sf}, @code{\sff},
1340 @code{\sp}, @code{\spp}, @code{\sfz}, and @code{\rfz}.
1343 @cindex Crescendo and Decrescendo
1347 @cindex @code{\decr}
1348 @cindex @code{\rced}
1354 A crescendo mark is started with @code{\cr} and terminated with
1355 @code{\rc} (the textual reverse of @code{cr}). A decrescendo mark is
1356 started with @code{\decr} and terminated with @code{\rced}. There are
1357 also shorthands for these marks. A crescendo can be started with
1358 @code{\<} and a decrescendo can be started with @code{\>}. Either one
1359 can be terminated with @code{\!}. Note that @code{\!} must go before
1360 the last note of the dynamic mark whereas @code{\rc} and @code{\rced} go
1361 after the last note. Because these marks are bound to notes, if you
1362 want to get several marks during one note, you must use spacer notes.
1364 @lilypond[fragment,verbatim,center]
1365 c'' \< \! c'' d'' \decr e'' \rced
1366 < f''1 { s4 \< \! s2 \> \! s4 } >
1371 You can also use a text saying @emph{cresc.} instead of hairpins. Here
1372 is an example how to do it:
1374 @lilypond[fragment,relative,verbatim]
1376 \property Voice.crescendoText = "cresc."
1377 \property Voice.crescendoSpanner = #'dashed-line
1393 @cindex @code{\repeat}
1395 To specify repeats, use the @code{\repeat} keyword. Since repeats
1396 should work differently when played or printed, there are a few
1397 different variants of repeats.
1401 Repeated music is fully written (played) out. Useful for MIDI
1405 This is the normal notation: Repeats are not written out, but
1406 alternative endings (voltas) are printed, left to right.
1409 Alternative endings are written stacked. Which is unfortunately not
1410 practical for anything right now.
1416 Make measure repeats. These look like percent signs.
1422 * Manual repeat commands::
1424 * Tremolo subdivision::
1429 @subsection Repeat syntax
1431 The syntax for repeats is
1434 \repeat @var{variant} @var{repeatcount} @var{repeatbody}
1437 If you have alternative endings, you may add
1438 @cindex @code{\alternative}
1440 \alternative @code{@{} @var{alternative1}
1442 @var{alternative3} @dots{} @code{@}}
1444 where each @var{alternative} is a music expression.
1446 Normal notation repeats are used like this:
1447 @lilypond[fragment,verbatim]
1449 \repeat volta 2 { c'4 d' e' f' }
1450 \repeat volta 2 { f' e' d' c' }
1453 With alternative endings:
1455 @lilypond[fragment,verbatim]
1457 \repeat volta 2 {c'4 d' e' f'}
1458 \alternative { {d'2 d'} {f' f} }
1462 Folded repeats look like this:@footnote{Folded repeats offer little
1463 more over simultaneous music. However, it is to be expected that
1464 more functionality -- especially for the MIDI backend -- will be
1465 implemented at some point in the future.}
1468 @lilypond[fragment,verbatim]
1470 \repeat fold 2 {c'4 d' e' f'}
1471 \alternative { {d'2 d'} {f' f} }
1477 If you don't give enough alternatives for all of the repeats, then
1478 the first alternative is assumed to be repeated often enough to equal
1479 the specified number of repeats.
1482 @lilypond[fragment,verbatim]
1486 \repeat volta 3 { e | c2 d2 | e2 f2 | }
1487 \alternative { { g4 g g } { a | a a a a | b2. } }
1495 As you can see, LilyPond doesn't remember the timing information, nor
1496 are slurs or ties repeated, so you have to reset timing information
1497 after a repeat, e.g. using a bar-check (See @ref{Bar check}),
1498 @code{Score.measurePosition} or @code{\partial}. We hope to fix this
1501 It is possible to nest @code{\repeat}, although it probably is only
1502 meaningful for unfolded repeats.
1504 @node Manual repeat commands
1505 @subsection Manual repeat commands
1507 @cindex @code{repeatCommands}
1509 The property @code{repeatCommands} can be used to control the layout of
1510 repeats. Its value is a Scheme list of repeat commands, where each repeat
1518 @item (volta . @var{text})
1519 Print a volta bracket saying @var{text}.
1521 Stop a running volta bracket
1524 @lilypond[verbatim, fragment]
1526 \property Score.repeatCommands = #'((volta "93") end-repeat)
1528 \property Score.repeatCommands = #'((volta #f))
1533 @node Tremolo repeats
1534 @subsection Tremolo repeats
1535 @cindex tremolo beams
1537 To place tremolo marks between notes, use @code{\repeat} with tremolo
1539 @lilypond[verbatim,center,singleline]
1541 \context Voice \notes\relative c' {
1542 \repeat "tremolo" 8 { c16 d16 }
1543 \repeat "tremolo" 4 { c16 d16 }
1544 \repeat "tremolo" 2 { c16 d16 }
1545 \repeat "tremolo" 4 c16
1553 At present, the spacing between tremolo beams is not regular, since the
1554 spacing engine does not notice that not all notes are printed.
1556 @node Tremolo subdivision
1557 @subsection Tremolo subdivision
1558 @cindex tremolo marks
1559 @cindex @code{tremoloFlags}
1561 Tremolo marks can be printed on a single note by adding
1562 `@code{:}[@var{length}]' after the note. The length must be at least 8.
1563 A @var{length} value of 8 gives one line across the note stem. If the
1564 length is omitted, then then the last value (stored in
1565 @code{Voice.tremoloFlags}) is used.
1567 @lilypond[verbatim,fragment,center]
1570 Using this mechanism pays off when you entering many tremolos, since the
1571 default argument saves a lot of typing.
1576 Tremolos in this style do not carry over into the MIDI output.
1579 @node Measure repeats
1580 @subsection Measure repeats
1582 @cindex percent repeats
1583 @cindex measure repeats
1585 In the @code{percent} style, a note pattern can be repeated. It is
1586 printed once, and then the pattern is replaced with a special sign.
1588 @lilypond[verbatim,singleline]
1589 \context Voice { \repeat "percent" 5 { c'1 } }
1592 At present, only repeats of whole measures are supported.
1594 @node Rhythmic music
1595 @section Rhythmic music
1602 @node Rhythmic staffs
1603 @subsection Rhythmic staffs
1605 Some times you might want to show only the rhythm of a melody. This can
1606 be done with the rhythmic staff. All pitches of notes on such a staff
1607 are squashed, and the staff itself looks has a single staff line:
1609 @lilypond[fragment,relative ]
1610 \context RhythmicStaff {
1612 c4 e8 f g2 | r4 g r2 | g1:32 | r1 |
1619 @section Piano music
1621 Piano music is an odd type of notation: two staffs are largely
1622 independent, but sometimes voices can cross between the two staffs. The
1623 @code{PianoStaff} is especially built to handle this cross-staffing
1624 behavior. In this section we discuss the @code{PianoStaff} and some
1625 other pianistic peculiarities.
1628 * Automatic staff changes::
1629 * Manual staff switches::
1636 @c . {Automatic staff changes}
1637 @node Automatic staff changes
1638 @subsection Automatic staff changes
1639 @cindex Automatic staff changes
1641 Voices can be switched from top to bottom staff automatically. The
1644 \autochange @var{contexttype} @var{musicexp}
1646 This will switch notation context of @var{musicexp} between a
1647 @var{contexttype} named @code{up} and @code{down}. Typically, you use
1648 @code{Staff} for @var{contexttype}. The autochanger switches on basis
1649 of pitch (central C is the turning point), and it looks ahead skipping
1650 over rests to switch rests in advance.
1652 @lilypond[verbatim,singleline]
1653 \score { \notes \context PianoStaff <
1654 \context Staff = "up" {
1655 \autochange Staff \context Voice = VA < \relative c' {
1656 g4 a b c d r4 a g } > }
1657 \context Staff = "down" {
1663 Note how spacer rests are used to prevent the bottom staff from
1664 terminating too soon.
1667 @node Manual staff switches
1668 @subsection Manual staff switches
1670 @cindex manual staff switches
1671 @cindex staff switch, manual
1673 Voices can be switched between staffs manually, using the following command:
1675 \translator Staff = @var{which} @var{music}
1677 The string @var{which} is the name of the staff. Typically it is
1678 @code{"up"} or @code{"down"}.
1680 Formally, this construct is a music expression indicating that the
1681 context which is a direct child of the a context of type
1682 @var{contexttype} should be shifted to a context of type
1683 @var{contexttype} and the specified name.
1685 @cindex @code{\translator}
1687 \translator @var{contexttype} = @var{name}
1696 Piano pedal instruction can be expressed using
1697 @code{\sustainDown}, @code{\sustainUp}, @code{\unaChorda},
1698 @code{\treChorde}, @code{\sostenutoDown} and @code{\sostenutoUp}.
1700 These identifiers are short hands for spanner commands of the types
1701 @code{Sustain}, @code{UnaChorda} and @code{Sostenuto}:
1703 @lilypond[fragment,verbatim]
1704 c''4 \spanrequest \start "Sustain" c''4 c''4 \spanrequest \stop "Sustain"
1707 The symbols that are printed can be modified by setting
1708 @code{pedal@var{X}Strings}, where @var{X} is one of the pedal
1709 types. Refer to the generated documentation for more information.
1714 Currently, brackets are not supported, only text markings (ie. *Ped
1720 @subsection Arpeggio
1723 @cindex broken arpeggio
1724 @cindex @code{\arpeggio}
1726 You can specify an arpeggio sign on a chord by attaching an
1727 @code{\arpeggio} to a note of the chord.
1731 @lilypond[fragment,relative,verbatim]
1732 \context Voice <c'\arpeggio e g c>
1736 When an arpeggio crosses staffs in piano music, you attach an arpeggio
1737 to the chords in both staffs, and set
1738 @code{PianoStaff.connectArpeggios}.
1741 @lilypond[fragment,relative,verbatim]
1742 \context PianoStaff <
1743 \property PianoStaff.connectArpeggios = ##t
1744 \context Voice = one { <c''\arpeggio e g c> }
1745 \context Voice = other { \clef bass; <c,,\arpeggio e g>}
1750 This command creates @code{Arpeggio} grobs.
1754 It is not possible to mix
1755 connected arpeggios and unconnected arpeggios at the same time.
1758 @c . {VoiceFollower}
1760 @subsection VoiceFollower
1762 @cindex follow voice
1763 @cindex staff switching
1766 @cindex @code{followVoice}
1768 Whenever a voice switches to another staff a line connecting the notes
1769 can be printed automatically. This is enabled if the property
1770 @code{PianoStaff.followVoice} is set to true:
1773 @lilypond[fragment,relative,verbatim]
1774 \context PianoStaff <
1775 \property PianoStaff.followVoice = ##t
1776 \context Staff \context Voice {
1778 \translator Staff=two
1781 \context Staff=two {\clef bass; \skip 1*2;}
1795 * Automatic syllable durations::
1801 @subsection Lyrics mode
1804 To print lyrics in LilyPond, you must first make a music expression from
1805 the lyric text. When they're in a music expression, that music
1806 expression can be printed by selecting an appropriate context. We shall
1807 discuss lyric printing in this order.
1811 @cindex @code{\lyrics}
1813 You can enter lyrics in a special input mode of LilyPond. This mode is
1814 called Lyrics mode, and it is introduced by the keyword @code{\lyrics}.
1815 The purpose of this mode is that you can enter lyrics as plain text,
1816 punctuation and accents without any hassle.
1818 The precise definition of this mode is in @ref{Lyrics mode
1819 definition}. The definition itself is ludicrous, and this will remain so
1820 until the authors of LilyPond acquire a deeper understanding of
1821 character encoding, or someone else steps up to fix this.
1823 Syllables are entered like notes, with pitches replaced by text. For
1824 example, @code{Twin- kle twin- kle} enters four syllables. Note that
1825 the hyphen has no special meaning for lyrics, and does not introduce
1828 Spaces can be introduced into a lyric either by using quotes
1829 (@code{"}) or by using an underscore without quotes: @code{He_could4
1830 not4}. All unquoted underscores are converted to spaces.
1832 @c . {Printing lyrics}
1833 @node Printing lyrics
1834 @subsection Printing lyrics
1837 Normally, you will want to have notes and syllables matched
1838 automatically. This is accomplished using @code{\addlyrics}, which is
1839 documented in @ref{Automatic syllable durations}. Setting
1840 @code{automaticMelismata} in the melody staff, will cause slurs to be
1841 interpreted as melismata. Lyric syllables must be interpreted within a
1842 @code{Lyrics} context in order to printing them.
1844 @lilypond[verbatim,singleline]
1845 \addlyrics \notes \relative c' {
1847 \property Staff.automaticMelismata = ##t
1850 \context Lyrics \lyrics {
1852 share the so -- ftware; }
1856 @cindex lyric extender
1859 As you can see, extender lines are entered as @code{__}. This will
1860 create an extender, a line that extends over the entire duration of the
1861 lyric. This line will run all the way to the start of the next lyric,
1862 so you may want to shorten it by using a blank lyric (using @code{_}).
1866 If you want to have hyphens centered between syllables (rather than
1867 attached to the end of the first syllable) you can use the special
1868 `@code{-}@code{-}' lyric as a separate word between syllables. This
1869 will result in a hyphen which length varies depending on the space
1870 between syllables, and which will be centered between the syllables.
1872 @cindex Lyric hyphen
1874 @node Automatic syllable durations
1875 @subsection Automatic syllable durations
1876 @cindex Automatic syllable durations
1878 @cindex automatic lyric durations
1879 @cindex @code{\addlyrics}
1881 If you have lyrics that are set to a melody, you can import the rhythm
1882 of that melody into the lyrics using @code{\addlyrics}. The syntax for
1885 \addlyrics @var{musicexpr1 musicexpr2}
1888 This means that both @var{musicexpr1} and @var{musicexpr2} are
1889 interpreted, but that every non-command atomic music expression
1890 (``every syllable'') in @var{musicexpr2} is interpreted using timing
1891 of @var{musicexpr1}.
1892 @cindex @code{automaticMelismata}
1894 If the property @code{automaticMelismata} is set in the
1895 context of @var{musicexpr1}, no lyrics will be put on slurred or tied
1898 @lilypond[verbatim,fragment]
1901 \property Voice.automaticMelismata = ##t
1902 c8 () cis d8. e16 f2
1904 \context Lyrics \lyrics {
1908 If you want the lyric lines to be above the melody staff, or in some
1909 other, more complex configuration, then build that configuration first
1910 using simultaneous music, and use @code{\addlyrics} after that.
1912 @lilypond[verbatim, singleline]
1914 \context Lyrics = LA { s1 }
1915 \context Staff = SA { s1 }
1917 \context Staff = SA \relative c' { c4 e g g }
1918 \context Lyrics = LA \lyrics { geen ge -- don -- der } >
1921 For @code{\addlyrics} you should use a single rhythm melody, and single
1922 rhythm lyrics (a constant duration is the obvious choice). If you do
1923 not, you can get undesired effects when using multiple stanzas:
1925 @lilypond[verbatim,fragment]
1928 c8 () cis d8. e16 f2
1930 \context Lyrics \lyrics
1935 It is valid (but probably not very useful) to use notes instead of
1936 lyrics for @var{musicexpr2}.
1939 @subsection More stanzas
1943 If you have multiple stanzas printed underneath each other, the separate
1944 syllables should be aligned around punctuation. LilyPond can do this if
1945 you explain it which lyric lines belong to which melody.
1947 To this end, give the Voice context an identity, and set the LyricsVoice
1948 to name starting with that identity. In the following example, the Voice
1949 identity is @code{duet}, and the identities of the LyricsVoices are
1950 @code{duet-1} and @code{duet-2}.
1953 @lilypond[singleline,verbatim]
1956 \notes \relative c'' \context Voice = duet { \time 3/4;
1958 \lyrics \context Lyrics <
1959 \context LyricsVoice = "duet-1" {
1960 \property LyricsVoice . stanza = "Bert"
1961 Hi, my name is bert. }
1962 \context LyricsVoice = "duet-2" {
1963 \property LyricsVoice . stanza = "Ernie"
1964 Ooooo, ch\'e -- ri, je t'aime. }
1969 You can add stanza numbers by setting @code{LyricsVoice.Stanza} (for the
1970 first system) and @code{LyricsVoice.stz} for the following systems.
1972 @cindex stanza numbering
1980 LilyPond has support for both entering and printing chords. Chords are
1981 a harmonic device that is characterized by a set of pitches. It is
1982 something different from simultaneous music, although you can express a
1983 chord using simultaneous music. In fact, chords are internally stored as
1984 simultaneous music expressions. This means you can enter chords by name,
1985 and print them as note head, or enter as notes and print as chord names:
1988 @lilypond[verbatim,singleline]
1989 twoWays = \notes \transpose c'' {
1999 < \context ChordNames \twoWays
2000 \context Staff \twoWays > }
2003 Note that this example also shows that the LilyPond chord does not
2004 attempt to be intelligent, if you enter @code{f bes d}, it does no
2005 attempt to find out whether it this is an inversion.
2009 * Printing named chords::
2014 @subsection Chords mode
2017 Chord mode is a mode where you can input sets of pitches using common
2018 names. It is introduced by the keyword @code{\chords}. It is similar
2019 to note mode, but words are also looked up in a chord modifier table
2020 (containing @code{maj}, @code{dim}, etc).
2022 Dashes and carets are used to indicate chord additions and subtractions,
2023 so articulation scripts can not be entered in Chord mode.
2025 The syntax for named chords is as follows:
2028 @var{tonic}[@var{duration}][@code{-}@var{modifiers}][@code{^}@var{subtractions}][@code{/}@var{inversion}][@code{/+}@var{bass}].
2031 @var{tonic} should be the tonic note of the chord, and @var{duration}
2032 is the chord duration in the usual notation. There are two kinds of
2033 modifiers. One type is @emph{chord additions}, which are obtained by
2034 listing intervals separated by dots. An interval is written by its
2035 number with an optional @code{+} or @code{-} to indicate raising or
2036 lowering by half a step. Chord additions has two effects: It adds
2037 the specified interval and all lower odd numbered intervals to the
2038 chord, and it may lower or raise the specified interval. Intervals
2039 must be separated by a dot (@code{.}).
2041 Throughout these examples, chords have been shifted around the staff
2042 using @code{\transpose}.
2047 @lilypond[fragment,verbatim]
2051 c:9 c:9-.5+.7+ c:3-.5- c:4.6.8
2063 The second type of modifier that may appear after the @code{:} is a
2064 named modifier. Named modifiers are listed in the file
2065 @file{chord-modifiers.ly}. The available modifiers are @code{m} and
2066 @code{min} which lower the 3rd half a step, `@code{aug}' which
2067 raises the 5th, `@code{dim}' which lowers the 5th,
2068 `@code{maj}' which adds a raised 7th, and `@code{sus}'
2069 which replaces the 5th with a 4th.
2073 @lilypond[fragment,verbatim]
2076 c1:m c:min7 c:maj c:aug c:dim c:sus
2084 Chord subtractions are used to eliminate notes from a chord. The
2085 notes to be subtracted are listed after a @code{^} character,
2088 @lilypond[fragment,verbatim,center]
2097 Chord inversions can be specified by appending `@code{/}' and the name
2098 of a single note to a chord. In a chord inversion, the inverted note is
2099 transposed down until it is the lowest note in the chord. If the
2100 specified note is not in the chord, a warning will be printed.
2102 @lilypond[fragment,verbatim,center]
2112 Bass notes can be added by `@code{/+}' and
2113 the name of a single note to a chord. This has the effect of
2114 adding the specified note to the chord, lowered by an octave,
2115 so it becomes the lowest note in the chord.
2117 @lilypond[fragment,verbatim,center]
2129 @c . {Printing named chords}
2130 @node Printing named chords
2131 @subsection Printing named chords
2133 @cindex printing chord names
2136 @cindex @code{ChordNames}
2139 For displaying printed chord names, use the @code{ChordNames} context.
2140 The chords may be entered either using the notation described above, or
2141 directly using simultaneous music.
2144 @lilypond[verbatim,singleline]
2146 \chords {a1 b c} <d f g> <e g b>
2150 \context ChordNames \scheme
2151 \context Staff \transpose c'' \scheme
2157 You can make the chord changes stand out by setting property
2158 @code{ChordNames.chordChanges} to true. This will only display chord
2159 names when there's a change in the chords scheme and at the start of the
2165 c1:m \break c:m c:m c:m d
2170 \context ChordNames {
2171 \property ChordNames.chordChanges = ##t
2173 \context Staff \transpose c'' \scheme
2178 LilyPond examines chords specified as lists of notes to determine a name
2179 to give the chord. LilyPond will not try to identify chord inversions or
2180 added base, which may result in strange chord names when chords are
2181 entered as a list of pitches:
2186 @lilypond[verbatim,center,singleline]
2195 \context ChordNamesVoice \scheme
2196 \context Staff \scheme
2203 By default LilyPond uses chord name system proposed by Harald Banter
2204 (See @ref{Literature}). The system is is unambiguous and has a logical
2205 structure. Typical American style chord names may be selected by
2206 setting the @code{style} property of the @code{ChordNames.ChordName}
2207 grob to @code{'american}. Similarly @code{'jazz} selects Jazz
2210 Routines that determine the names to be printed are written in Scheme,
2211 and may be customized by the user. The code can be found in
2212 @file{scm/chord-name.scm}.
2214 [3 short examples showing differences between american, banter and jazz]
2217 @section Writing parts
2219 Orchestral music involves some special notation, both in the full score,
2220 as in the individual parts. This section explains how to tackle common
2221 problems in orchestral music.
2228 * Instrument names::
2230 * Sound output for transposing instruments::
2231 * Multi measure rests::
2232 * Automatic part combining::
2233 * Hara-kiri staffs::
2236 @c . {Rehearsal marks}
2237 @node Rehearsal marks
2238 @subsection Rehearsal marks
2239 @cindex Rehearsal marks
2241 @cindex @code{\mark}
2242 @cindex @code{Mark_engraver}
2245 \mark @var{unsigned};
2250 With this command, you can print a rehearsal mark above the system. You
2251 can provide a number, a string or a markup text as argument. If there is
2252 no argument, the property @code{rehearsalMark} is used and automatically
2255 @lilypond[fragment,verbatim]
2261 c1 \mark #'(music "scripts-segno") ;
2267 @subsection Bar numbers
2269 Bar numbers are printed at the start of the line by default. This is
2270 done by the @code{Bar_number_engraver} in the Score context.
2274 It is currently not possible to make boxed bar numbers, or print them at
2278 @node Instrument names
2279 @subsection Instrument names
2281 You can specify an instrument name for a staff by setting
2282 @code{Staff.instrument} and @code{Staff.instr}. This will print a string
2283 before the start of the staff. For the first start, @code{instrument} is
2284 used, for the next ones @code{instr} is used.
2286 @lilypond[verbatim,singleline]
2288 \property Staff.instrument = "ploink " { c''4 } }
2290 \translator { \StaffContext
2291 \consists "Instrument_name_engraver"; } } }
2294 This requires that you add the @code{Instrument_name_engraver} to the
2299 @subsection Transpose
2301 @cindex transposition of pitches
2302 @cindex @code{\transpose}
2304 A music expression can be transposed with @code{\transpose}. The syntax
2307 \transpose @var{pitch} @var{musicexpr}
2310 This means that middle C in @var{musicexpr} is transposed to
2313 @code{\transpose} distinguishes between enharmonic pitches: both
2314 @code{\transpose cis'} or @code{\transpose des'} will transpose up half
2315 a tone. The first version will print sharps and the second version
2319 @lilypond[fragment,verbatim]
2322 { \key e \major; c d e f }
2324 \transpose des'' { \key e \major; c d e f }
2325 \transpose cis'' { \key e \major; c d e f }
2331 If you want to use both @code{\transpose} and @code{\relative}, then
2332 you must use @code{\transpose} first. @code{\relative} will have no
2333 effect music that appears inside a @code{\transpose}.
2335 @node Sound output for transposing instruments
2336 @subsection Sound output transposing instruments
2338 When you want to play a score containing transposed and untransposed
2339 instruments, you have to instruct LilyPond the pitch offset (in
2340 semitones) for the transposed instruments. This is done using the
2341 @code{transposing} property. It does not affect printed output.
2343 @cindex @code{transposing}
2346 \property Staff.instrument = #"Cl. in B-flat"
2347 \property Staff.transposing = #-2
2351 @c . {Multi measure rests}
2352 @node Multi measure rests
2353 @subsection Multi measure rests
2354 @cindex Multi measure rests
2358 Multi measure rests are entered using `@code{R}'. It is specifically
2359 meant for entering parts: the rest can expand to fill a score with
2360 rests, or it can be printed as a single multimeasure rest This expansion
2361 is controlled by the property @code{Score.skipBars}. If this is set to true,
2362 Lily will not expand empty measures, and the appropriate number is added
2365 @lilypond[fragment,verbatim]
2366 \time 3/4; R2.*2 \property Score.skipBars = ##t R2.*17 R2.*4
2369 Currently, there is no way to condense multiple rests into a single
2372 @cindex condensing rests
2374 @node Automatic part combining
2375 @subsection Automatic part combining
2376 @cindex automatic part combining
2377 @cindex part combiner
2379 Automatic part combining is used to merge two parts of music onto on
2380 staff in an intelligent way. It is aimed primarily at typesetting Hymns
2381 and orchestral scores. When the two parts are identical for a period of
2382 time, only one is shown. In places where the two parts differ, stem
2383 directions are set automatically. Also, soli and @emph{a due} parts can be
2384 identified and marke.
2386 The syntax for part combining is
2389 \partcombine @var{context} @var{musicexpr1} @var{musicexpr2}
2392 where the pieces of music @var{musicexpr1} and @var{musicexpr2} will be
2393 combined into one context @var{context}. The names of the music
2394 expressions must start with the prefixes @code{one} and @code{two}.
2396 [Name of music expressions? is that context name? ]
2398 The most useful function of the part combiner to combining threads into
2399 one voice, as common for wind parts in orchestral scores:
2401 @lilypond[verbatim,singleline,fragment]
2403 \context Voice=one \partcombine Voice
2404 \context Thread=one \relative c'' {
2407 \context Thread=two \relative c'' {
2413 Notice that the first @code{g} appears only once, although it was
2414 specified twice (once in each Thread). Also note that stem, slur and tie
2415 directions are set automatically, depending whether there is a solo or
2416 unisono. The Thread called @code{one} always gets up stems, and "solo",
2417 while @code{two} always gets down stems and "Solo II".
2419 If you just want the splitting of Threads and setting of directions, and
2420 not the textual markings, you may set the property @var{soloADue} to
2421 false. This mode can be used to set hymns:
2423 @lilypond[verbatim,singleline,fragment]
2425 \property Staff.soloADue = ##f
2426 \context Voice=one \partcombine Voice
2427 \context Thread=one \relative c'' {
2430 \context Thread=two \relative c'' {
2436 There are a number of other properties that you can use to tweak
2437 the behavior of part combining, refer to the automatically generated
2438 documentation. Look for @code{Thread_devnull_engraver}
2439 @code{Voice_devnull_engraver} and @code{A2_engraver}.
2441 @cindex @code{Thread_devnull_engraver}
2442 @cindex @code{Voice_engraver}
2443 @cindex @code{A2_engraver}
2445 @node Hara-kiri staffs
2446 @subsection Hara-kiri staffs
2448 In orchestral scores, staffs that only have rests are usually removed.
2449 This saves some space. LilyPond also supports this through the
2450 hara-kiri@footnote{Hara kiri, also called Seppuku, is the ritual suicide
2451 of the Japanese Samourai warriors.} staff. This staff commits suicide
2452 when it finds itself to be empty after the line-breaking process---note
2453 that it will not disappear when it contains normal rests, you must use
2454 multi measure rests.
2456 The hara kiri staff is specialized version of the Staff context. It is
2457 available as the context identifier @code{\HaraKiriStaffContext}.
2458 Observe how the second staff in this example disappears in the second
2463 \notes \relative c' <
2464 \context Staff = SA { e4 f g a \break c1 }
2465 \context Staff = SB { c4 d e f \break R1 }
2469 \translator { \HaraKiriStaffContext }
2482 A @emph{custos} (plural: @emph{custodes}; latin word for "guard") is a
2483 staff context symbol that appears at the end of a staff line. It
2484 anticipates the pitch of the first note(s) of the following line and
2485 thus helps the player or singer to manage line breaks during
2486 performance, thus enhancing readability of a score.
2491 \notes { c'1 d' e' d' \break c' d' e' d' }
2495 \consists Custos_engraver;
2496 Custos \override #'style = #'mensural;
2503 Custodes were frequently used in music notation until the 16th century.
2504 There were different appearences for different notation styles.
2505 Nowadays, they have survived only in special forms of musical notation
2506 such as via the @emph{editio vaticana} dating back to the beginning of
2509 For typesetting custodes, just put a @code{Custos_engraver} into the
2510 @code{StaffContext} when declaring the @code{\paper} block. In this
2511 block, you can also globally control the appearance of the custos symbol
2512 by setting the custos @code{style} property. Currently supported styles
2513 are @code{vaticana}, @code{medicaea}, @code{hufnagel} and
2520 \consists Custos_engraver;
2521 Custos \override #'style = #'mensural;
2526 The property can also be set locally, for example in a @code{\notes}
2531 \property Staff.Custos \override #'style = #'vaticana
2532 c'1 d' e' d' \break c' d' e' d'
2536 @c . {Tuning output}
2538 @section Tuning output
2540 LilyPond tries to take as much formatting as possible out of your
2541 hands. Nevertheless, there are situations where it needs some help, or
2542 where you want to override its decisions. In this section we discuss
2543 ways to do just that.
2545 Notation output is specified in so called grobs (graphic objects). Each
2546 grob carries with it a set of properties (grob properties) specific to
2547 that object. For example, a stem grob has properties that specify its
2548 direction, length and thickness.
2551 The most common way of tuning the output is to alter the values of these
2552 properties. There are two ways of doing that: first, you can temporarily
2553 change the definition of a certain type of grob, thus affecting a whole
2554 set of objects. Second, you can select one specific object, and set a
2558 * Tuning groups of grobs ::
2559 * Tuning per grob ::
2565 @node Tuning groups of grobs
2566 @subsection Tuning groups of grobs
2568 @cindex grob description
2570 A grob definition is a Scheme association list, that is stored in a context
2571 property. By assigning to that property (using plain @code{\property}),
2572 you can change the resulting grobs.
2574 @lilypond[verbatim, fragment]
2575 c'4 \property Voice.Stem \override #'meta = #'((interfaces . ())) c'4
2578 The @code{\property} statement effectively empties the definition of the
2579 Stem object. One of the effects is that property specifying how it
2580 should be printed is erased, with the effect of rendering it invisible.
2586 This mechanism is fairly crude, since you can only set, but not modify,
2587 the definition of a grob. For this reason, there is a more advanced
2588 mechanism: you can add a property on top of an existing definition, or
2589 remove a property: @code{\override} adds a settings, @code{\revert}
2590 removes that setting.
2593 c'4 \property Voice.Stem \override #'thickness = #4.0
2594 c'4 \property Voice.Stem \revert #'thickness
2598 For the digirati, the grob description is an Scheme association
2599 list. Since it is singly linked, we can treat it as a stack, and
2600 @code{\override} and @code{\revert} are just push and pop
2601 operations. This pushing and popping is also used for overriding automatic
2604 If you revert a setting which was not set in the first place, then it
2605 has no effect. However, if the setting was set as a system default, it
2606 may remove the default value, and this may give surprising results,
2607 including crashes. In other words, if you use @code{\override} and
2608 @code{\revert}, be sure to balance the overrides and reverts.
2610 If balancing them is too much work, use the @code{\set} shorthand. It
2611 performs a revert followed by an override:
2613 \property Voice.Stem \set #'thickness = #2.0
2616 Formally the syntax for these constructions is
2618 \property @var{context}.@var{grobname} \override @var{symbol} = @var{value}
2619 \property @var{context}.@var{grobname} \set @var{symbol} = @var{value}
2620 \property @var{context}.@var{grobname} \revert @var{symbol}
2622 Here @var{symbol} is a Scheme expression of symbol type, @var{context}
2623 and @var{grobname} are strings and @var{value} is a Scheme expression.
2627 LilyPond will hang or crash if @var{value} contains cyclic references.
2631 @node Tuning per grob
2632 @subsection Tuning per grob
2634 @cindex \outputproperty
2636 A second way of tuning grobs is the more arcane @code{\outputproperty}
2638 Syntax is as follows
2640 \outputproperty @var{predicate} @var{symbol} = @var{value}
2642 Here @code{predicate} is a Scheme function taking a grob argument, and
2643 returning a boolean. This statement is processed by the
2644 @code{Output_property_engraver}. It instructs the engraver to feed all
2645 grobs that it sees to @var{predicate}. Whenever the predicate returns
2646 true, the grob property @var{symbol} will be set to @var{value}.
2648 You will need to combine this statement with @code{\context} to select
2649 the appropriate context to apply this to.
2651 If possible, avoid this feature: the semantics are not very clean, and
2652 the syntax and semantics are up for rewrite.
2654 Here are some random examples:
2656 @lilypond[fragment,verbatim,singleline]
2658 \context Staff \outputproperty
2659 #(make-type-checker 'note-head-interface)
2660 #'extra-offset = #'(0.5 . 0.75)
2664 @cindex @code{extra-offset}
2666 This selects all note heads occurring at current staff level, and sets
2667 the @code{extra-offset} of those heads to @code{(0.5,0.75)}, shifting
2670 Move the text "m.d.", but not the fingering instruction "2".
2671 @lilypond[verbatim,singleline]
2672 #(define (make-text-checker text)
2673 (lambda (grob) (equal? text (ly-get-grob-property grob 'text))))
2676 \notes\relative c''' {
2677 \property Voice.Stem \set #'direction = #1
2678 \outputproperty #(make-text-checker "m.d.")
2679 #'extra-offset = #'(-3.5 . -4.5)
2689 @subsection What to tune?
2691 This all tells you how to tune grobs, but what variables are there? The
2692 question is not answered in this manual (although you may encounter
2695 Grob properties are tied directly to the implementation of LilyPond, and
2696 they are thus a moving target. Documentation of such variables are part
2697 of the generated documentation: this documentation is generated from the
2698 sourcecode of lily for each version, so it is usually mch more up to
2699 date than this manual. It should be available from the same place where
2700 you got this manual.
2702 To decide how to tune a grob, you need to find the following information
2705 which grob to modify
2707 which property to modify
2709 which context the grob comes from.
2712 Included with the automatically generated documentation is a master list
2713 of grobs. Each one can be clicked, taking you to a overview of the
2714 available properties.
2716 There is also a master list of contexts. Clicking each takes you to an
2717 overview of the context, listing which grob types are created there.
2720 @node Font selection
2721 @subsection Font selection
2723 Most graphics in LilyPond are composed of characters of fonts. You can
2724 alter the characteristics of the font by setting certain grob
2725 properties. The mechanism that is used for this resembles LaTeX's New
2726 Font Selection Scheme. Within this scheme, a font is entirely
2727 characterized by its font name.
2729 For each grob that uses fonts (in other words, each grob that supports
2730 @code{font-interface}) a font-name must be selected before it can be
2731 printed. The font name is selected by looking at a number of grob
2736 The general class of the typeface. Supported are roman (Computer
2737 Modern), braces (for piano staff braces), music (the standard music
2738 font), dynamic (font for dynamic signs) and typewriter
2741 A symbol indicating the shape of the font, a finer gradation than
2742 font-family. Choices are italic and upright
2744 Symbol indicating the serie of the font. Series form a finer gradation
2745 than font-shape. Choices are medium and bold.
2747 @item font-relative-size
2748 A number indicating the size relative the standard size. For example,
2749 with 20pt staff height, relative size -1 corresponds to 16pt staff
2750 height, and relative size +1 corresponds to 23 pt staff height.
2752 @item font-design-size
2753 A number indicating the design size of the font.
2755 This is a feature of the Computer Modern Font: each point size has a
2756 slightly different design. Smaller design sizes are relatively wider,
2757 which enhances readability. Scalable type faces such TrueType and Adobe
2758 Type1 usually come as ``one design fits all sizes''.
2761 The name of the font, without the design size, eg. @code{cmr},
2762 @code{cmti}, etc. Setting this overrides font-family, font-shape and
2767 The font is selected by taking the first font that satisfies all
2768 qualifiers specified. You can override any of these fields through
2769 @code{\override} and @code{\revert}. The special value @code{*} matches
2770 any value for that qualifier.
2773 \property Lyrics.LyricText \override #'font-series = #'bold
2774 \property Lyrics.LyricText \override #'font-shape = #'*
2777 @cindex @code{font-style}
2779 There are also pre-cooked font selection qualifiers. These are selected
2780 through the grob property @code{font-style}. For example, the style
2781 @code{finger} selects family @code{number} and relative size @code{-3}.
2782 Styles available include: volta, finger, tuplet, timesig, mmrest,
2783 script, large, Large and dynamic.
2785 The style sheets and tables for selecting fonts are located in
2786 @file{scm/font.scm}. Refer to this file for more information.
2790 Relative size is not linked to any real size. There is no mechanism to
2791 select magnifications of fonts, meaning that you can not scale fonts
2792 continuoussly. There is no style sheet provided for other fonts besides
2795 @cindex font selection
2796 @cindex font magnification
2797 @cindex @code{font-interface}
2803 @subsection Text markup
2807 LilyPond has an internal mechanism to typeset texts. You can
2808 form text markup expressions by composing scheme expressions
2809 in the following way.
2811 @lilypond[verbatim, singleline]
2816 c^#'(italic "italic")
2817 d_#'((bold italic) "ff")
2819 f_#'(lines "one" (bold "two"))
2820 g^#'(music "noteheads-2" "flags-u3")
2824 Normally, the Scheme markup text is stored in the @code{text} property
2825 of a grob. Formally, it is defined as follows:
2828 text: string | (head? text+)
2829 head: markup | (markup+)
2830 markup-item: property | abbrev
2831 property: (@var{key} . @var{value})
2832 abbrev: @code{rows lines roman music bold italic named super sub text}
2833 @code{finger volta timesig mmrest mark script large Large dynamic}
2836 The markup is broken down and converted into a list of grob properties,
2837 which are prepended to the property list. The @var{key}-@var{value}
2838 pair is a grob property.
2840 The following abbreviations are currently defined:
2844 horizontal mode: set all text on one line (default)
2846 vertical mode: set every text on new line
2856 lookup by character name
2858 plain text lookup (by character value)
2864 select fingering number fontstyle
2866 select volta number fontstyle
2868 select time signature number fontstyle
2870 select multi measure rest number fontstyle
2872 select mark number fontstyle
2874 select scriptsize roman fontstyle
2876 select large roman fontstyle
2878 select Large roman fontstyle
2880 select dynamics fontstyle
2883 It is possible to use @TeX{} commands in the strings, but this should be
2884 avoided because this makes it impossible for LilyPond to compute the
2885 exact length of the string, which may lead to collisions. Also, @TeX{}
2886 commands won't work with direct postscript output.
2890 @section Page layout
2904 @subsection Paper block
2907 The most important output definition is the @code{\paper} block, for
2908 music notation. The syntax is
2911 @code{\paper @{} [@var{paperidentifier}] @var{items} @code{@}}
2914 where each of the items is one of
2917 @item An assignment. The assignment must be terminated by a
2920 @item A context definition. See @ref{Notation Contexts} for
2921 more information on context definitions.
2923 @item \stylesheet declaration. Its syntax is
2925 \stylesheet @var{alist}
2928 See @file{scm/font.scm} for details of @var{alist}.
2929 @item an \elementdescriptions declaration.
2931 \elementdescriptions @var{alist}
2933 See @file{scm/grob-description.scm} for details of @var{alist}.
2937 @c . {Paper variables}
2938 @node Paper variables
2939 @subsection Paper variables
2940 @cindex Paper variables
2942 The paper block has some variables you may want to use or change:
2945 @cindex @code{indent}
2947 The indentation of the first line of music.
2948 @cindex @code{staffspace}
2950 @item @code{staffspace}
2951 The distance between two staff lines, calculated from the center
2952 of the lines. If you want scale independent output, then you should
2953 use either this or @code{stafflinethickness}
2954 as a unit for distances you modify.
2956 @cindex @code{linewidth}
2957 @item @code{linewidth}
2958 Sets the width of the lines.
2960 If set to a negative value, a single
2961 unjustified line is produced.
2963 @cindex @code{textheight}
2965 @item @code{textheight}
2966 Sets the total height of the music on each page. Only used by
2969 @cindex @code{interscoreline}
2971 @item @code{interscoreline}
2972 Sets the spacing between systems.
2974 @cindex @code{interscorelinefill}
2978 @item @code{interscorelinefill}
2979 If set to a positive number, the distance between the score
2980 lines will stretch in order to fill the full page. In that
2981 case @code{interscoreline} specifies the minimum spacing.
2986 @cindex @code{stafflinethickness}
2988 @item @code{stafflinethickness}
2989 Determines the thickness of staff lines, and also acts as a scaling
2990 parameter for other line thicknesses.
2997 @subsection Font size
3000 The Feta font provides musical symbols at six different sizes. These
3001 fonts are 11 point, 13 point, 16 point, 20 point,
3002 23 point, and 26 point. The point size of a font is the
3003 height of the five lines in a staff when displayed in the font.
3005 Definitions for these sizes are the files @file{paperSZ.ly}, where
3006 @code{SZ} is one of 11, 13, 16, 20, 23 and 26. If you include any of
3007 these files, the identifiers @code{paperEleven}, @code{paperThirteen},
3008 @code{paperSixteen}, @code{paperTwenty}, @code{paperTwentythree}, and
3009 @code{paperTwentysix} are defined respectively. The default
3010 @code{\paper} block is also set.
3012 The font definitions are generated using a Scheme function. For more
3013 details, see the file @file{font.scm}.
3019 @subsection Paper size
3024 @cindex @code{papersize}
3026 To change the paper size, you must first set the
3027 @code{papersize} variable at top level. Set it to
3028 the strings @code{a4}, @code{letter}, or @code{legal}. After this
3029 specification, you must set the font as described above. If you want
3030 the default font, then use the 20 point font. The new paper size will
3031 not take effect if the font is not loaded and selected afterwards.
3035 \include "paper16.ly"
3039 \paper @{ \paperSixteen @}
3043 The file @code{paper16.ly} will now include a file named @file{a4.ly}, which
3044 will set the paper variables @code{hsize} and @code{vsize} (used by
3055 @subsection Line break
3058 @cindex breaking lines
3060 Line breaks are normally computed automatically. They are chosen such
3061 that the resulting spacing has low variation, and looks neither cramped
3064 Occasionally you might want to override the automatic breaks; you can do
3065 this by specifying @code{\break}. This will force a line break at this
3066 point. Do remember that line breaks can only occur at places where there
3067 are barlines. If you want to have a line break where there is no
3068 barline, you can force an invisible barline by entering @code{\bar "";}.
3070 Similarly, @code{\noBreak} forbids a line break at a certain point.
3072 @cindex @code{\penalty}
3074 The @code{\break} and @code{\noBreak} commands are defined in terms of
3075 the penalty command:
3077 \penalty @var{int} @code{;}
3080 This encourages or discourages LilyPond to make a line break at this
3085 The scaling of the @code{\penalty} argument is not well-defined. The
3086 command is rather kludgy, and slated for rewriting.
3090 @subsection Page break
3093 @cindex breaking pages
3096 Page breaks are normally computed by @TeX{}, so they are not under
3097 direct control of LilyPond. However, you can insert a commands into the
3098 @file{.tex} output to instruct @TeX{} where to break pages. For more
3099 details, see the example file @file{input/test/between-systems.ly}
3110 LilyPond can produce MIDI output. The performance lacks lots of
3111 interesting effects, such as swing, articulation, slurring, tieing,
3112 etc., but it is good enough for proof-hearing the music you enter.
3114 Dynamics and tempo changes are interpreted.
3116 [TODO: mention volume control/Instrument Equaliser]
3121 It is currently not possible to use the percussion channel (generally
3122 channel 10 of a MIDI file).
3126 * MIDI instrument names::
3131 @subsection MIDI block
3135 The MIDI block is analogous to the paper block, but it is somewhat
3136 simpler. The @code{\midi} block can contain:
3140 @item a @code{\tempo} definition
3141 @item context definitions
3144 Assignments in the @code{\midi} block are not allowed.
3148 @cindex context definition
3150 Context definitions follow precisely the same syntax as within the
3151 \paper block. Translation modules for sound are called performers.
3152 The contexts for MIDI output are defined in @file{ly/performer.ly}.
3155 @node MIDI instrument names
3156 @subsection MIDI instrument names
3158 @cindex instrument names
3159 @cindex @code{Staff.midiInstrument}
3160 @cindex @code{Staff.instrument}
3162 The MIDI instrument name is set by the @code{Staff.midiInstrument}
3163 property or, if that property is not set, the @code{Staff.instrument}
3164 property. The instrument name should be chosen from the list in
3165 @ref{MIDI instruments}.
3169 If the selected string does not exactly match, then LilyPond uses the
3170 default piano. It is not possible to select an instrument by number.
3182 @section Music entry
3190 One of the applications of LilyPond is to enter music from existing
3191 written or printed material. When you're doing this kind of copying
3192 work, you can easily make mistakes. This section deals with tricks and
3193 features that help you enter music, and find and correct mistakes.
3197 @subsection Relative
3199 @cindex relative octave specification
3201 Octaves are specified by adding @code{'} and @code{,} to pitch names.
3202 When you copy existing music, it is easy to accidentally put a pitch in
3203 the wrong octave and hard to find such an error. To prevent these
3204 errors, LilyPond features octave entry.
3206 @cindex @code{\relative}
3208 \relative @var{startpitch} @var{musicexpr}
3211 The octave of notes that appear in @var{musicexpr} are calculated as
3212 follows: If no octave changing marks are used, the basic interval
3213 between this and the last note is always taken to be a fourth or less.
3214 The octave changing marks @code{'} and @code{,} can then
3215 be added to raise or lower the pitch by an extra octave. Upon entering
3216 relative mode, an absolute starting pitch must be specified that will
3217 act as the predecessor of the first note of @var{musicexpr}.
3219 This distance is determined without regarding accidentals: a
3220 @code{fisis} following a @code{ceses} will be put above the
3223 Entering music that changes octave frequently is easy in relative mode.
3224 @lilypond[fragment,singleline,verbatim,center]
3230 And octave changing marks are used for intervals greater than a fourth.
3231 @lilypond[fragment,verbatim,center]
3233 c g c f, c' a, e'' }
3236 If the preceding item is a chord, the first note of the chord is used
3237 to determine the first note of the next chord. But other notes
3238 within the second chord are determined by looking at the immediately
3241 @lilypond[fragment,verbatim,center]
3248 @cindex @code{\notes}
3250 The pitch after the @code{\relative} contains a notename. To parse
3251 the pitch as a notename, you have to be in note mode, so there must
3252 be a surrounding @code{\notes} keyword (which is not
3255 The relative conversion will not affect @code{\transpose},
3256 @code{\chords} or @code{\relative} sections in its argument. If you
3257 want to use relative within transposed music, you must place an
3258 additional @code{\relative} inside the @code{\transpose}.
3263 @subsection Bar check
3267 @cindex @code{barCheckNoSynchronize}
3271 Whenever a bar check is encountered during interpretation, a warning
3272 message is issued if it doesn't fall at a measure boundary. This can
3273 help you find errors in the input. Depending on the value of
3274 @code{barCheckNoSynchronize}, the beginning of the measure will be
3275 relocated, so this can also be used to shorten measures.
3277 A bar check is entered using the bar symbol, @code{|}
3281 @c . {Point and click}
3282 @node Point and click
3283 @subsection Point and click
3285 Point and click lets you find notes in the input by clicking on them in
3286 the Xdvi window. This makes it very easy to find input that causes some
3287 error in the sheet music.
3289 To use it, you need the following software
3293 @uref{ftp://ftp.math.berkeley.edu/pub/Software/TeX/xdvi.tar.gz,plain
3294 Xdvi} version 22.36 or newer.
3296 Note that most @TeX{} distributions ship with xdvik, which is a
3297 different and less well maintained program. To find out which xdvi you
3298 are running, try @code{xdvi --version} or @code{xdvi.bin --version}.
3303 Add one these lines to the top of your .ly file. The first one is for
3304 line location only. The second one is more convenient, but requires
3305 patching @code{emacsclient}.
3308 #(set! point-and-click line-location)
3309 #(set! point-and-click line-column-location)
3312 In the emacs startup file (usually @file{~/.emacs}), add the following
3317 If you want emacs to jump to the exact spot (and not just the line) on a
3318 click, you must enable column positioning. To do so, you need to patch
3319 emacsclient. Apply @file{emacsclient.patch} (included with the source
3320 package) to @file{emacsclient.c} and @file{server.el} from the emacs
3321 source code. Recompile and stick the recompiled emacsclient into a bin
3322 directory, and put @file{server.el} into a elisp directory
3323 (eg. @file{~/usr/share/emacs/}). Add the following to your @file{.emacs}
3324 init file, before invoking server-start.
3327 (setq load-path (cons "~/usr/share/emacs" load-path))
3331 Xdvi must be configured to use the emacs editor. Before starting, set
3332 the environment variable @code{XEDITOR} to
3334 emacsclient --no-wait +%c:%l %f
3336 Xdvi also must be configured to find the fonts. Refer to the
3337 xdvi documentation for more information.
3339 When viewing, control-mousebutton 1 will take you to the originating
3340 line and column. Control-mousebutton 2 will show all clickable boxes.
3344 When you convert the TeX file to PostScript using dvips, dvips
3345 will complain about not finding @code{src:X:Y} files. Those complaints are
3346 harmless, and can be ignored.
3349 @node Interpretation context
3350 @section Interpretation context
3353 * Notation Contexts::
3354 * Creating contexts::
3355 * Default contexts::
3356 * Context properties::
3357 * Changing context definitions::
3358 * Defining new contexts::
3362 @c . {Notation Contexts}
3363 @node Notation Contexts
3364 @subsection Notation Contexts
3366 @cindex notation contexts
3368 Notation contexts are objects that only exist during a run of LilyPond.
3369 During the interpretation phase of LilyPond (when it prints
3370 "interpreting music"), the music expresiion in a @code{\score} block is
3371 interpreted in time order. This is the same order that humans hear and
3374 During this interpretation, the notation context is holds the state for
3375 the current point within the music. It contains information like
3378 @item What notes are playing at this point?
3379 @item What symbols will be printed at this point?
3380 @item What is the current key signature, time signature, point within
3384 Contexts are grouped hierarchically: A @code{Voice} context is
3385 contained in a @code{Staff} context (because a staff can contain
3386 multiple voices at any point), a @code{Staff} context is contained in
3387 a @code{Score}, @code{StaffGroup}, or @code{ChoirStaff} context (because
3388 these can all contain multiple staffs).
3391 Contexts associated with sheet music output are called @emph{notation
3392 contexts}, those for sound output are called performance contexts.
3395 @node Creating contexts
3396 @subsection Creating contexts
3398 @cindex @code{\context}
3399 @cindex context selection
3401 Contexts for a music expression can be selected manually, using the
3402 following music expression.
3405 \context @var{contexttype} [= @var{contextname}] @var{musicexpr}
3408 This instructs lilypond to interpret @var{musicexpr} within the context
3409 of type @var{contexttype} and with name @var{contextname}. If this
3410 context does not exist, it will be created.
3414 @lilypond[verbatim,singleline]
3416 \notes \relative c'' {
3417 c4 <d4 \context Staff = "another" e4> f
3424 In this example, the @code{c} and @code{d} are printed on the
3425 default staff. For the @code{e}, a context Staff called
3426 @code{another} is specified; since that does not exist, a new
3427 context is created. Within @code{another}, a (default) Voice context
3428 is created for the @code{e4}. When all music referring to a
3429 context is finished, the context is ended as well. So after the
3430 third quarter, @code{another} is removed.
3434 @node Default contexts
3435 @subsection Default contexts
3437 Most music expressions don't need @code{\context}: they inherit the
3438 notation context from their parent. Each note is a music expression, and
3439 as you can see in the following example, only the sequential music
3440 enclosing the three notes has an explicit context.
3442 @lilypond[verbatim,singleline]
3443 \score { \notes \context Voice = goUp { c'4 d' e' } }
3446 There are some quirks that you must keep in mind when dealing with
3449 First, every top-level music is interpreted by the Score context, in other
3450 words, you may think of @code{\score} working like
3453 \context Score @var{music}
3457 Second, sequential music follows the contexts of its
3458 ``children''. Consider the following example.
3460 @lilypond[verbatim, singleline]
3461 \score { \context Score \notes { c'4 ( d' )e' } }
3464 The sequential music is interpreted by the Score context initially
3465 (notice that the @code{\context} specification is redundant), but when a
3466 note is encountered, contexts are setup to accept that note. In this
3467 case, a Thread, Voice and Staff are created. The rest of the sequential
3468 music is also interpreted with the same Thread, Voice and Staff context,
3469 putting the notes on the same staff, in the same voice.
3471 This is a convenient mechanism, but do not expect opening chords to work
3472 without @code{\context}. For every note, a separate staff is
3475 @lilypond[verbatim, singleline]
3476 \score { \notes <c'4 es'> }
3479 Of course, if the chord is preceded by a normal note in sequential
3480 music, the chord will be interpreted by the Thread of the preceding
3482 @lilypond[verbatim,singleline]
3483 \score { \notes { c'4 <c'4 es'> } }
3488 @node Context properties
3489 @subsection Context properties
3491 Notation contexts can be modified from within the @file{.ly} file. The
3492 following music expression does that job:
3494 @cindex @code{\property}
3496 \property @var{contextname}.@var{propname} = @var{value}
3499 Sets the @var{propname} property of the context @var{contextname} to the
3500 specified Scheme expression @var{value}. All @var{propname} and
3501 @var{contextname} are strings, which are typically unquoted.
3503 Properties that are set in one context are inherited by all of the
3504 contained contexts. This means that a property valid for the
3505 @code{Voice} context can be set in the @code{Score} context (for
3506 example) and thus take effect in all @code{Voice} contexts.
3508 Properties can be unset using the following expression:
3510 \property @var{contextname}.@var{propname} \unset
3513 This removes the definition of @var{propname} in @var{contextname}. If
3514 @var{propname} was not defined in @var{contextname} (but was inherited
3515 from a higher context), then this has no effect.
3520 @code{\property \unset} is not the inverse of @code{\property \set}
3525 @c . {Context definitions}
3526 @node Changing context definitions
3527 @subsection Changing context definitions
3529 @cindex context definition
3530 @cindex translator definition
3532 The most common way to define a context is by extending an existing
3533 context. You can change an existing context from the paper block, by
3534 first initializing a translator with an existing context identifier:
3538 @var{context-identifier}
3541 Then you can add engravers, remove engravers.
3542 The syntax for these operations are respectively
3544 \remove @var{engravername}
3545 \consists @var{engravername}
3549 Here @var{engravername} is a string, the name of an engraver in the
3552 @var{propname} = @var{value}
3556 @lilypond[verbatim,singleline]
3560 \translator { \StaffContext
3561 \remove Clef_engraver;
3567 You can also set properties in a translator definition. The syntax is as
3570 @var{propname} is a string and @var{value} is a Scheme
3573 @var{propname} = @var{value}
3574 @var{propname} \set @var{symbol} = @var{value}
3575 @var{propname} \override @var{symbol} = @var{value}
3576 @var{propname} \revert @var{symbol}
3580 These type of property assignments happen before interpretation starts,
3581 so a @code{\property} expression will override any predefined settings.
3584 To simplify editing translators, all standard contexts have standard
3585 identifiers called @var{name}@code{Context}, e.g. @code{StaffContext},
3586 @code{VoiceContext}.
3588 @node Defining new contexts
3589 @subsection Defining new contexts
3591 If you want to build a context from scratch, you must also supply the
3592 following extra information:
3594 @item A name, specified by @code{\name @var{contextname};}.
3596 @item A cooperation module. This is specified by @code{\type
3603 \type "Engraver_group_engraver";
3604 \name "SimpleStaff";
3606 \consists "Staff_symbol_engraver";
3607 \consists "Note_head_engraver";
3608 \consistsend "Axis_group_engraver";
3612 Basic building blocks of translation are called engravers; they are
3613 special C++ classes.
3615 The argument of @code{\type} is the name for a special engraver that
3616 handles cooperation between simple engravers such as
3617 @code{Note_head_engraver} and @code{Staff_symbol_engraver}. Alternatives
3618 for this engraver are the following:
3620 @cindex @code{Engraver_group_engraver}
3621 @item @code{Engraver_group_engraver}
3622 The standard cooperation engraver.
3624 @cindex @code{Score_engraver}
3626 @item @code{Score_engraver}
3627 This is cooperation module that should be in the top level context,
3628 and only the toplevel context.
3630 @cindex @code{Grace_engraver_group}
3632 @item @code{Grace_engraver_group}
3633 This is a special cooperation module (resembling
3634 @code{Score_engraver}) that is used to created an embedded
3641 @item @code{\alias} @var{alternate-name} @code{;}
3642 This specifies a different name. In the above example,
3643 @code{\property Staff.X = Y} will also work on @code{SimpleStaff}s
3645 @item @code{\consistsend} @var{engravername} @code{;}
3646 Analogous to @code{\consists}, but makes sure that
3647 @var{engravername} is always added to the end of the list of
3650 Some engraver types need to be at the end of the list; this
3651 insures they are put there, and stay there, if a user adds or
3652 removes engravers. This command is usually not needed for
3655 @item @code{\accepts} @var{contextname} @code{;}
3656 Add @var{contextname} to the list of context this context can
3657 contain. The first listed context is the context to create by
3660 @item @code{\denies}. The opposite of @code{\accepts}. Added for
3661 completeness, but is never used in practice.
3664 @item @code{\name} @var{contextname} @code{;}
3665 This sets name of the context, e.g. @code{Staff}, @code{Voice}. If
3666 the name is not specified, the translator won't do anything.
3669 In the @code{\paper} block, it is also possible to define translator
3670 identifiers. Like other block identifiers, the identifier can only
3671 be used as the very first item of a translator. In order to define
3672 such an identifier outside of @code{\score}, you must do
3678 foo = \translator @{ @dots{} @}
3685 \translator @{ \foo @dots{} @}
3693 @cindex paper types, engravers, and pre-defined translators
3700 @c . {Syntactic details}
3701 @node Syntactic details
3702 @section Syntactic details
3703 @cindex Syntactic details
3705 This section describes details that were too boring to be put elsewhere.
3710 * Music expressions::
3711 * Manipulating music expressions::
3719 @subsection Top level
3722 This section describes what you may enter at top level.
3726 @subsubsection Score
3729 @cindex score definition
3731 The output is generated combining a music expression with an output
3732 definition. A score block has the following syntax:
3735 \score @{ @var{musicexpr} @var{outputdefs} @}
3738 @var{outputdefs} are zero or more output definitions. If none is
3739 supplied, the default @code{\paper} block will be added.
3743 @c . {Default output}
3744 @subsubsection Default output
3746 Default values for the @code{\paper} and @code{\midi} block are set by
3747 entering such a block at top-level.
3750 @subsubsection Header
3752 @cindex @code{\header}
3755 A header describes bibilographic information of the file's contents. It
3756 can also appear in a @code{\score} block. Tools like @code{ly2dvi} can
3757 use this information for generating titles. Key values that are used by
3758 @code{ly2dvi} are: title, subtitle, composer, opus, poet, instrument,
3759 metre, arranger, piece and tagline.
3761 @cindex @code{ly2dvi}
3765 \header @{ @var{key1} = @var{val1};
3766 @var{key2} = @var{val2}; @dots{} @}
3769 It is customary to put the @code{\header} at the top of the file.
3771 @subsubsection Default output
3773 A @code{\midi} or @code{\paper} block at top-level sets the default
3775 paper block for all scores that lack an explicit paper block.
3779 @subsection Identifiers
3782 All of the information in a LilyPond input file, is represented as a
3783 Scheme value. In addition to normal Scheme data types (such as pair,
3784 number, boolean, etc.), LilyPond has a number of specialized data types,
3791 @item Translator_def
3795 @item Music_output_def
3796 @item Moment (rational number)
3799 LilyPond also includes some transient object types. Objects of these
3800 types are built during a LilyPond run, and do not `exist' per se within
3801 your input file. These objects are created as a result of your input
3802 file, so you can include commands in the input to manipulate them,
3803 during a lilypond run.
3806 @item Grob: short for Graphical object. See @ref{Grobs}.
3807 @item Molecule: device-independent page output object,
3808 including dimensions. Produced by some Grob functions
3810 @item Translator: object that produces audio objects or Grobs. This is
3811 not yet user accessible.
3812 @item Font_metric: object representing a font. (See @ref{Font metrics})
3817 @node Music expressions
3818 @subsection Music expressions
3820 @cindex music expressions
3822 Music in LilyPond is entered as a music expression. Notes, rests, lyric
3823 syllables are music expressions, and you can combine music expressions
3824 to form new ones, for example by enclosing a list of expressions in
3825 @code{\sequential @{ @}} or @code{< >}. In the following example, a
3826 compound expression is formed out of the quarter note @code{c} and a
3827 quarter note @code{d}:
3830 \sequential @{ c4 d4 @}
3833 @cindex Sequential music
3834 @cindex @code{\sequential}
3835 @cindex sequential music
3838 @cindex Simultaneous music
3839 @cindex @code{\simultaneous}
3841 The two basic compound music expressions are simultaneous and
3845 \sequential @code{@{} @var{musicexprlist} @code{@}}
3846 \simultaneous @code{@{} @var{musicexprlist} @code{@}}
3848 For both, there is a shorthand:
3850 @code{@{} @var{musicexprlist} @code{@}}
3854 @code{<} @var{musicexprlist} @code{>}
3856 for simultaneous music.
3857 In principle, the way in which you nest sequential and simultaneous to
3858 produce music is not relevant. In the following example, three chords
3859 are expressed in two different ways:
3861 @lilypond[fragment,verbatim,center]
3862 \notes \context Voice {
3863 <a c'> <b d' > <c' e'>
3864 < { a b c' } { c' d' e' } >
3869 Other compound music expressions include
3872 \transpose @var{pitch} @var{expr}
3873 \apply @var{func} @var{expr}
3874 \context @var{type} = @var{id} @var{expr}
3875 \times @var{fraction} @var{expr}
3879 @c . {Manipulating music expressions}
3880 @node Manipulating music expressions
3881 @subsection Manipulating music expressions
3883 The @code{\apply} mechanism gives you access to the internal
3884 representation of music. You can write Scheme-functions that operate
3885 directly on it. The syntax is
3887 \apply #@var{func} @var{music}
3889 This means that @var{func} is applied to @var{music}. The function
3890 @var{func} should return a music expression.
3892 This example replaces the text string of a script. It also shows a dump
3893 of the music it processes, which is useful if you want to know more
3894 about how music is stored.
3896 #(define (testfunc x)
3897 (if (equal? (ly-get-mus-property x 'text) "foo")
3898 (ly-set-mus-property x 'text "bar"))
3900 (ly-set-mus-property x 'elements
3901 (map testfunc (ly-get-mus-property x 'elements)))
3906 \apply #testfunc { c4_"foo" }
3910 For more information on what is possible, see the @ref{Tricks} and the
3911 automatically generated documentation.
3914 Directly accessing internal representations is dangerous: the
3915 implementation is subject to changes, so you should avoid this feature
3920 @c . {Span requests}
3926 @subsubsection Span requests
3927 @cindex Span requests
3929 Notational constructs that start and end on different notes can be
3930 entered using span requests. The syntax is as follows:
3934 \spanrequest @var{startstop} @var{type}
3938 @cindex @code{\start}
3939 @cindex @code{\stop}
3941 This defines a spanning request. The @var{startstop} parameter is either
3942 -1 (@code{\start}) or 1 (@code{\stop}) and @var{type} is a string that
3943 describes what should be started. Much of the syntactic sugar is a
3944 shorthand for @code{\spanrequest}, for example,
3946 @lilypond[fragment,verbatim,center]
3947 c'4-\spanrequest \start "slur"
3948 c'4-\spanrequest \stop "slur"
3951 Among the supported types are @code{crescendo}, @code{decrescendo},
3952 @code{beam}, @code{slur}. This is an internal command. Users are
3953 encouraged to use the shorthands which are defined in the initialization
3954 file @file{spanners.ly}.
3959 @subsection Assignments
3962 Identifiers allow objects to be assigned to names during the parse
3963 stage. To assign an identifier, you use @var{name}@code{=}@var{value}
3964 and to refer to an identifier, you preceed its name with a backslash:
3965 `@code{\}@var{name}'. @var{value} is any valid Scheme value or any of
3966 the input-types listed above. Identifier assignments can appear at top
3967 level in the LilyPond file, but also in @code{\paper} blocks.
3969 Semicolons are forbidden after top level assignments, but mandatory in
3970 other places. The rules about semicolons and assignments are very
3971 confusing, but when LilyPond input evolves more towards Scheme, we hope
3972 that this problem will grow smaller.
3974 An identifier can be created with any string for its name, but you will
3975 only be able to refer to identifiers whose names begin with a letter,
3976 being entirely alphabetical. It is impossible to refer to an identifier
3977 whose name is the same as the name of a keyword.
3979 The right hand side of an identifier assignment is parsed completely
3980 before the assignment is done, so it is allowed to redefine an
3981 identifier in terms of its old value, e.g.
3987 When an identifier is referenced, the information it points to is
3988 copied. For this reason, an identifier reference must always be the
3989 first item in a block.
3993 \paperIdent % wrong and invalid
3997 \paperIdent % correct
4002 @c . {Lexical modes}
4004 @subsection Lexical modes
4005 @cindex Lexical modes
4008 @cindex @code{\notes}
4009 @cindex @code{\chords}
4010 @cindex @code{\lyrics}
4012 To simplify entering notes, lyrics, and chords, LilyPond has three
4013 special input modes on top of the default mode: note, lyrics and chords
4014 mode. These input modes change the way that normal, unquoted words are
4015 interpreted: for example, the word @code{cis} may be interpreted as a
4016 C-sharp, as a lyric syllable `cis' or as a C-sharp major triad
4019 A mode switch is entered as a compound music expressions
4021 @code{\notes} @var{musicexpr}
4022 @code{\chords} @var{musicexpr}
4023 @code{\lyrics} @var{musicexpr}.
4026 In each of these cases, these expressions do not add anything to the
4027 meaning of their arguments. They are just a way to indicate that the
4028 arguments should be parsed in indicated mode. The modes are treated in
4029 more detail in the @ref{Note entry}, @ref{Lyrics} and
4032 You may nest different input modes.
4036 @subsection Ambiguities
4041 The grammar contains a number of ambiguities. We hope to resolve them at
4045 @item The assignment
4051 can be interpreted as making a string identifier @code{\foo}
4052 containing @code{"bar"}, or a music identifier @code{\foo}
4053 containing the syllable `bar'.
4055 @item The assignment
4061 can be interpreted as making an integer identifier
4062 containing -6, or a Request identifier containing the
4063 fingering `6' (with neutral direction).
4065 @item If you do a nested repeat like
4077 then it is ambiguous to which @code{\repeat} the
4078 @code{\alternative} belongs. This is the classic if-then-else
4079 dilemma. It may be solved by using braces.
4081 @item (an as yet unidentified ambiguity :-)
4085 @c . {Lexical details}
4086 @node Lexical details
4087 @section Lexical details
4089 Even more boring details, now on lexical side of the input parser.
4100 * Version information::
4105 @subsection Comments
4108 @cindex block comment
4109 @cindex line comment
4113 A one line comment is introduced by a @code{%} character.
4114 Block comments are started by @code{%@{} and ended by @code{%@}}.
4115 They cannot be nested.
4118 @subsection Direct Scheme
4122 @cindex Scheme, in-line code
4125 LilyPond contains a Scheme interpreter (the GUILE library) for
4126 internal use. In some places Scheme expressions also form valid syntax:
4127 whereever it is allowed,
4131 evaluates the specified Scheme code. If this is used at toplevel, then
4132 the result is discarded. Example:
4134 \property Staff.TestObject \override #'foobar = #(+ 1 2)
4137 @code{\override} expects two Scheme expressions, so there are two Scheme
4138 expressions. The first one is a symbol (@code{foobar}), the second one
4139 an integer (namely, 3).
4141 Scheme is a full-blown programming language, and a full discussion is
4142 outside the scope of this document. Interested readers are referred to
4143 the website @uref{http://www.schemers.org/} for more information on
4148 @subsection Keywords
4152 Keywords start with a backslash, followed by a number of lower case
4153 alphabetic characters. These are all the keywords.
4156 apply arpeggio autochange spanrequest commandspanrequest
4157 simultaneous sequential accepts alternative bar breathe
4158 char chordmodifiers chords clef cm consists consistsend
4159 context denies duration dynamicscript elementdescriptions
4160 font grace header in lyrics key mark pitch
4161 time times midi mm name pitchnames notes outputproperty
4162 override set revert partial paper penalty property pt
4163 relative remove repeat addlyrics partcombine score
4164 script stylesheet skip textscript tempo translator
4169 @subsection Integers
4177 Formed from an optional minus sign followed by digits. Arithmetic
4178 operations cannot be done with integers, and integers cannot be mixed
4183 @cindex real numbers
4189 Formed from an optional minus sign and a sequence of digits followed
4190 by a @emph{required} decimal point and an optional exponent such as
4191 @code{-1.2e3}. Reals can be built up using the usual operations:
4192 `@code{+}', `@code{-}', `@code{*}', and
4193 `@code{/}', with parentheses for grouping.
4201 A real constant can be followed by one of the dimension keywords:
4202 @code{\mm} @code{\pt}, @code{\in}, or @code{\cm}, for millimeters,
4203 points, inches and centimeters, respectively. This converts the number
4204 a number that is the internal representation of that dimension.
4212 Begins and ends with the @code{"} character. To include a @code{"}
4213 character in a string write @code{\"}. Various other backslash
4214 sequences have special interpretations as in the C language. A string
4215 that contains no spaces can be written without the quotes. See
4216 @ref{Lexical modes} for details on unquoted strings; their
4217 interpretation varies depending on the situation. Strings can be
4218 concatenated with the @code{+} operator.
4220 The tokenizer accepts the following commands. They have no grammatical
4221 function, hence they can appear anywhere in the input.
4225 @subsection Main input
4228 @cindex @code{\maininput}
4230 The @code{\maininput} command is used in init files to signal that the
4231 user file must be read. This command cannot be used in a user file.
4233 @node File inclusion
4234 @subsection File inclusion
4235 @cindex @code{\include}
4237 \include @var{filename}
4240 Include @var{filename}. The argument @var{filename} may be a quoted string (an
4241 unquoted string will not work here!) or a string identifier. The full
4242 filename including the @file{.ly} extension must be given,
4245 @node Version information
4246 @subsection Version information
4247 @cindex @code{\version}
4249 \version @var{string} ;
4252 Specify the version of LilyPond that a file was written for. The
4253 argument is a version string in quotes, for example @code{"1.2.0"}.
4254 This is used to detect invalid input, and to aid
4255 @code{convert-ly} a tool that automatically upgrades input files. See
4256 See @ref{convert-ly} for more information on @code{convert-ly}.
4265 @c .{Local emacs vars}
4268 @c minor-mode: font-lock
4269 @c minor-mode: outline
4270 @c outline-layout: (-1 : 0)
4271 @c outline-use-mode-specific-leader: "@c \."
4272 @c outline-primary-bullet: "{"
4273 @c outline-stylish-prefixes: nil
4274 @c outline-override-protect: t