4 @c A menu is needed before every deeper *section nesting of @nodes
5 @c Run M-x texinfo-all-menus-update
6 @c to automagically fill in these menus
7 @c before saving changes
15 Rhythm staff (clef, x-notehead)
20 @c .{Reference Manual}
22 @node Reference Manual
23 @chapter Reference Manual
25 This document describes GNU LilyPond and its input format. The last
26 revision of this document was for LilyPond 1.3.136.
55 The purpose of LilyPond is explained informally by the term `music
56 typesetter'. This is not a fully correct name: not only does the
57 program print musical symbols, it also makes esthetic decisions.
58 Symbols and their placements are @emph{generated} from a high-level
59 musical description. In other words, LilyPond would be best described
60 by `music compiler' or `music to notation compiler'.
62 LilyPond is linked to GUILE, GNU's Scheme library for extension. The
63 Scheme library provides the glue that holds together the low-level
64 routines and separate modules general, which are C++
66 When lilypond is run to typeset sheet music, the following happens:
68 @item GUILE Initialization: various scheme files are read
69 @item parsing: first standard @code{ly} initialization files are read, and
70 then the user @file{ly} file is read.
71 @item interpretation: the music in the file is processed ``in playing
72 order'', i.e. the order that you use to read sheet music, or the
73 order in which notes are played.
76 in this step, the results of the interpretation, a typesetting
77 specification, is solved.
79 @item the visible results ("virtual ink") is written to the output file.
82 During these stages different types of data play the the main role:
83 during parsing, @strong{Music} objects are created. During the
84 interpretation, @strong{context} is constructed, and with this context
85 af network of @strong{graphical objects} (``grobs'') is created. The
86 grobs contain unknown variables, and the network forms a set of
87 equations. After solving the equations and filling in these variables,
88 the printed output (in the form of @strong{molecules}) is written to an
91 These threemanship of tasks (parsing, translating, typesetting) and
92 data-structures (music, context, graphical objects) permeates the entire
93 design of the program. This manual is ordered in terms of user
94 tasks. With each concept will be explained to which of the three parts
103 The most basic forms of music are notes. We discuss how you enter them
104 here. Notes on their own don't form valid input, but for the sake of
105 brevity we omit obligotary lint such as @code{\score} blocks and
106 @code{\paper} declarations.
112 * Defining pitch names::
125 @cindex Note specification
127 @cindex entering notes
129 The verbose syntax for pitch specification is
131 @cindex @code{\pitch}
133 \pitch @var{scmpitch}
136 @var{scmpitch} is a pitch scheme object, see @ref{Pitch data type}.
138 In Note and Chord mode, pitches may be designated by names. The default
139 names are the Dutch note names. The notes are specified by the letters
140 @code{a} through @code{g} (where the octave is formed by notes ranging
141 from @code{c}, to @code{b}). The pitch @code{c} is an octave below
142 middle C and the letters span the octave above that C.
144 @cindex note names, Dutch
146 In Dutch, a sharp is formed by adding @code{-is} to the end of a pitch
147 name. A flat is formed by adding @code{-es}. Double sharps and double
148 flats are obtained by adding @code{-isis} or @code{-eses}. @code{aes}
149 and @code{ees} are contracted to @code{as} and @code{es} in Dutch, but
150 both forms are accepted.
152 LilyPond has predefined sets of notenames for various other languages.
153 To use them, simply include the language specific init file. For
154 example: @code{\include "english.ly"}. The available language files and
155 the names they define are:
158 Note Names sharp flat
159 nederlands.ly c d e f g a bes b -is -es
160 english.ly c d e f g a bf b -s/-sharp -f/-flat
161 deutsch.ly c d e f g a b h -is -es
162 norsk.ly c d e f g a b h -iss/-is -ess/-es
163 svenska.ly c d e f g a b h -iss -ess
164 italiano.ly do re mi fa sol la sib si -d -b
165 catalan.ly do re mi fa sol la sib si -d/-s -b
173 The optional octave specification takes the form of a series of
174 single quote (`@code{'}') characters or a series of comma
175 (`@code{,}') characters. Each @code{'} raises the pitch by one
176 octave; each @code{,} lowers the pitch by an octave.
178 @lilypond[fragment,verbatim,center]
179 c' c'' es' g' as' gisis' ais'
182 @c . {Defining pitch names}
183 @node Defining pitch names
184 @subsection Defining pitch names
186 @cindex defining pitch names
187 @cindex pitch names, defining
189 Note names and chord modifiers can be customised for nationalities. The
190 syntax is as follows.
192 @cindex @code{\pitchnames}
193 @cindex @code{\chordmodifiers}
195 \pitchnames @var{scheme-alist}
196 \chordmodifiers @var{scheme-alist}
199 See @file{ly/nederlands.ly} and @file{ly/chord-modifiers.ly} for
200 specific examples how to do this.
206 @subsection Durations
210 @cindex @code{\duration}
212 The syntax for a verbose duration specification is
214 \duration @var{scmduration}
216 Here, @var{scmduration} is a Scheme object of type Duration. See
217 @ref{Duration} for more information.
220 In Note, Chord, and Lyrics mode, durations may be designated by numbers
221 and dots: durations are entered as their reciprocal values. For notes
222 longer than a whole note, use identifiers.
228 c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64
230 r1 r2 r4 r8 r16 r32 r64 r64
236 \notes \relative c'' {
237 a\longa a\breve \autoBeamOff
238 a1 a2 a4 a8 a16 a32 a64 a64
240 r1 r2 r4 r8 r16 r32 r64 r64
245 \remove "Clef_engraver";
246 \remove "Staff_symbol_engraver";
247 \remove "Time_signature_engraver";
248 \consists "Pitch_squash_engraver";
255 As you can see, the longa is not printed. To get a longa note head, you
256 have to use a mensural note heads. This is done accomplished by setting
257 the @code{style} property of the NoteHead grob to @code{mensural}.
259 If the duration is omitted then it is set to the previous duration
260 entered. At the start of parsing a quarter note is assumed. The
261 duration can be followed by a dot (`@code{.}') to obtain dotted note
265 @lilypond[fragment,verbatim,center]
271 You can alter the length of duration by appending
272 `@code{*}@var{fraction}'. This will not affect the appearance of the
273 notes or rests produced.
279 A note specification has the form
282 @var{pitch}[@var{octavespec}][!][?][@var{duration}]
285 LilyPond will determine what accidentals to typeset depending on the key
286 and context. The alteration refers to what note is heard, not to whether
287 an accidental is printed. A reminder accidental
288 @cindex reminder accidental
290 can be forced by adding an exclamation mark @code{!} after the pitch. A
291 cautionary accidental,
292 @cindex cautionary accidental
293 i.e., an accidental within parentheses can be obtained by adding the
294 question mark `@code{?}' after the pitch.
296 @lilypond[fragment,verbatim,center]
297 cis' d' e' cis' c'? d' e' c'!
301 @node Easy Notation note heads
302 @subsection Easy Notation note heads
304 @cindex easy notation
307 A entirely different type of note head is the "easyplay" note head: a
308 note head that includes a note name. It is used in some publications by
309 Hal-Leonard Inc. music publishers.
311 @lilypond[singleline,verbatim]
312 \include "paper26.ly"
314 \notes { c'2 e'4 f' | g'1 }
315 \paper { \translator { \EasyNotation } }
319 Note that @code{EasyNotation} overrides a @code{Score} context. You
320 probably will want to print it with magnification to make it better
326 If you view the result with Xdvi, then staff lines will show through the
327 letters. Printing the postscript file obtained either by using dvips or
328 the @code{-f ps} option of lilypond will produce the desired result.
338 A tie connects two adjacent note heads of the same pitch. When used
339 with chords, it connects all of the note heads whose pitches match.
340 Ties are indicated using the tilde symbol `@code{~}'.
341 If you try to tie together chords which have no common pitches, a
342 warning message will appear and no ties will be created.
344 @lilypond[fragment,verbatim,center]
345 e' ~ e' <c' e' g'> ~ <c' e' g'>
348 If you dislike the amount of ties created for a chord, you set
349 @code{Thread.sparseTies} to true, resulting in a smaller number of
351 @lilypond[fragment,verbatim,center]
352 \property Thread.sparseTies = ##t
353 <c' e' g'> ~ <c' e' g'>
356 In its meaning a tie is just a way of extending a note duration, similar
357 to the augmentation dot: the following example are three ways of notating
358 exactly the same concept.
359 @lilypond[fragment, singleline]
362 At present, the tie is implemented as a separate thing, temporally
363 located in between the notes. There is also no way to convert
364 between tied notes, dotted notes and plain notes.
368 @subsubsection Tuplets
372 Tuplets are made out of a music expression by multiplying their duration
375 @cindex @code{\times}
377 \times @var{fraction} @var{musicexpr}
380 The duration of @var{musicexpr} will be multiplied by the fraction.
381 In print, the fraction's denominator will be printed over the notes,
382 optionally with a bracket. The most common tuplet is the triplet in
383 which 3 notes have the length of 2, so the notes are 2/3 of
384 their written length:
386 @lilypond[fragment,verbatim,center]
387 g'4 \times 2/3 {c'4 c' c'} d'4 d'4
390 [todo: document tupletSpannerDuration]
400 Rests are entered like notes, with note name `@code{r}'.
410 \skip @var{duration} @code{;}
415 Skips the amount of time specified by @var{duration}. If no other music
416 is played, a gap will be left for the skipped time with no notes
417 printed. The short hand is only available in Note and Chord mode.
422 @subsection Note mode
427 @cindex @code{\notes}
429 Note mode is the lexical mode generally used for inputting notes. The
435 This instructs the tokenizer to interpret @var{expr} in note mode. If a
436 a sequence of alfabetical characters, like @code{foobar}, LilyPond first
437 checks if @code{foobar} is a pitch name. If it is not a pitch name,
438 then it is treated as a string.
440 Numbers and dots indicate durations, so you can enter floating point
441 numbers in this mode.
445 @section Staff notation
447 @cindex Staff notation
457 @subsection Key signature
462 Changing the key signature is done with the @code{\key} command.
464 @code{\key} @var{pitch} @var{type} @code{;}
467 @cindex @code{\minor}
468 @cindex @code{\major}
469 @cindex @code{\minor}
470 @cindex @code{\ionian}
471 @cindex @code{\locrian}
472 @cindex @code{\aeolian}
473 @cindex @code{\mixolydian}
474 @cindex @code{\lydian}
475 @cindex @code{\phrygian}
476 @cindex @code{\dorian}
478 Here, @var{type} should be @code{\major} or @code{\minor} to get
479 @var{pitch}-major or @var{pitch}-minor, respectively. The second
480 argument is optional; the default is major keys. The @var{\context}
481 argument can also be given as an integer, which tells the number of
482 semitones that should be added to the pitch given in the subsequent
483 @code{\key} commands to get the corresponding major key, e.g.,
484 @code{\minor} is defined as 3. The standard mode names @code{\ionian},
485 @code{\locrian}, @code{\aeolian}, @code{\mixolydian}, @code{\lydian},
486 @code{\phrygian}, and @code{\dorian} are also defined.
488 This command sets context property @code{Staff.keySignature}.
490 @cindex @code{keySignature}
493 @subsection Clef changes
496 \clef @var{clefname} @code{;}
502 \property Staff.clefGlyph = @var{glyph associated with clefname}
503 \property Staff.clefPosition = @var{clef Y-position for clefname}
504 \property Staff.clefOctavation = @var{extra pitch of clefname}
507 Supported clef-names include
510 @item treble, violin, G, G2: G clef on 2nd line
511 @item french: G clef on 1st line
512 @item soprano: C clef on 1st line
513 @item mezzosoprano: C clef on 2nd line
514 @item alto: C clef on 3rd line
515 @item tenor: C clef on 4th line
516 @item baritone: C clef on 5th line
517 @item varbaritone: F clef on 3rd line
518 @item bass, F: F clef on 4th line
519 @item subbass: F clef on 5th line
520 @item percussion: percussion clef
523 Supported associated glyphs (for @code{Staff.clefGlyph}) are:
526 @item clefs-C: modern style C clef
527 @item clefs-F: modern style F clef
528 @item clefs-G: modern style G clef
529 @item clefs-vaticana_do: Editio Vaticana style do clef
530 @item clefs-vaticana_fa: Editio Vaticana style fa clef
531 @item clefs-medicaea_do: Editio Medicaea style do clef
532 @item clefs-medicaea_fa: Editio Medicaea style fa clef
533 @item clefs-mensural1_c: modern style mensural C clef
534 @item clefs-mensural2_c: historic style small mensural C clef
535 @item clefs-mensural3_c: historic style big mensural C clef
536 @item clefs-mensural1_f: historic style traditional mensural F clef
537 @item clefs-mensural2_f: historic style new mensural F clef
538 @item clefs-mensural_g: historic style mensural G clef
539 @item clefs-hufnagel_do: historic style hufnagel do clef
540 @item clefs-hufnagel_fa: historic style hufnagel fa clef
541 @item clefs-hufnagel_do_fa: historic style hufnagel combined do/fa clef
542 @item clefs-percussion: modern style percussion clef
545 @emph{Modern style} means ``as is typeset in current editions.''
546 @emph{Historic style} means ``as was typeset or written in contemporary
547 historic editions''. @emph{Editio XXX style} means ``as is/was printed in
550 @cindex Vaticana, Editio
551 @cindex Medicaea, Editio
552 @cindex hufnagel clefs
555 @c . {Time signature}
557 @subsection Time signature
558 @cindex Time signature
562 The time signature is changed by the @code{\time} command. Syntax:
564 \time @var{numerator}@code{/}@var{denominator} @code{;}
566 Internally, this is a short-cut for doing
568 \property Score.timeSignatureFraction = #'(@var{numerator} . @var{denominator})
571 [TODO: discuss options for layout]
575 @subsubsection Partial
579 @cindex partial measure
580 @cindex measure, partial
581 @cindex shorten measures
582 @cindex @code{\partial}
584 Partial measures are entered using the @code{\partial} command:
586 \partial @var{duration} @code{;}
589 Internally, this is a short cut for
592 \property Score.measurePosition = -@var{length of duration}
598 @subsection Bar lines
602 @cindex measure lines
609 This is a short-cut for doing
611 \property Score.whichBar = @var{bartype}
614 You are encouraged to use @code{\repeat} for repetitions. See
615 @ref{Repeats}, and the documentation of @code{whichBar} in the generated
624 [TODO: collisions, rest-collisinos, voiceX identifiers, how to
625 which contexts to instantiate.]
629 @cindex @code{\shiftOff}
630 @item @code{\shiftOff}
631 Disable horizontal shifting of note heads that collide.
633 @cindex @code{\shiftOn}
634 @item @code{\shiftOn}
635 Enable note heads that collide with other note heads to be
636 shifted horiztonally. Also @code{\shiftOnn} and @code{\shiftOnnn}
637 set different shift values.
639 @cindex @code{\stemBoth}
640 @item @code{\stemBoth}
641 Allow stems, beams, and slurs to point either upwards or
642 downwards, decided automatically by LilyPond.
644 @cindex @code{\stemDown}
645 @item @code{\stemDown}
646 Force stems, beams, and slurs to point down.
648 @cindex @code{\stemUp}
650 Force stems, beams and slurs to point up.
657 Beams are used to group short notes into chunks that are aligned with
658 the metrum. LilyPond guesses where beams should be inserted, but if
659 you're not satisfied with the automatic beaming, you can either instruct
660 lilypond which patterns to beam automatically. In specific cases, you
661 can also specify explicitly what to beam and what not.
664 @c . {Automatic beams}
665 @subsection Automatic beams
667 @cindex @code{Voice.autoBeamSettings}
668 @cindex @code{(end * * * *)}
669 @cindex @code{(begin * * * *)}
671 A large number of Voice properties are used to decide how to generate
672 beams. Their default values appear in @file{scm/auto-beam.scm}.
674 By default, automatic beams can start on any note@footnote{In exotic
675 time signatures such as 1/8 and 1/16 this is not true} but can only end
676 in a few positions within the measure: they can end on a beat, or at
677 durations specified by the properties in
678 @code{Voice.autoBeamSettings}. The defaults for @code{autoBeamSettings}
679 are defined in @file{scm/auto-beam.scm}.
681 The syntax for changing the value @code{autoBeamSettings} is set using
682 @code{\override} and unset using @code{\revert}:
684 \property Voice.autoBeamSettings \override #'(@var{BE} @var{N} @var{M} @var{P} @var{Q}) = @var{dur}
685 \property Voice.autoBeamSettings \revert #'(@var{BE} @var{N} @var{M} @var{P} @var{Q})
687 Here, @var{BE} is the symbol @code{begin} or @code{end}. It determines
688 whether the rule applies to begin or end-points. The quantity
689 @var{N}/@var{M} refers to a time signature (@code{* *} may be entered to
690 designate all time signatures), @var{P}/@var{Q} refers to the length of
691 the beamed notes (@code{* *} designate notes of any length).
693 If you want automatic beams to end on every quarter note, you can
696 \property Voice.autoBeamSettings \override
697 #'(end * * * *) = #(make-moment 1 4)
699 The duration a quarter note is 1/4 of a whole note. It is entered as
700 @code{(make-moment 1 4)}.
702 The same syntax can be used to specify beam starting points. In this
703 example, you automatic beams can only end on a dotted quarter note.
705 \property Voice.autoBeamSettings \override
706 #'(begin * * * *) = #(make-moment 3 8)
708 In 4/4 time signature, this means that automatic beams could end only on
709 3/8 and on the fourth beat of the measure (after 3/4, that is 2 times
710 3/8 has passed within the measure).
712 You can also restrict rules to specific time signatures. A rule that
713 should only be applied in @var{N}/@var{M} time signature is formed by
714 replacing the first asterisks by @var{N} and @var{M}. For example, a
715 rule for 6/8 time exclusively looks like
717 \property Voice.autoBeamSettings \override
718 #'(begin 6 8 * *) = ...
721 If you want a rule to apply to certain types of beams, you can use the
722 second pair of asterisks. Beams are classified according to the shortest
723 note they contain. For a beam ending rule that only applies to beams
724 with 32nd notes (and no shorter notes), you would use @code{(end * * 1
727 [say something about irregular meters. eg 5/8 = 2+3/8, 3+2/8]
729 Automatic beams can not be put on the last note in a score.
731 @cindex automatic beam generation
733 @cindex @code{Voice.noAutoBeaming}
735 Automatic beaming is on by default, but it can switched off by setting
736 @code{Voice.noAutoBeaming} to true. You you may find this necessary for
737 a melody that goes with lyrics.
740 @cindex Automatic beams
741 @subsubsection Manual beams
742 @cindex beams, manual
746 In some cases it may be necessary to override LilyPond's automatic
747 beaming algorithm. For example, the auto beamer will not beam over
748 rests or bar lines, so if you want that, specify the begin and end point
749 manually using @code{[} and @code{]}:
752 @lilypond[fragment,relative,verbatim]
754 r4 [r8 g'' a r8] r8 [g | a] r8
757 Whenever an manual beam is busy, the auto beam will not produce
760 @cindex @code{stemLeftBeamCount}
762 If you have specific wishes for the number of beams, you can fully
763 control the number of beams through the properties
764 @code{Voice.stemLeftBeamCount} and @code{Voice.stemRightBeamCount}.
766 @lilypond[fragment,relative,verbatim]
769 [f8 r16 \property Voice.stemLeftBeamCount = #1 f g a]
773 @cindex @code{stemRightBeamCount}
776 [FIXME: explain common tweaks.]
779 @node Expressive marks
780 @section Expressive marks
787 A slur indicates that notes are to be played bound or @em{legato}. In
788 lilypond, they are entered using parentheses:
789 @lilypond[fragment,verbatim,center]
790 f'()g'()a' [a'8 b'(] a'4 g'2 )f'4
794 Slurs avoid crossing stems, and are attached to note heads whenever
795 possible. In some instances involving beams slurs may be attached to a
796 stem end. If you want to override this layout you can do this through
797 @code{Voice.Slur}'s grob-property @code{attachment}:
799 [TODO: remove this section]
802 @lilypond[fragment,relative,verbatim]
803 \property Voice.Slur \set #'direction = #1
804 \property Voice.Stem \set #'length = #5.5
806 \property Voice.Slur \set #'attachment = #'(stem . stem)
811 If a slur would strike through a stem or beam, the slur will be moved
812 away upward or downward. If this happens, attaching the slur to the
813 stems might look better:
816 @lilypond[fragment,relative,verbatim]
817 \property Voice.Stem \set #'direction = #1
818 \property Voice.Slur \set #'direction = #1
820 \property Voice.Slur \set #'attachment = #'(stem . stem)
825 Similarly, the curvature of a slur is adjusted to stay clear of note
826 heads and stems. When that would increase the curvature too much, the
827 slur is reverted to its default shape. The threshold for this decision
828 is in @code{Voice.Slur}'s grob-property @code{beautiful}. In some
829 cases, you may prefer curved slurs to vertically moved ones. You can
830 express this by increasing the @code{beautiful} value:
832 [hoe gedefd?? wat betekent beautiful = X?]
834 [dit voorbeeld is te lang: junken, of inkorten]
839 \notes \context PianoStaff <
841 \context Staff=up { s1 * 6/4 }
842 \context Staff=down <
844 \autochange Staff \context Voice
846 d,8( a' d f a d f d a f d )a
854 Slur \override #'beautiful = #5.0
855 Slur \override #'direction = #1
856 Stem \override #'direction = #-1
857 autoBeamSettings \override #'(end * * * *)
862 VerticalAlignment \override #'threshold = #'(5 . 5)
869 @cindex Adusting slurs
872 @subsection Phrasing slur
874 @cindex phrasing slur
875 @cindex phrasing mark
877 A phrasing slur (or phrasing mark) connects chords and is used to
878 indicate a musical sentence. It is entered using @code{\(} and @code{\)}.
879 @lilypond[fragment,verbatim,center,relative]
880 \time 6/4; c''\((d)e f(e)\)d
883 Typographically, the phrasing slur behaves almost exactly like a normal
884 slur. The grob associated with it is @code{Voice.PhrasingSlur}.
887 @subsection Breath marks
889 Breath marks are entered using @code{\breathe}:
891 @lilypond[fragment,relative]
895 Currently, only tick marks are supported, comma style breath marks are
896 not. The grob for this object is called @code{Voice.BreathingSign}.
902 @subsubsection Text spanner
905 Some textual indications, e.g. rallentando, accelerando, often extend
906 over a many measures. This is indicated by following the text with a
907 dotted line. You can create such texts in LilyPond using
908 text spanners. The syntax is as follows:
910 \spanrequest \start "text"
911 \spanrequest \stop "text"
913 LilyPond will respond by creating a @code{Voice.TextSpanner} grob. The
914 string to be printed, as well as the style is set through grob
917 An application ---or rather, a hack---is to fake octavation indications.
918 @lilypond[fragment,relative,verbatim]
919 \relative c' { a'''' b c a
920 \property Voice.TextSpanner \set #'type = #'dotted-line
921 \property Voice.TextSpanner \set #'edge-height = #'(0 . 1.5)
922 \property Voice.TextSpanner \set #'edge-text = #'("8va " . "")
923 \property Staff.centralCPosition = #-13
924 a\spanrequest \start "text" b c a \spanrequest \stop "text" }
941 @subsection Articulation
944 @cindex articulations
948 A variety of symbols can appear above and below notes to indicate
949 different characteristics of the performance. These symbols can be
950 added to a note with `@var{note}@code{-\}@var{name}'. Numerous symbols
951 are defined in @file{script.ly} and @file{script.scm}. Symbols can be
952 forced to appear above or below the note by writing
953 `@var{note}@code{^\}@var{name}' and `@var{note}@code{_\}@var{name}'
954 respectively. Here is a chart showing symbols above notes, with the
955 name of the corresponding symbol appearing underneath.
960 \property Score.LyricSyllable \override #'font-family =
962 \property Score.LyricSyllable \override #'font-shape = #'upright
963 c''-\accent c''-\marcato c''-\staccatissimo c''-\fermata
964 c''-\stopped c''-\staccato c''-\tenuto c''-\upbow
965 c''-\downbow c''^\lheel c''-\rheel c''^\ltoe
966 c''-\rtoe c''-\turn c''-\open c''-\flageolet
967 c''-\reverseturn c''-\trill c''-\prall c''-\mordent
968 c''-\prallprall c''-\prallmordent c''-\upprall c''-\downprall
969 c''-\thumb c''-\segno c''-\coda
971 \context Lyrics \lyrics {
972 accent__ marcato__ staccatissimo__ fermata
973 stopped__ staccato__ tenuto__ upbow
974 downbow__ lheel__ rheel__ ltoe
975 rtoe__ turn__ open__ flageolet
976 reverseturn__ trill__ prall__ mordent
977 prallprall__ prallmordent__ uprall__ downprall
982 linewidth = 5.875\in;
987 All of these note ornaments appear in the printed output but have no
988 effect on the MIDI rendering of the music.
990 To save typing work, some shorthands are available:
991 @lilypond[singleline]
993 \notes \context Voice {
994 \property Voice.TextScript \set #'font-family = #'typewriter
995 \property Voice.TextScript \set #'font-shape = #'upright
1001 c''4-^_"c-\\^{ }" s4
1008 Fingering instructions can also be entered in this shorthand.
1009 @lilypond[verbatim, singleline, fragment]
1010 c'4-1 c'4-2 c'4-3 c'4-4
1013 Unfortunately, there is no support adding fingering instructions to
1014 individual note heads. Some hacks exist, though. See
1015 @file{input/test/script-horizontal.ly}.
1018 @cindex @code{\script}
1027 Defines a script printing request. The argument is a string which
1028 points into the script-alias table defined in @file{scm/script.scm}.
1029 Usually the @code{\script} keyword is not used directly. Various
1030 helpful identifier definitions appear in @file{script.ly}.
1032 For information on how to add scripts, consult @file{scm/script.scm}.
1038 @subsection Text scripts
1039 @cindex Text scripts
1041 In addition, it is possible to place arbitrary strings of text or markup
1042 text (see @ref{Text markup}) above or below notes by using a string:
1043 @code{c^"text"}. The text is typeset in italic by default.
1045 The amount of space taken by these indications by default does not
1046 influence, spacing, but setting @code{Voice.textNonEmpty} to true will
1047 take the widths into account. The identifier @code{\fattext} is defined
1048 in the standard includes.
1049 @lilypond[fragment,singleline]
1050 \relative c' { c4^"longtext" \fatText c4_"longlongtext" c4 }
1053 Text scripts are created in form of @code{Voice.TextScript} grobs.
1055 For purposes of defining identifiers, a more verbose form also exists:
1058 \textscript @var{text}
1061 Defines a text to be printed over or under a note. @var{text} is a
1062 string or a markup text.
1066 foo = \textscript #'(finger "6")
1073 This is equivalent to @code{c4-6 c4-"foo"}.
1078 @subsection Grace notes
1087 @cindex @code{\grace}
1090 @cindex @code{graceAlignPosition}
1092 Grace notes are ornaments that are written out, but do not take up any
1093 logical time in a measure. LilyPond has limited support for grace notes.
1094 The syntax is as follows.
1096 \grace @var{musicexpr}
1099 When grace music is interpreted, a score-within-a-score is set up:
1100 @var{musicexpr} has its own time bookkeeping, and you could (for
1101 example) have a separate time signature within grace notes. While in
1102 this score-within-a-score, you can create notes, beams, slurs, etc.
1103 Unbeamed eighth notes and shorter by default have a slash through the
1104 stem. This behavior can be controlled with the
1105 @code{Stem}.@code{flag-style} property.
1108 @lilypond[fragment,verbatim]
1110 \grace c8 c4 \grace { [c16 c16] } c4
1111 \grace { \property Grace.Stem \override #'flag-style = ##f c16 } c4
1118 At present, nesting @code{\grace} notes is not supported. The following
1119 may cause run-time errors:
1121 @code{\grace @{ \grace c32 c16 @} c4}
1123 Since the meaning of such a construct is unclear, we don't consider this
1124 a loss. Similarly, juxtaposing two @code{\grace} sections is
1125 syntactically valid, but makes no sense and may cause runtime errors.
1126 Ending a staff or score with grace notes may also generate a run-time
1127 error, since there will be no main note to attach the grace notes to.
1130 A grace note expression has duration 0; the next real note is assumed to
1131 be the main note. If you want the note to appear after the main note,
1132 set @code{Voice.graceAlignPosition} to @code{1}.
1134 The present implementation of grace notes is not robust and generally
1135 kludgy. We expect it to change after LilyPond 1.4. Syntax changes might
1136 also be implemented.
1143 * Crescendo and Decrescendo::
1151 @subsubsection Glissando
1154 @cindex @code{\glissando}
1156 A glissando line can be requested by attaching a @code{\glissando} to a
1160 @lilypond[fragment,relative,verbatim]
1165 Printing of an additional text (such as @emph{gliss.}) must be done
1172 @subsubsection Dynamics
1185 @cindex @code{\ffff}
1195 Absolute dynamic marks are specified by using an identifier after a
1196 note: @code{c4-\ff}. The available dynamic marks are: @code{\ppp},
1197 @code{\pp}, @code{\p}, @code{\mp}, @code{\mf}, @code{\f}, @code{\ff},
1198 @code{\fff}, @code{\fff}, @code{\fp}, @code{\sf}, @code{\sff},
1199 @code{\sp}, @code{\spp}, @code{\sfz}, and @code{\rfz}.
1202 @cindex Crescendo and Decrescendo
1206 @cindex @code{\decr}
1207 @cindex @code{\rced}
1213 A crescendo mark is started with @code{\cr} and terminated with
1214 @code{\rc} (the textual reverse of @code{cr}). A decrescendo mark is
1215 started with @code{\decr} and terminated with @code{\rced}. There are
1216 also shorthands for these marks. A crescendo can be started with
1217 @code{\<} and a decrescendo can be started with @code{\>}. Either one
1218 can be terminated with @code{\!}. Note that @code{\!} must go before
1219 the last note of the dynamic mark whereas @code{\rc} and @code{\rced} go
1220 after the last note. Because these marks are bound to notes, if you
1221 want to get several marks during one note, you must use spacer notes.
1223 @lilypond[fragment,verbatim,center]
1224 c'' \< \! c'' d'' \decr e'' \rced
1225 < f''1 { s4 \< \! s2 \> \! s4 } >
1230 You can also use a text saying @emph{cresc.} instead of hairpins. Here
1231 is an example how to do it:
1233 @lilypond[fragment,relative,verbatim]
1235 \property Voice.crescendoText = "cresc."
1236 \property Voice.crescendoSpanner = #'dashed-line
1252 @cindex @code{\repeat}
1254 To specify repeats, use the @code{\repeat} keyword. Since repeats
1255 should work differently when played or printed, there are a few
1256 different variants of repeats.
1260 Repeated music is fully written (played) out. Useful for MIDI
1264 This is the normal notation: Repeats are not written out, but
1265 alternative endings (voltas) are printed, left to right.
1268 Alternative endings are written stacked. Which is unfortunately not
1269 practical for anything right now.
1275 Make measure repeats. These look like percent signs.
1281 * Manual repeat commands::
1283 * Tremolo subdivision::
1288 @subsection Repeat syntax
1290 The syntax for repeats is
1293 \repeat @var{variant} @var{repeatcount} @var{repeatbody}
1296 If you have alternative endings, you may add
1297 @cindex @code{\alternative}
1299 \alternative @code{@{} @var{alternative1}
1301 @var{alternative3} @dots{} @code{@}}
1303 where each @var{alternative} is a music expression.
1305 Normal notation repeats are used like this:
1306 @lilypond[fragment,verbatim]
1308 \repeat volta 2 { c'4 d' e' f' }
1309 \repeat volta 2 { f' e' d' c' }
1312 With alternative endings:
1314 @lilypond[fragment,verbatim]
1316 \repeat volta 2 {c'4 d' e' f'}
1317 \alternative { {d'2 d'} {f' f} }
1321 Folded repeats look like this:@footnote{Folded repeats offer little
1322 more over simultaneous music. However, it is to be expected that
1323 more functionality -- especially for the MIDI backend -- will be
1324 implemented at some point in the future.}
1327 @lilypond[fragment,verbatim]
1329 \repeat fold 2 {c'4 d' e' f'}
1330 \alternative { {d'2 d'} {f' f} }
1336 If you don't give enough alternatives for all of the repeats, then
1337 the first alternative is assumed to be repeated often enough to equal
1338 the specified number of repeats.
1341 @lilypond[fragment,verbatim]
1345 \repeat volta 3 { e | c2 d2 | e2 f2 | }
1346 \alternative { { g4 g g } { a | a a a a | b2. } }
1352 As you can see, LilyPond doesn't remember the timing information, nor
1353 are slurs or ties repeated, so you have to reset timing information
1354 after a repeat, e.g. using a bar-check (See @ref{Bar checks}),
1355 @code{Score.measurePosition} or @code{\partial}. We hope to fix this
1358 It is possible to nest @code{\repeat}, although it probably is only
1359 meaningful for unfolded repeats.
1361 @node Manual repeat commands
1362 @subsection Manual repeat commands
1364 @cindex @code{repeatCommands}
1366 The property @code{repeatCommands} can be used to control the layout of
1367 repeats. Its value is a Scheme list of repeat commands, where each repeat
1375 @item (volta . @var{text})
1376 Print a volta bracket saying @var{text}.
1378 Stop a running volta bracket
1381 @lilypond[verbatim, fragment]
1383 \property Score.repeatCommands = #'((volta "93") end-repeat)
1385 \property Score.repeatCommands = #'((volta #f))
1390 [explain precendence: \bar, repeatCommands, whichBar, defaultBarType]
1392 @node Tremolo repeats
1393 @subsection Tremolo repeats
1394 @cindex tremolo beams
1396 To place tremolo marks between notes, use @code{\repeat} with tremolo
1398 @lilypond[verbatim,center,singleline]
1400 \context Voice \notes\relative c' {
1401 \repeat "tremolo" 8 { c16 d16 }
1402 \repeat "tremolo" 4 { c16 d16 }
1403 \repeat "tremolo" 2 { c16 d16 }
1404 \repeat "tremolo" 4 c16
1409 At present, the spacing between tremolo beams is not regular, since the
1410 spacing engine does not notice that not all notes are printed.
1412 @node Tremolo subdivision
1413 @subsection Tremolo subdivision
1414 @cindex tremolo marks
1415 @cindex @code{tremoloFlags}
1417 Tremolo marks can be printed on a single note by adding
1418 `@code{:}[@var{length}]' after the note. The length must be at least 8.
1419 A @var{length} value of 8 gives one line across the note stem. If the
1420 length is omitted, then then the last value (stored in
1421 @code{Voice.tremoloFlags}) is used.
1423 @lilypond[verbatim,fragment,center]
1426 Using this mechanism pays off when you entering many tremolos, since the
1427 default argument saves a lot of typing.
1429 Tremolos in this style do not carry over into the MIDI output.
1432 @node Measure repeats
1433 @subsection Measure repeats
1435 @cindex percent repeats
1436 @cindex measure repeats
1438 In the @code{percent} style, a note pattern can be repeated. It is
1439 printed once, and then the pattern is replaced with a special sign.
1441 @lilypond[verbatim,singleline]
1442 \context Voice { \repeat "percent" 5 { c'1 } }
1445 At present, only repeats of whole measures are supported.
1449 @section Piano music
1451 Piano music is an odd type of notation: two staffs are largely
1452 independent, but sometimes voices can cross between the two staffs. The
1453 @code{PianoStaff} is especially built to handle this cross-staffing
1454 behavior. In this section we discuss the @code{PianoStaff} and some
1455 other pianistic peculiarities.
1458 * Automatic staff changes::
1459 * Manual staff switches::
1466 @c . {Automatic staff changes}
1467 @node Automatic staff changes
1468 @subsection Automatic staff changes
1469 @cindex Automatic staff changes
1471 Voices can be switched from top to bottom staff automatically. The
1474 \autochange @var{contexttype} @var{musicexp}
1476 This will switch notation context of @var{musicexp} between a
1477 @var{contexttype} named @code{up} and @code{down}. Typically, you use
1478 @code{Staff} for @var{contexttype}. The autochanger switches on basis
1479 of pitch (central C is the turning point), and it looks ahead skipping
1480 over rests to switch rests in advance.
1482 @lilypond[verbatim,singleline]
1483 \score { \notes \context PianoStaff <
1484 \context Staff = "up" {
1485 \autochange Staff \context Voice = VA < \relative c' {
1486 g4 a b c d r4 a g } > }
1487 \context Staff = "down" {
1493 Note how spacer rests are used to prevent the bottom staff from
1494 terminating too soon.
1497 @node Manual staff switches
1498 @subsection Manual staff switches
1500 @cindex manual staff switches
1501 @cindex staff switch, manual
1503 Voices can be switched between staffs manually, using the following command:
1505 \translator Staff = @var{which} @var{music}
1507 The string @var{which} is the name of the staff. Typically it is
1508 @code{"up"} or @code{"down"}.
1510 Formally, this construct is a music expression indicating that the
1511 context which is a direct child of the a context of type
1512 @var{contexttype} should be shifted to a context of type
1513 @var{contexttype} and the specified name.
1515 @cindex @code{\translator}
1517 \translator @var{contexttype} = @var{name}
1526 Piano pedals can be entered using the span requests (See @ref{Span
1527 requests}) of the types @code{Sustain}, @code{UnaChorda} and
1530 @lilypond[fragment,verbatim]
1531 c''4 \spanrequest \start "Sustain" c4 c4 \spanrequest \stop "Sustain"
1534 For these verbose expressions, standard shorthands have been defined:
1535 @code{sustainDown}, @code{sustainUp}, @code{unaChorda},
1536 @code{treChorde}, @code{sostenutoDown} and @code{sostenutoUp}. The
1537 symbols that are printed can be modified by setting
1538 @code{pedal@var{X}Strings}, where @var{X} is one of the pedal
1539 types. Refer to the generated documentation for more information.
1541 Currently, brackets are not supported, only text markings (ie. *Ped
1547 @subsection Arpeggio
1550 @cindex broken arpeggio
1551 @cindex @code{\arpeggio}
1553 You can specify an arpeggio sign on a chord by attaching an
1554 @code{\arpeggio} to a note of the chord.
1558 @lilypond[fragment,relative,verbatim]
1559 \context Voice <c'\arpeggio e g c>
1563 When an arpeggio crosses staffs in piano music, you attach an arpeggio
1564 to the chords in both staffs, and set
1565 @code{PianoStaff.connectArpeggios}.
1568 @lilypond[fragment,relative,verbatim]
1569 \context PianoStaff <
1570 \property PianoStaff.connectArpeggios = ##t
1571 \context Voice = one { <c''\arpeggio e g c> }
1572 \context Voice = other { \clef bass; <c,,\arpeggio e g>}
1577 This command creates @code{Arpeggio} grobs. It is not possible to mix
1578 connected arpeggios and unconnected arpeggios at the same time.
1581 @c . {Follow Thread}
1583 @subsection Follow Thread
1584 @cindex follow thread
1585 @cindex staff switching
1588 [todo: different name, eg. voice line ? ]
1590 @cindex @code{followThread}
1592 Whenever a voice switches to another staff a line connecting the notes
1593 can be printed automatically. This is enabled if the property
1594 @code{PianoStaff.followThread} is set to true:
1597 @lilypond[fragment,relative,verbatim]
1598 \context PianoStaff <
1599 \property PianoStaff.followThread = ##t
1600 \context Staff \context Voice {
1602 \translator Staff=two
1605 \context Staff=two {\clef bass; \skip 1*2;}
1619 * Automatic syllable durations::
1625 @subsection Lyrics mode
1629 @cindex @code{\lyrics}
1631 Lyrics mode is introduced by the keyword @code{\lyrics}. This mode has
1632 rules that make it easy to include punctuation and diacritical marks in
1633 words: The purpose of Lyrics mode is that you can enter lyrics in @TeX{}
1634 format or a standard encoding without needing quotes. The precise
1635 definition of this mode is ludicrous, and this will remain so until the
1636 authors of LilyPond acquire a deeper understanding of character
1637 encoding, or someone else steps up to fix this.
1639 A word in Lyrics mode begins with: an alphabetic character, @code{_},
1640 @code{?}, @code{!}, @code{:}, @code{'}, the control characters @code{^A}
1641 through @code{^F}, @code{^Q} through @code{^W}, @code{^Y}, @code{^^},
1642 any 8-bit character with ASCII code over 127, or a two-character
1643 combination of a backslash followed by one of @code{`}, @code{'},
1644 @code{"}, or @code{^}.
1646 Subsequent characters of a word can be any character that is not a digit
1647 and not white space. One important consequence of this is that a word
1648 can end with `@code{@}}', which may be confusing. However, LilyPond will
1649 issue a warning. Any @code{_} character which appears in an unquoted
1650 word is converted to a space. This provides a mechanism for introducing
1651 spaces into words without using quotes. Quoted words can also be used
1652 in Lyrics mode to specify words that cannot be written with the above
1653 rules. Here are some examples. Not all of these words are printable by
1658 2B_||_!2B % not a word because it starts with a digit
1659 ``Hello'' % not a word because it starts with `
1660 _ _ _ _ % 4 words, each one a space
1663 Since combinations of numbers and dots are used for indicating
1664 durations, you can not enter real numbers in this mode.
1666 @cindex lyrics expressions
1668 Syllables are entered like notes, with pitches replaced by text. For
1669 example, @code{Twin-4 kle4 twin-4 kle4} enters four syllables, each
1670 with quarter note duration. Note that the hyphen has no special
1671 meaning for lyrics, and does not introduce special symbols. See
1672 @ref{Lexical modes} for a description of what is interpreted as
1675 Spaces can be introduced into a lyric either by using quotes
1676 (@code{"}) or by using an underscore without quotes: @code{He_could4
1677 not4}. All unquoted underscores are converted to spaces. Printing
1678 lyrics is discussed in the next section.
1681 @c . {Printing lyrics}
1682 @node Printing lyrics
1683 @subsection Printing lyrics
1687 Lyric syllables must be interpreted within a @code{Lyrics} context for
1688 printing them. Here is a full example:
1694 \notes \transpose c'' {
1696 e f g2 | e4 f g2 \bar "|.";
1698 \context Lyrics \lyrics {
1699 Va-4 der Ja- cob Va- der Ja- cob
1700 Slaapt gij nog?2 Slaapt4 gij nog?2
1712 @cindex lyric extender
1714 You may want a continuous line after the syllables to show melismata.
1715 To achieve this effect, add a @code{__} lyric as a separate word
1716 after the lyric to be extended. This will create an extender, a line
1717 that extends over the entire duration of the lyric. This line will
1718 run all the way to the start of the next lyric, so you may want to
1719 shorten it by using a blank lyric (using @code{_}).
1726 \notes \relative c'' {
1727 a4 () b () c () d | c () d () b () a | c () d () b () a
1729 \context Lyrics \lyrics {
1730 foo1 __ | bar2. __ _4 | baz1 __
1738 @cindex Lyric hyphen
1740 If you want to have hyphens centered between syllables (rather than
1741 attached to the end of the first syllable) you can use the special
1742 `@code{-}@code{-}' lyric as a separate word between syllables. This
1743 will result in a hyphen which length varies depending on the space
1744 between syllables, and which will be centered between the syllables.
1752 \notes \transpose c'' {
1754 e f g2 | e4 f g2 \bar "|.";
1756 \context Lyrics \lyrics {
1757 Va4 -- der Ja -- cob | Va -- der Ja -- cob |
1758 Slaapt gij nog?2 | Slaapt4 gij nog?2
1767 @c . {Automatic syllable durations}
1768 @node Automatic syllable durations
1769 @subsection Automatic syllable durations
1770 @cindex Automatic syllable durations
1773 @cindex automatic lyric durations
1774 @cindex @code{\addlyrics}
1776 If you have lyrics that are set to a melody, you can import the rhythm
1777 of that melody into the lyrics using @code{\addlyrics}. The syntax for
1780 \addlyrics @var{musicexpr1 musicexpr2}
1783 This means that both @var{musicexpr1} and @var{musicexpr2} are
1784 interpreted, but that every non-command atomic music expression
1785 (``every syllable'') in @var{musicexpr2} is interpreted using timing
1786 of @var{musicexpr1}.
1787 @cindex @code{automaticMelismata}
1789 If the property @code{automaticMelismata} is set in the
1790 context of @var{musicexpr1}, no lyrics will be put on slurred or tied
1794 @lilypond[verbatim,fragment]
1797 \property Voice.automaticMelismata = ##t
1798 c8 () cis d8. e16 f2
1800 \context Lyrics \lyrics {
1805 You should use a single rhythm melody, and single rhythm lyrics (a
1806 constant duration is the obvious choice). If you do not, you will get
1807 undesired effects when using multiple stanzas:
1810 @lilypond[verbatim,fragment]
1813 c8 () cis d8. e16 f2
1815 \context Lyrics \lyrics
1822 It is valid (but probably not very useful) to use notes instead of
1823 lyrics for @var{musicexpr2}.
1826 @subsection More stanzas
1830 If you have multiple stanzas printed underneath each other, the separate
1831 syllables should be aligned around punctuation. LilyPond can do this if
1832 you explain it which lyric lines belong to which melody.
1834 To this end, give the Voice context an identity, and set the LyricsVoice
1835 to name starting with that identity. In the following example, the Voice
1836 identity is @code{duet}, and the identities of the LyricsVoices are
1837 @code{duet-1} and @code{duet-2}.
1840 @lilypond[singleline,verbatim]
1843 \notes \relative c'' \context Voice = duet { \time 3/4; g2 e4 a2 f4 g2. }
1844 \lyrics \context Lyrics <
1845 \context LyricsVoice = "duet-1" {
1846 \property LyricsVoice . stanza = "Bert"
1847 Hi, my name is bert. }
1848 \context LyricsVoice = "duet-2" {
1849 \property LyricsVoice . stanza = "Ernie"
1850 Ooooo, ch\'e -- ri, je t'aime. }
1855 You can add stanza numbers by setting @code{LyricsVoice.Stanza} (for the
1856 first system) and @code{LyricsVoice.stz} for the following systems.
1858 @cindex stanza numbering
1866 [chords vs. simultaneous music]
1870 * Entering named chords::
1871 * Printing named chords::
1876 @subsection Chords mode
1879 Chord mode is introduced by the keyword
1880 @code{\chords}. It is similar to Note mode, but
1881 words are also looked up in a chord modifier table (containing
1882 @code{maj}, @code{dim}, etc).
1884 Since combinations of numbers and dots are used for indicating
1885 durations, you can not enter real numbers in this mode. Dashes
1886 and carets are used to indicate chord additions and subtractions,
1887 so scripts can not be entered in Chord mode.
1889 @c . {Entering named chords}
1890 @node Entering named chords
1891 @subsection Entering named chords
1892 @cindex Chords names
1894 Chord names are a way to generate simultaneous music expressions that
1895 correspond with traditional chord names. It can only be used in
1896 Chord mode (see @ref{Lexical modes}).
1900 @var{tonic}[@var{duration}][@code{-}@var{modifiers}][@code{^}@var{subtractions}][@code{/}@var{inversion}][@code{/+}@var{bass}].
1903 @var{tonic} should be the tonic note of the chord, and @var{duration}
1904 is the chord duration in the usual notation. There are two kinds of
1905 modifiers. One type is @emph{chord additions}, which are obtained by
1906 listing intervals separated by dots. An interval is written by its
1907 number with an optional @code{+} or @code{-} to indicate raising or
1908 lowering by half a step. Chord additions has two effects: It adds
1909 the specified interval and all lower odd numbered intervals to the
1910 chord, and it may lower or raise the specified interval. Intervals
1911 must be separated by a dot (@code{.}).
1914 Throughout these examples, chords have been shifted around the staff
1915 using @code{\transpose}.
1920 @lilypond[fragment,verbatim]
1924 c:9 c:9-.5+.7+ c:3-.5- c:4.6.8
1936 The second type of modifier that may appear after the @code{:} is a
1937 named modifier. Named modifiers are listed in the file
1938 @file{chord-modifiers.ly}. The available modifiers are @code{m} and
1939 @code{min} which lower the 3rd half a step, `@code{aug}' which
1940 raises the 5th, `@code{dim}' which lowers the 5th,
1941 `@code{maj}' which adds a raised 7th, and `@code{sus}'
1942 which replaces the 5th with a 4th.
1946 @lilypond[fragment,verbatim]
1949 c1:m c:min7 c:maj c:aug c:dim c:sus
1957 Chord subtractions are used to eliminate notes from a chord. The
1958 notes to be subtracted are listed after a @code{^} character,
1961 @lilypond[fragment,verbatim,center]
1970 Chord inversions can be specified by appending `@code{/}' and
1971 the name of a single note to a chord. This has the effect of
1972 lowering the specified note by an octave so it becomes the lowest
1973 note in the chord. If the specified note is not in the chord, a
1974 warning will be printed.
1976 @lilypond[fragment,verbatim,center]
1986 Bass notes can be added by `@code{/+}' and
1987 the name of a single note to a chord. This has the effect of
1988 adding the specified note to the chord, lowered by an octave,
1989 so it becomes the lowest note in the chord.
1991 @lilypond[fragment,verbatim,center]
2000 The most interesting application is printing chord names, which is
2001 explained in the next subsection.
2003 You should not combine @code{\relative} with named chords. [FIXME]
2005 @c . {Printing named chords}
2006 @node Printing named chords
2007 @subsection Printing named chords
2013 @cindex printing chord names
2016 @cindex @code{ChordNames}
2017 @cindex @code{ChordNameVoice}
2019 For displaying printed chord names, use the @code{ChordNames} and
2020 @code{ChordNameVoice} contexts. The chords may be entered either using
2021 the notation described above, or directly using simultaneous music.
2024 @lilypond[verbatim,singleline]
2026 \chords {a1 b c} <d f g> <e g b>
2030 \context ChordNamesVoice \scheme
2031 \context Staff \transpose c'' \scheme
2037 You can make the chord changes stand out more by setting property
2038 @code{ChordNames.chordChanges} to true. This will only display chord
2039 names when there's a change in the chords scheme, but always display the
2040 chord name after a line break:
2046 c1:m \break c:m c:m c:m d
2051 \context ChordNames \scheme
2052 \context Staff \transpose c'' \scheme
2055 linewidth = 40 * \staffspace;
2067 LilyPond examines chords specified as lists of notes to determine a
2068 name to give the chord. LilyPond will not try to
2069 identify chord inversions or added base, which may result in strange
2070 chord names when chords are entered as a list of pitches:
2073 @lilypond[verbatim,center,singleline]
2082 \context ChordNamesVoice \scheme
2083 \context Staff \scheme
2089 To specify chord inversions, append @code{/<notename>}. To specify an
2090 added bass note, append @code{/+<notename}:
2093 @lilypond[verbatim,center,singleline]
2100 \context ChordNames \scheme
2101 \context Staff \transpose c'' \scheme
2107 The chord names that LilyPond should print are fully customizable. The
2108 code to print chord names is written in Scheme. It can be found in
2109 @file{scm/chord-name.scm}. Chord names are based on Banter style
2110 naming, which is unambiguous and has a logical structure. Typical
2111 American style chord names are implemented as a variation on Banter
2112 names, they can be selected by setting property @code{ChordName.style}
2117 \include "english.ly"
2122 df:m5- % Diminished triad
2123 c:5^3 % Root-fifth chord
2124 c:4^3 % Suspended fourth triad
2125 c:5+ % Augmented triad
2127 c:m5-.7- % Diminished seventh
2128 c:7+ % Major seventh
2129 c:7.4^3 % Dominant seventh suspended fourth
2130 c:5+.7 % Augmented dominant seventh
2131 c:m5-.7 % "Half" diminished seventh
2132 c:5-.7 % Dominant seventh flat fifth
2133 c:5-.7+ % Major seventh flat fifth
2134 c:m7+ % Minor-major seventh
2135 c:m7 % Minor seventh
2136 c:7 % Dominant seventh
2139 c:9^7 % Major triad w/added ninth
2140 c:6.9^7 % Six/Nine chord
2141 c:9 % Dominant ninth
2142 c:7+.9 % Major ninth
2143 c:m7.9 % Minor ninth
2148 \context ChordNames \scheme
2149 \context Staff \transpose c'' \scheme
2154 ChordName \override #'word-space = #1
2155 ChordName \override #'style = #'american
2162 Similarly, Jazz style chord names are implemented as a variation on
2163 American style names:
2169 c:6 % 6 = major triad with added sixth
2170 c:maj % triangle = maj
2175 c:m % m = minor triad
2176 c:m.6 % m6 = minor triad with added sixth
2177 c:m.7+ % m triangle = minor major seventh chord
2185 c:7.5+ % +7 = augmented dominant
2186 c:7.5- % 7b5 = hard diminished dominant
2193 c:13.9-^11 % 7(b9,13)
2194 c:13.9+^11 % 7(#9,13)
2196 c:13-.9-^11 % 7(b9,b13)
2197 c:13-.9+^11 % 7(#9,b13)
2199 % half diminished chords
2200 c:m5-.7 % slashed o = m7b5
2201 c:9.3-.5- % o/7(pure 9)
2204 c:m5-.7- % o = diminished seventh chord
2209 \context ChordNames \scheme
2210 \context Staff \transpose c'' \scheme
2215 ChordName \override #'word-space = #1
2216 ChordName \override #'style = #'jazz
2224 @section Writing parts
2229 * Instrument names::
2231 * Sound output for transposing instruments::
2232 * Multi measure rests::
2233 * Automatic part combining::
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") ;
2266 @node Instrument names
2267 @subsection Instrument names
2269 You can specify an instrument name for a staff by setting
2270 @code{Staff.instrument} and @code{Staff.instr}. This will print a string
2271 before the start of the staff. For the first start, @code{instrument} is
2272 used, for the next ones @code{instr} is used.
2274 @lilypond[verbatim,singleline]
2276 \property Staff.instrument = "instr " { c''4 } }
2278 \translator { \StaffContext
2279 \consists "Instrument_name_engraver"; } } }
2282 This requires that you add the @code{Instrument_name_engraver} to the
2287 @subsection Transpose
2289 @cindex transposition of pitches
2290 @cindex @code{\transpose}
2292 A music expression can be transposed with @code{\transpose}. The syntax
2295 \transpose @var{pitch} @var{musicexpr}
2298 This means that middle C in @var{musicexpr} is transposed to
2301 @code{\transpose} distinguishes between enharmonic pitches: both
2302 @code{\transpose cis'} or @code{\transpose des'} will transpose up half
2303 a tone. The first version will print sharps and the second version
2307 @lilypond[fragment,verbatim]
2310 { \key e \major; c d e f }
2312 \transpose des'' { \key e \major; c d e f }
2313 \transpose cis'' { \key e \major; c d e f }
2319 If you want to use both @code{\transpose} and @code{\relative}, then
2320 you must use @code{\transpose} first. @code{\relative} will have no
2321 effect music that appears inside a @code{\transpose}.
2323 @node Sound output for transposing instruments
2324 @subsection Sound output transposing instruments
2326 When you want to play a score containing transposed and untransposed
2327 instruments, you have to instruct LilyPond the pitch offset (in
2328 semitones) for the transposed instruments. This is done using
2331 @cindex @code{transposing}
2334 \property Staff.instrument = #"Cl. in B-flat"
2335 \property Staff.transposing = #-2
2339 @c . {Multi measure rests}
2340 @node Multi measure rests
2341 @subsection Multi measure rests
2342 @cindex Multi measure rests
2346 Multi measure rests are entered using `@code{R}'. It is specifically
2347 meant for entering parts: the rest can expand to fill a score with
2348 rests, or it can be printed as a single multimeasure rest This expansion
2349 is controlled by the property @code{Score.skipBars}. If this is set to true,
2350 Lily will not expand empty measures, and the appropriate number is added
2353 @lilypond[fragment,verbatim]
2354 \time 3/4; R2.*2 \property Score.skipBars = ##t R2.*17 R2.*4
2357 Currently, there is no way to condense multiple rests into a single
2360 @cindex condensing rests
2362 @node Automatic part combining
2363 @subsection Automatic part combining
2364 @cindex automatic part combining
2365 @cindex part combiner
2367 Automatic part combining is used to merge two parts of music onto on
2368 staff in an intelligent way. It is aimed primarily at typesetting Hymns
2369 and orchestral scores. When the two parts are identical for a period of
2370 time, only will be shown. In places where the two parts differ, stem
2371 directions are set automatically. Also, soli and @`{a} due parts can be
2372 identified and marke.
2375 @subsubsection Part combine syntax
2377 The syntax for part combining is
2380 \partcombine @var{context} @var{musicexpr1} @var{musicexpr2}
2383 where the pieces of music @var{musicexpr1} and @var{musicexpr2} will be
2384 combined into one context @var{context}. The names of the music
2385 expressions must start with the prefixes @code{one} and @code{two}.
2387 @subsubsection Part combine usage
2389 @cindex @code{Thread_devnull_engraver}
2390 @cindex @code{Voice_engraver}
2391 @cindex @code{A2_engraver}
2393 The most useful function of the part combiner to combining threads into
2394 one voice, as common for wind parts in orchestral scores:
2396 @lilypond[verbatim,singleline,fragment]
2398 \context Voice=one \partcombine Voice
2399 \context Thread=one \notes\relative c'' {
2402 \context Thread=two \notes\relative c'' {
2408 If you have developed a bit of a feel for LilyPond's functioning, you
2409 will notice that what you see above is quite unusual. The first
2410 @code{g} appears only once, although it was specified twice (once in
2411 each Thread). That is the work of the
2412 @code{Thread_devnull_engraver}@footnote{On unix systems, the file
2413 @file{/dev/null} is special device: anything written to it is
2414 discarded.}, that works closely together with the part combiner. When
2415 the part combiner notices that two threads are identical, it tells the
2416 @code{Thread_devnull_engraver} to discard everything in the second
2419 Similarly, the markings @emph{@`{a}2}, @emph{Solo} and @emph{Solo II},
2420 are created by the @code{A2_engraver}. The @code{A2_engraver} also acts
2421 upon instructions of the part combiner. Another thing that the
2422 @code{A2_engraver} does, is forcing of stem, slur and tie directions,
2423 always when both threads are not identical; up for the musicexpr called
2424 @code{one}, down for the musicexpr called @code{two}.
2426 There is actually a third engraver involved in part combining; the
2427 @code{Voice_devnull_engraver}. This one takes care of removing
2428 redundant spanners such as beams, slurs, ties, crescendi, etc.
2430 If you just want the splitting of Threads and setting of directions, and
2431 not the textual markings, you may set the property @var{soloADue} to false:
2433 @lilypond[verbatim,singleline]
2435 \notes \context Staff <
2436 \context Voice=one \partcombine Voice
2437 \context Thread=one\relative c'' {
2440 \context Thread=two\relative c'' {
2453 There are a number of other properties that you can use to tweak the
2454 behavior of part combining, refer to the automatically generated
2455 documentation of the involved engravers and the examples in the tutorial.
2464 A @emph{custos} (plural: @emph{custodes}; latin word for "guard") is a
2465 staff context symbol that appears at the end of a staff line. It
2466 anticipates the pitch of the first note(s) of the following line and
2467 thus helps the player or singer to manage line breaks during
2468 performance, thus enhancing readability of a score.
2473 \notes { c'1 d' e' d' \break c' d' e' d' }
2477 \consists Custos_engraver;
2478 Custos \override #'style = #'mensural;
2485 Custodes were frequently used in music notation until the 16th century.
2486 There were different appearences for different notation styles.
2487 Nowadays, they have survived only in special forms of musical notation
2488 such as via the editio vaticana dating back to the beginning of the 20th
2491 For typesetting custodes, just put a @code{Custos_engraver} into the
2492 @code{StaffContext} when declaring the @code{\paper} block. In this
2493 block, you can also globally control the appearance of the custos symbol
2494 by setting the custos @code{style} property. Currently supported styles
2495 are @code{vaticana}, @code{medicaea}, @code{hufnagel} and
2502 \consists Custos_engraver;
2503 Custos \override #'style = #'mensural;
2508 The property can also be set locally, for example in a @code{\notes}
2513 \property Staff.Custos \override #'style = #'vaticana
2514 c'1 d' e' d' \break c' d' e' d'
2518 @c . {Tuning output}
2520 @section Tuning output
2522 LilyPond tries to take as much formatting as possible out of your
2523 hands. Nevertheless, there are situations where it needs some help, or
2524 where you want to override its decisions.
2526 Here we discuss how you can do that.
2528 Notational output is specified in so called grobs (graphic
2529 objects). Each grob carries with it a set of properties (grob
2530 properties) specific to that grob. For example, a stem grob has grob
2531 properties that specify its direction, length and thickness.
2533 The most common way of tuning the output is to alter the values of these
2534 properties. There are two ways of doing that: first, you can
2535 specifically select a set of grobs at one point, and set properties as
2536 you wish, or secondly, you can (temporarily) modify the definition of a
2537 grob, thereby affecting an entire group of grobs.
2540 * Tuning groups of grobs ::
2541 * Tuning per grob ::
2546 @node Tuning groups of grobs
2547 @subsection Tuning groups of grobs
2549 @cindex grob description
2551 A grob definition is an association list, that is stored in a context
2552 property. By assigning to that property (using plain @code{\property}),
2553 you can change the resulting grobs.
2554 @lilypond[verbatim, fragment]
2555 c'4 \property Voice.Stem \override #'meta = #'((interfaces . ())) c'4
2557 The @code{\property} statement effectively empties the definition of the
2558 Stem object. One of the effects is that property specifying how it
2559 should be printed is erased, with the effect of rendering it invisible.
2566 This mechanism is fairly crude, since you can only set, but not modify,
2567 the definition of a grob. For this reason, there is a more advanced
2568 mechanism: you can add a property on top of an existing definition, or
2569 remove a property: @code{\override} adds a settings, @code{\revert}
2570 removes that setting.
2572 c'4 \property Voice.Stem \override #'thickness = #4.0
2573 c'4 \property Voice.Stem \revert #'thickness
2577 For the digirati, the grob description is an Scheme association
2578 list. Since it is singly linked, we can treat it as a stack, and
2579 @code{\override} and @code{\revert} are just push and pop
2580 operations. This pushing and popping is also used in the
2581 @code{autoBeamSettings} property.
2583 If you revert a setting which was not set in the first place, then it
2584 has no effect. However, if the setting was set as a system default, it
2585 may remove the default value, and this may give surprising results,
2586 including crashes. In other words, if you use @code{\override} and
2587 @code{\revert}, be sure to balance the overrides and reverts.
2589 If balancing them is too much work, use the following shorthand:
2590 @code{\set} performs a revert followed by an override:
2592 \property Voice.Stem \set #'thickness = #2.0
2595 Formally the syntax for these constructions is
2597 \property @var{context}.@var{grobname} \override @var{symbol} = @var{value}
2598 \property @var{context}.@var{grobname} \set @var{symbol} = @var{value}
2599 \property @var{context}.@var{grobname} \revert @var{symbol}
2601 Here @var{symbol} is a Scheme expression of symbol type, @var{context}
2602 and @var{grobname} are strings and @var{value} is a Scheme expression.
2604 LilyPond will hang or crash if @var{value} contains cyclic references.
2608 @node Tuning per grob
2609 @subsection Tuning per grob
2611 @cindex \outputproperty
2613 A second way of tuning grobs is the more arcane @code{\outputproperty}
2615 Syntax is as follows
2617 \outputproperty @var{predicate} @var{symbol} = @var{value}
2619 Here @code{predicate} is a Scheme functoin taking a grob a argument
2620 argument, and returning a boolean. This statement is processed by the
2621 @code{Output_property_engraver}. It instructs the engraver to feed all
2622 grobs that it sees to @var{predicate}. Whenever the predicate returns
2623 true, the grob property @var{symbol} will be set to @var{value}.
2625 You will need to combine this statement with @code{\context} to select
2626 the appropriate context to apply this to.
2628 If possible, avoid this feature: the semantics are not very clean, and
2629 the syntax and semantics are up for rewrite.
2631 Here are some random examples:
2633 @lilypond[fragment,verbatim,singleline]
2635 \context Staff \outputproperty
2636 #(make-type-checker 'note-head-interface)
2637 #'extra-offset = #'(0.5 . 0.75)
2641 @cindex @code{extra-offset}
2643 This selects all note heads occurring at current staff level, and sets
2644 the @code{extra-offset} of those heads to @code{(0.5,0.75)}, shifting
2647 Move the text "m.d.", but not the fingering instruction "2".
2648 @lilypond[verbatim,singleline]
2649 #(define (make-text-checker text)
2650 (lambda (grob) (equal? text (ly-get-elt-property grob 'text))))
2653 \notes\relative c''' {
2654 \property Voice.Stem \set #'direction = #1
2655 \outputproperty #(make-text-checker "m.d.")
2656 #'extra-offset = #'(-3.5 . -4.5)
2666 @subsection What to tune?
2668 This all tells you how to tune grobs, but what variables are there? The
2669 question is not answered in this manual (although you may encounter
2672 Grob properties are tied directly to the implementation of LilyPond, and
2673 they are thus a moving target. Refer to the automatically generated
2674 documentation of the internals (available from the website).
2676 You need the following information
2680 which grob to modify
2682 which property to modify
2684 which context the grob comes from.
2687 Included with the automatically generated documentation is a master list
2688 of grobs. Each one can be clicked, taking you to a overview of the
2689 available properties.
2691 There is also a master list of contexts. Clicking each takes you to an
2692 overview of the context, listing which grob types are created there.
2697 @subsection Text markup
2701 LilyPond has an internal mechanism to typeset texts. You can
2702 form text markup expressions by composing scheme expressions
2703 in the following way.
2707 \notes \relative c' {
2709 c-#'(upright "upright")
2710 c-#'((bold upright) "bold")
2711 d-#'(lines "one" ((bold upright) "two"))
2712 e-#'(music (named "noteheads-2" "flags-u3"))
2714 \paper { linewidth = 10.\cm; }
2718 Normally, the Scheme markup text is stored in the @code{text} property
2719 of a grob. Formally, it is defined as follows:
2722 text: string | (head? text+)
2723 head: markup | (markup+)
2724 markup-item: property | abbrev | @var{fontstyle}
2725 property: (@var{key} . @var{value})
2726 abbrev: @code{rows lines roman music bold italic named super sub text}
2729 The markup is broken down and converted into a list of grob properties,
2730 which are prepended to the grop's property list. The
2731 @var{key}-@var{value} pair is a grob property.
2733 The following abbreviations are currently
2738 horizontal mode: set all text on one line (default)
2740 vertical mode: set every text on new line
2750 lookup by character name
2752 plain text lookup (by character value)
2759 @var{fontstyle} may be any of @code{finger volta timesig mmrest mark
2760 script large Large dynamic}
2763 It is possible to use @TeX{} commands in the strings, but this should be
2764 avoided because this makes it impossible for LilyPond to compute the
2765 exact length of the string, which may lead to collisions. Also, @TeX{}
2766 commands won't work with direct postscript output.
2770 @section Page layout
2784 @subsection Paper block
2787 The most important output definition is the @code{\paper} block, for
2788 music notation. The syntax is
2791 @code{\paper @{} [@var{paperidentifier}] @var{items} @code{@}}
2794 where each of the items is one of
2797 @item An assignment. The assignment must be terminated by a
2800 @item A context definition. See @ref{Notation Contexts} for
2801 more information on context definitions.
2803 @item \stylesheet declaration. Its syntax is
2805 \stylesheet @var{alist}
2808 See @file{font.scm} for details of @var{alist}.
2811 @c . {Paper variables}
2812 @node Paper variables
2813 @subsection Paper variables
2814 @cindex Paper variables
2816 The paper block has some variables you may want to use or change:
2819 @cindex @code{indent}
2821 The indentation of the first line of music.
2822 @cindex @code{staffspace}
2824 @item @code{staffspace}
2825 The distance between two staff lines, calculated from the center
2826 of the lines. You should use either this or @code{stafflinethickness}
2827 as a unit for distances you modify.
2829 @cindex @code{linewidth}
2830 @item @code{linewidth}
2831 Sets the width of the lines.
2833 If set to a negative value, a single
2834 unjustified line is produced.
2836 @cindex @code{textheight}
2838 @item @code{textheight}
2839 Sets the total height of the music on each page. Only used by
2841 @cindex @code{interscoreline}
2843 @item @code{interscoreline}
2844 Sets the spacing between the score lines. Defaults to 16 pt.
2845 @cindex @code{interscorelinefill}
2847 @item @code{interscorelinefill}
2848 If set to a positive number, the distance between the score
2849 lines will stretch in order to fill the full page. In that
2850 case @code{interscoreline} specifies the minimum spacing.
2852 @cindex @code{stafflinethickness}
2854 @item @code{stafflinethickness}
2855 Determines the thickness of staff lines, and also acts as a scaling
2856 parameter for other line thicknesses.
2863 @subsection Font size
2866 The Feta font provides musical symbols at six different sizes. These
2867 fonts are 11 point, 13 point, 16 point, 20 point,
2868 23 point, and 26 point. The point size of a font is the
2869 height of the five lines in a staff when displayed in the font.
2871 Definitions for these sizes are the files @file{paperSZ.ly}, where
2872 @code{SZ} is one of 11, 13, 16, 20, 23 and 26. If you include any of
2873 these files, the identifiers @code{paperEleven}, @code{paperThirteen},
2874 @code{paperSixteen}, @code{paperTwenty}, @code{paperTwentythree}, and
2875 @code{paperTwentysix} are defined respectively. The default
2876 @code{\paper} block is also set.
2878 The font definitions are generated using a Scheme function. For more
2879 details, see the file @file{font.scm}.
2885 @subsection Paper size
2890 @cindex @code{papersize}
2892 To change the paper size, you must first set the
2893 @code{papersize} variable at top level. Set it to
2894 the strings @code{a4}, @code{letter}, or @code{legal}. After this
2895 specification, you must set the font as described above. If you want
2896 the default font, then use the 20 point font. The new paper size will
2897 not take effect if the font is not loaded and selected afterwards.
2901 \include "paper16.ly"
2905 \paper @{ \paperSixteen @}
2909 The file "paper16.ly" will now include a file named @file{a4.ly}, which
2910 will set the paper variables @code{hsize} and @code{vsize} (used by
2921 @subsection Line break
2924 @cindex breaking lines
2926 Line breaks are normally computed automatically. They are chosen such
2927 that the resulting spacing has low variation, and looks neither cramped
2930 Occasionally you might want to override the automatic breaks; you can do
2931 this by specifying @code{\break}. This will force a line break at this
2932 point. Do remember that line breaks can only occur at places where there
2933 are barlines. If you want to have a line break where there is no
2934 barline, you can force a barline by entering @code{\bar "";}.
2936 Similarly, @code{\noBreak} forbids a line break at a certain point.
2938 @cindex @code{\penalty}
2940 The @code{\break} and @code{\noBreak} commands are defined in terms of
2941 the penalty command:
2943 \penalty @var{int} @code{;}
2946 This imposes encourages or discourages LilyPond to make a line break
2949 @strong{Warning} do not use @code{\penalty} directly. It is rather
2950 kludgy, and slated for rewriting.
2954 @subsection Page break
2957 @cindex breaking pages
2960 Page breaks are normally computed by @TeX{}, so they are not under direct
2961 control. However, you can insert a commands into the @file{.tex} output to
2962 instruct @TeX{} where to break pages. For more details, see the
2963 example file @file{input/test/between-systems.ly}
2977 LilyPond allows MIDI output, with the purpose of proof-hearing the music
2978 you enter. The performance lacks lots of interesting effects, such as
2979 swing, articulation, slurring, tieing, etc.
2981 Also note that it is not possible to use the percussion channel
2982 (generally channel 10 of a MIDI file).
2986 * MIDI instrument names::
2992 @subsection MIDI block
2996 The MIDI block is analogous to the paper block, but it is somewhat
2997 simpler. The @code{\midi} block can contain:
3001 @item a @code{\tempo} definition
3002 @item context definitions
3005 Assignments in the @code{\midi} block are not allowed.
3009 @cindex context definition
3011 Context definitions follow precisely the same syntax as within the
3012 \paper block. Translation modules for sound are called performers.
3013 The contexts for MIDI output are defined in @file{ly/performer.ly}.
3016 [Instrument Equaliser]
3018 FIXME: would it be useful to refer to files like scm/midi.scm,
3019 or to give examples of how to tweak MIDI output volume?
3022 @c . {MIDI instrument names}
3023 @node MIDI instrument names
3024 @subsection MIDI instrument names
3025 @cindex instrument names
3026 @cindex @code{Staff.midiInstrument}
3027 @cindex @code{Staff.instrument}
3029 The MIDI instrument name is set by the @code{Staff.midiInstrument}
3030 property or, if that property is not set, the @code{Staff.instrument}
3031 property. The instrument name should be chosen from the following list.
3032 If the selected string does not exactly match, then LilyPond uses the
3035 [FIXME: to appendix ]
3039 "acoustic grand" "contrabass" "lead 7 (fifths)"
3040 "bright acoustic" "tremolo strings" "lead 8 (bass+lead)"
3041 "electric grand" "pizzicato strings" "pad 1 (new age)"
3042 "honky-tonk" "orchestral strings" "pad 2 (warm)"
3043 "electric piano 1" "timpani" "pad 3 (polysynth)"
3044 "electric piano 2" "string ensemble 1" "pad 4 (choir)"
3045 "harpsichord" "string ensemble 2" "pad 5 (bowed)"
3046 "clav" "synthstrings 1" "pad 6 (metallic)"
3047 "celesta" "synthstrings 2" "pad 7 (halo)"
3048 "glockenspiel" "choir aahs" "pad 8 (sweep)"
3049 "music box" "voice oohs" "fx 1 (rain)"
3050 "vibraphone" "synth voice" "fx 2 (soundtrack)"
3051 "marimba" "orchestra hit" "fx 3 (crystal)"
3052 "xylophone" "trumpet" "fx 4 (atmosphere)"
3053 "tubular bells" "trombone" "fx 5 (brightness)"
3054 "dulcimer" "tuba" "fx 6 (goblins)"
3055 "drawbar organ" "muted trumpet" "fx 7 (echoes)"
3056 "percussive organ" "french horn" "fx 8 (sci-fi)"
3057 "rock organ" "brass section" "sitar"
3058 "church organ" "synthbrass 1" "banjo"
3059 "reed organ" "synthbrass 2" "shamisen"
3060 "accordion" "soprano sax" "koto"
3061 "harmonica" "alto sax" "kalimba"
3062 "concertina" "tenor sax" "bagpipe"
3063 "acoustic guitar (nylon)" "baritone sax" "fiddle"
3064 "acoustic guitar (steel)" "oboe" "shanai"
3065 "electric guitar (jazz)" "english horn" "tinkle bell"
3066 "electric guitar (clean)" "bassoon" "agogo"
3067 "electric guitar (muted)" "clarinet" "steel drums"
3068 "overdriven guitar" "piccolo" "woodblock"
3069 "distorted guitar" "flute" "taiko drum"
3070 "guitar harmonics" "recorder" "melodic tom"
3071 "acoustic bass" "pan flute" "synth drum"
3072 "electric bass (finger)" "blown bottle" "reverse cymbal"
3073 "electric bass (pick)" "skakuhachi" "guitar fret noise"
3074 "fretless bass" "whistle" "breath noise"
3075 "slap bass 1" "ocarina" "seashore"
3076 "slap bass 2" "lead 1 (square)" "bird tweet"
3077 "synth bass 1" "lead 2 (sawtooth)" "telephone ring"
3078 "synth bass 2" "lead 3 (calliope)" "helicopter"
3079 "violin" "lead 4 (chiff)" "applause"
3080 "viola" "lead 5 (charang)" "gunshot"
3081 "cello" "lead 6 (voice)"
3092 @cindex beats per minute
3093 @cindex metronome marking
3095 @cindex @code{\tempo}
3097 \tempo @var{duration} = @var{perminute} @code{;}
3100 Used to specify the tempo. For example, @code{\tempo 4 = 76;} requests
3101 output with 76 quarter notes per minute.
3109 @section Music entry
3120 @subsection Relative
3122 @cindex relative octave specification
3124 Octaves are specified by adding @code{'} and @code{,} to pitch names.
3125 When you copy existing music, it is easy to accidentally put a pitch in
3126 the wrong octave and hard to find such an error. To prevent these
3127 errors, LilyPond features octave entry.
3129 @cindex @code{\relative}
3131 \relative @var{startpitch} @var{musicexpr}
3134 The octave of notes that appear in @var{musicexpr} are calculated as
3135 follows: If no octave changing marks are used, the basic interval
3136 between this and the last note is always taken to be a fourth or less.
3137 The octave changing marks @code{'} and @code{,} can then
3138 be added to raise or lower the pitch by an extra octave. Upon entering
3139 relative mode, an absolute starting pitch must be specified that will
3140 act as the predecessor of the first note of @var{musicexpr}.
3142 This distance is determined without regarding accidentals: a
3143 @code{fisis} following a @code{ceses} will be put above the
3146 Entering scales is straightforward in relative mode.
3148 @lilypond[fragment,verbatim,center]
3150 g a b c d e f g g, g
3154 And octave changing marks are used for intervals greater than a fourth.
3156 @lilypond[fragment,verbatim,center]
3158 c g c f, c' a, e'' }
3161 If the preceding item is a chord, the first note of the chord is used
3162 to determine the first note of the next chord. But other notes
3163 within the second chord are determined by looking at the immediately
3166 @lilypond[fragment,verbatim,center]
3173 @cindex @code{\notes}
3175 The pitch after the @code{\relative} contains a notename. To parse
3176 the pitch as a notename, you have to be in note mode, so there must
3177 be a surrounding @code{\notes} keyword (which is not
3180 The relative conversion will not affect @code{\transpose} or
3181 @code{\relative} sections in its argument. If you want to use
3182 relative within transposed music, you must place an additional
3183 @code{\relative} inside the @code{\transpose}.
3188 @subsection Bar check
3192 @cindex @code{barCheckNoSynchronize}
3196 Whenever a bar check is encountered during interpretation, a warning
3197 message is issued if it doesn't fall at a measure boundary. This can
3198 help you find errors in the input. Depending on the value of
3199 @code{barCheckNoSynchronize}, the beginning of the measure will be
3200 relocated, so this can also be used to shorten measures.
3202 A bar check is entered using the bar symbol, @code{|}
3206 @c . {Point and click}
3207 @node Point and click
3208 @subsection Point and click
3217 * Notation Contexts::
3218 * Creating contexts::
3219 * Default contexts::
3220 * Context properties::
3221 * Changing context definitions::
3222 * Defining new contexts::
3225 @c . {Music expressions}
3229 @c . {Notation Contexts}
3230 @node Notation Contexts
3231 @subsection Notation Contexts
3233 @cindex notation contexts
3235 Notation contexts are objects that only exist during a run of LilyPond.
3236 During the interpretation phase of LilyPond (when lily prints
3237 "interpreting music"), music a @code{\score} block is interpreted in
3238 time order, i.e. in much the same order that humans read, play, and
3241 During this reading, the notation context is holds the state
3242 for the current point within the music. It contains information like
3245 @item What notes are playing at this point?
3246 @item What symbols will be printed at this point?
3247 @item What is the current key signature, time signature, point within
3251 Contexts are grouped hierarchically: A @code{Voice} context is
3252 contained in a @code{Staff} context (because a staff can contain
3253 multiple voices at any point), a @code{Staff} context is contained in
3254 a @code{Score}, @code{StaffGroup}, or @code{ChoirStaff} context (because
3255 these can all contain multiple staffs).
3258 Contexts associated with sheet music output are called @emph{notation
3259 contexts}, those for sound output are called performance contexts.
3262 @node Creating contexts
3263 @subsection Creating contexts
3265 @cindex @code{\context}
3266 @cindex context selection
3268 Contexts for a music expression can be selected manually, using the
3269 following music expression.
3272 \context @var{contexttype} [= @var{contextname}] @var{musicexpr}
3275 This instructs lilypond to interpret @var{musicexpr} within the context
3276 of type @var{contexttype} and with name @var{contextname}. If this
3277 context does not exist, it will be created.
3281 @lilypond[verbatim,singleline]
3283 \notes \relative c'' {
3284 c4 <d4 \context Staff = "another" e4> f
3291 In this example, the @code{c} and @code{d} are printed on the
3292 default staff. For the @code{e}, a context Staff called
3293 @code{another} is specified; since that does not exist, a new
3294 context is created. Within @code{another}, a (default) Voice context
3295 is created for the @code{e4}. When all music referring to a
3296 context is finished, the context is ended as well. So after the
3297 third quarter, @code{another} is removed.
3301 @node Default contexts
3302 @subsection Default contexts
3304 Most music expressions don't need @code{\context}: they inherit the
3305 notation context from their parent. Each note is a music expression, and
3306 as you can see in the following example, only the sequential music
3307 enclosing the three notes has an explicit context.
3309 @lilypond[verbatim,singleline]
3310 \score { \notes \context Voice = goUp { c'4 d' e' } }
3313 There are some quirks that you must keep in mind when dealing with
3316 Every top-level music is interpreted by the Score context, in other
3317 words, you may think of @code{\score} working like
3320 \context Score @var{music}
3324 Sequential music follows the contexts of its "children". Take this example
3325 @lilypond[verbatim, singleline]
3326 \score { \context Score \notes { c'4 ( d' )e' } }
3329 The sequential music is interpreted by the Score context initially
3330 (notice that the @code{\context} specification is redundant), but when a
3331 note is encountered, contexts are setup to accept that note. In this
3332 case, a Thread, Voice and Staff are created. The rest of the sequential
3333 music is also interpreted with the same Thread, Voice and Staff context,
3334 putting the notes on the same staff, in the same voice.
3336 This is a convenient mechanism, but do not expect opening chords to work
3337 without @code{\context}. For every note, a separate staff is
3340 @lilypond[verbatim, singleline]
3341 \score { \notes <c'4 es'> }
3344 Of course, if the chord is preceded by a normal note in sequential
3345 music, the chord will be interpreted by the Thread of the preceding
3347 @lilypond[verbatim,singleline]
3348 \score { \notes { c'4 <c'4 es'> } }
3353 @node Context properties
3354 @subsection Context properties
3356 Notation contexts can be modified from within the @file{.ly} file. The
3357 following music expression does that job:
3359 @cindex @code{\property}
3361 \property @var{contextname}.@var{propname} = @var{value}
3364 Sets the @var{propname} property of the context @var{contextname} to the
3365 specified Scheme expression @var{value}. All @var{propname} and
3366 @var{contextname} are strings, which are typically unquoted.
3368 Properties that are set in one context are inherited by all of the
3369 contained contexts. This means that a property valid for the
3370 @code{Voice} context can be set in the @code{Score} context (for
3371 example) and thus take effect in all @code{Voice} contexts.
3376 @c . {Context definitions}
3377 @node Changing context definitions
3378 @subsection Changing context definitions
3380 @cindex context definition
3381 @cindex translator definition
3383 The most common way to define a context is by extending an existing
3384 context. You can change an existing context from the paper block, by
3385 first initializing a translator with an existing context identifier:
3389 @var{context-identifier}
3392 Then you can add engravers, remove engravers and set context
3393 properties. The syntax for these operations are respectively
3395 \remove @var{engravername}
3396 \consists @var{engravername}
3397 @var{propname} = @var{value}
3400 Here @var{engravername} is a string, the name of an engraver in the
3401 system. @var{propname} is a string and @var{value} is a Scheme
3404 @lilypond[verbatim,singleline]
3408 \translator { \StaffContext
3409 \consists Instrument_name_engraver;
3411 \remove Clef_engraver;
3417 These type of property assignments happen before interpretation starts,
3418 so a @code{\property} expression will override any predefined settings.
3420 Engravers are the actual C++ modules that do the work in the
3421 interpretation phase.
3424 There are some pre-defined identifiers to simplify editing translators,
3425 they are defined in @file{ly/engraver.ly}. These pre-defined
3429 @cindex @code{StaffContext}
3430 @item @code{StaffContext}
3431 Default Staff context.
3432 @cindex @code{RhythmicStaffContext}
3434 @item @code{RhythmicStaffContext}
3435 Default RhythmicStaff context.
3436 @cindex @code{VoiceContext}
3438 @item @code{VoiceContext}
3439 Default Voice context.
3440 @cindex @code{ScoreContext}
3442 @item @code{ScoreContext}
3443 Default Score context.
3445 @cindex @code{HaraKiriStaffContext}
3447 @item @code{HaraKiriStaffContext}
3448 Staff context that does not print if it only contains rests.
3449 Useful for orchestral scores.@footnote{Harakiri, also called
3450 Seppuku, is the ritual suicide of the Japanese Samourai warriors.}
3453 @node Defining new contexts
3454 @subsection Defining new contexts
3456 If you want to build a context from scratch, you must also supply the
3457 following extra information:
3459 @item A name, specified by @code{\name @var{contextname};}.
3461 @item A cooperation engraver. This is specified by @code{\type
3466 A context definition has this syntax:
3470 \translator @code{@{}
3471 @var{translatorinit} @var{translatormodifierlist}
3475 @var{translatorinit} can be an identifier or
3479 where @var{typename} is one of
3481 The cooperation engraver groups other engravers, and specifies how they
3482 should cooperate. Choices are:
3485 @cindex @code{Engraver_group_engraver}
3486 @item @code{Engraver_group_engraver}
3487 The standard cooperation engraver.
3489 @cindex @code{Score_engraver}
3491 @item @code{Score_engraver}
3492 This is cooperation module that should be in the top level context,
3493 and only the toplevel context.
3495 @cindex @code{Grace_engraver_group}
3497 @item @code{Grace_engraver_group}
3498 This is a special cooperation module (resembling
3499 @code{Score_engraver}) that is used to created an embedded
3503 @var{translatormodifierlist} is a list of items where each item is
3507 @item @code{\consists} @var{engravername} @code{;}
3508 Add @var{engravername} to the list of modules in this context.
3509 The order of engravers added with @code{\consists} is
3512 @item @code{\consistsend} @var{engravername} @code{;}
3513 Analogous to @code{\consists}, but makes sure that
3514 @var{engravername} is always added to the end of the list of
3517 Some engraver types need to be at the end of the list; this
3518 insures they are put there, and stay there, if a user adds or
3519 removes engravers. This command is usually not needed for
3522 @item @code{\accepts} @var{contextname} @code{;}
3523 Add @var{contextname} to the list of context this context can
3524 contain. The first listed context is the context to create by
3527 @item @code{\denies}. The opposite of @code{\accepts}. Added for
3528 completeness, but is never used in practice.
3531 @item @code{\remove} @var{engravername} @code{;}
3532 Remove a previously added (with @code{\consists}) engraver.
3534 @item @code{\name} @var{contextname} @code{;}
3535 This sets name of the context, e.g. @code{Staff}, @code{Voice}. If
3536 the name is not specified, the translator won't do anything.
3538 @item @var{propname} @code{=} @var{value} @code{;}
3539 A property assignment.
3542 In the @code{\paper} block, it is also possible to define translator
3543 identifiers. Like other block identifiers, the identifier can only
3544 be used as the very first item of a translator. In order to define
3545 such an identifier outside of @code{\score}, you must do
3551 foo = \translator @{ @dots{} @}
3558 \translator @{ \foo @dots{} @}
3566 @cindex paper types, engravers, and pre-defined translators
3571 Properties can be preset within the @code{\translator} block
3572 corresponding to the appropriate context. In this case, the syntax
3576 @var{propname} @code{=} @var{value}
3579 The property settings are used during the interpretation phase. They
3580 are read by the LilyPond modules where interpretation contexts are
3581 built of. These modules are called @emph{translators}. Translators for
3582 notation are called @emph{engravers}, and translators for sound are
3583 called @emph{performers}.
3588 @c . {Syntactic details}
3589 @node Syntactic details
3590 @section Syntactic details
3591 @cindex Syntactic details
3595 * Music expressions::
3596 * Manipulating music expressions::
3605 @subsection Top level
3608 This section describes what you may enter at top level.
3612 @subsubsection Score
3615 @cindex score definition
3617 The output is generated combining a music expression with an output
3618 definition. A score block has the following syntax:
3621 \score @{ @var{musicexpr} @var{outputdefs} @}
3624 @var{outputdefs} are zero or more output definitions. If no output
3625 definition is supplied, the default @code{\paper} block will be added.
3629 @c . {Default output}
3630 @subsubsection Default output
3632 Default values for the @code{\paper} and @code{\midi} block are set by
3633 entering such a block at top-level.
3636 @subsubsection Header
3638 @cindex @code{\header}
3643 \header @{ @var{key1} = @var{val1};
3644 @cindex @code{ly2dvi}
3645 @var{key2} = @var{val2}; @dots{} @}
3649 A header describes the file's contents. It can also appear in a
3650 @code{\score} block. Tools like @code{ly2dvi} can use this
3651 information for generating titles. Key values that are used by
3652 @code{ly2dvi} are: title, subtitle, composer, opus, poet, instrument,
3653 metre, arranger, piece and tagline.
3655 It is customary to put the @code{\header} at the top of the file.
3657 @subsubsection Default output
3659 A @code{\midi} or @code{\paper} block at top-level sets the default
3661 paper block for all scores that lack an explicit paper block.
3665 @subsection Identifiers
3668 All of the information in a LilyPond input file, is represented as a
3669 Scheme value. In addition to normal Scheme data types (such as pair,
3670 number, boolean, etc.), LilyPond has a number of specialized data types,
3677 @item Translator_def
3681 @item Music_output_def
3682 @item Moment (rational number)
3685 LilyPond also includes some transient object types. Objects of these
3686 types are built during a LilyPond run, and do not `exist' per se within
3687 your input file. These objects are created as a result of your input
3688 file, so you can include commands in the input to manipulate them,
3689 during a lilypond run.
3692 @item Grob: short for Graphical object. See @ref{Grobs}.
3693 @item Molecule: device-independent page output object,
3694 including dimensions. Produced by some Grob functions
3696 @item Translator: object that produces audio objects or Grobs. This is
3697 not yet user accessible.
3698 @item Font_metric: object representing a font. (See @ref{Font metrics})
3703 @node Music expressions
3704 @subsection Music expressions
3706 @cindex music expressions
3708 Music in LilyPond is entered as a music expression. Notes, rests, lyric
3709 syllables are music expressions, and you can combine music expressions
3710 to form new ones, for example by enclosing a list of expressions in
3711 @code{\sequential @{ @}} or @code{< >}. In this example, a compound
3712 expression is formed out of the quarter note @code{c} and a quarter note
3716 \sequential @{ c4 d4 @}
3719 @cindex Sequential music
3720 @cindex @code{\sequential}
3721 @cindex sequential music
3724 @cindex Simultaneous music
3725 @cindex @code{\simultaneous}
3727 The two basic compound music expressions are simultaneous and
3731 \sequential @code{@{} @var{musicexprlist} @code{@}}
3732 \simultaneous @code{@{} @var{musicexprlist} @code{@}}
3734 For both, there is a shorthand:
3736 @code{@{} @var{musicexprlist} @code{@}}
3740 @code{<} @var{musicexprlist} @code{>}
3742 for simultaneous music.
3743 Other compound music expressions include
3746 \transpose @var{pitch} @var{expr}
3747 \apply @var{func} @var{expr}
3748 \context @var{type} = @var{id} @var{expr}
3749 \times @var{fraction} @var{expr}
3752 In principle, the way in which you nest sequential and simultaneous to
3753 produce music is not relevant. In the following example, three chords
3754 are expressed in two different ways:
3756 @lilypond[fragment,verbatim,center]
3757 \notes \context Voice {
3758 <a c'> <b d' > <c' e'>
3759 < { a b c' } { c' d' e' } >
3763 However, in some cases, LilyPond will also try to choose contexts, and
3764 use the structure of the music expression to do so. This can have
3765 undesired effects: for example, LilyPond will create a separate staff
3766 for each note if you start a @code{\score} with a chord:
3767 @lilypond[verbatim,center,singleline]
3772 The solution is to explicitly instantiate the context you desire.
3773 In this case this is typically a Voice context
3774 @lilypond[verbatim,center,singleline]
3776 \notes\context Voice <c''4 e''>
3779 If you use @code{\context Staff} you will get separate stems for each
3780 note head, leading to collisions, so don't use that.
3784 @c . {Manipulating music expressions}
3785 @node Manipulating music expressions
3786 @subsection Manipulating music expressions
3788 The @code{\apply} mechanism gives you access to the internal
3789 representation of music. You can write Scheme-functions that operate
3790 directly on it. The syntax is
3792 \apply #@var{func} @var{music}
3794 This means that @var{func} is applied to @var{music}. The function
3795 @var{func} should return a music expression.
3797 This example replaces the text string of a script. It also shows a dump
3798 of the music it processes, which is useful if you want to know more
3799 about how music is stored.
3801 #(define (testfunc x)
3802 (if (equal? (ly-get-mus-property x 'text) "foo")
3803 (ly-set-mus-property x 'text "bar"))
3805 (ly-set-mus-property x 'elements
3806 (map testfunc (ly-get-mus-property x 'elements)))
3811 \apply #testfunc { c4_"foo" }
3815 For more information on what is possible, see the @ref{Tricks} and the
3816 automatically generated documentation.
3818 As always: directly accessing internal representations is dangerous: the
3819 implementation is subject to changes, so you should not use this if
3823 @c . {Span requests}
3825 @subsubsection Span requests
3826 @cindex Span requests
3828 Notational constructs that start and end on different notes can be
3829 entered using span requests. The syntax is as follows:
3833 \spanrequest @var{startstop} @var{type}
3837 @cindex @code{\start}
3838 @cindex @code{\stop}
3840 This defines a spanning request. The @var{startstop} parameter is either
3841 -1 (@code{\start}) or 1 (@code{\stop}) and @var{type} is a string that
3842 describes what should be started. Much of the syntactic sugar is a
3843 shorthand for @code{\spanrequest}, for example,
3845 @lilypond[fragment,verbatim,center]
3846 c'4-\spanrequest \start "slur"
3847 c'4-\spanrequest \stop "slur"
3850 Among the supported types are @code{crescendo}, @code{decrescendo},
3851 @code{beam}, @code{slur}. This is an internal command. Users are
3852 encouraged to use the shorthands which are defined in the initialization
3853 file @file{spanners.ly}.
3858 @subsection Assignments
3861 Identifiers allow objects to be assigned to names during the parse
3862 stage. To assign an identifier, you use @var{name}@code{=}@var{value}
3863 and to refer to an identifier, you preceed its name with a backslash:
3864 `@code{\}@var{name}'. @var{value} is any valid Scheme value or any of
3865 the input-types listed above. Identifier assignments can appear at top
3866 level in the LilyPond file, but also in @code{\paper} blocks.
3868 Semicolons are forbidden after top level assignments, but mandatory in
3869 other places. The rules about semicolons and assignments are very
3870 confusing, but when LilyPond input evolves more towards Scheme, we hope
3871 that this problem will grow smaller.
3873 An identifier can be created with any string for its name, but you will
3874 only be able to refer to identifiers whose names begin with a letter,
3875 being entirely alphabetical. It is impossible to refer to an identifier
3876 whose name is the same as the name of a keyword.
3878 The right hand side of an identifier assignment is parsed completely
3879 before the assignment is done, so it is allowed to redefine an
3880 identifier in terms of its old value, e.g.
3886 When an identifier is referenced, the information it points to is
3887 copied. For this reason, an identifier reference must always be the
3888 first item in a block.
3892 \paperIdent % wrong and invalid
3896 \paperIdent % correct
3900 @c . {Lexical details}
3901 @node Lexical details
3902 @subsection Lexical details
3903 @cindex Lexical details
3908 @subsubsection Comments
3914 A one line comment is introduced by a @code{%} character.
3915 Block comments are started by @code{%@{} and ended by @code{%@}}.
3916 They cannot be nested.
3918 @c . {Direct Scheme}
3919 @subsubsection Direct Scheme
3922 @cindex Scheme, in-line code
3925 LilyPond contains a Scheme interpreter (the GUILE library) for
3926 internal use. In some places Scheme expressions also form valid syntax:
3927 whereever it is allowed,
3931 evaluates the specified Scheme code. If this is used at toplevel, then
3932 the result is discarded. Example:
3934 \property Staff.TestObject \override #'foobar = #(+ 1 2)
3937 @code{\override} expects two Scheme expressions, so there are two Scheme
3938 expressions. The first one is a symbol (@code{foobar}), the second one
3939 an integer (namely, 3).
3941 Scheme is a full-blown programming language, and a full discussion is
3942 outside the scope of this document. Interested readers are referred to
3943 the website @uref{http://www.schemers.org/} for more information on
3948 @subsubsection Keywords
3952 Keywords start with a backslash, followed by a number of lower case
3953 alphabetic characters. These are all the keywords.
3956 apply arpeggio autochange spanrequest commandspanrequest
3957 simultaneous sequential accepts alternative bar breathe
3958 char chordmodifiers chords clef cm consists consistsend
3959 context denies duration dynamicscript elementdescriptions
3960 font grace header in lyrics key mark pitch
3961 time times midi mm name pitchnames notes outputproperty
3962 override set revert partial paper penalty property pt
3963 relative remove repeat addlyrics partcombine score
3964 script stylesheet skip textscript tempo translator
3969 @subsubsection Integers
3977 Formed from an optional minus sign followed by digits. Arithmetic
3978 operations cannot be done with integers, and integers cannot be mixed
3982 @subsubsection Reals
3983 @cindex real numbers
3989 Formed from an optional minus sign and a sequence of digits followed
3990 by a @emph{required} decimal point and an optional exponent such as
3991 @code{-1.2e3}. Reals can be built up using the usual operations:
3992 `@code{+}', `@code{-}', `@code{*}', and
3993 `@code{/}', with parentheses for grouping.
4001 A real constant can be followed by one of the dimension keywords:
4002 @code{\mm} @code{\pt}, @code{\in}, or @code{\cm}, for millimeters,
4003 points, inches and centimeters, respectively. This converts the number
4004 to a real that is the internal representation of dimensions.
4008 @subsubsection Strings
4012 Begins and ends with the @code{"} character. To include a @code{"}
4013 character in a string write @code{\"}. Various other backslash
4014 sequences have special interpretations as in the C language. A string
4015 that contains no spaces can be written without the quotes. See
4016 @ref{Lexical modes} for details on unquoted strings; their
4017 interpretation varies depending on the situation. Strings can be
4018 concatenated with the @code{+} operator.
4020 The tokenizer accepts the following commands. They have no grammatical
4021 function, hence they can appear anywhere in the input.
4025 @subsubsection Main input
4028 @cindex @code{\maininput}
4030 The @code{\maininput} command is used in init files to signal that the
4031 user file must be read. This command cannot be used in a user file.
4033 @c . {File inclusion}
4034 @subsubsection Main input
4037 @subsubsection File inclusion
4038 @cindex @code{\include}
4040 \include @var{filename}
4043 Include @var{filename}. The argument @var{filename} may be a quoted string (an
4044 unquoted string will not work here!) or a string identifier. The full
4045 filename including the @file{.ly} extension must be given,
4047 @subsubsection Version information
4048 @cindex @code{\version}
4050 \version @var{string} ;
4053 Specify the version of LilyPond that a file was written for. The
4054 argument is a version string in quotes, for example @code{"1.2.0"}.
4055 This is used to detect invalid input, and to aid
4056 @code{convert-ly} a tool that automatically upgrades input files. See
4057 See @ref{convert-ly} for more information on @code{convert-ly}.
4063 @subsubsection Defining pitch names
4064 @cindex Lexical modes
4065 @cindex definining pitch names
4066 @cindex pitch names, definining
4068 @cindex chord modifier names
4070 A @code{\paper} block at top level sets the default paper block. A
4071 @code{\midi} block at top level works similarly.
4074 @subsubsection Assignments
4078 Identifier assignments may appear at top level. @ref{Assignments}
4082 @c . {Direct scheme}
4083 @subsubsection Direct scheme
4084 @cindex Direct scheme
4086 Scheme statements maybe issued to produce interesting side-effects.
4089 @c . {Lexical modes}
4091 @subsection Lexical modes
4092 @cindex Lexical modes
4095 @cindex @code{\notes}
4096 @cindex @code{\chords}
4097 @cindex @code{\lyrics}
4099 To simplify entering notes, lyrics, and chords, LilyPond has three
4100 special input modes on top of the default mode: note, lyrics and chords
4101 mode. These input modes change the way that normal, unquoted words are
4102 interpreted: for example, the word @code{cis} may be interpreted as a
4103 C-sharp, as a lyric syllable `cis' or as a C-sharp major triad
4106 A mode switch is entered as a compound music expressions
4108 @code{\notes} @var{musicexpr}
4109 @code{\chords} @var{musicexpr}
4110 @code{\lyrics} @var{musicexpr}.
4113 In each of these cases, these expressions do not add anything to the
4114 meaning of their arguments. They are just a way to indicate that the
4115 arguments should be parsed in indicated mode. The modes are treated in
4116 more detail in the @ref{Note entry}, @ref{Lyrics} and
4119 You may nest different input modes.
4123 @subsection Ambiguities
4128 The grammar contains a number of ambiguities. We hope to resolve them at
4132 @item The assignment
4138 can be interpreted as making a string identifier @code{\foo}
4139 containing @code{"bar"}, or a music identifier @code{\foo}
4140 containing the syllable `bar'.
4142 @item The assignment
4148 can be interpreted as making an integer identifier
4149 containing -6, or a Request identifier containing the
4150 fingering `6' (with neutral direction).
4152 @item If you do a nested repeat like
4164 then it is ambiguous to which @code{\repeat} the
4165 @code{\alternative} belongs. This is the classic if-then-else
4166 dilemma. It may be solved by using braces.
4168 @item (an as yet unidentified ambiguity :-)
4175 @c .{Local emacs vars}
4178 @c minor-mode: font-lock
4179 @c minor-mode: outline
4180 @c outline-layout: (-1 : 0)
4181 @c outline-use-mode-specific-leader: "@c \."
4182 @c outline-primary-bullet: "{"
4183 @c outline-stylish-prefixes: nil
4184 @c outline-override-protect: t