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 @emph{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]
800 maybe reinclude other slur features and move back to tricks?
803 @lilypond[fragment,relative,verbatim]
804 \property Voice.Slur \set #'direction = #1
805 \property Voice.Stem \set #'length = #5.5
807 \property Voice.Slur \set #'attachment = #'(stem . stem)
812 If a slur would strike through a stem or beam, the slur will be moved
813 away upward or downward. If this happens, attaching the slur to the
814 stems might look better:
817 @lilypond[fragment,relative,verbatim]
818 \property Voice.Stem \set #'direction = #1
819 \property Voice.Slur \set #'direction = #1
821 \property Voice.Slur \set #'attachment = #'(stem . stem)
826 Similarly, the curvature of a slur is adjusted to stay clear of note
827 heads and stems. When that would increase the curvature too much, the
828 slur is reverted to its default shape. The threshold for this decision
829 is in @code{Voice.Slur}'s grob-property @code{beautiful}. In some
830 cases, you may prefer curved slurs to vertically moved ones. You can
831 express this by increasing the @code{beautiful} value:
833 [hoe gedefd?? wat betekent beautiful = X?]
835 [dit voorbeeld is te lang: junken, of inkorten]
840 \notes \context PianoStaff <
842 \context Staff=up { s1 * 6/4 }
843 \context Staff=down <
845 \autochange Staff \context Voice
847 d,8( a' d f a d f d a f d )a
855 Slur \override #'beautiful = #5.0
856 Slur \override #'direction = #1
857 Stem \override #'direction = #-1
858 autoBeamSettings \override #'(end * * * *)
863 VerticalAlignment \override #'threshold = #'(5 . 5)
870 @cindex Adusting slurs
873 @subsection Phrasing slur
875 @cindex phrasing slur
876 @cindex phrasing mark
878 A phrasing slur (or phrasing mark) connects chords and is used to
879 indicate a musical sentence. It is entered using @code{\(} and @code{\)}.
880 @lilypond[fragment,verbatim,center,relative]
881 \time 6/4; c''\((d)e f(e)\)d
884 Typographically, the phrasing slur behaves almost exactly like a normal
885 slur. The grob associated with it is @code{Voice.PhrasingSlur}.
888 @subsection Breath marks
890 Breath marks are entered using @code{\breathe}:
892 @lilypond[fragment,relative]
896 Currently, only tick marks are supported, comma style breath marks are
897 not. The grob for this object is called @code{Voice.BreathingSign}.
903 @subsubsection Text spanner
906 Some textual indications, e.g. rallentando, accelerando, often extend
907 over a many measures. This is indicated by following the text with a
908 dotted line. You can create such texts in LilyPond using
909 text spanners. The syntax is as follows:
911 \spanrequest \start "text"
912 \spanrequest \stop "text"
914 LilyPond will respond by creating a @code{Voice.TextSpanner} grob. The
915 string to be printed, as well as the style is set through grob
918 An application ---or rather, a hack---is to fake octavation indications.
919 @lilypond[fragment,relative,verbatim]
920 \relative c' { a'''' b c a
921 \property Voice.TextSpanner \set #'type = #'dotted-line
922 \property Voice.TextSpanner \set #'edge-height = #'(0 . 1.5)
923 \property Voice.TextSpanner \set #'edge-text = #'("8va " . "")
924 \property Staff.centralCPosition = #-13
925 a\spanrequest \start "text" b c a \spanrequest \stop "text" }
942 @subsection Articulation
945 @cindex articulations
949 A variety of symbols can appear above and below notes to indicate
950 different characteristics of the performance. These symbols can be
951 added to a note with `@var{note}@code{-\}@var{name}'. Numerous symbols
952 are defined in @file{script.ly} and @file{script.scm}. Symbols can be
953 forced to appear above or below the note by writing
954 `@var{note}@code{^\}@var{name}' and `@var{note}@code{_\}@var{name}'
955 respectively. Here is a chart showing symbols above notes, with the
956 name of the corresponding symbol appearing underneath.
961 \property Score.LyricSyllable \override #'font-family =
963 \property Score.LyricSyllable \override #'font-shape = #'upright
964 c''-\accent c''-\marcato c''-\staccatissimo c''-\fermata
965 c''-\stopped c''-\staccato c''-\tenuto c''-\upbow
966 c''-\downbow c''^\lheel c''-\rheel c''^\ltoe
967 c''-\rtoe c''-\turn c''-\open c''-\flageolet
968 c''-\reverseturn c''-\trill c''-\prall c''-\mordent
969 c''-\prallprall c''-\prallmordent c''-\upprall c''-\downprall
970 c''-\thumb c''-\segno c''-\coda
972 \context Lyrics \lyrics {
973 accent__ marcato__ staccatissimo__ fermata
974 stopped__ staccato__ tenuto__ upbow
975 downbow__ lheel__ rheel__ ltoe
976 rtoe__ turn__ open__ flageolet
977 reverseturn__ trill__ prall__ mordent
978 prallprall__ prallmordent__ uprall__ downprall
983 linewidth = 5.875\in;
988 All of these note ornaments appear in the printed output but have no
989 effect on the MIDI rendering of the music.
991 To save typing work, some shorthands are available:
992 @lilypond[singleline]
994 \notes \context Voice {
995 \property Voice.TextScript \set #'font-family = #'typewriter
996 \property Voice.TextScript \set #'font-shape = #'upright
1002 c''4-^_"c-\\^{ }" s4
1009 Fingering instructions can also be entered in this shorthand.
1010 @lilypond[verbatim, singleline, fragment]
1011 c'4-1 c'4-2 c'4-3 c'4-4
1014 Unfortunately, there is no support adding fingering instructions to
1015 individual note heads. Some hacks exist, though. See
1016 @file{input/test/script-horizontal.ly}.
1019 @cindex @code{\script}
1028 Defines a script printing request. The argument is a string which
1029 points into the script-alias table defined in @file{scm/script.scm}.
1030 Usually the @code{\script} keyword is not used directly. Various
1031 helpful identifier definitions appear in @file{script.ly}.
1033 For information on how to add scripts, consult @file{scm/script.scm}.
1039 @subsection Text scripts
1040 @cindex Text scripts
1042 In addition, it is possible to place arbitrary strings of text or markup
1043 text (see @ref{Text markup}) above or below notes by using a string:
1044 @code{c^"text"}. The text is typeset in italic by default.
1046 The amount of space taken by these indications by default does not
1047 influence, spacing, but setting @code{Voice.textNonEmpty} to true will
1048 take the widths into account. The identifier @code{\fattext} is defined
1049 in the standard includes.
1050 @lilypond[fragment,singleline]
1051 \relative c' { c4^"longtext" \fatText c4_"longlongtext" c4 }
1054 Text scripts are created in form of @code{Voice.TextScript} grobs.
1056 For purposes of defining identifiers, a more verbose form also exists:
1059 \textscript @var{text}
1062 Defines a text to be printed over or under a note. @var{text} is a
1063 string or a markup text.
1067 foo = \textscript #'(finger "6")
1074 This is equivalent to @code{c4-6 c4-"foo"}.
1079 @subsection Grace notes
1088 @cindex @code{\grace}
1091 @cindex @code{graceAlignPosition}
1093 Grace notes are ornaments that are written out, but do not take up any
1094 logical time in a measure. LilyPond has limited support for grace notes.
1095 The syntax is as follows.
1097 \grace @var{musicexpr}
1100 When grace music is interpreted, a score-within-a-score is set up:
1101 @var{musicexpr} has its own time bookkeeping, and you could (for
1102 example) have a separate time signature within grace notes. While in
1103 this score-within-a-score, you can create notes, beams, slurs, etc.
1104 Unbeamed eighth notes and shorter by default have a slash through the
1105 stem. This behavior can be controlled with the
1106 @code{Stem}.@code{flag-style} property.
1109 @lilypond[fragment,verbatim]
1111 \grace c8 c4 \grace { [c16 c16] } c4
1112 \grace { \property Grace.Stem \override #'flag-style = ##f c16 } c4
1119 At present, nesting @code{\grace} notes is not supported. The following
1120 may cause run-time errors:
1122 @code{\grace @{ \grace c32 c16 @} c4}
1124 Since the meaning of such a construct is unclear, we don't consider this
1125 a loss. Similarly, juxtaposing two @code{\grace} sections is
1126 syntactically valid, but makes no sense and may cause runtime errors.
1127 Ending a staff or score with grace notes may also generate a run-time
1128 error, since there will be no main note to attach the grace notes to.
1131 A grace note expression has duration 0; the next real note is assumed to
1132 be the main note. If you want the note to appear after the main note,
1133 set @code{Voice.graceAlignPosition} to @code{1}.
1135 The present implementation of grace notes is not robust and generally
1136 kludgy. We expect it to change after LilyPond 1.4. Syntax changes might
1137 also be implemented.
1144 * Crescendo and Decrescendo::
1152 @subsubsection Glissando
1155 @cindex @code{\glissando}
1157 A glissando line can be requested by attaching a @code{\glissando} to a
1161 @lilypond[fragment,relative,verbatim]
1166 Printing of an additional text (such as @emph{gliss.}) must be done
1173 @subsubsection Dynamics
1186 @cindex @code{\ffff}
1196 Absolute dynamic marks are specified by using an identifier after a
1197 note: @code{c4-\ff}. The available dynamic marks are: @code{\ppp},
1198 @code{\pp}, @code{\p}, @code{\mp}, @code{\mf}, @code{\f}, @code{\ff},
1199 @code{\fff}, @code{\fff}, @code{\fp}, @code{\sf}, @code{\sff},
1200 @code{\sp}, @code{\spp}, @code{\sfz}, and @code{\rfz}.
1203 @cindex Crescendo and Decrescendo
1207 @cindex @code{\decr}
1208 @cindex @code{\rced}
1214 A crescendo mark is started with @code{\cr} and terminated with
1215 @code{\rc} (the textual reverse of @code{cr}). A decrescendo mark is
1216 started with @code{\decr} and terminated with @code{\rced}. There are
1217 also shorthands for these marks. A crescendo can be started with
1218 @code{\<} and a decrescendo can be started with @code{\>}. Either one
1219 can be terminated with @code{\!}. Note that @code{\!} must go before
1220 the last note of the dynamic mark whereas @code{\rc} and @code{\rced} go
1221 after the last note. Because these marks are bound to notes, if you
1222 want to get several marks during one note, you must use spacer notes.
1224 @lilypond[fragment,verbatim,center]
1225 c'' \< \! c'' d'' \decr e'' \rced
1226 < f''1 { s4 \< \! s2 \> \! s4 } >
1231 You can also use a text saying @emph{cresc.} instead of hairpins. Here
1232 is an example how to do it:
1234 @lilypond[fragment,relative,verbatim]
1236 \property Voice.crescendoText = "cresc."
1237 \property Voice.crescendoSpanner = #'dashed-line
1253 @cindex @code{\repeat}
1255 To specify repeats, use the @code{\repeat} keyword. Since repeats
1256 should work differently when played or printed, there are a few
1257 different variants of repeats.
1261 Repeated music is fully written (played) out. Useful for MIDI
1265 This is the normal notation: Repeats are not written out, but
1266 alternative endings (voltas) are printed, left to right.
1269 Alternative endings are written stacked. Which is unfortunately not
1270 practical for anything right now.
1276 Make measure repeats. These look like percent signs.
1282 * Manual repeat commands::
1284 * Tremolo subdivision::
1289 @subsection Repeat syntax
1291 The syntax for repeats is
1294 \repeat @var{variant} @var{repeatcount} @var{repeatbody}
1297 If you have alternative endings, you may add
1298 @cindex @code{\alternative}
1300 \alternative @code{@{} @var{alternative1}
1302 @var{alternative3} @dots{} @code{@}}
1304 where each @var{alternative} is a music expression.
1306 Normal notation repeats are used like this:
1307 @lilypond[fragment,verbatim]
1309 \repeat volta 2 { c'4 d' e' f' }
1310 \repeat volta 2 { f' e' d' c' }
1313 With alternative endings:
1315 @lilypond[fragment,verbatim]
1317 \repeat volta 2 {c'4 d' e' f'}
1318 \alternative { {d'2 d'} {f' f} }
1322 Folded repeats look like this:@footnote{Folded repeats offer little
1323 more over simultaneous music. However, it is to be expected that
1324 more functionality -- especially for the MIDI backend -- will be
1325 implemented at some point in the future.}
1328 @lilypond[fragment,verbatim]
1330 \repeat fold 2 {c'4 d' e' f'}
1331 \alternative { {d'2 d'} {f' f} }
1337 If you don't give enough alternatives for all of the repeats, then
1338 the first alternative is assumed to be repeated often enough to equal
1339 the specified number of repeats.
1342 @lilypond[fragment,verbatim]
1346 \repeat volta 3 { e | c2 d2 | e2 f2 | }
1347 \alternative { { g4 g g } { a | a a a a | b2. } }
1353 As you can see, LilyPond doesn't remember the timing information, nor
1354 are slurs or ties repeated, so you have to reset timing information
1355 after a repeat, e.g. using a bar-check (See @ref{Bar checks}),
1356 @code{Score.measurePosition} or @code{\partial}. We hope to fix this
1359 It is possible to nest @code{\repeat}, although it probably is only
1360 meaningful for unfolded repeats.
1362 @node Manual repeat commands
1363 @subsection Manual repeat commands
1365 @cindex @code{repeatCommands}
1367 The property @code{repeatCommands} can be used to control the layout of
1368 repeats. Its value is a Scheme list of repeat commands, where each repeat
1376 @item (volta . @var{text})
1377 Print a volta bracket saying @var{text}.
1379 Stop a running volta bracket
1382 @lilypond[verbatim, fragment]
1384 \property Score.repeatCommands = #'((volta "93") end-repeat)
1386 \property Score.repeatCommands = #'((volta #f))
1391 [explain precendence: \bar, repeatCommands, whichBar, defaultBarType]
1393 @node Tremolo repeats
1394 @subsection Tremolo repeats
1395 @cindex tremolo beams
1397 To place tremolo marks between notes, use @code{\repeat} with tremolo
1399 @lilypond[verbatim,center,singleline]
1401 \context Voice \notes\relative c' {
1402 \repeat "tremolo" 8 { c16 d16 }
1403 \repeat "tremolo" 4 { c16 d16 }
1404 \repeat "tremolo" 2 { c16 d16 }
1405 \repeat "tremolo" 4 c16
1410 At present, the spacing between tremolo beams is not regular, since the
1411 spacing engine does not notice that not all notes are printed.
1413 @node Tremolo subdivision
1414 @subsection Tremolo subdivision
1415 @cindex tremolo marks
1416 @cindex @code{tremoloFlags}
1418 Tremolo marks can be printed on a single note by adding
1419 `@code{:}[@var{length}]' after the note. The length must be at least 8.
1420 A @var{length} value of 8 gives one line across the note stem. If the
1421 length is omitted, then then the last value (stored in
1422 @code{Voice.tremoloFlags}) is used.
1424 @lilypond[verbatim,fragment,center]
1427 Using this mechanism pays off when you entering many tremolos, since the
1428 default argument saves a lot of typing.
1430 Tremolos in this style do not carry over into the MIDI output.
1433 @node Measure repeats
1434 @subsection Measure repeats
1436 @cindex percent repeats
1437 @cindex measure repeats
1439 In the @code{percent} style, a note pattern can be repeated. It is
1440 printed once, and then the pattern is replaced with a special sign.
1442 @lilypond[verbatim,singleline]
1443 \context Voice { \repeat "percent" 5 { c'1 } }
1446 At present, only repeats of whole measures are supported.
1450 @section Piano music
1452 Piano music is an odd type of notation: two staffs are largely
1453 independent, but sometimes voices can cross between the two staffs. The
1454 @code{PianoStaff} is especially built to handle this cross-staffing
1455 behavior. In this section we discuss the @code{PianoStaff} and some
1456 other pianistic peculiarities.
1459 * Automatic staff changes::
1460 * Manual staff switches::
1467 @c . {Automatic staff changes}
1468 @node Automatic staff changes
1469 @subsection Automatic staff changes
1470 @cindex Automatic staff changes
1472 Voices can be switched from top to bottom staff automatically. The
1475 \autochange @var{contexttype} @var{musicexp}
1477 This will switch notation context of @var{musicexp} between a
1478 @var{contexttype} named @code{up} and @code{down}. Typically, you use
1479 @code{Staff} for @var{contexttype}. The autochanger switches on basis
1480 of pitch (central C is the turning point), and it looks ahead skipping
1481 over rests to switch rests in advance.
1483 @lilypond[verbatim,singleline]
1484 \score { \notes \context PianoStaff <
1485 \context Staff = "up" {
1486 \autochange Staff \context Voice = VA < \relative c' {
1487 g4 a b c d r4 a g } > }
1488 \context Staff = "down" {
1494 Note how spacer rests are used to prevent the bottom staff from
1495 terminating too soon.
1498 @node Manual staff switches
1499 @subsection Manual staff switches
1501 @cindex manual staff switches
1502 @cindex staff switch, manual
1504 Voices can be switched between staffs manually, using the following command:
1506 \translator Staff = @var{which} @var{music}
1508 The string @var{which} is the name of the staff. Typically it is
1509 @code{"up"} or @code{"down"}.
1511 Formally, this construct is a music expression indicating that the
1512 context which is a direct child of the a context of type
1513 @var{contexttype} should be shifted to a context of type
1514 @var{contexttype} and the specified name.
1516 @cindex @code{\translator}
1518 \translator @var{contexttype} = @var{name}
1527 Piano pedals can be entered using the span requests (See @ref{Span
1528 requests}) of the types @code{Sustain}, @code{UnaChorda} and
1531 @lilypond[fragment,verbatim]
1532 c''4 \spanrequest \start "Sustain" c4 c4 \spanrequest \stop "Sustain"
1535 For these verbose expressions, standard shorthands have been defined:
1536 @code{sustainDown}, @code{sustainUp}, @code{unaChorda},
1537 @code{treChorde}, @code{sostenutoDown} and @code{sostenutoUp}. The
1538 symbols that are printed can be modified by setting
1539 @code{pedal@var{X}Strings}, where @var{X} is one of the pedal
1540 types. Refer to the generated documentation for more information.
1542 Currently, brackets are not supported, only text markings (ie. *Ped
1548 @subsection Arpeggio
1551 @cindex broken arpeggio
1552 @cindex @code{\arpeggio}
1554 You can specify an arpeggio sign on a chord by attaching an
1555 @code{\arpeggio} to a note of the chord.
1559 @lilypond[fragment,relative,verbatim]
1560 \context Voice <c'\arpeggio e g c>
1564 When an arpeggio crosses staffs in piano music, you attach an arpeggio
1565 to the chords in both staffs, and set
1566 @code{PianoStaff.connectArpeggios}.
1569 @lilypond[fragment,relative,verbatim]
1570 \context PianoStaff <
1571 \property PianoStaff.connectArpeggios = ##t
1572 \context Voice = one { <c''\arpeggio e g c> }
1573 \context Voice = other { \clef bass; <c,,\arpeggio e g>}
1578 This command creates @code{Arpeggio} grobs. It is not possible to mix
1579 connected arpeggios and unconnected arpeggios at the same time.
1582 @c . {Follow Thread}
1584 @subsection Follow Thread
1585 @cindex follow thread
1586 @cindex staff switching
1589 [todo: different name, eg. voice line ? ]
1591 @cindex @code{followThread}
1593 Whenever a voice switches to another staff a line connecting the notes
1594 can be printed automatically. This is enabled if the property
1595 @code{PianoStaff.followThread} is set to true:
1598 @lilypond[fragment,relative,verbatim]
1599 \context PianoStaff <
1600 \property PianoStaff.followThread = ##t
1601 \context Staff \context Voice {
1603 \translator Staff=two
1606 \context Staff=two {\clef bass; \skip 1*2;}
1620 * Automatic syllable durations::
1626 @subsection Lyrics mode
1630 @cindex @code{\lyrics}
1632 Lyrics mode is introduced by the keyword @code{\lyrics}. This mode has
1633 rules that make it easy to include punctuation and diacritical marks in
1634 words: The purpose of Lyrics mode is that you can enter lyrics in @TeX{}
1635 format or a standard encoding without needing quotes. The precise
1636 definition of this mode is ludicrous, and this will remain so until the
1637 authors of LilyPond acquire a deeper understanding of character
1638 encoding, or someone else steps up to fix this.
1640 A word in Lyrics mode begins with: an alphabetic character, @code{_},
1641 @code{?}, @code{!}, @code{:}, @code{'}, the control characters @code{^A}
1642 through @code{^F}, @code{^Q} through @code{^W}, @code{^Y}, @code{^^},
1643 any 8-bit character with ASCII code over 127, or a two-character
1644 combination of a backslash followed by one of @code{`}, @code{'},
1645 @code{"}, or @code{^}.
1647 Subsequent characters of a word can be any character that is not a digit
1648 and not white space. One important consequence of this is that a word
1649 can end with `@code{@}}', which may be confusing. However, LilyPond will
1650 issue a warning. Any @code{_} character which appears in an unquoted
1651 word is converted to a space. This provides a mechanism for introducing
1652 spaces into words without using quotes. Quoted words can also be used
1653 in Lyrics mode to specify words that cannot be written with the above
1654 rules. Here are some examples. Not all of these words are printable by
1659 2B_||_!2B % not a word because it starts with a digit
1660 ``Hello'' % not a word because it starts with `
1661 _ _ _ _ % 4 words, each one a space
1664 Since combinations of numbers and dots are used for indicating
1665 durations, you can not enter real numbers in this mode.
1667 @cindex lyrics expressions
1669 Syllables are entered like notes, with pitches replaced by text. For
1670 example, @code{Twin-4 kle4 twin-4 kle4} enters four syllables, each
1671 with quarter note duration. Note that the hyphen has no special
1672 meaning for lyrics, and does not introduce special symbols. See
1673 @ref{Lexical modes} for a description of what is interpreted as
1676 Spaces can be introduced into a lyric either by using quotes
1677 (@code{"}) or by using an underscore without quotes: @code{He_could4
1678 not4}. All unquoted underscores are converted to spaces. Printing
1679 lyrics is discussed in the next section.
1682 @c . {Printing lyrics}
1683 @node Printing lyrics
1684 @subsection Printing lyrics
1688 Lyric syllables must be interpreted within a @code{Lyrics} context for
1689 printing them. Here is a full example:
1695 \notes \transpose c'' {
1697 e f g2 | e4 f g2 \bar "|.";
1699 \context Lyrics \lyrics {
1700 Va-4 der Ja- cob Va- der Ja- cob
1701 Slaapt gij nog?2 Slaapt4 gij nog?2
1713 @cindex lyric extender
1715 You may want a continuous line after the syllables to show melismata.
1716 To achieve this effect, add a @code{__} lyric as a separate word
1717 after the lyric to be extended. This will create an extender, a line
1718 that extends over the entire duration of the lyric. This line will
1719 run all the way to the start of the next lyric, so you may want to
1720 shorten it by using a blank lyric (using @code{_}).
1727 \notes \relative c'' {
1728 a4 () b () c () d | c () d () b () a | c () d () b () a
1730 \context Lyrics \lyrics {
1731 foo1 __ | bar2. __ _4 | baz1 __
1739 @cindex Lyric hyphen
1741 If you want to have hyphens centered between syllables (rather than
1742 attached to the end of the first syllable) you can use the special
1743 `@code{-}@code{-}' lyric as a separate word between syllables. This
1744 will result in a hyphen which length varies depending on the space
1745 between syllables, and which will be centered between the syllables.
1753 \notes \transpose c'' {
1755 e f g2 | e4 f g2 \bar "|.";
1757 \context Lyrics \lyrics {
1758 Va4 -- der Ja -- cob | Va -- der Ja -- cob |
1759 Slaapt gij nog?2 | Slaapt4 gij nog?2
1768 @c . {Automatic syllable durations}
1769 @node Automatic syllable durations
1770 @subsection Automatic syllable durations
1771 @cindex Automatic syllable durations
1774 @cindex automatic lyric durations
1775 @cindex @code{\addlyrics}
1777 If you have lyrics that are set to a melody, you can import the rhythm
1778 of that melody into the lyrics using @code{\addlyrics}. The syntax for
1781 \addlyrics @var{musicexpr1 musicexpr2}
1784 This means that both @var{musicexpr1} and @var{musicexpr2} are
1785 interpreted, but that every non-command atomic music expression
1786 (``every syllable'') in @var{musicexpr2} is interpreted using timing
1787 of @var{musicexpr1}.
1788 @cindex @code{automaticMelismata}
1790 If the property @code{automaticMelismata} is set in the
1791 context of @var{musicexpr1}, no lyrics will be put on slurred or tied
1795 @lilypond[verbatim,fragment]
1798 \property Voice.automaticMelismata = ##t
1799 c8 () cis d8. e16 f2
1801 \context Lyrics \lyrics {
1806 You should use a single rhythm melody, and single rhythm lyrics (a
1807 constant duration is the obvious choice). If you do not, you will get
1808 undesired effects when using multiple stanzas:
1811 @lilypond[verbatim,fragment]
1814 c8 () cis d8. e16 f2
1816 \context Lyrics \lyrics
1823 It is valid (but probably not very useful) to use notes instead of
1824 lyrics for @var{musicexpr2}.
1827 @subsection More stanzas
1831 If you have multiple stanzas printed underneath each other, the separate
1832 syllables should be aligned around punctuation. LilyPond can do this if
1833 you explain it which lyric lines belong to which melody.
1835 To this end, give the Voice context an identity, and set the LyricsVoice
1836 to name starting with that identity. In the following example, the Voice
1837 identity is @code{duet}, and the identities of the LyricsVoices are
1838 @code{duet-1} and @code{duet-2}.
1841 @lilypond[singleline,verbatim]
1844 \notes \relative c'' \context Voice = duet { \time 3/4; g2 e4 a2 f4 g2. }
1845 \lyrics \context Lyrics <
1846 \context LyricsVoice = "duet-1" {
1847 \property LyricsVoice . stanza = "Bert"
1848 Hi, my name is bert. }
1849 \context LyricsVoice = "duet-2" {
1850 \property LyricsVoice . stanza = "Ernie"
1851 Ooooo, ch\'e -- ri, je t'aime. }
1856 You can add stanza numbers by setting @code{LyricsVoice.Stanza} (for the
1857 first system) and @code{LyricsVoice.stz} for the following systems.
1859 @cindex stanza numbering
1867 [chords vs. simultaneous music]
1871 * Entering named chords::
1872 * Printing named chords::
1877 @subsection Chords mode
1880 Chord mode is introduced by the keyword
1881 @code{\chords}. It is similar to Note mode, but
1882 words are also looked up in a chord modifier table (containing
1883 @code{maj}, @code{dim}, etc).
1885 Since combinations of numbers and dots are used for indicating
1886 durations, you can not enter real numbers in this mode. Dashes
1887 and carets are used to indicate chord additions and subtractions,
1888 so scripts can not be entered in Chord mode.
1890 @c . {Entering named chords}
1891 @node Entering named chords
1892 @subsection Entering named chords
1893 @cindex Chords names
1895 Chord names are a way to generate simultaneous music expressions that
1896 correspond with traditional chord names. It can only be used in
1897 Chord mode (see @ref{Lexical modes}).
1901 @var{tonic}[@var{duration}][@code{-}@var{modifiers}][@code{^}@var{subtractions}][@code{/}@var{inversion}][@code{/+}@var{bass}].
1904 @var{tonic} should be the tonic note of the chord, and @var{duration}
1905 is the chord duration in the usual notation. There are two kinds of
1906 modifiers. One type is @emph{chord additions}, which are obtained by
1907 listing intervals separated by dots. An interval is written by its
1908 number with an optional @code{+} or @code{-} to indicate raising or
1909 lowering by half a step. Chord additions has two effects: It adds
1910 the specified interval and all lower odd numbered intervals to the
1911 chord, and it may lower or raise the specified interval. Intervals
1912 must be separated by a dot (@code{.}).
1915 Throughout these examples, chords have been shifted around the staff
1916 using @code{\transpose}.
1921 @lilypond[fragment,verbatim]
1925 c:9 c:9-.5+.7+ c:3-.5- c:4.6.8
1937 The second type of modifier that may appear after the @code{:} is a
1938 named modifier. Named modifiers are listed in the file
1939 @file{chord-modifiers.ly}. The available modifiers are @code{m} and
1940 @code{min} which lower the 3rd half a step, `@code{aug}' which
1941 raises the 5th, `@code{dim}' which lowers the 5th,
1942 `@code{maj}' which adds a raised 7th, and `@code{sus}'
1943 which replaces the 5th with a 4th.
1947 @lilypond[fragment,verbatim]
1950 c1:m c:min7 c:maj c:aug c:dim c:sus
1958 Chord subtractions are used to eliminate notes from a chord. The
1959 notes to be subtracted are listed after a @code{^} character,
1962 @lilypond[fragment,verbatim,center]
1971 Chord inversions can be specified by appending `@code{/}' and
1972 the name of a single note to a chord. This has the effect of
1973 lowering the specified note by an octave so it becomes the lowest
1974 note in the chord. If the specified note is not in the chord, a
1975 warning will be printed.
1977 @lilypond[fragment,verbatim,center]
1987 Bass notes can be added by `@code{/+}' and
1988 the name of a single note to a chord. This has the effect of
1989 adding the specified note to the chord, lowered by an octave,
1990 so it becomes the lowest note in the chord.
1992 @lilypond[fragment,verbatim,center]
2001 The most interesting application is printing chord names, which is
2002 explained in the next subsection.
2004 You should not combine @code{\relative} with named chords. [FIXME]
2006 @c . {Printing named chords}
2007 @node Printing named chords
2008 @subsection Printing named chords
2014 @cindex printing chord names
2017 @cindex @code{ChordNames}
2018 @cindex @code{ChordNameVoice}
2020 For displaying printed chord names, use the @code{ChordNames} and
2021 @code{ChordNameVoice} contexts. The chords may be entered either using
2022 the notation described above, or directly using simultaneous music.
2025 @lilypond[verbatim,singleline]
2027 \chords {a1 b c} <d f g> <e g b>
2031 \context ChordNamesVoice \scheme
2032 \context Staff \transpose c'' \scheme
2038 You can make the chord changes stand out more by setting property
2039 @code{ChordNames.chordChanges} to true. This will only display chord
2040 names when there's a change in the chords scheme, but always display the
2041 chord name after a line break:
2047 c1:m \break c:m c:m c:m d
2052 \context ChordNames \scheme
2053 \context Staff \transpose c'' \scheme
2056 linewidth = 40 * \staffspace;
2068 LilyPond examines chords specified as lists of notes to determine a
2069 name to give the chord. LilyPond will not try to
2070 identify chord inversions or added base, which may result in strange
2071 chord names when chords are entered as a list of pitches:
2074 @lilypond[verbatim,center,singleline]
2083 \context ChordNamesVoice \scheme
2084 \context Staff \scheme
2090 To specify chord inversions, append @code{/<notename>}. To specify an
2091 added bass note, append @code{/+<notename}:
2094 @lilypond[verbatim,center,singleline]
2101 \context ChordNames \scheme
2102 \context Staff \transpose c'' \scheme
2108 The chord names that LilyPond should print are fully customizable. The
2109 code to print chord names is written in Scheme. It can be found in
2110 @file{scm/chord-name.scm}. Chord names are based on Banter style
2111 naming, which is unambiguous and has a logical structure. Typical
2112 American style chord names are implemented as a variation on Banter
2113 names, they can be selected by setting property @code{ChordName.style}
2118 \include "english.ly"
2123 df:m5- % Diminished triad
2124 c:5^3 % Root-fifth chord
2125 c:4^3 % Suspended fourth triad
2126 c:5+ % Augmented triad
2128 c:m5-.7- % Diminished seventh
2129 c:7+ % Major seventh
2130 c:7.4^3 % Dominant seventh suspended fourth
2131 c:5+.7 % Augmented dominant seventh
2132 c:m5-.7 % "Half" diminished seventh
2133 c:5-.7 % Dominant seventh flat fifth
2134 c:5-.7+ % Major seventh flat fifth
2135 c:m7+ % Minor-major seventh
2136 c:m7 % Minor seventh
2137 c:7 % Dominant seventh
2140 c:9^7 % Major triad w/added ninth
2141 c:6.9^7 % Six/Nine chord
2142 c:9 % Dominant ninth
2143 c:7+.9 % Major ninth
2144 c:m7.9 % Minor ninth
2149 \context ChordNames \scheme
2150 \context Staff \transpose c'' \scheme
2155 ChordName \override #'word-space = #1
2156 ChordName \override #'style = #'american
2163 Similarly, Jazz style chord names are implemented as a variation on
2164 American style names:
2170 c:6 % 6 = major triad with added sixth
2171 c:maj % triangle = maj
2176 c:m % m = minor triad
2177 c:m.6 % m6 = minor triad with added sixth
2178 c:m.7+ % m triangle = minor major seventh chord
2186 c:7.5+ % +7 = augmented dominant
2187 c:7.5- % 7b5 = hard diminished dominant
2194 c:13.9-^11 % 7(b9,13)
2195 c:13.9+^11 % 7(#9,13)
2197 c:13-.9-^11 % 7(b9,b13)
2198 c:13-.9+^11 % 7(#9,b13)
2200 % half diminished chords
2201 c:m5-.7 % slashed o = m7b5
2202 c:9.3-.5- % o/7(pure 9)
2205 c:m5-.7- % o = diminished seventh chord
2210 \context ChordNames \scheme
2211 \context Staff \transpose c'' \scheme
2216 ChordName \override #'word-space = #1
2217 ChordName \override #'style = #'jazz
2225 @section Writing parts
2230 * Instrument names::
2232 * Sound output for transposing instruments::
2233 * Multi measure rests::
2234 * Automatic part combining::
2237 @c . {Rehearsal marks}
2238 @node Rehearsal marks
2239 @subsection Rehearsal marks
2240 @cindex Rehearsal marks
2242 @cindex @code{\mark}
2243 @cindex @code{Mark_engraver}
2246 \mark @var{unsigned};
2251 With this command, you can print a rehearsal mark above the system. You
2252 can provide a number, a string or a markup text as argument. If there is
2253 no argument, the property @code{rehearsalMark} is used and automatically
2256 @lilypond[fragment,verbatim]
2262 c1 \mark #'(music "scripts-segno") ;
2267 @node Instrument names
2268 @subsection Instrument names
2270 You can specify an instrument name for a staff by setting
2271 @code{Staff.instrument} and @code{Staff.instr}. This will print a string
2272 before the start of the staff. For the first start, @code{instrument} is
2273 used, for the next ones @code{instr} is used.
2275 @lilypond[verbatim,singleline]
2277 \property Staff.instrument = "instr " { c''4 } }
2279 \translator { \StaffContext
2280 \consists "Instrument_name_engraver"; } } }
2283 This requires that you add the @code{Instrument_name_engraver} to the
2288 @subsection Transpose
2290 @cindex transposition of pitches
2291 @cindex @code{\transpose}
2293 A music expression can be transposed with @code{\transpose}. The syntax
2296 \transpose @var{pitch} @var{musicexpr}
2299 This means that middle C in @var{musicexpr} is transposed to
2302 @code{\transpose} distinguishes between enharmonic pitches: both
2303 @code{\transpose cis'} or @code{\transpose des'} will transpose up half
2304 a tone. The first version will print sharps and the second version
2308 @lilypond[fragment,verbatim]
2311 { \key e \major; c d e f }
2313 \transpose des'' { \key e \major; c d e f }
2314 \transpose cis'' { \key e \major; c d e f }
2320 If you want to use both @code{\transpose} and @code{\relative}, then
2321 you must use @code{\transpose} first. @code{\relative} will have no
2322 effect music that appears inside a @code{\transpose}.
2324 @node Sound output for transposing instruments
2325 @subsection Sound output transposing instruments
2327 When you want to play a score containing transposed and untransposed
2328 instruments, you have to instruct LilyPond the pitch offset (in
2329 semitones) for the transposed instruments. This is done using
2332 @cindex @code{transposing}
2335 \property Staff.instrument = #"Cl. in B-flat"
2336 \property Staff.transposing = #-2
2340 @c . {Multi measure rests}
2341 @node Multi measure rests
2342 @subsection Multi measure rests
2343 @cindex Multi measure rests
2347 Multi measure rests are entered using `@code{R}'. It is specifically
2348 meant for entering parts: the rest can expand to fill a score with
2349 rests, or it can be printed as a single multimeasure rest This expansion
2350 is controlled by the property @code{Score.skipBars}. If this is set to true,
2351 Lily will not expand empty measures, and the appropriate number is added
2354 @lilypond[fragment,verbatim]
2355 \time 3/4; R2.*2 \property Score.skipBars = ##t R2.*17 R2.*4
2358 Currently, there is no way to condense multiple rests into a single
2361 @cindex condensing rests
2363 @node Automatic part combining
2364 @subsection Automatic part combining
2365 @cindex automatic part combining
2366 @cindex part combiner
2368 Automatic part combining is used to merge two parts of music onto on
2369 staff in an intelligent way. It is aimed primarily at typesetting Hymns
2370 and orchestral scores. When the two parts are identical for a period of
2371 time, only will be shown. In places where the two parts differ, stem
2372 directions are set automatically. Also, soli and @`{a} due parts can be
2373 identified and marke.
2376 @subsubsection Part combine syntax
2378 The syntax for part combining is
2381 \partcombine @var{context} @var{musicexpr1} @var{musicexpr2}
2384 where the pieces of music @var{musicexpr1} and @var{musicexpr2} will be
2385 combined into one context @var{context}. The names of the music
2386 expressions must start with the prefixes @code{one} and @code{two}.
2388 @subsubsection Part combine usage
2390 @cindex @code{Thread_devnull_engraver}
2391 @cindex @code{Voice_engraver}
2392 @cindex @code{A2_engraver}
2394 The most useful function of the part combiner to combining threads into
2395 one voice, as common for wind parts in orchestral scores:
2397 @lilypond[verbatim,singleline,fragment]
2399 \context Voice=one \partcombine Voice
2400 \context Thread=one \notes\relative c'' {
2403 \context Thread=two \notes\relative c'' {
2409 If you have developed a bit of a feel for LilyPond's functioning, you
2410 will notice that what you see above is quite unusual. The first
2411 @code{g} appears only once, although it was specified twice (once in
2412 each Thread). That is the work of the
2413 @code{Thread_devnull_engraver}@footnote{On unix systems, the file
2414 @file{/dev/null} is special device: anything written to it is
2415 discarded.}, that works closely together with the part combiner. When
2416 the part combiner notices that two threads are identical, it tells the
2417 @code{Thread_devnull_engraver} to discard everything in the second
2420 Similarly, the markings @emph{@`{a}2}, @emph{Solo} and @emph{Solo II},
2421 are created by the @code{A2_engraver}. The @code{A2_engraver} also acts
2422 upon instructions of the part combiner. Another thing that the
2423 @code{A2_engraver} does, is forcing of stem, slur and tie directions,
2424 always when both threads are not identical; up for the musicexpr called
2425 @code{one}, down for the musicexpr called @code{two}.
2427 There is actually a third engraver involved in part combining; the
2428 @code{Voice_devnull_engraver}. This one takes care of removing
2429 redundant spanners such as beams, slurs, ties, crescendi, etc.
2431 If you just want the splitting of Threads and setting of directions, and
2432 not the textual markings, you may set the property @var{soloADue} to false:
2434 @lilypond[verbatim,singleline]
2436 \notes \context Staff <
2437 \context Voice=one \partcombine Voice
2438 \context Thread=one\relative c'' {
2441 \context Thread=two\relative c'' {
2454 There are a number of other properties that you can use to tweak the
2455 behavior of part combining, refer to the automatically generated
2456 documentation of the involved engravers and the examples in the tutorial.
2465 A @emph{custos} (plural: @emph{custodes}; latin word for "guard") is a
2466 staff context symbol that appears at the end of a staff line. It
2467 anticipates the pitch of the first note(s) of the following line and
2468 thus helps the player or singer to manage line breaks during
2469 performance, thus enhancing readability of a score.
2474 \notes { c'1 d' e' d' \break c' d' e' d' }
2478 \consists Custos_engraver;
2479 Custos \override #'style = #'mensural;
2486 Custodes were frequently used in music notation until the 16th century.
2487 There were different appearences for different notation styles.
2488 Nowadays, they have survived only in special forms of musical notation
2489 such as via the editio vaticana dating back to the beginning of the 20th
2492 For typesetting custodes, just put a @code{Custos_engraver} into the
2493 @code{StaffContext} when declaring the @code{\paper} block. In this
2494 block, you can also globally control the appearance of the custos symbol
2495 by setting the custos @code{style} property. Currently supported styles
2496 are @code{vaticana}, @code{medicaea}, @code{hufnagel} and
2503 \consists Custos_engraver;
2504 Custos \override #'style = #'mensural;
2509 The property can also be set locally, for example in a @code{\notes}
2514 \property Staff.Custos \override #'style = #'vaticana
2515 c'1 d' e' d' \break c' d' e' d'
2519 @c . {Tuning output}
2521 @section Tuning output
2523 LilyPond tries to take as much formatting as possible out of your
2524 hands. Nevertheless, there are situations where it needs some help, or
2525 where you want to override its decisions.
2527 Here we discuss how you can do that.
2529 Notational output is specified in so called grobs (graphic
2530 objects). Each grob carries with it a set of properties (grob
2531 properties) specific to that grob. For example, a stem grob has grob
2532 properties that specify its direction, length and thickness.
2534 The most common way of tuning the output is to alter the values of these
2535 properties. There are two ways of doing that: first, you can
2536 specifically select a set of grobs at one point, and set properties as
2537 you wish, or secondly, you can (temporarily) modify the definition of a
2538 grob, thereby affecting an entire group of grobs.
2541 * Tuning groups of grobs ::
2542 * Tuning per grob ::
2547 @node Tuning groups of grobs
2548 @subsection Tuning groups of grobs
2550 @cindex grob description
2552 A grob definition is an association list, that is stored in a context
2553 property. By assigning to that property (using plain @code{\property}),
2554 you can change the resulting grobs.
2555 @lilypond[verbatim, fragment]
2556 c'4 \property Voice.Stem \override #'meta = #'((interfaces . ())) c'4
2558 The @code{\property} statement effectively empties the definition of the
2559 Stem object. One of the effects is that property specifying how it
2560 should be printed is erased, with the effect of rendering it invisible.
2567 This mechanism is fairly crude, since you can only set, but not modify,
2568 the definition of a grob. For this reason, there is a more advanced
2569 mechanism: you can add a property on top of an existing definition, or
2570 remove a property: @code{\override} adds a settings, @code{\revert}
2571 removes that setting.
2573 c'4 \property Voice.Stem \override #'thickness = #4.0
2574 c'4 \property Voice.Stem \revert #'thickness
2578 For the digirati, the grob description is an Scheme association
2579 list. Since it is singly linked, we can treat it as a stack, and
2580 @code{\override} and @code{\revert} are just push and pop
2581 operations. This pushing and popping is also used in the
2582 @code{autoBeamSettings} property.
2584 If you revert a setting which was not set in the first place, then it
2585 has no effect. However, if the setting was set as a system default, it
2586 may remove the default value, and this may give surprising results,
2587 including crashes. In other words, if you use @code{\override} and
2588 @code{\revert}, be sure to balance the overrides and reverts.
2590 If balancing them is too much work, use the following shorthand:
2591 @code{\set} performs a revert followed by an override:
2593 \property Voice.Stem \set #'thickness = #2.0
2596 Formally the syntax for these constructions is
2598 \property @var{context}.@var{grobname} \override @var{symbol} = @var{value}
2599 \property @var{context}.@var{grobname} \set @var{symbol} = @var{value}
2600 \property @var{context}.@var{grobname} \revert @var{symbol}
2602 Here @var{symbol} is a Scheme expression of symbol type, @var{context}
2603 and @var{grobname} are strings and @var{value} is a Scheme expression.
2605 LilyPond will hang or crash if @var{value} contains cyclic references.
2609 @node Tuning per grob
2610 @subsection Tuning per grob
2612 @cindex \outputproperty
2614 A second way of tuning grobs is the more arcane @code{\outputproperty}
2616 Syntax is as follows
2618 \outputproperty @var{predicate} @var{symbol} = @var{value}
2620 Here @code{predicate} is a Scheme functoin taking a grob a argument
2621 argument, and returning a boolean. This statement is processed by the
2622 @code{Output_property_engraver}. It instructs the engraver to feed all
2623 grobs that it sees to @var{predicate}. Whenever the predicate returns
2624 true, the grob property @var{symbol} will be set to @var{value}.
2626 You will need to combine this statement with @code{\context} to select
2627 the appropriate context to apply this to.
2629 If possible, avoid this feature: the semantics are not very clean, and
2630 the syntax and semantics are up for rewrite.
2632 Here are some random examples:
2634 @lilypond[fragment,verbatim,singleline]
2636 \context Staff \outputproperty
2637 #(make-type-checker 'note-head-interface)
2638 #'extra-offset = #'(0.5 . 0.75)
2642 @cindex @code{extra-offset}
2644 This selects all note heads occurring at current staff level, and sets
2645 the @code{extra-offset} of those heads to @code{(0.5,0.75)}, shifting
2648 Move the text "m.d.", but not the fingering instruction "2".
2649 @lilypond[verbatim,singleline]
2650 #(define (make-text-checker text)
2651 (lambda (grob) (equal? text (ly-get-elt-property grob 'text))))
2654 \notes\relative c''' {
2655 \property Voice.Stem \set #'direction = #1
2656 \outputproperty #(make-text-checker "m.d.")
2657 #'extra-offset = #'(-3.5 . -4.5)
2667 @subsection What to tune?
2669 This all tells you how to tune grobs, but what variables are there? The
2670 question is not answered in this manual (although you may encounter
2673 Grob properties are tied directly to the implementation of LilyPond, and
2674 they are thus a moving target. Refer to the automatically generated
2675 documentation of the internals (available from the website).
2677 You need the following information
2681 which grob to modify
2683 which property to modify
2685 which context the grob comes from.
2688 Included with the automatically generated documentation is a master list
2689 of grobs. Each one can be clicked, taking you to a overview of the
2690 available properties.
2692 There is also a master list of contexts. Clicking each takes you to an
2693 overview of the context, listing which grob types are created there.
2698 @subsection Text markup
2702 LilyPond has an internal mechanism to typeset texts. You can
2703 form text markup expressions by composing scheme expressions
2704 in the following way.
2708 \notes \relative c' {
2710 c-#'(upright "upright")
2711 c-#'((bold upright) "bold")
2712 d-#'(lines "one" ((bold upright) "two"))
2713 e-#'(music (named "noteheads-2" "flags-u3"))
2715 \paper { linewidth = 10.\cm; }
2719 Normally, the Scheme markup text is stored in the @code{text} property
2720 of a grob. Formally, it is defined as follows:
2723 text: string | (head? text+)
2724 head: markup | (markup+)
2725 markup-item: property | abbrev | @var{fontstyle}
2726 property: (@var{key} . @var{value})
2727 abbrev: @code{rows lines roman music bold italic named super sub text}
2730 The markup is broken down and converted into a list of grob properties,
2731 which are prepended to the grop's property list. The
2732 @var{key}-@var{value} pair is a grob property.
2734 The following abbreviations are currently
2739 horizontal mode: set all text on one line (default)
2741 vertical mode: set every text on new line
2751 lookup by character name
2753 plain text lookup (by character value)
2760 @var{fontstyle} may be any of @code{finger volta timesig mmrest mark
2761 script large Large dynamic}
2764 It is possible to use @TeX{} commands in the strings, but this should be
2765 avoided because this makes it impossible for LilyPond to compute the
2766 exact length of the string, which may lead to collisions. Also, @TeX{}
2767 commands won't work with direct postscript output.
2771 @section Page layout
2785 @subsection Paper block
2788 The most important output definition is the @code{\paper} block, for
2789 music notation. The syntax is
2792 @code{\paper @{} [@var{paperidentifier}] @var{items} @code{@}}
2795 where each of the items is one of
2798 @item An assignment. The assignment must be terminated by a
2801 @item A context definition. See @ref{Notation Contexts} for
2802 more information on context definitions.
2804 @item \stylesheet declaration. Its syntax is
2806 \stylesheet @var{alist}
2809 See @file{font.scm} for details of @var{alist}.
2812 @c . {Paper variables}
2813 @node Paper variables
2814 @subsection Paper variables
2815 @cindex Paper variables
2817 The paper block has some variables you may want to use or change:
2820 @cindex @code{indent}
2822 The indentation of the first line of music.
2823 @cindex @code{staffspace}
2825 @item @code{staffspace}
2826 The distance between two staff lines, calculated from the center
2827 of the lines. You should use either this or @code{stafflinethickness}
2828 as a unit for distances you modify.
2830 @cindex @code{linewidth}
2831 @item @code{linewidth}
2832 Sets the width of the lines.
2834 If set to a negative value, a single
2835 unjustified line is produced.
2837 @cindex @code{textheight}
2839 @item @code{textheight}
2840 Sets the total height of the music on each page. Only used by
2842 @cindex @code{interscoreline}
2844 @item @code{interscoreline}
2845 Sets the spacing between the score lines. Defaults to 16 pt.
2846 @cindex @code{interscorelinefill}
2848 @item @code{interscorelinefill}
2849 If set to a positive number, the distance between the score
2850 lines will stretch in order to fill the full page. In that
2851 case @code{interscoreline} specifies the minimum spacing.
2853 @cindex @code{stafflinethickness}
2855 @item @code{stafflinethickness}
2856 Determines the thickness of staff lines, and also acts as a scaling
2857 parameter for other line thicknesses.
2864 @subsection Font size
2867 The Feta font provides musical symbols at six different sizes. These
2868 fonts are 11 point, 13 point, 16 point, 20 point,
2869 23 point, and 26 point. The point size of a font is the
2870 height of the five lines in a staff when displayed in the font.
2872 Definitions for these sizes are the files @file{paperSZ.ly}, where
2873 @code{SZ} is one of 11, 13, 16, 20, 23 and 26. If you include any of
2874 these files, the identifiers @code{paperEleven}, @code{paperThirteen},
2875 @code{paperSixteen}, @code{paperTwenty}, @code{paperTwentythree}, and
2876 @code{paperTwentysix} are defined respectively. The default
2877 @code{\paper} block is also set.
2879 The font definitions are generated using a Scheme function. For more
2880 details, see the file @file{font.scm}.
2886 @subsection Paper size
2891 @cindex @code{papersize}
2893 To change the paper size, you must first set the
2894 @code{papersize} variable at top level. Set it to
2895 the strings @code{a4}, @code{letter}, or @code{legal}. After this
2896 specification, you must set the font as described above. If you want
2897 the default font, then use the 20 point font. The new paper size will
2898 not take effect if the font is not loaded and selected afterwards.
2902 \include "paper16.ly"
2906 \paper @{ \paperSixteen @}
2910 The file "paper16.ly" will now include a file named @file{a4.ly}, which
2911 will set the paper variables @code{hsize} and @code{vsize} (used by
2922 @subsection Line break
2925 @cindex breaking lines
2927 Line breaks are normally computed automatically. They are chosen such
2928 that the resulting spacing has low variation, and looks neither cramped
2931 Occasionally you might want to override the automatic breaks; you can do
2932 this by specifying @code{\break}. This will force a line break at this
2933 point. Do remember that line breaks can only occur at places where there
2934 are barlines. If you want to have a line break where there is no
2935 barline, you can force a barline by entering @code{\bar "";}.
2937 Similarly, @code{\noBreak} forbids a line break at a certain point.
2939 @cindex @code{\penalty}
2941 The @code{\break} and @code{\noBreak} commands are defined in terms of
2942 the penalty command:
2944 \penalty @var{int} @code{;}
2947 This imposes encourages or discourages LilyPond to make a line break
2950 @strong{Warning} do not use @code{\penalty} directly. It is rather
2951 kludgy, and slated for rewriting.
2955 @subsection Page break
2958 @cindex breaking pages
2961 Page breaks are normally computed by @TeX{}, so they are not under direct
2962 control. However, you can insert a commands into the @file{.tex} output to
2963 instruct @TeX{} where to break pages. For more details, see the
2964 example file @file{input/test/between-systems.ly}
2978 LilyPond allows MIDI output, with the purpose of proof-hearing the music
2979 you enter. The performance lacks lots of interesting effects, such as
2980 swing, articulation, slurring, tieing, etc.
2982 Also note that it is not possible to use the percussion channel
2983 (generally channel 10 of a MIDI file).
2987 * MIDI instrument names::
2993 @subsection MIDI block
2997 The MIDI block is analogous to the paper block, but it is somewhat
2998 simpler. The @code{\midi} block can contain:
3002 @item a @code{\tempo} definition
3003 @item context definitions
3006 Assignments in the @code{\midi} block are not allowed.
3010 @cindex context definition
3012 Context definitions follow precisely the same syntax as within the
3013 \paper block. Translation modules for sound are called performers.
3014 The contexts for MIDI output are defined in @file{ly/performer.ly}.
3017 [Instrument Equaliser]
3019 FIXME: would it be useful to refer to files like scm/midi.scm,
3020 or to give examples of how to tweak MIDI output volume?
3023 @c . {MIDI instrument names}
3024 @node MIDI instrument names
3025 @subsection MIDI instrument names
3026 @cindex instrument names
3027 @cindex @code{Staff.midiInstrument}
3028 @cindex @code{Staff.instrument}
3030 The MIDI instrument name is set by the @code{Staff.midiInstrument}
3031 property or, if that property is not set, the @code{Staff.instrument}
3032 property. The instrument name should be chosen from the following list.
3033 If the selected string does not exactly match, then LilyPond uses the
3036 [FIXME: to appendix ]
3040 "acoustic grand" "contrabass" "lead 7 (fifths)"
3041 "bright acoustic" "tremolo strings" "lead 8 (bass+lead)"
3042 "electric grand" "pizzicato strings" "pad 1 (new age)"
3043 "honky-tonk" "orchestral strings" "pad 2 (warm)"
3044 "electric piano 1" "timpani" "pad 3 (polysynth)"
3045 "electric piano 2" "string ensemble 1" "pad 4 (choir)"
3046 "harpsichord" "string ensemble 2" "pad 5 (bowed)"
3047 "clav" "synthstrings 1" "pad 6 (metallic)"
3048 "celesta" "synthstrings 2" "pad 7 (halo)"
3049 "glockenspiel" "choir aahs" "pad 8 (sweep)"
3050 "music box" "voice oohs" "fx 1 (rain)"
3051 "vibraphone" "synth voice" "fx 2 (soundtrack)"
3052 "marimba" "orchestra hit" "fx 3 (crystal)"
3053 "xylophone" "trumpet" "fx 4 (atmosphere)"
3054 "tubular bells" "trombone" "fx 5 (brightness)"
3055 "dulcimer" "tuba" "fx 6 (goblins)"
3056 "drawbar organ" "muted trumpet" "fx 7 (echoes)"
3057 "percussive organ" "french horn" "fx 8 (sci-fi)"
3058 "rock organ" "brass section" "sitar"
3059 "church organ" "synthbrass 1" "banjo"
3060 "reed organ" "synthbrass 2" "shamisen"
3061 "accordion" "soprano sax" "koto"
3062 "harmonica" "alto sax" "kalimba"
3063 "concertina" "tenor sax" "bagpipe"
3064 "acoustic guitar (nylon)" "baritone sax" "fiddle"
3065 "acoustic guitar (steel)" "oboe" "shanai"
3066 "electric guitar (jazz)" "english horn" "tinkle bell"
3067 "electric guitar (clean)" "bassoon" "agogo"
3068 "electric guitar (muted)" "clarinet" "steel drums"
3069 "overdriven guitar" "piccolo" "woodblock"
3070 "distorted guitar" "flute" "taiko drum"
3071 "guitar harmonics" "recorder" "melodic tom"
3072 "acoustic bass" "pan flute" "synth drum"
3073 "electric bass (finger)" "blown bottle" "reverse cymbal"
3074 "electric bass (pick)" "skakuhachi" "guitar fret noise"
3075 "fretless bass" "whistle" "breath noise"
3076 "slap bass 1" "ocarina" "seashore"
3077 "slap bass 2" "lead 1 (square)" "bird tweet"
3078 "synth bass 1" "lead 2 (sawtooth)" "telephone ring"
3079 "synth bass 2" "lead 3 (calliope)" "helicopter"
3080 "violin" "lead 4 (chiff)" "applause"
3081 "viola" "lead 5 (charang)" "gunshot"
3082 "cello" "lead 6 (voice)"
3093 @cindex beats per minute
3094 @cindex metronome marking
3096 @cindex @code{\tempo}
3098 \tempo @var{duration} = @var{perminute} @code{;}
3101 Used to specify the tempo. For example, @code{\tempo 4 = 76;} requests
3102 output with 76 quarter notes per minute.
3110 @section Music entry
3121 @subsection Relative
3123 @cindex relative octave specification
3125 Octaves are specified by adding @code{'} and @code{,} to pitch names.
3126 When you copy existing music, it is easy to accidentally put a pitch in
3127 the wrong octave and hard to find such an error. To prevent these
3128 errors, LilyPond features octave entry.
3130 @cindex @code{\relative}
3132 \relative @var{startpitch} @var{musicexpr}
3135 The octave of notes that appear in @var{musicexpr} are calculated as
3136 follows: If no octave changing marks are used, the basic interval
3137 between this and the last note is always taken to be a fourth or less.
3138 The octave changing marks @code{'} and @code{,} can then
3139 be added to raise or lower the pitch by an extra octave. Upon entering
3140 relative mode, an absolute starting pitch must be specified that will
3141 act as the predecessor of the first note of @var{musicexpr}.
3143 This distance is determined without regarding accidentals: a
3144 @code{fisis} following a @code{ceses} will be put above the
3147 Entering scales is straightforward in relative mode.
3149 @lilypond[fragment,verbatim,center]
3151 g a b c d e f g g, g
3155 And octave changing marks are used for intervals greater than a fourth.
3157 @lilypond[fragment,verbatim,center]
3159 c g c f, c' a, e'' }
3162 If the preceding item is a chord, the first note of the chord is used
3163 to determine the first note of the next chord. But other notes
3164 within the second chord are determined by looking at the immediately
3167 @lilypond[fragment,verbatim,center]
3174 @cindex @code{\notes}
3176 The pitch after the @code{\relative} contains a notename. To parse
3177 the pitch as a notename, you have to be in note mode, so there must
3178 be a surrounding @code{\notes} keyword (which is not
3181 The relative conversion will not affect @code{\transpose} or
3182 @code{\relative} sections in its argument. If you want to use
3183 relative within transposed music, you must place an additional
3184 @code{\relative} inside the @code{\transpose}.
3189 @subsection Bar check
3193 @cindex @code{barCheckNoSynchronize}
3197 Whenever a bar check is encountered during interpretation, a warning
3198 message is issued if it doesn't fall at a measure boundary. This can
3199 help you find errors in the input. Depending on the value of
3200 @code{barCheckNoSynchronize}, the beginning of the measure will be
3201 relocated, so this can also be used to shorten measures.
3203 A bar check is entered using the bar symbol, @code{|}
3207 @c . {Point and click}
3208 @node Point and click
3209 @subsection Point and click
3218 * Notation Contexts::
3219 * Creating contexts::
3220 * Default contexts::
3221 * Context properties::
3222 * Changing context definitions::
3223 * Defining new contexts::
3226 @c . {Music expressions}
3230 @c . {Notation Contexts}
3231 @node Notation Contexts
3232 @subsection Notation Contexts
3234 @cindex notation contexts
3236 Notation contexts are objects that only exist during a run of LilyPond.
3237 During the interpretation phase of LilyPond (when lily prints
3238 "interpreting music"), music a @code{\score} block is interpreted in
3239 time order, i.e. in much the same order that humans read, play, and
3242 During this reading, the notation context is holds the state
3243 for the current point within the music. It contains information like
3246 @item What notes are playing at this point?
3247 @item What symbols will be printed at this point?
3248 @item What is the current key signature, time signature, point within
3252 Contexts are grouped hierarchically: A @code{Voice} context is
3253 contained in a @code{Staff} context (because a staff can contain
3254 multiple voices at any point), a @code{Staff} context is contained in
3255 a @code{Score}, @code{StaffGroup}, or @code{ChoirStaff} context (because
3256 these can all contain multiple staffs).
3259 Contexts associated with sheet music output are called @emph{notation
3260 contexts}, those for sound output are called performance contexts.
3263 @node Creating contexts
3264 @subsection Creating contexts
3266 @cindex @code{\context}
3267 @cindex context selection
3269 Contexts for a music expression can be selected manually, using the
3270 following music expression.
3273 \context @var{contexttype} [= @var{contextname}] @var{musicexpr}
3276 This instructs lilypond to interpret @var{musicexpr} within the context
3277 of type @var{contexttype} and with name @var{contextname}. If this
3278 context does not exist, it will be created.
3282 @lilypond[verbatim,singleline]
3284 \notes \relative c'' {
3285 c4 <d4 \context Staff = "another" e4> f
3292 In this example, the @code{c} and @code{d} are printed on the
3293 default staff. For the @code{e}, a context Staff called
3294 @code{another} is specified; since that does not exist, a new
3295 context is created. Within @code{another}, a (default) Voice context
3296 is created for the @code{e4}. When all music referring to a
3297 context is finished, the context is ended as well. So after the
3298 third quarter, @code{another} is removed.
3302 @node Default contexts
3303 @subsection Default contexts
3305 Most music expressions don't need @code{\context}: they inherit the
3306 notation context from their parent. Each note is a music expression, and
3307 as you can see in the following example, only the sequential music
3308 enclosing the three notes has an explicit context.
3310 @lilypond[verbatim,singleline]
3311 \score { \notes \context Voice = goUp { c'4 d' e' } }
3314 There are some quirks that you must keep in mind when dealing with
3317 Every top-level music is interpreted by the Score context, in other
3318 words, you may think of @code{\score} working like
3321 \context Score @var{music}
3325 Sequential music follows the contexts of its "children". Take this example
3326 @lilypond[verbatim, singleline]
3327 \score { \context Score \notes { c'4 ( d' )e' } }
3330 The sequential music is interpreted by the Score context initially
3331 (notice that the @code{\context} specification is redundant), but when a
3332 note is encountered, contexts are setup to accept that note. In this
3333 case, a Thread, Voice and Staff are created. The rest of the sequential
3334 music is also interpreted with the same Thread, Voice and Staff context,
3335 putting the notes on the same staff, in the same voice.
3337 This is a convenient mechanism, but do not expect opening chords to work
3338 without @code{\context}. For every note, a separate staff is
3341 @lilypond[verbatim, singleline]
3342 \score { \notes <c'4 es'> }
3345 Of course, if the chord is preceded by a normal note in sequential
3346 music, the chord will be interpreted by the Thread of the preceding
3348 @lilypond[verbatim,singleline]
3349 \score { \notes { c'4 <c'4 es'> } }
3354 @node Context properties
3355 @subsection Context properties
3357 Notation contexts can be modified from within the @file{.ly} file. The
3358 following music expression does that job:
3360 @cindex @code{\property}
3362 \property @var{contextname}.@var{propname} = @var{value}
3365 Sets the @var{propname} property of the context @var{contextname} to the
3366 specified Scheme expression @var{value}. All @var{propname} and
3367 @var{contextname} are strings, which are typically unquoted.
3369 Properties that are set in one context are inherited by all of the
3370 contained contexts. This means that a property valid for the
3371 @code{Voice} context can be set in the @code{Score} context (for
3372 example) and thus take effect in all @code{Voice} contexts.
3377 @c . {Context definitions}
3378 @node Changing context definitions
3379 @subsection Changing context definitions
3381 @cindex context definition
3382 @cindex translator definition
3384 The most common way to define a context is by extending an existing
3385 context. You can change an existing context from the paper block, by
3386 first initializing a translator with an existing context identifier:
3390 @var{context-identifier}
3393 Then you can add engravers, remove engravers and set context
3394 properties. The syntax for these operations are respectively
3396 \remove @var{engravername}
3397 \consists @var{engravername}
3398 @var{propname} = @var{value}
3401 Here @var{engravername} is a string, the name of an engraver in the
3402 system. @var{propname} is a string and @var{value} is a Scheme
3405 @lilypond[verbatim,singleline]
3409 \translator { \StaffContext
3410 \consists Instrument_name_engraver;
3412 \remove Clef_engraver;
3418 These type of property assignments happen before interpretation starts,
3419 so a @code{\property} expression will override any predefined settings.
3421 Engravers are the actual C++ modules that do the work in the
3422 interpretation phase.
3425 There are some pre-defined identifiers to simplify editing translators,
3426 they are defined in @file{ly/engraver.ly}. These pre-defined
3430 @cindex @code{StaffContext}
3431 @item @code{StaffContext}
3432 Default Staff context.
3433 @cindex @code{RhythmicStaffContext}
3435 @item @code{RhythmicStaffContext}
3436 Default RhythmicStaff context.
3437 @cindex @code{VoiceContext}
3439 @item @code{VoiceContext}
3440 Default Voice context.
3441 @cindex @code{ScoreContext}
3443 @item @code{ScoreContext}
3444 Default Score context.
3446 @cindex @code{HaraKiriStaffContext}
3448 @item @code{HaraKiriStaffContext}
3449 Staff context that does not print if it only contains rests.
3450 Useful for orchestral scores.@footnote{Harakiri, also called
3451 Seppuku, is the ritual suicide of the Japanese Samourai warriors.}
3454 @node Defining new contexts
3455 @subsection Defining new contexts
3457 If you want to build a context from scratch, you must also supply the
3458 following extra information:
3460 @item A name, specified by @code{\name @var{contextname};}.
3462 @item A cooperation engraver. This is specified by @code{\type
3467 A context definition has this syntax:
3471 \translator @code{@{}
3472 @var{translatorinit} @var{translatormodifierlist}
3476 @var{translatorinit} can be an identifier or
3480 where @var{typename} is one of
3482 The cooperation engraver groups other engravers, and specifies how they
3483 should cooperate. Choices are:
3486 @cindex @code{Engraver_group_engraver}
3487 @item @code{Engraver_group_engraver}
3488 The standard cooperation engraver.
3490 @cindex @code{Score_engraver}
3492 @item @code{Score_engraver}
3493 This is cooperation module that should be in the top level context,
3494 and only the toplevel context.
3496 @cindex @code{Grace_engraver_group}
3498 @item @code{Grace_engraver_group}
3499 This is a special cooperation module (resembling
3500 @code{Score_engraver}) that is used to created an embedded
3504 @var{translatormodifierlist} is a list of items where each item is
3508 @item @code{\consists} @var{engravername} @code{;}
3509 Add @var{engravername} to the list of modules in this context.
3510 The order of engravers added with @code{\consists} is
3513 @item @code{\consistsend} @var{engravername} @code{;}
3514 Analogous to @code{\consists}, but makes sure that
3515 @var{engravername} is always added to the end of the list of
3518 Some engraver types need to be at the end of the list; this
3519 insures they are put there, and stay there, if a user adds or
3520 removes engravers. This command is usually not needed for
3523 @item @code{\accepts} @var{contextname} @code{;}
3524 Add @var{contextname} to the list of context this context can
3525 contain. The first listed context is the context to create by
3528 @item @code{\denies}. The opposite of @code{\accepts}. Added for
3529 completeness, but is never used in practice.
3532 @item @code{\remove} @var{engravername} @code{;}
3533 Remove a previously added (with @code{\consists}) engraver.
3535 @item @code{\name} @var{contextname} @code{;}
3536 This sets name of the context, e.g. @code{Staff}, @code{Voice}. If
3537 the name is not specified, the translator won't do anything.
3539 @item @var{propname} @code{=} @var{value} @code{;}
3540 A property assignment.
3543 In the @code{\paper} block, it is also possible to define translator
3544 identifiers. Like other block identifiers, the identifier can only
3545 be used as the very first item of a translator. In order to define
3546 such an identifier outside of @code{\score}, you must do
3552 foo = \translator @{ @dots{} @}
3559 \translator @{ \foo @dots{} @}
3567 @cindex paper types, engravers, and pre-defined translators
3572 Properties can be preset within the @code{\translator} block
3573 corresponding to the appropriate context. In this case, the syntax
3577 @var{propname} @code{=} @var{value}
3580 The property settings are used during the interpretation phase. They
3581 are read by the LilyPond modules where interpretation contexts are
3582 built of. These modules are called @emph{translators}. Translators for
3583 notation are called @emph{engravers}, and translators for sound are
3584 called @emph{performers}.
3589 @c . {Syntactic details}
3590 @node Syntactic details
3591 @section Syntactic details
3592 @cindex Syntactic details
3596 * Music expressions::
3597 * Manipulating music expressions::
3606 @subsection Top level
3609 This section describes what you may enter at top level.
3613 @subsubsection Score
3616 @cindex score definition
3618 The output is generated combining a music expression with an output
3619 definition. A score block has the following syntax:
3622 \score @{ @var{musicexpr} @var{outputdefs} @}
3625 @var{outputdefs} are zero or more output definitions. If no output
3626 definition is supplied, the default @code{\paper} block will be added.
3630 @c . {Default output}
3631 @subsubsection Default output
3633 Default values for the @code{\paper} and @code{\midi} block are set by
3634 entering such a block at top-level.
3637 @subsubsection Header
3639 @cindex @code{\header}
3644 \header @{ @var{key1} = @var{val1};
3645 @cindex @code{ly2dvi}
3646 @var{key2} = @var{val2}; @dots{} @}
3650 A header describes the file's contents. It can also appear in a
3651 @code{\score} block. Tools like @code{ly2dvi} can use this
3652 information for generating titles. Key values that are used by
3653 @code{ly2dvi} are: title, subtitle, composer, opus, poet, instrument,
3654 metre, arranger, piece and tagline.
3656 It is customary to put the @code{\header} at the top of the file.
3658 @subsubsection Default output
3660 A @code{\midi} or @code{\paper} block at top-level sets the default
3662 paper block for all scores that lack an explicit paper block.
3666 @subsection Identifiers
3669 All of the information in a LilyPond input file, is represented as a
3670 Scheme value. In addition to normal Scheme data types (such as pair,
3671 number, boolean, etc.), LilyPond has a number of specialized data types,
3678 @item Translator_def
3682 @item Music_output_def
3683 @item Moment (rational number)
3686 LilyPond also includes some transient object types. Objects of these
3687 types are built during a LilyPond run, and do not `exist' per se within
3688 your input file. These objects are created as a result of your input
3689 file, so you can include commands in the input to manipulate them,
3690 during a lilypond run.
3693 @item Grob: short for Graphical object. See @ref{Grobs}.
3694 @item Molecule: device-independent page output object,
3695 including dimensions. Produced by some Grob functions
3697 @item Translator: object that produces audio objects or Grobs. This is
3698 not yet user accessible.
3699 @item Font_metric: object representing a font. (See @ref{Font metrics})
3704 @node Music expressions
3705 @subsection Music expressions
3707 @cindex music expressions
3709 Music in LilyPond is entered as a music expression. Notes, rests, lyric
3710 syllables are music expressions, and you can combine music expressions
3711 to form new ones, for example by enclosing a list of expressions in
3712 @code{\sequential @{ @}} or @code{< >}. In this example, a compound
3713 expression is formed out of the quarter note @code{c} and a quarter note
3717 \sequential @{ c4 d4 @}
3720 @cindex Sequential music
3721 @cindex @code{\sequential}
3722 @cindex sequential music
3725 @cindex Simultaneous music
3726 @cindex @code{\simultaneous}
3728 The two basic compound music expressions are simultaneous and
3732 \sequential @code{@{} @var{musicexprlist} @code{@}}
3733 \simultaneous @code{@{} @var{musicexprlist} @code{@}}
3735 For both, there is a shorthand:
3737 @code{@{} @var{musicexprlist} @code{@}}
3741 @code{<} @var{musicexprlist} @code{>}
3743 for simultaneous music.
3744 Other compound music expressions include
3747 \transpose @var{pitch} @var{expr}
3748 \apply @var{func} @var{expr}
3749 \context @var{type} = @var{id} @var{expr}
3750 \times @var{fraction} @var{expr}
3753 In principle, the way in which you nest sequential and simultaneous to
3754 produce music is not relevant. In the following example, three chords
3755 are expressed in two different ways:
3757 @lilypond[fragment,verbatim,center]
3758 \notes \context Voice {
3759 <a c'> <b d' > <c' e'>
3760 < { a b c' } { c' d' e' } >
3764 However, in some cases, LilyPond will also try to choose contexts, and
3765 use the structure of the music expression to do so. This can have
3766 undesired effects: for example, LilyPond will create a separate staff
3767 for each note if you start a @code{\score} with a chord:
3768 @lilypond[verbatim,center,singleline]
3773 The solution is to explicitly instantiate the context you desire.
3774 In this case this is typically a Voice context
3775 @lilypond[verbatim,center,singleline]
3777 \notes\context Voice <c''4 e''>
3780 If you use @code{\context Staff} you will get separate stems for each
3781 note head, leading to collisions, so don't use that.
3785 @c . {Manipulating music expressions}
3786 @node Manipulating music expressions
3787 @subsection Manipulating music expressions
3789 The @code{\apply} mechanism gives you access to the internal
3790 representation of music. You can write Scheme-functions that operate
3791 directly on it. The syntax is
3793 \apply #@var{func} @var{music}
3795 This means that @var{func} is applied to @var{music}. The function
3796 @var{func} should return a music expression.
3798 This example replaces the text string of a script. It also shows a dump
3799 of the music it processes, which is useful if you want to know more
3800 about how music is stored.
3802 #(define (testfunc x)
3803 (if (equal? (ly-get-mus-property x 'text) "foo")
3804 (ly-set-mus-property x 'text "bar"))
3806 (ly-set-mus-property x 'elements
3807 (map testfunc (ly-get-mus-property x 'elements)))
3812 \apply #testfunc { c4_"foo" }
3816 For more information on what is possible, see the @ref{Tricks} and the
3817 automatically generated documentation.
3819 As always: directly accessing internal representations is dangerous: the
3820 implementation is subject to changes, so you should not use this if
3824 @c . {Span requests}
3826 @subsubsection Span requests
3827 @cindex Span requests
3829 Notational constructs that start and end on different notes can be
3830 entered using span requests. The syntax is as follows:
3834 \spanrequest @var{startstop} @var{type}
3838 @cindex @code{\start}
3839 @cindex @code{\stop}
3841 This defines a spanning request. The @var{startstop} parameter is either
3842 -1 (@code{\start}) or 1 (@code{\stop}) and @var{type} is a string that
3843 describes what should be started. Much of the syntactic sugar is a
3844 shorthand for @code{\spanrequest}, for example,
3846 @lilypond[fragment,verbatim,center]
3847 c'4-\spanrequest \start "slur"
3848 c'4-\spanrequest \stop "slur"
3851 Among the supported types are @code{crescendo}, @code{decrescendo},
3852 @code{beam}, @code{slur}. This is an internal command. Users are
3853 encouraged to use the shorthands which are defined in the initialization
3854 file @file{spanners.ly}.
3859 @subsection Assignments
3862 Identifiers allow objects to be assigned to names during the parse
3863 stage. To assign an identifier, you use @var{name}@code{=}@var{value}
3864 and to refer to an identifier, you preceed its name with a backslash:
3865 `@code{\}@var{name}'. @var{value} is any valid Scheme value or any of
3866 the input-types listed above. Identifier assignments can appear at top
3867 level in the LilyPond file, but also in @code{\paper} blocks.
3869 Semicolons are forbidden after top level assignments, but mandatory in
3870 other places. The rules about semicolons and assignments are very
3871 confusing, but when LilyPond input evolves more towards Scheme, we hope
3872 that this problem will grow smaller.
3874 An identifier can be created with any string for its name, but you will
3875 only be able to refer to identifiers whose names begin with a letter,
3876 being entirely alphabetical. It is impossible to refer to an identifier
3877 whose name is the same as the name of a keyword.
3879 The right hand side of an identifier assignment is parsed completely
3880 before the assignment is done, so it is allowed to redefine an
3881 identifier in terms of its old value, e.g.
3887 When an identifier is referenced, the information it points to is
3888 copied. For this reason, an identifier reference must always be the
3889 first item in a block.
3893 \paperIdent % wrong and invalid
3897 \paperIdent % correct
3901 @c . {Lexical details}
3902 @node Lexical details
3903 @subsection Lexical details
3904 @cindex Lexical details
3909 @subsubsection Comments
3915 A one line comment is introduced by a @code{%} character.
3916 Block comments are started by @code{%@{} and ended by @code{%@}}.
3917 They cannot be nested.
3919 @c . {Direct Scheme}
3920 @subsubsection Direct Scheme
3923 @cindex Scheme, in-line code
3926 LilyPond contains a Scheme interpreter (the GUILE library) for
3927 internal use. In some places Scheme expressions also form valid syntax:
3928 whereever it is allowed,
3932 evaluates the specified Scheme code. If this is used at toplevel, then
3933 the result is discarded. Example:
3935 \property Staff.TestObject \override #'foobar = #(+ 1 2)
3938 @code{\override} expects two Scheme expressions, so there are two Scheme
3939 expressions. The first one is a symbol (@code{foobar}), the second one
3940 an integer (namely, 3).
3942 Scheme is a full-blown programming language, and a full discussion is
3943 outside the scope of this document. Interested readers are referred to
3944 the website @uref{http://www.schemers.org/} for more information on
3949 @subsubsection Keywords
3953 Keywords start with a backslash, followed by a number of lower case
3954 alphabetic characters. These are all the keywords.
3957 apply arpeggio autochange spanrequest commandspanrequest
3958 simultaneous sequential accepts alternative bar breathe
3959 char chordmodifiers chords clef cm consists consistsend
3960 context denies duration dynamicscript elementdescriptions
3961 font grace header in lyrics key mark pitch
3962 time times midi mm name pitchnames notes outputproperty
3963 override set revert partial paper penalty property pt
3964 relative remove repeat addlyrics partcombine score
3965 script stylesheet skip textscript tempo translator
3970 @subsubsection Integers
3978 Formed from an optional minus sign followed by digits. Arithmetic
3979 operations cannot be done with integers, and integers cannot be mixed
3983 @subsubsection Reals
3984 @cindex real numbers
3990 Formed from an optional minus sign and a sequence of digits followed
3991 by a @emph{required} decimal point and an optional exponent such as
3992 @code{-1.2e3}. Reals can be built up using the usual operations:
3993 `@code{+}', `@code{-}', `@code{*}', and
3994 `@code{/}', with parentheses for grouping.
4002 A real constant can be followed by one of the dimension keywords:
4003 @code{\mm} @code{\pt}, @code{\in}, or @code{\cm}, for millimeters,
4004 points, inches and centimeters, respectively. This converts the number
4005 to a real that is the internal representation of dimensions.
4009 @subsubsection Strings
4013 Begins and ends with the @code{"} character. To include a @code{"}
4014 character in a string write @code{\"}. Various other backslash
4015 sequences have special interpretations as in the C language. A string
4016 that contains no spaces can be written without the quotes. See
4017 @ref{Lexical modes} for details on unquoted strings; their
4018 interpretation varies depending on the situation. Strings can be
4019 concatenated with the @code{+} operator.
4021 The tokenizer accepts the following commands. They have no grammatical
4022 function, hence they can appear anywhere in the input.
4026 @subsubsection Main input
4029 @cindex @code{\maininput}
4031 The @code{\maininput} command is used in init files to signal that the
4032 user file must be read. This command cannot be used in a user file.
4034 @c . {File inclusion}
4035 @subsubsection Main input
4038 @subsubsection File inclusion
4039 @cindex @code{\include}
4041 \include @var{filename}
4044 Include @var{filename}. The argument @var{filename} may be a quoted string (an
4045 unquoted string will not work here!) or a string identifier. The full
4046 filename including the @file{.ly} extension must be given,
4048 @subsubsection Version information
4049 @cindex @code{\version}
4051 \version @var{string} ;
4054 Specify the version of LilyPond that a file was written for. The
4055 argument is a version string in quotes, for example @code{"1.2.0"}.
4056 This is used to detect invalid input, and to aid
4057 @code{convert-ly} a tool that automatically upgrades input files. See
4058 See @ref{convert-ly} for more information on @code{convert-ly}.
4064 @subsubsection Defining pitch names
4065 @cindex Lexical modes
4066 @cindex definining pitch names
4067 @cindex pitch names, definining
4069 @cindex chord modifier names
4071 A @code{\paper} block at top level sets the default paper block. A
4072 @code{\midi} block at top level works similarly.
4075 @subsubsection Assignments
4079 Identifier assignments may appear at top level. @ref{Assignments}
4083 @c . {Direct scheme}
4084 @subsubsection Direct scheme
4085 @cindex Direct scheme
4087 Scheme statements maybe issued to produce interesting side-effects.
4090 @c . {Lexical modes}
4092 @subsection Lexical modes
4093 @cindex Lexical modes
4096 @cindex @code{\notes}
4097 @cindex @code{\chords}
4098 @cindex @code{\lyrics}
4100 To simplify entering notes, lyrics, and chords, LilyPond has three
4101 special input modes on top of the default mode: note, lyrics and chords
4102 mode. These input modes change the way that normal, unquoted words are
4103 interpreted: for example, the word @code{cis} may be interpreted as a
4104 C-sharp, as a lyric syllable `cis' or as a C-sharp major triad
4107 A mode switch is entered as a compound music expressions
4109 @code{\notes} @var{musicexpr}
4110 @code{\chords} @var{musicexpr}
4111 @code{\lyrics} @var{musicexpr}.
4114 In each of these cases, these expressions do not add anything to the
4115 meaning of their arguments. They are just a way to indicate that the
4116 arguments should be parsed in indicated mode. The modes are treated in
4117 more detail in the @ref{Note entry}, @ref{Lyrics} and
4120 You may nest different input modes.
4124 @subsection Ambiguities
4129 The grammar contains a number of ambiguities. We hope to resolve them at
4133 @item The assignment
4139 can be interpreted as making a string identifier @code{\foo}
4140 containing @code{"bar"}, or a music identifier @code{\foo}
4141 containing the syllable `bar'.
4143 @item The assignment
4149 can be interpreted as making an integer identifier
4150 containing -6, or a Request identifier containing the
4151 fingering `6' (with neutral direction).
4153 @item If you do a nested repeat like
4165 then it is ambiguous to which @code{\repeat} the
4166 @code{\alternative} belongs. This is the classic if-then-else
4167 dilemma. It may be solved by using braces.
4169 @item (an as yet unidentified ambiguity :-)
4176 @c .{Local emacs vars}
4179 @c minor-mode: font-lock
4180 @c minor-mode: outline
4181 @c outline-layout: (-1 : 0)
4182 @c outline-use-mode-specific-leader: "@c \."
4183 @c outline-primary-bullet: "{"
4184 @c outline-stylish-prefixes: nil
4185 @c outline-override-protect: t