3 @c - Reinsert subsection commands that were lost in the
4 @c ancient conversion from YODL! /MB
5 @c - Restructure! Separate internal commands from user level commands. /MB
6 @c - Add some words about Guile. /MB
7 @c - Fix indexing (keyindex) so it doesn't add line breaks /MB
9 @c ugh: because of @include, we need to fill in these nodes
10 @node Reference Manual
11 @chapter Reference Manual
15 * Top level:: Top level
16 * Pitch names:: Pitch names
17 * Lexical conventions:: Lexical conventions
18 * Other languages:: Note names in various languages
19 * Lexical modes:: modes
21 * Music expressions:: Music expressions
22 * Atomic music expressions:: Atomic music expressions
23 * Note specification:: notedesc
25 * Manual beams:: Manual beam
26 * stem tremolo:: tremolo
27 * Compound music expressions:: Compound music expressions
30 * transpose:: transpose
31 * Ambiguities:: Ambiguities
32 * Notation conversion specifics:: Notation conversion specifics
33 * Automatic Beaming:: Automatic Beaming
34 * Chord Names:: Chord Names
35 * lyricprint:: lyricprint
36 * Notation Contexts:: Notation Contexts
37 * Properties:: Changing formatting
38 * Page layout:: Layout
39 * contextdefs:: contextdefs
40 * Sound output:: Sound output
42 * Pre-defined Identifiers:: Pre-defined Identifiers
43 @c May be fragile. Better make single link to generated doco?
44 * Interpretation contexts:(lilypond-internals)LilyPond interpretation contexts.
45 * Engravers:(lilypond-internals)LilyPond engravers.
46 * Backend:(lilypond-internals)LilyPond backend.
54 This document@footnote{This document has been revised for LilyPond 1.2.}
55 describes the the GNU LilyPond input format This format represents a
56 piece of music in an elegant way, but contains enough information for
57 both automatic typesetting and automatic performances.
59 LilyPond input can be classified into three types:
61 @item musical expressions: a musical expression is some combination of
63 @item output definitions: recipes for translating those musical
64 expressions into performances (MIDI) or graphics (eg. PostScript).
66 @item declarations: by declaring and naming musical expressions, you
67 can enter and edit them in manageable chunks.
77 This section describes what you may enter at top level.
81 @cindex score definition
83 The output is generated combining a music expression with an output
84 definition. A score block has the following syntax:
87 \score @{ @var{musicexpr} @var{outputdefs} @}
90 @var{outputdefs} are zero or more output definitions. If no output
91 definition is supplied, the default @code{\paper} block will be added.
100 \header @{ @var{key1} = @var{val1};
101 @var{key2} = @var{val2}; @dots{} @}
104 A header describes the file's contents. It can also appear in a
105 @code{\score} block. Tools like @code{ly2dvi}@indexcode{ly2dvi} can use this
106 information for generating titles. Key values that are used by
107 @code{ly2dvi} are: title, subtitle, composer, opus, poet, instrument,
108 metre, arranger, piece and tagline.
110 It is customary to put the @code{\header} at the top of the file.
115 Note names and chord modifiers can be customised for nationalities.
116 languages and conventions. The syntax is as follows.
118 \pitchnames @keyindex{pitchnames} @var{scheme-alist}
119 \chordmodifiers@keyindex{chordmodifiers} @var{scheme-alist}
122 See @file{ly/nederlands.ly} and @file{ly/chord-modifiers.ly} for
123 specific examples how to do this. tables can be tailored specified
124 using. Some national note names have been provided, see @ref{Other
127 A @code{\paper} block at top level sets the default paper block. A
128 @code{\midi} block at top level works similarly.
132 Identifier assignments may appear at top level. Semicolons are
133 forbidden after top level assignments.
137 @node Lexical conventions
138 @section Lexical conventions
140 @cindex lexical conventions
144 @unnumberedsubsec Comments
151 A one line comment is introduced by a `@code{%}' character.
152 Block comments are started by `@code{%@{}' and ended by `@code{%@}}'.
153 They cannot be nested.
155 @unnumberedsubsec Scheme
159 LilyPond contains a Scheme interpreter (the GUILE library) for
160 internal use. The interpreter is accessed by the pound sign:
162 Whereever the syntax allows Scheme expressions, you may enter one as
168 Evaluates the specified Scheme code. If this is used at toplevel, then
169 the result is discarded. Example:
171 \property Staff.TestObject \override #'symbol = #(+ 1 2)
174 (in this case, @code{\override} expects two Scheme expressions.
176 [refer appendix/ online intro on Scheme]
178 @unnumberedsubsec Keywords
182 Keywords start with a backslash, followed by a number of lower case
183 alphabetic characters. These are all the keywords.
186 apply arpeggio autochange spanrequest commandspanrequest
187 simultaneous sequential accepts alternative bar breathe
188 char chordmodifiers chords clef cm consists consistsend
189 context denies duration dynamicscript elementdescriptions
190 font grace header in lyrics key mark musicalpitch
191 time times midi mm name pitchnames notes outputproperty
192 override set revert partial paper penalty property pt
193 relative remove repeat addlyrics partcombine score
194 script stylesheet skip textscript tempo translator
198 @unnumberedsubsec Integers
202 Formed from an optional minus sign followed by digits. Arithmetic
203 operations cannot be done with integers, and integers cannot be mixed
206 @unnumberedsubsec Reals
211 Formed from an optional minus sign and a sequence of digits followed
212 by a @emph{required} decimal point and an optional exponent such as
213 @code{-1.2e3}. Reals can be built up using the usual operations:
214 `@code{+}@indexcode{+}', `@code{-}@indexcode{-}', `@code{*}@indexcode{*}', and
215 `@code{/}@indexcode{/}', with parentheses for grouping.
217 A real constant can be followed by one of the dimension
220 @code{\mm}@keyindex{mm},
221 @code{\pt}@keyindex{pt}, @code{\in}@keyindex{in}, or
222 @code{\cm}@keyindex{cm}, for millimeters, points, inches and
223 centimeters, respectively. This converts the number to a real that
224 is the internal representation of dimensions.
230 Begins and ends with the `@code{"}' character. To include a `@code{"}'
231 character in a string write `@code{\"}'. Various other backslash
232 sequences have special interpretations as in the C language. A string
233 that contains no spaces can be written without the quotes. See
234 @ref{Lexical modes} for details on unquoted strings; their interpretation varies
235 depending on the situation. Strings can be concatenated with the
238 The tokenizer accepts the following commands. They have no grammatical
239 function, hence they can appear anywhere in the input.
242 \maininput@keyindex{maininput}
245 This command is used in init files to signal that the user file must
246 be read. This command cannot be used in a user file.
248 @unnumberedsubsec file inclusion
251 \include@keyindex{include} @var{file}
254 Include @var{file}. The argument @var{file} may be a quoted string (an
255 unquoted string will not work here!) or a string identifier. The full
256 filename including the @file{.ly} extension must be given,
258 @unnumberedsubsec Version information
261 \version@keyindex{version} @var{string} ;
264 Specify the version of LilyPond that a file was written for. The
265 argument is a version string in quotes, for example @code{"1.2.0"}.
266 This is used to detect invalid input, and to aid
267 @code{convert-ly}, a tool that automatically upgrades input files.
270 @node Other languages
271 @section Other languages
272 @cindex Other languages
274 Note name definitions have been provided in various languages.
275 Simply include the language specific init file. For example:
276 `@code{\include "english.ly"}'. The available language files and the
277 names they define are:
280 Note Names sharp flat
281 nederlands.ly c d e f g a bes b -is -es
282 english.ly c d e f g a bf b -s/-sharp -f/-flat
283 deutsch.ly c d e f g a b h -is -es
284 norsk.ly c d e f g a b h -iss/-is -ess/-es
285 svenska.ly c d e f g a b h -iss -ess
286 italiano.ly do re mi fa sol la sib si -d -b
287 catalan.ly do re mi fa sol la sib si -d/-s -b
290 Pitch names can be redefined using the @code{\pitchnames} command, see
294 @section Lexical modes
295 @cindex Lexical modes
299 To simplify entering notes, lyrics, and chords, @emph{Lilypond} has three
300 special input modes on top of the default mode. In each mode, words
301 are identified on the input. If @code{"word"} is encountered, it is
302 treated as a string. If @code{\word} is encountered, it is treated as
303 a keyword or as an identifier. The behavior of the modes differs in
304 two ways: Different modes treat unquoted words differently, and
305 different modes have different rules for deciding what is a word.
311 At the start of parsing, @emph{Lilypond} is in Normal mode. In Normal
312 mode, a word is an alphabetic character followed by alphanumeric
313 characters. If @code{word} is encountered on the input it is
319 Note mode is introduced by the keyword
320 @code{\notes}@keyindex{notes}. In Note mode, words can only
321 contain alphabetic characters. If @code{word} is encountered,
322 LilyPond first checks for a notename of @code{word}. If no
323 notename is found, then @code{word} is treated as a string.
325 Since combinations of numbers and dots are used for indicating
326 durations, it is not possible to enter real numbers in this mode.
331 Chord mode is introduced by the keyword
332 @code{\chords}@keyindex{chords}. It is similar to Note mode, but
333 words are also looked up in a chord modifier table (containing
334 @code{maj}, @code{dim}, etc).
336 Since combinations of numbers and dots are used for indicating
337 durations, you can not enter real numbers in this mode. Dashes
338 and carets are used to indicate chord additions and subtractions,
339 so scripts can not be entered in Chord mode.
344 Lyrics mode is introduced by the keyword
345 @code{\lyrics}@keyindex{lyrics}. This mode has rules that make it
346 easy to include punctuation and diacritical marks in words. A
347 word in Lyrics mode begins with: an alphabetic character,
348 `@code{_}', `@code{?}', `@code{!}', `@code{:}', `@code{'}', the
349 control characters @code{^A} through @code{^F}, @code{^Q} through
350 @code{^W}, @code{^Y}, @code{^^}, any 8-bit character with ASCII code
351 over 127, or a two-character combination of a backslash followed
352 by one of `@code{`}', `@code{'}', `@code{"}', or
353 `@code{^}'.@footnote{The purpose of Lyrics mode is that you can
354 enter lyrics in @TeX{} format or a standard encoding without
355 needing quotes. The precise definition of this mode indeed is
356 ludicrous. This will remain so until the authors of LilyPond
357 acquire a deeper understanding of character encoding, or someone
358 else steps up to fix this.}
360 Subsequent characters of a word can be any character that is not
361 a digit and not white space. One important consequence of this
362 is that a word can end with `@code{@}}', which may be confusing if
363 you thought the closing brace was going to terminate Lyrics
364 mode.@footnote{LilyPond will issue a warning, though.} Any
365 `@code{_}' character which appears in an unquoted word is
366 converted to a space. This provides a mechanism for introducing
367 spaces into words without using quotes. Quoted words can also be
368 used in Lyrics mode to specify words that cannot be written with
369 the above rules. Here are some examples. Not all of these words
370 are printable by @TeX{}.
374 2B_||_!2B % not a word because it starts with a digit
375 ``Hello'' % not a word because it starts with `
376 _ _ _ _ % 4 words, each one a space
379 Since combinations of numbers and dots are used for indicating
380 durations, you can not enter real numbers in this mode.
383 [todo: include short table showign differences]
390 [say something about types]
392 All of the information in a LilyPond input file, is represented as a
393 Scheme value. In addition to normal Scheme data types (such as pair,
394 number, boolean, etc.), LilyPond has a number of specialized data types,
399 @item Music: see @ref{Music expressions}
401 @item Translator_def:
402 See section @ref{contextdefs} for more information
407 @item Music_output_def (TODO: this is not really a Scheme object
408 yet. Nevertheless, you can use identifiers to make references to them )
409 @item Moment (rational number)
412 LilyPond also includes some transient object types. Objects of these
413 types are built during a LilyPond run, and do not `exist' per se within
414 your input file. These objects are created as a result of your input
415 file, so you can include commands in the input to manipulate them,
416 during a lilypond run.
419 @item Grob: short for Graphical object. See @ref{Grobs}.
420 @item Molecule: device-independent page output object,
421 including dimensions. Produced by some Grob functions
423 @item Translator: object that produces audio objects or Grobs.
424 @item Font_metric: object representing a font. (Not yet user
427 @c @item Audio_element: (todo, smobme)
430 Identifiers allow objects to be assigned to names during the parse
431 stage. To assign an identifier, you use `@var{name}=@var{value}' and to
432 refer to an identifier, you preceed its name with a backslash:
433 `@code{\}@var{name}'. Identifier assignments must appear at top level
434 in the @emph{Lilypond} file. Semicolons are forbidden after assignments
435 appearing at top level but they are obligatory after assignments
436 appearing in the @code{\paper} block, see Section @ref{Page layout}.
438 @var{value} is any valid Scheme value or any of the input-types listed
441 An identifier can be created with any string for its name, but you will
442 only be able to refer to identifiers whose names begin with a letter,
443 being entirely alphanumeric. It is impossible to refer to an identifier
444 whose name is the same as the name of a keyword.
446 The right hand side of an identifier assignment is parsed completely
447 before the assignment is done, so it is allowed to redefine an
448 identifier in terms of its old value, e.g.
454 When an identifier is referenced, the information it points to is
455 copied. For this reason, an identifier reference must always be the
456 first item in a block.
460 \paperIdent % wrong and invalid
464 \paperIdent % correct
470 @node Music expressions
471 @section Music expressions
473 @cindex music expressions
475 Music in @emph{Lilypond} is entered as a music expression. Notes, rests,
476 lyric syllables are music expressions (the atomic
478 @cindex atomic music expressions
479 and you can combine music expressions to form new ones. This example
480 forms a compound expressions out of the quarter @code{c} note and a
484 \sequential @{ c4 d4 @}
487 The meaning of this compound expression is to play the `@code{c}'
488 first, and then the `@code{d}' (as opposed to playing them
489 simultaneously, for instance).
491 Atomic music expression are discussed in
492 subsection @ref{Atomic music expressions}. Compound music expressions are
493 discussed in subsection @ref{Compound music expressions}.
497 @node Atomic music expressions
498 @section Atomic music expressions
508 The syntax for pitch specification is
512 \musicalpitch@keyindex{musicalpitch} @{ @var{octave} @var{note} @var{shift} @}
515 @var{octave} is specified by an integer, zero for the octave
516 containing middle C. @var{note} is a number from 0 to 7, with 0
517 corresponding to C and 7 corresponding to B. The shift is zero for a
518 natural, negative to add flats, or positive to add sharps.
520 In Note and Chord mode, pitches may be designated by names. See
521 section @ref{Other languages} for pitch names in different languages.
523 The syntax for duration specification is
526 \duration@keyindex{duration}
527 @{ @var{length} @var{dotcount} @}
530 @var{length} is the negative logarithm (base 2) of the duration:
531 1 is a half note, 2 is a quarter note, 3 is an eighth
532 note, etc. The number of dots after the note is given by
535 In Note, Chord, and Lyrics mode, durations may be designated by
539 @node Note specification
540 @section Note specification
541 @cindex Note specification
545 @cindex entering notes
547 A note specification has the form
550 @var{pitch}[@var{octavespec}][!][?][@var{duration}]
553 The pitch of the note is specified by the note's name.
556 The default names are the Dutch note names. The notes are specified
557 by the letters `@code{c}' through `@code{b}', where `@code{c}' is an
558 octave below middle C and the letters span the octave above that C.
560 @cindex notenames!Dutch
561 a sharp is formed by adding `@code{-is}' to the end of a pitch name. A
562 flat is formed by adding `@code{-es}'. Double sharps and double flats
563 are obtained by adding `@code{-isis}' or `@code{-eses}'. `@code{aes}'
564 and `@code{ees}' are contracted to `@code{as}' and `@code{es}' in Dutch,
565 but both forms will be accepted.
567 LilyPond has predefined sets of notenames for various languages. See
568 @ref{Other languages}.
572 The optional octave specification takes the form of a series of
573 single quote (`@code{'}@indexcode{'}') characters or a series of comma
574 (`@code{,}@indexcode{,}') characters. Each @code{'} raises the pitch by one
575 octave; each @code{,} lowers the pitch by an octave.
577 @lilypond[fragment,verbatim,center]
578 c' d' e' f' g' a' b' c''
581 @lilypond[fragment,verbatim,center]
582 cis' dis' eis' fis' gis' ais' bis'
585 @lilypond[fragment,verbatim,center]
586 ces' des' es' fes' ges' as' bes'
589 @lilypond[fragment,verbatim,center]
590 cisis' eisis' gisis' aisis' beses'
593 @lilypond[fragment,verbatim,center]
594 ceses' eses' geses' ases' beses'
597 Whenever a C-sharp is desired, you must specify a C-sharp. LilyPond
598 will determine what accidentals to typeset depending on the key and
599 context. A reminder accidental
600 @cindex reminder accidental
602 forced by adding an exclamation mark `@code{!}' after the pitch. A
603 cautionary accidental,
604 @cindex cautionary accidental
606 accidental within parentheses can be obtained by adding the question
607 mark `@code{?}@indexcode{?}' after the pitch.
609 @lilypond[fragment,verbatim,center]
610 cis' d' e' cis' c'? d' e' c'!
616 Durations are entered as their reciprocal values. For notes longer
617 than a whole note, use identifiers.
623 c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64
632 \notes \relative c'' {
634 a1 a2 a4 a8 a16 a32 a64 a64
639 \remove "Clef_engraver";
640 \remove "Staff_symbol_engraver";
651 r1 r2 r4 r8 r16 r32 r64 r64
660 \notes \relative c'' {
662 r1 r2 r4 r8 r16 r32 r64 r64
665 loose_column_distance = 2.5 * \staffspace;
669 \remove "Clef_engraver";
670 \remove "Staff_symbol_engraver";
671 \remove "Bar_engraver";
678 If the duration is omitted then it is set equal to the previous
679 duration. If there is no previous duration, a quarter note is
680 assumed. The duration can be followed by a dot (`@code{.}@indexcode{.}')
681 to obtain dotted note lengths.
683 @lilypond[fragment,verbatim,center]
687 You can alter the length of duration by writing
688 `@code{*}@var{fraction}' after it. This will not affect the
689 appearance of note heads or rests.
692 Rests are entered like notes, with note name `@code{r}@indexcode{r}', or
693 `@code{R}@indexcode{R}'. There is also a note name
694 `@code{s}@indexcode{s}', which produces a space of the specified
695 duration. `@code{R}' is specifically meant for entering parts: the
696 @code{R} rest can expand to fill a score with rests, or it can be
697 printed as a single multimeasure rest.
699 You can control the expansion by setting the property
700 @code{Score.skipBars}. If this is set to true, Lily will not expand
701 empty measures, and the multimeasure rests automatically adds the
704 Note that there is currently no way to condense multiple rests into a
705 single multimeasure rest.
709 @cindex lyrics expressions
711 Syllables are entered like notes, with pitches replaced by text. For
712 example, `@code{Twin-4 kle4 twin-4 kle4}' enters four syllables, each
713 with quarter note duration. Note that the hyphen has no special
714 meaning for lyrics, and does not introduce special symbols. See
715 section @ref{Lexical modes} for a description of what is interpreted as
718 Spaces can be introduced into a lyric either by using quotes
719 (`@code{"}') or by using an underscore without quotes: `@code{He_could4
720 not4}'. All unquoted underscores are converted to spaces. Printing
721 lyrics is discussed in section @ref{lyricprint}.
728 \property@keyindex{property}
729 @var{contextname}.@var{propname} = @var{value}
732 Sets the @var{propname} property of the context @var{contextname} to
733 the specified @var{value}. All three arguments are strings.
734 Depending on the context, it may be necessary to quote the strings or
735 to leave space on both sides of the dot.
739 @cindex translator switches
742 \translator@keyindex{translator}
743 @var{contexttype} = @var{name}
746 A music expression indicating that the context which is a direct
747 child of the a context of type @var{contexttype} should be shifted to
748 a context of type @var{contexttype} and the specified name.
750 Usually this is used to switch staffs in Piano music, e.g.
753 \translator Staff = top @var{Music}
757 @cindex output properties
760 These allow you to tweak what is happening in the back-end
761 directly. If you want to control every detail of the output
762 formatting, this is the feature to use. The downside to this is that
763 you need to know exactly how the backend works. Example:
766 @lilypond[fragment,verbatim]
768 \context Staff \outputproperty
769 #(make-type-checker 'Note_head)
770 #'extra-offset = #'(5.0 . 7.5)
774 This selects all note heads occurring at current staff level, and sets
775 the extra-offset of those heads to (5,7.5), shifting them up and
778 Use of this feature is entirely on your own risk: if you use this, the
779 result will depend very heavily on the implementation of the backend,
780 which we change regularly and unscrupulously.
785 Commands are music expressions that have no duration.
789 @code{\key}@keyindex{key} @var{pitch} @var{type} @code{;}
792 Change the key signature. @var{type} should be
793 @code{\major}@keyindex{major} or @code{\minor}@keyindex{minor} to get
794 @var{pitch}-major or @var{pitch}-minor, respectively. The second
795 argument is optional; the default is major keys. The @var{\context}
796 argument can also be given as an integer, which tells the number of
797 semitones that should be added to the pitch given in the subsequent
798 @code{\key}@keyindex{key} commands to get the corresponding major key,
799 e.g., @code{\minor}@keyindex{minor} is defined as 3. The standard
800 mode names @code{\ionian}@keyindex{ionian},
801 @code{\locrian}@keyindex{locrian}, @code{\aeolian}@keyindex{aeolian},
802 @code{\mixolydian}@keyindex{mixolydian}, @code{\lydian}@keyindex{lydian},
803 @code{\phrygian}@keyindex{phrygian}, and @code{\dorian}@keyindex{dorian}
808 \mark@keyindex{mark} @var{unsigned};
812 Prints a mark over or under the staff. You must add
813 @code{Mark_engraver}@indexcode{Mark_engraver} to the Score context for
820 \bar@keyindex{bar} @var{bartype};
823 This is a short-cut for doing
825 \property Score.whichBar = @var{bartype}
828 You are encouraged to use @code{\repeat} for repetitions. See
829 @ref{Repeats}, and the documentation of @code{whichBar} in
830 @ref{(lilypond-internals)LilyPond context properties}.
834 \time@keyindex{time} @var{numerator}@code{/}@var{denominator} @code{;}
837 A short-cut for doing
839 \property Score.timeSignatureFraction = #'(@var{numerator} . @var{denominator})
842 See the documentation of @code{timeSignatureFraction}
846 \tempo@keyindex{tempo} @var{duration} = @var{perminute} @code{;}
849 Used to specify the tempo. For example, `@code{\tempo 4 = 76;}'
850 requests output with 76 quarter notes per minute.
853 \partial@keyindex{partial} @var{duration} @code{;}
859 \property Score.measurePosition = @var{length of duration}
862 See the documentation of @code{measurePosition}.
870 @code{|}@indexcode{|}
875 @cindex shorten measures
879 `@code{|}' is a bar check. Whenever a bar check is encountered during
880 interpretation, a warning message is issued if it doesn't fall at a
881 measure boundary. This can help you finding errors in the input.
882 Depending on the value of @code{barCheckNoSynchronize}
883 @indexcode{barCheckNoSynchronize} The beginning of the measure will be
884 relocated, so this can also be used to shorten measures.
888 \penalty@keyindex{penalty} @var{int} @code{;}
891 Discourage or encourage line breaks. See identifiers
892 @code{\break}@keyindex{break} and @code{\nobreak}@keyindex{nobreak} in
893 section [on identifiers] [FIXME].
896 \clef@keyindex{clef} @var{clefname} @code{;}
902 \property Clef.clefGlyph = @var{symbol associated with clefname}
903 \property Clef.clefPosition = @var{clef Y-position for clefname}
904 \property Clef.clefOctavation = @var{extra pitch of clefname}
907 Supported clef-names include
913 \skip@keyindex{skip} @var{duration} @code{;}
916 Skips the amount of time specified by @var{duration}. If no other
917 music is played, a gap will be left for the skipped time with no
918 notes printed. It works in Note Mode or Lyrics Mode. In Note mode,
919 this has the same effect as the space rest `@code{s}'.
923 @section Manual beams
926 A beam is specified by surrounding the beamed notes with brackets
927 `@code{[}@indexcode{[}' and `@code{]}@indexcode{]}'.
929 @lilypond[fragment,verbatim,center]
930 [a'8 a'] [a'16 a' a' a']
933 Some more elaborate constructions:
935 @lilypond[fragment,verbatim,center]
936 [a'16 <a' c''> c'' <a' c''>]
937 \times 2/3 { [e'8 f' g'] }
940 Beaming can be generated automatically; see section @ref{Automatic Beaming}.
943 To place tremolo marks between notes, use @code{\repeat} with tremolo
945 @cindex tremolo beams
946 To create tremolo beams on a single note, simply attach
947 `@code{:}@var{length}' to the note itself.
949 @lilypond[fragment,verbatim,center]
950 \repeat "tremolo" 8 { c16 d16 }
951 \repeat "tremolo" 4 { c16 d16 }
954 @lilypond[fragment,verbatim,center]
959 @cindex --@@@code{-}@code{-}
967 The syntax for an extender mark is `@code{__}'. This syntax can only
968 be used within lyrics mode. The syntax for a spanning hyphen (i.e.,
969 a hyphen that will be printed between two lyric syllables) is
975 A tie connects two adjacent note heads of the same pitch. When used
976 with chords, it connects all of the note heads whose pitches match.
977 Ties are indicated using the tilde symbol `@code{~}@indexcode{~}'.
978 If you try to tie together chords which have no common pitches, a
979 warning message will appear and no ties will be created.
981 @lilypond[fragment,verbatim,center]
982 e' ~ e' <c' e' g'> ~ <c' e' g'>
987 [TODO: explain Requests]
990 @cindex articulations
996 A variety of symbols can appear above and below notes to indicate
997 different characteristics of the performance. These symbols can be
998 added to a note with `@var{note}@code{-\}@var{name}'. Numerous symbols
999 are defined in @file{script.ly} and @file{script.scm}. Symbols can be
1000 forced to appear above or below the note by writing
1001 `@var{note}@code{^\}@var{name}' and `@var{note}@code{_\}@var{name}'
1002 respectively. Here is a chart showing symbols above notes, with the
1003 name of the corresponding symbol appearing underneath.
1009 c''-\accent c''-\marcato c''-\staccatissimo c''-\fermata
1010 c''-\stopped c''-\staccato c''-\tenuto c''-\upbow
1011 c''-\downbow c''^\lheel c''-\rheel c''^\ltoe
1012 c''-\rtoe c''-\turn c''-\open c''-\flageolet
1013 c''-\reverseturn c''-\trill c''-\prall c''-\mordent
1014 c''-\prallprall c''-\prallmordent c''-\upprall c''-\downprall
1015 c''-\thumb c''-\segno c''-\coda
1017 \context Lyrics \lyrics {
1018 accent__ marcato__ staccatissimo__ fermata
1019 stopped__ staccato__ tenuto__ upbow
1020 downbow__ lheel__ rheel__ ltoe
1021 rtoe__ turn__ open__ flageolet
1022 reverseturn__ trill__ prall__ mordent
1023 prallprall__ prallmordent__ uprall__ downprall
1024 thumb__ segno__ coda
1028 linewidth = 5.875\in;
1035 In addition, it is possible to place arbitrary strings of text or
1036 @TeX{} above or below notes by using a string instead of an
1037 identifier: `@code{c^"text"}'. Fingerings
1040 placed by simply using digits. All of these note ornaments appear in
1041 the printed output but have no effect on the MIDI rendering of the
1044 To save typing, fingering instructions (digits 0 to 9 are
1045 supported) and single characters shorthands exist for a few
1052 \property Voice.textStyle = typewriter
1058 c''4-^_"c-\\^{ }" s4
1065 linewidth = 5.875 \in;
1072 Dynamic marks are specified by using an identifier after a note:
1073 `@code{c4-\ff}' (the dash is optional for dynamics: `@code{c4 \ff})'.
1074 The available dynamic marks are:
1075 @code{\ppp}@keyindex{ppp},
1076 @code{\pp}@keyindex{pp}, @code{\p}@keyindex{p}, @code{\mp}@keyindex{mp},
1077 @code{\mf}@keyindex{mf}, @code{\f}@keyindex{f}, @code{\ff}@keyindex{ff},
1078 @code{\fff}@keyindex{fff}, @code{\fff}@keyindex{ffff},
1079 @code{\fp}@keyindex{fp}, @code{\sf}@keyindex{sf},
1080 @code{\sff}@keyindex{sff}, @code{\sp}@keyindex{sp},
1081 @code{\spp}@keyindex{spp}, @code{\sfz}@keyindex{sfz}, and
1082 @code{\rfz}@keyindex{rfz}.
1087 \textscript@keyindex{textscript} @var{text} @var{style}
1090 Defines a text to be printed over or under a note. @var{style} is a
1091 string that may be one of @code{roman}, @code{italic}, @code{typewriter},
1092 @code{bold}, @code{Large}, @code{large}, @code{dynamic} or @code{finger}.
1094 You can attach a general textscript request using this syntax:
1099 c4-\textscript "6" "finger"
1100 c4-\textscript "foo" "normal"
1105 This is equivalent to `@code{c4-6 c4-"foo"}'.
1112 \script@keyindex{script} @var{alias}
1115 Prints a symbol above or below a note. The argument is a string
1116 which points into the script-alias table defined in @file{script.scm}.
1117 The scheme definitions specify whether the symbol follows notes into
1118 the staff, dependence of symbol placement on staff direction, and a
1119 priority for placing several symbols over one note. Usually the
1120 @code{\script}@keyindex{script} keyword is not used directly. Various
1121 helpful identifier definitions appear in @file{script.ly}.
1126 Slurs connects chords and try to avoid crossing stems. A slur is
1127 started with `@code{(}' and stopped with `@code{)}'. The
1128 starting `@code{(}' appears to the right of the first note in
1129 the slur. The terminal `@code{)}' appears to the left of the
1130 first note in the slur. This makes it possible to put a note in
1131 slurs from both sides:
1133 @lilypond[fragment,verbatim,center]
1134 f'()g'()a' [a'8 b'(] a'4 g'2 )f'4
1140 A crescendo mark is started with @code{\cr}@keyindex{cr} and terminated
1141 with @code{\rc}@keyindex{rc}. A decrescendo mark is started with
1142 @code{\decr}@keyindex{decr} and terminated with
1143 @code{\rced}@keyindex{rced}. There are also shorthands for these
1144 marks. A crescendo can be started with @code{\<}@keyindex{<} and a
1145 decrescendo can be started with @code{\>}@keyindex{>}. Either one can
1146 be terminated with @code{\!}@keyindex{"!}. Note that @code{\!}
1147 must go before the last note of the dynamic mark whereas @code{\rc}
1148 and @code{\rced} go after the last note. Because these marks are
1149 bound to notes, if you want to get several marks during one note, you
1150 must use spacer notes.
1152 @lilypond[fragment,verbatim,center]
1153 c'' \< \! c'' d'' \decr e'' \rced
1154 < f''1 { s4 \< \! s2 \> \! s4 } >
1160 \spanrequest@keyindex{spanrequest} @var{startstop} @var{type}
1163 Define a spanning request. The @var{startstop} parameter is either -1
1164 (@code{\start}@keyindex{start}) or 1 (@code{\stop}@keyindex{stop}) and
1165 @var{type} is a string that describes what should be started.
1166 Supported types are @code{crescendo}, @code{decrescendo},
1167 @code{beam}, @code{slur}. This is an internal command. Users should
1168 use the shorthands which are defined in the initialization file
1171 You can attach a (general) span request to a note using
1173 @lilypond[fragment,verbatim,center]
1174 c'4-\spanrequest \start "slur"
1175 c'4-\spanrequest \stop "slur"
1178 The slur syntax with parentheses is a shorthand for this.
1182 @section stem tremolo
1183 @cindex tremolo marks
1185 Tremolo marks can be printed on a single note by adding
1186 `@code{:}[@var{length}]' after the note. The length must be at
1187 least 8. A @var{length} value of 8 gives one line across
1188 the note stem. If the length is omitted, then the last value is
1189 used, or the value of the @code{tremoloFlags}@indexcode{tremoloFlags} property if there was
1192 @lilypond[verbatim,fragment,center]
1198 @node Compound music expressions
1199 @section Compound music expressions
1201 @cindex compound music expressions
1203 Music expressions are compound data structures. You can nest music
1204 expressions any way you like. This simple example shows how three
1205 chords can be expressed in two different ways:
1207 @lilypond[fragment,verbatim,center]
1208 \notes \context Staff {
1210 <a c'> <b d' > <c' e'>
1211 < { a b c' } { c' d' e' } >
1215 @cindex context selection
1216 @c @keyindex{context}
1219 \context @var{contexttype} [= @var{contextname}] @var{musicexpr}
1222 Interpret @var{musicexpr} within a context of type @var{contexttype}.
1223 If the context does not exist, it will be created. The new context
1224 can optionally be given a name.
1230 Mode switching keywords form compound music expressions: @code{\notes}
1231 @keyindex{notes} @var{musicexpr}, @code{\chords} @keyindex{chords}
1232 @var{musicexpr}, and @code{\lyrics} @keyindex{lyrics} @var{musicexpr}.
1233 These expressions do not add anything to the meaning of their
1234 arguments. They are just a way to indicate that the arguments should
1235 be parsed in indicated mode. See @ref{Lexical modes} for more
1236 information on modes.
1238 @cindex sequential music
1244 \sequential@keyindex{sequential}
1245 @code{@{} @var{musicexprlist} @code{@}}
1248 This means that list should be played or written in sequence, i.e.,
1249 the second after the first, the third after the second. The duration
1250 of sequential music is the the sum of the durations of the elements.
1251 There is a shorthand, which leaves out the keyword:
1255 @code{@{} @var{musicexprlist} @code{@}}
1260 @cindex simultaneous music
1267 \simultaneous@keyindex{simultaneous}
1268 @code{@{} @var{musicexprlist} @code{@}}
1271 It constructs a music expression where all of its arguments start at
1272 the same moment. The duration is the maximum of the durations of the
1273 elements. The following shorthand is a common idiom:
1277 @code{<} @var{musicexprlist} @code{>}
1280 If you try to use a chord as the first thing in your score, you might
1281 get multiple staffs instead of a chord.
1283 @lilypond[verbatim,center]
1292 This happens because the chord is interpreted by a score context.
1293 Each time a note is encountered a default Voice context (along with a
1294 Staff context) is created. The solution is to explicitly instantiate
1297 @lilypond[verbatim,center]
1299 \notes\context Voice <c''4 e''>
1311 @cindex relative pitch specification
1313 It is easy to get confused by octave changing marks and accidentally
1314 putting a pitch in the wrong octave. A much better way of entering a
1315 note's octave is `the relative octave' mode.
1319 \relative@keyindex{relative} @var{startpitch} @var{musicexpr}
1322 The octave of notes that appear in @var{musicexpr} are calculated as
1323 follows: If no octave changing marks are used, the basic interval
1324 between this and the last note is always taken to be a fourth or
1325 less.@footnote{The interval is determined without regarding
1326 accidentals. A @code{fisis} following a @code{ceses} will be put above
1327 the @code{ceses}.} The octave changing marks `@code{'}' and `@code{,}'
1328 can then be added to raise or lower the pitch by an extra octave.
1329 Upon entering relative mode, an absolute starting pitch must be
1330 specified that will act as the predecessor of the first note of
1333 Entering scales is straightforward in relative mode.
1335 @lilypond[fragment,verbatim,center]
1341 And octave changing marks are used for intervals greater than a fourth.
1343 @lilypond[fragment,verbatim,center]
1345 c g c f, c' a, e'' }
1348 If the preceding item is a chord, the first note of the chord is used
1349 to determine the first note of the next chord. But other notes
1350 within the second chord are determined by looking at the immediately
1353 @lilypond[fragment,verbatim,center]
1361 The pitch after the @code{\relative} contains a notename. To parse
1362 the pitch as a notename, you have to be in note mode, so there must
1363 be a surrounding @code{\notes}@keyindex{notes} keyword (which is not
1366 The relative conversion will not affect @code{\transpose} or
1367 @code{\relative} sections in its argument. If you want to use
1368 relative within transposed music, you must place an additional
1369 @code{\relative} inside the @code{\transpose}.
1371 It is strongly recommended to use relative pitch mode: less work,
1372 less error-prone, and more readable.
1376 Chord names are a way to generate simultaneous music expressions that
1377 correspond with traditional chord names. It can only be used in
1378 Chord mode (see section @ref{Lexical modes}).
1382 @var{tonic}[@var{duration}][@code{-}@var{modifiers}][@code{^}@var{subtractions}][@code{/}@var{inversion}][@code{/+}@var{bass}].
1385 @var{tonic} should be the tonic note of the chord, and @var{duration}
1386 is the chord duration in the usual notation. There are two kinds of
1387 modifiers. One type is @emph{chord additions}, which are obtained by
1388 listing intervals separated by dots. An interval is written by its
1389 number with an optional `@code{+}' or `@code{-}' to indicate raising or
1390 lowering by half a step. Chord additions has two effects: It adds
1391 the specified interval and all lower odd numbered intervals to the
1392 chord, and it may lower or raise the specified interval. Intervals
1393 must be separated by a dot (`@code{.}').
1397 @lilypond[fragment,verbatim]
1401 c:9 c:9-.5+.7+ c:3-.5- c:4.6.8
1408 The second type of modifier that may appear after the `@code{:}' is a
1409 named modifier. Named modifiers are listed in the file
1410 @file{chord-modifiers.ly}. The available modifiers are `@code{m}' and
1411 `@code{min}' which lower the 3rd half a step, `@code{aug}@indexcode{aug}' which
1412 raises the 5th, `@code{dim}@indexcode{dim}' which lowers the 5th,
1413 `@code{maj}@indexcode{maj}' which adds a raised 7th, and `@code{sus}@indexcode{sus}'
1414 which replaces the 5th with a 4th.
1418 @lilypond[fragment,verbatim]
1421 c1:m c:min7 c:maj c:aug c:dim c:sus
1429 Chord subtractions are used to eliminate notes from a chord. The
1430 notes to be subtracted are listed after a `@code{^}' character,
1433 @lilypond[fragment,verbatim,center]
1441 Chord inversions can be specified by appending `@code{/}@indexcode{/}' and
1442 the name of a single note to a chord. This has the effect of
1443 lowering the specified note by an octave so it becomes the lowest
1444 note in the chord. If the specified note is not in the chord, a
1445 warning will be printed.
1447 @lilypond[fragment,verbatim,center]
1456 Bass notes can be added by `@code{/+}@indexcode{/+}' and
1457 the name of a single note to a chord. This has the effect of
1458 adding the specified note to the chord, lowered by an octave,
1459 so it becomes the lowest note in the chord.
1461 @lilypond[fragment,verbatim,center]
1470 Throughout these examples, chords have been shifted around the staff
1471 using @code{\transpose}.
1473 You should not combine @code{\relative} with named chords.
1479 Tuplets are made out of a music expression by multiplying their
1480 duration with a fraction.
1484 \times@keyindex{times} @var{fraction} @var{musicexpr}
1487 The duration of @var{musicexpr} will be multiplied by the fraction.
1488 In print, the fraction's denominator will be printed over the notes,
1489 optionally with a bracket. The most common tuplet is the triplet in
1490 which 3 notes have the length of 2, so the notes are 2/3 of
1491 their written length:
1493 @lilypond[fragment,verbatim,center]
1494 g'4 \times 2/3 {c'4 c' c'} d'4 d'4
1503 \grace@keyindex{grace} @var{musicexpr}
1506 A grace note expression has duration 0; the next real note is
1507 assumed to be the main note.
1509 You cannot have the grace note after the main note, in terms of
1510 duration, and main notes, but you can typeset the grace notes to the
1511 right of the main note using the property
1512 @code{graceAlignPosition}@indexcode{graceAlignPosition}.
1514 When grace music is interpreted, a score-within-a-score is set up:
1515 @var{musicexpr} has its own time bookkeeping, and you could (for
1516 example) have a separate time signature within grace notes. While in
1517 this score-within-a-score, you can create notes, beams, slurs, etc.
1518 Unbeamed eighth notes and shorter by default have a slash through the
1519 stem. This behavior can be controlled with the
1520 @code{flagStyle}@indexcode{flagStyle} property.
1524 @lilypond[fragment,verbatim]
1526 \grace c8 c4 \grace { [c16 c16] } c4
1527 \grace { \property Grace.flagStyle = "" c16 } c4
1533 At present, nesting @code{\grace}@keyindex{grace} notes, e.g.
1537 @code{\grace @{ \grace c32 c16 @} c4}
1540 may result in run-time errors of LilyPond. Since the meaning of such
1541 a construct is unclear, we don't consider this a loss. Similarly,
1542 juxtaposing two @code{\grace} sections is syntactically valid, but
1543 makes no sense and may cause runtime errors.
1545 Ending a staff or score with grace notes may also generate a run-time
1546 error, since there will be no main note to attach the grace notes to.
1555 In order to specify repeats, use the @code{\repeat}@keyindex{repeat}
1556 keyword. Since repeats look and sound differently when played or
1557 printed, there are a few different variants of repeats.
1561 Repeated music is fully written (played) out. Useful for MIDI
1565 This is the normal notation: Repeats are not written out, but
1566 alternative endings (voltas) are printed, left to right.
1569 Alternative endings are written stacked, which is useful for
1573 The syntax for repeats is
1577 \repeat @var{variant} @var{repeatcount} @var{repeatbody}
1580 If you have alternative endings, you may add
1584 \alternative@keyindex{alternative}
1585 @code{@{} @var{alternative1}
1587 @var{alternative3} @dots{} @code{@}}
1590 where each @var{alternative} is a Music expression.
1592 Normal notation repeats are used like this:
1596 @lilypond[fragment,verbatim]
1598 \repeat volta 2 { c'4 d' e' f' }
1599 \repeat volta 2 { f' e' d' c' }
1604 With alternative endings:
1608 @lilypond[fragment,verbatim]
1610 \repeat volta 2 {c'4 d' e' f'}
1611 \alternative { {d'2 d'} {f' f} }
1616 Folded repeats look like this:@footnote{Folded repeats offer little
1617 more over simultaneous music. However, it is to be expected that
1618 more functionality -- especially for the MIDI backend -- will be
1623 @lilypond[fragment,verbatim]
1625 \repeat fold 2 {c'4 d' e' f'}
1626 \alternative { {d'2 d'} {f' f} }
1633 @lilypond[fragment,verbatim]
1637 \repeat volta 2 { e | c2 d2 | e2 f2 | }
1638 \alternative { { g4 g g } { a | a a a a | b1 } }
1645 If you don't give enough alternatives for all of the repeats, then
1646 the first alternative is assumed to be repeated often enough to equal
1647 the specified number of repeats.
1651 @lilypond[fragment,verbatim]
1654 \repeat volta 3 { \partial 4; e | c2 d2 | e2 f2 | }
1655 \alternative { { g4 g g }
1656 {\partial 1; e4 e e }
1657 {\partial 1; a a a a | b1 } }
1664 It is possible to nest @code{\repeat}. This is not entirely
1665 supported: the notes will come be in the right places, but the repeat
1673 @cindex transposition of pitches
1675 A music expression can be transposed with
1676 @code{\transpose}@keyindex{transpose}. The syntax is
1680 \transpose @var{pitch} @var{musicexpr}
1683 This means that middle C in @var{musicexpr} is transposed to
1686 @code{\transpose} distinguishes between enharmonic pitches: both
1687 @code{\transpose cis'} or @code{\transpose des'} will transpose up half
1688 a tone. The first version will print sharps and the second version
1693 @lilypond[fragment,verbatim]
1696 { \key e \major; c d e f }
1698 \transpose des'' { \key e \major; c d e f }
1699 \transpose cis'' { \key e \major; c d e f }
1705 If you want to use both @code{\transpose} and @code{\relative}, then
1706 you must use @code{\transpose} first. @code{\relative} will have no
1707 effect music that appears inside a @code{\transpose}.
1711 @cindex automatic lyric durations
1713 If you have lyrics that are set to a melody, you can import the
1714 rhythm of that melody into the lyrics using @code{\addlyrics}.
1715 @keyindex{addlyrics} The syntax for this is
1719 \addlyrics @var{musicexpr1 musicexpr2}
1722 This means that both @var{musicexpr1} and @var{musicexpr2} are
1723 interpreted, but that every non-command atomic music expression
1724 (``every syllable'') in @var{musicexpr2} is interpreted using timing
1725 of @var{musicexpr1}.
1727 If the property @code{automaticMelismata}@indexcode{automaticMelismata} is set in the
1728 context of @var{musicexpr1}, no lyrics will be put on slurred or tied
1733 @lilypond[verbatim,fragment]
1736 \property Voice.automaticMelismata = ##t
1737 c8 () cis d8. e16 f2
1739 \context Lyrics \lyrics {
1745 You should use a single rhythm melody, and single rhythm lyrics (a
1746 constant duration is the obvious choice). If you do not, you will get
1747 undesired effects when using multiple stanzas:
1751 @lilypond[verbatim,fragment]
1754 c8 () cis d8. e16 f2
1756 \context Lyrics \lyrics
1763 It is valid (but probably not very useful) to use notes instead of
1764 lyrics for @var{musicexpr2}.
1770 @section Ambiguities
1774 The grammar contains a number of ambiguities.@footnote{The authors
1775 hope to resolve them at a later time.}
1778 @item The assignment
1784 can be interpreted as making a string identifier @code{\foo}
1785 containing @code{"bar"}, or a music identifier @code{\foo}
1786 containing the syllable `bar'.
1788 @item The assignment
1794 can be interpreted as making an integer identifier
1795 containing -6, or a Request identifier containing the
1796 fingering `6' (with neutral direction).
1798 @item If you do a nested repeat like
1810 then it is ambiguous to which @code{\repeat} the
1811 @code{\alternative} belongs. This is the classic if-then-else
1812 dilemma. It may be solved by using braces.
1814 @item (an as yet unidentified ambiguity :-)
1819 @node Notation conversion specifics
1820 @section Notation conversion specifics
1823 @node Automatic Beaming
1824 @section Automatic Beaming
1825 @cindex automatic beam generation
1828 @c beamAuto vs autoBeam ?
1830 By default, LilyPond will generate beams automatically. This feature
1831 can be disabled by setting the
1832 @code{Voice.beamAuto}@indexcode{Voice.beamAuto} property to false.
1833 It can be overridden for specific cases by specifying explicit beams.
1836 A large number of Voice properties are used to decide how to generate
1837 beams. Their default values appear in @file{scm/auto-beam.scm}. In
1838 general, beams can begin anywhere, but their ending location is
1839 significant. Beams can end on a beat, or at durations specified by the
1841 @code{Voice.autoBeamSettings}@indexcode{Voice.autoBeamSettings}.
1842 To end beams every quarter note, for example, you could set the property
1843 @code{(end * * * *)} @indexcode{(end * * * *)} to `@code{(make-moment 1
1844 4)}'. To end beams at every three eighth notes you would set
1845 it to `@code{(make-moment 1 8)}'.
1846 The same syntax can be used to specify beam
1847 starting points using
1848 @code{(begin * * * *)}@indexcode{(begin * * * *)}, eg:
1851 \property Voice.autoBeamSettings \override
1852 #'(end * * * *) = #(make-moment 1 4)
1853 \property Voice.autoBeamSettings \override
1854 #'(begin * * * *) = #(make-moment 1 8)
1858 To allow different settings for different time signatures, instead of
1859 the first two asterisks @code{* *} you can specify a time signature; use
1860 @code{(end N M * *)} to restrict the definition to
1861 `@var{N}@code{/}@var{M}' time. For example, to specify beams ending
1862 only for 6/8 time you would use the property @code{(end 6 8 * *)}.
1864 To allow different endings for notes of different durations, instead of
1865 th last two asterisks you can specify a duration; use @code{(end * * N
1866 M)} to restrict the definition to beams that contain notes of
1867 `@var{N}@code{/}@var{M}' duration.
1869 For example, to specify beam endings for beams that contain 32nd notes,
1870 you would use @code{(end * * 1 32)}.
1874 @section Chord Names
1878 @cindex printing!chord names
1880 For displaying printed chord names, use the
1881 @code{ChordNames}@indexcode{ChordNames} and
1882 @code{ChordNameVoice}@indexcode{ChordNameVoice} contexts. The chords
1883 may be entered either using the notation described above, or directly
1884 using simultaneous music.
1889 \chords {a1 b c} <d f g> <e g b>
1893 \context ChordNamesVoice \scheme
1894 \context Staff \transpose c'' \scheme
1896 \paper { linewidth = -1.; }
1902 You can make the chord changes stand out more by setting property
1903 @code{ChordNames.chordChanges} to true. This will only display
1904 chord names when there's a change in the chords scheme, but always
1905 display the chord name after a line break:
1911 % \property ChordNames.chordChanges = ##t
1912 c1:m \break c:m c:m c:m d
1917 \context ChordNamesVoice \scheme
1918 \context Staff \transpose c'' \scheme
1921 linewidth = 40 * \staffspace;
1929 LilyPond examines chords specified as lists of notes to determine a
1930 name to give the chord. LilyPond will not try to
1931 identify chord inversions or added base, which may result in strange
1932 chord names when chords are entered as a list of pitches:
1935 @lilypond[verbatim,center]
1944 \context ChordNamesVoice \scheme
1945 \context Staff \scheme
1947 \paper { linewidth = -1.; }
1952 To specify chord inversions, append @code{/<notename>}. To specify an
1953 added bass note, append @code{/+<notename}:
1956 @lilypond[verbatim,center]
1963 \context ChordNames \scheme
1964 \context Staff \transpose c'' \scheme
1966 \paper { linewidth = -1.; }
1971 The chord names that LilyPond should print are fully customisable. The
1972 default code can be found in @file{scm/chord-name.scm}. Chord names are
1973 based on Banter style naming, which is unambiguous and has a logical
1974 structure. Typical American style chord names are implemented as a
1975 variation on Banter names, they can be selected by setting poperty
1976 @code{ChordName.style} to @code{american}:
1980 \include "english.ly"
1985 df:m5- % Diminished triad
1986 c:5^3 % Root-fifth chord
1987 c:4^3 % Suspended fourth triad
1988 c:5+ % Augmented triad
1990 c:m5-.7- % Diminished seventh
1991 c:7+ % Major seventh
1992 c:7.4^3 % Dominant seventh suspended fourth
1993 c:5+.7 % Augmented dominant seventh
1994 c:m5-.7 % "Half" diminished seventh
1995 c:5-.7 % Dominant seventh flat fifth
1996 c:5-.7+ % Major seventh flat fifth
1997 c:m7+ % Minor-major seventh
1998 c:m7 % Minor seventh
1999 c:7 % Dominant seventh
2002 c:9^7 % Major triad w/added ninth
2003 c:6.9^7 % Six/Nine chord
2004 c:9 % Dominant ninth
2005 c:7+.9 % Major ninth
2006 c:m7.9 % Minor ninth
2011 \context ChordNames \scheme
2012 \context Staff \transpose c'' \scheme
2017 ChordName \override #'word-space = #1
2018 ChordName \override #'style = #'american
2025 Similarly, Jazz style chord names are implemented as a variation on
2026 American style names:
2032 c:6 % 6 = major triad with added sixth
2033 c:maj % triangle = maj
2038 c:m % m = minor triad
2039 c:m.6 % m6 = minor triad with added sixth
2040 c:m.7+ % m triangle = minor major seventh chord
2048 c:7.5+ % +7 = augmented dominant
2049 c:7.5- % 7b5 = hard diminished dominant
2056 c:13.9-^11 % 7(b9,13)
2057 c:13.9+^11 % 7(#9,13)
2059 c:13-.9-^11 % 7(b9,b13)
2060 c:13-.9+^11 % 7(#9,b13)
2062 % half diminished chords
2063 c:m5-.7 % slashed o = m7b5
2064 c:9.3-.5- % o/7(pure 9)
2067 c:m5-.7- % o = diminished seventh chord
2072 \context ChordNames \scheme
2073 \context Staff \transpose c'' \scheme
2078 ChordName \override #'word-space = #1
2079 ChordName \override #'style = #'jazz
2091 @cindex printing!lyrics
2094 Lyric syllables must be interpreted within a @code{Lyrics} context
2096 @cindex context!Lyrics
2099 Here is a full example:
2105 \notes \transpose c'' {
2107 e f g2 | e4 f g2 \bar "|.";
2109 \context Lyrics \lyrics {
2110 Va-4 der Ja- cob Va- der Ja- cob
2111 Slaapt gij nog?2 Slaapt4 gij nog?2
2119 You may want a continuous line after the syllables to show melismata.
2120 To achieve this effect, add a `@code{__}' lyric as a separate word
2121 after the lyric to be extended. This will create an extender, a line
2122 that extends over the entire duration of the lyric. This line will
2123 run all the way to the start of the next lyric, so you may want to
2124 shorten it by using a blank lyric (using `@code{_}').
2131 \notes \relative c'' {
2132 a4 () b () c () d | c () d () b () a | c () d () b () a
2134 \context Lyrics \lyrics {
2135 foo1 __ | bar2. __ _4 | baz1 __
2144 If you want to have hyphens centered between syllables (rather than
2145 attached to the end of the first syllable) you can use the special
2146 `@code{-}@code{-}' lyric as a separate word between syllables. This
2147 will result in a hyphen which length varies depending on the space
2148 between syllables, and which will be centered between the syllables.
2156 \notes \transpose c'' {
2158 e f g2 | e4 f g2 \bar "|.";
2160 \context Lyrics \lyrics {
2161 Va4 -- der Ja -- cob | Va -- der Ja -- cob |
2162 Slaapt gij nog?2 | Slaapt4 gij nog?2
2172 @node Notation Contexts
2173 @section Notation Contexts
2175 @cindex notation contexts
2177 Notation contexts are objects that only exist during a run of
2178 LilyPond. During the interpretation phase of LilyPond, the Music
2179 expression contained in a @code{\score} block is interpreted in time
2180 order. This is the order in which humans read, play, and write
2183 A context is an object that holds the reading state of the
2184 expression; it contains information like
2187 @item What notes are playing at this point?
2188 @item What symbols will be printed at this point?
2189 @item In what style will they printed?
2190 @item What is the current key signature, time signature, point within
2194 Contexts are grouped hierarchically: A @code{Voice} context is
2195 contained in a @code{Staff} context (because a staff can contain
2196 multiple voices at any point), a @code{Staff} context is contained in
2197 a @code{Score}, @code{StaffGroup}, or @code{ChoirStaff} context (because
2198 these can all contain multiple staffs).
2200 Contexts associated with sheet music output are called @emph{notation
2201 contexts}, those for sound output are called playing contexts.
2203 Contexts are created either manually or automatically. Initially,
2204 the top level music expression is interpreted by the top level
2205 context (the @code{Score} context). When a atomic music expression
2206 (i.e. a note, a rest, @code{\bar}, or @code{\time} commands), a nested
2207 set of contexts is created that can process these atomic expressions,
2213 \score @{ \notes < c4 > @}
2218 The sequential music, `@code{@{ c4 @}}' is interpreted by @code{Score}
2219 context. When the note `@code{c4}' itself is interpreted, a set of
2220 contexts is needed that will accept notes. The default for this is a
2221 @code{Voice} context, contained in a @code{Staff} context. Creation of
2222 these contexts results in the staff being printed.
2227 You can also create contexts manually, and you probably have to do so
2228 if you want to typeset complicated multiple part material. If a
2229 `@code{\context} @var{name} @var{musicexpr}' expression is encountered
2230 during the interpretation phase, the @var{musicexpr} argument will be
2231 interpreted with a context of type @var{name}. If you specify a name,
2232 the specific context with that name is searched.
2234 If a context of the specified type and name can not be found, a new
2235 one is created. For example,
2241 \notes \relative c'' {
2242 c4 <d4 \context Staff = "another" e4> f
2249 In this example, the @code{c} and @code{d} are printed on the
2250 default staff. For the @code{e}, a context Staff called
2251 `@code{another}' is specified; since that does not exist, a new
2252 context is created. Within @code{another}, a (default) Voice context
2253 is created for the @code{e4}. When all music referring to a
2254 context is finished, the context is ended as well. So after the
2255 third quarter, @code{another} is removed.
2257 Almost all music expressions inherit their interpretation context
2258 from their parent. In other words, suppose that the syntax for a
2263 \keyword @var{musicexpr1} @var{musicexpr2} @dots{}
2266 When the interpretation of this music expression starts, the context
2267 for @var{musicexpr1}, @var{musicexpr2}, etc. is that of the total
2270 Lastly, you may wonder, why this:
2276 \notes \relative c'' @{
2284 doesn't result in this:
2289 \notes \relative c'' {
2296 For the @code{c4}, a default @code{Staff} (with a contained
2297 @code{Voice}) context is created. After the @code{c4} ends, no
2298 music refers to this default staff, so it would be ended, with the
2299 result shown. To prevent this inconvenient behavior, the context to
2300 which the sequential music refers is adjusted during the
2301 interpretation. So after the @code{c4} ends, the context of the
2302 sequential music is also the default @code{Voice} context.
2303 The @code{d4} gets interpreted in the same context
2306 Properties that are set in one context are inherited by all of the
2307 contained contexts. This means that a property valid for the
2308 @code{Voice} context can be set in the @code{Score} context (for
2309 example) and thus take effect in all @code{Voice} contexts.
2311 Properties can be preset within the @code{\translator} block
2312 corresponding to the appropriate context. In this case, the syntax
2316 @var{propname} @code{=} @var{value}
2319 This assignment happens before interpretation starts, so a
2320 @code{\property} expression will override any predefined settings.
2322 The property settings are used during the interpretation phase. They
2323 are read by the LilyPond modules where interpretation contexts are
2324 built of. These modules are called @emph{translators}. Translators for
2325 notation are called @emph{engravers}, and translators for sound are
2326 called @emph{performers}.
2328 @mbinclude properties.itely
2331 @section Page layout
2333 @subsection Paper block
2335 The most important output definition is the @code{\paper} block, for
2336 music notation. The syntax is
2339 @code{\paper @{} [@var{paperidentifier}] @var{items} @code{@}}
2342 where each of the items is one of
2345 @item An assignment. The assignment must be terminated by a
2348 @item A context definition. See section @ref{contextdefs} for
2349 more information on context definitions.
2358 A margin shape declaration. The syntax is
2362 \shape @var{indent1}@code{,} @var{width1}@code{,}
2363 @var{indent2}@code{,} @var{width2} @dots{} @code{;}
2368 Each pair of @var{indent} and @var{width} values is a dimension
2369 specifying how far to indent and how wide to make the line.
2370 The indentation and width of successive lines are specified by
2371 the successive pairs of dimensions. The last pair of
2372 dimensions will define the characeristics of all lines beyond
2373 those explicitly specified.
2376 @item \stylesheet declaration. Its syntax is
2378 \stylesheet @var{alist}
2381 See @file{font.scm} for details of @var{alist}.
2384 @subsection Paper variables
2388 The paper block has some variables you may want to use or change:
2391 @item @code{indent}@indexcode{indent}
2392 The indentation of the first line of music.
2394 @item @code{staffspace}@indexcode{staffspace}
2395 The distance between two staff lines, calculated from the center
2396 of the lines. You should use either this or @code{rulethickness}
2397 as a unit for distances you modify.
2399 @item @code{linewidth}@indexcode{linewidth}
2400 Sets the width of the lines. If set to -1.0, a single
2401 unjustified line is produced. If you use this variable, you
2402 probably want to define it in staff spaces, ie
2404 linewidth = 30 * \staffspace;
2407 @item @code{textheight}@indexcode{textheight}
2408 Sets the total height of the music on each page. Only used by
2411 @item @code{interscoreline}@indexcode{interscoreline}
2412 Sets the spacing between the score lines. Defaults to 16 pt.
2414 @item @code{interscorelinefill}@indexcode{interscorelinefill}
2415 If set to a positive number, the distance between the score
2416 lines will stretch in order to fill the full page. In that
2417 case @code{interscoreline} specifies the minimum spacing.
2420 @item @code{stafflinethickness}@indexcode{stafflinethickness}
2421 Determines the thickness of staff lines, and also acts as a scaling
2422 parameter for other line thicknesses.
2426 @subsection Line breaks
2429 @cindex breaking lines
2431 Line breaks are normally computed automatically. They are chosen such
2432 that the resulting spacing has low variation, and looks neither cramped
2435 Occasionally you might want to override the automatic breaks; you can do
2436 this by specifying @code{\break} (see also @ref{Pre-defined
2437 Identifiers}). This will force a line break at this point. Do remember
2438 that line breaks can only occur at places where there are barlines. If
2439 you want to have a line break where there is no barline, you can force a
2440 barline by entering @code{\bar "";}.
2442 @subsection Page breaks
2444 Page breaks are normally computed by @TeX{}, so they are not under direct
2445 control. However, you can insert a commands into the .tex output to
2446 instruct @TeX{} where to break pages. For more details, see the
2447 example file @file{input/test/between-systems.ly}
2451 @cindex breaking pages
2454 @subsection Font size
2459 The Feta font provides musical symbols at six different sizes. These
2460 fonts are 11 point, 13 point, 16 point, 20 point,
2461 23 point, and 26 point. The point size of a font is the
2462 height of the five lines in a staff when displayed in the font.
2464 Definitions for these sizes are the files @file{paperSZ.ly}, where
2465 @code{SZ} is one of 11, 13, 16, 20, 23 and 26. If you include any of
2466 these files, the identifiers @code{paperEleven}, @code{paperThirteen},
2467 @code{paperSixteen}, @code{paperTwenty}, @code{paperTwentythree}, and
2468 @code{paperTwentysix} are defined respectively. The default
2469 @code{\paper} block is also set.
2471 The font definitions are generated using a Scheme function. For more
2472 details, see the file @file{font.scm}.
2474 @subsection paper size
2479 To change the paper size, you must first set the
2480 @code{papersize}@indexcode{papersize} variable at top level. Set it to
2481 the strings @code{a4}, @code{letter}, or @code{legal}. After this
2482 specification, you must set the font as described above. If you want
2483 the default font, then use the 20 point font. The new paper size will
2484 not take effect if the font is not loaded and selected afterwards.
2488 \include "paper16.ly"
2492 \paper @{ \paperSixteen @}
2496 The file "paper16.ly" will now include a file named @file{a4.ly}, which
2497 will set the paper variables @code{hsize} and @code{vsize} (used by
2501 @section contextdefs
2503 @cindex context definition
2504 @cindex translator definition
2505 @cindex engraver hacking
2508 A notation contexts is defined by the following information
2513 @item The LilyPond modules that do the actual conversion of music to
2514 notation. Each module is a so-called
2519 @item How these modules should cooperate, i.e. which ``cooperation
2520 module'' should be used. This cooperation module is a special
2523 @item What other contexts the context can contain,
2525 @item What properties are defined.
2528 A context definition has this syntax:
2532 \translator @code{@{}
2533 @var{translatorinit} @var{translatormodifierlist}
2537 @var{translatorinit} can be an identifier or of the form
2541 \type @var{typename} @code{;}
2544 @var{typename} is one of
2547 @item @code{Engraver_group_engraver}@indexcode{Engraver_group_engraver}
2548 The standard cooperation engraver.
2550 @item @code{Score_engraver}@indexcode{Score_engraver}
2551 This is cooperation module that should be in the top level context.
2553 @item @code{Grace_engraver_group}@indexcode{Grace_engraver_group}
2554 This is a special cooperation module (resembling
2555 @code{Score_engraver}) that is used to created an embedded
2559 @var{translatormodifierlist} is a list of items where each item is
2563 @item @code{\consists} @var{engravername} @code{;}
2564 Add @var{engravername} to the list of modules in this context.
2565 The order of engravers added with @code{\consists} is
2568 @item @code{\consistsend} @var{engravername} @code{;}
2569 Analogous to @code{\consists}, but makes sure that
2570 @var{engravername} is always added to the end of the list of
2573 Some engraver types need to be at the end of the list; this
2574 insures they are put there, and stay there, if a user adds or
2575 removes engravers. This command is usually not needed for
2578 @item @code{\accepts} @var{contextname} @code{;}
2579 Add @var{contextname} to the list of context this context can
2580 contain. The first listed context is the context to create by
2583 @item @code{\denies}. The opposite of @code{\accepts}. Added for
2584 completeness, but is never used in practice.
2587 @item @code{\remove} @var{engravername} @code{;}
2588 Remove a previously added (with @code{\consists}) engraver.
2590 @item @code{\name} @var{contextname} @code{;}
2591 This sets name of the context, e.g. @code{Staff}, @code{Voice}. If
2592 the name is not specified, the translator won't do anything.
2594 @item @var{propname} @code{=} @var{value} @code{;}
2595 A property assignment. It is allowed to use reals for
2599 In the @code{\paper} block, it is also possible to define translator
2600 identifiers. Like other block identifiers, the identifier can only
2601 be used as the very first item of a translator. In order to define
2602 such an identifier outside of @code{\score}, you must do
2608 foo = \translator @{ @dots{} @}
2615 \translator @{ \foo @dots{} @}
2623 @cindex paper types, engravers, and pre-defined translators
2625 Some pre-defined identifiers can simplify modification of
2626 translators. The pre-defined identifiers are:
2629 @item @code{StaffContext}@indexcode{StaffContext}
2630 Default Staff context.
2632 @item @code{RhythmicStaffContext}@indexcode{RhythmicStaffContext}
2633 Default RhythmicStaff context.
2635 @item @code{VoiceContext}@indexcode{VoiceContext}
2636 Default Voice context.
2638 @item @code{ScoreContext}@indexcode{ScoreContext}
2639 Default Score context.
2641 @item @code{ScoreWithNumbers}@indexcode{ScoreWithNumbers}
2642 Score context with numbering at the Score level.
2644 @item @code{BarNumberingStaffContext}@indexcode{BarNumberingStaffContext}
2645 Staff context with numbering at the Staff level.
2647 @item @code{HaraKiriStaffContext}@indexcode{HaraKiriStaffContext}
2648 Staff context that does not print if it only contains rests.
2649 Useful for orchestral scores.@footnote{Harakiri, also called
2650 Seppuku, is the ritual suicide of the Samourai.}
2652 @item @code{OrchestralPartStaffContext}@indexcode{OrchestralPartStaffContext}
2654 @item @code{OrchestralScoreContext}@indexcode{OrchestralScoreContext}
2657 Using these pre-defined values, you can remove or add items to the
2666 \remove Some_engraver;
2667 \consists Different_engraver;
2676 @section Sound output
2678 The MIDI block is analogous to the paper block, but it is somewhat
2679 simpler. The @code{\midi} block can contain:
2683 @item a @code{\tempo} definition
2684 @item context definitions
2687 Assignments in the @code{\midi} block are not allowed.
2691 @cindex context definition
2693 Context definitions follow precisely the same syntax as within the
2694 \paper block. Translation modules for sound are called performers.
2695 The contexts for MIDI output are defined in @file{ly/performer.ly}.
2699 @cindex MIDI instrument names
2704 The MIDI instrument name is set by the
2705 @code{Staff.midiInstrument}@indexcode{Staff.midiInstrument} property or,
2706 if that property is not set, the
2707 @code{Staff.instrument}@indexcode{Staff.instrument} property. The
2708 instrument name should be chosen from the following list. If the
2709 selected string does not exactly match, then LilyPond uses the default
2715 "acoustic grand" "contrabass" "lead 7 (fifths)"
2716 "bright acoustic" "tremolo strings" "lead 8 (bass+lead)"
2717 "electric grand" "pizzicato strings" "pad 1 (new age)"
2718 "honky-tonk" "orchestral strings" "pad 2 (warm)"
2719 "electric piano 1" "timpani" "pad 3 (polysynth)"
2720 "electric piano 2" "string ensemble 1" "pad 4 (choir)"
2721 "harpsichord" "string ensemble 2" "pad 5 (bowed)"
2722 "clav" "synthstrings 1" "pad 6 (metallic)"
2723 "celesta" "synthstrings 2" "pad 7 (halo)"
2724 "glockenspiel" "choir aahs" "pad 8 (sweep)"
2725 "music box" "voice oohs" "fx 1 (rain)"
2726 "vibraphone" "synth voice" "fx 2 (soundtrack)"
2727 "marimba" "orchestra hit" "fx 3 (crystal)"
2728 "xylophone" "trumpet" "fx 4 (atmosphere)"
2729 "tubular bells" "trombone" "fx 5 (brightness)"
2730 "dulcimer" "tuba" "fx 6 (goblins)"
2731 "drawbar organ" "muted trumpet" "fx 7 (echoes)"
2732 "percussive organ" "french horn" "fx 8 (sci-fi)"
2733 "rock organ" "brass section" "sitar"
2734 "church organ" "synthbrass 1" "banjo"
2735 "reed organ" "synthbrass 2" "shamisen"
2736 "accordion" "soprano sax" "koto"
2737 "harmonica" "alto sax" "kalimba"
2738 "concertina" "tenor sax" "bagpipe"
2739 "acoustic guitar (nylon)" "baritone sax" "fiddle"
2740 "acoustic guitar (steel)" "oboe" "shanai"
2741 "electric guitar (jazz)" "english horn" "tinkle bell"
2742 "electric guitar (clean)" "bassoon" "agogo"
2743 "electric guitar (muted)" "clarinet" "steel drums"
2744 "overdriven guitar" "piccolo" "woodblock"
2745 "distorted guitar" "flute" "taiko drum"
2746 "guitar harmonics" "recorder" "melodic tom"
2747 "acoustic bass" "pan flute" "synth drum"
2748 "electric bass (finger)" "blown bottle" "reverse cymbal"
2749 "electric bass (pick)" "skakuhachi" "guitar fret noise"
2750 "fretless bass" "whistle" "breath noise"
2751 "slap bass 1" "ocarina" "seashore"
2752 "slap bass 2" "lead 1 (square)" "bird tweet"
2753 "synth bass 1" "lead 2 (sawtooth)" "telephone ring"
2754 "synth bass 2" "lead 3 (calliope)" "helicopter"
2755 "violin" "lead 4 (chiff)" "applause"
2756 "viola" "lead 5 (charang)" "gunshot"
2757 "cello" "lead 6 (voice)"
2764 @node Pre-defined Identifiers
2766 @section Pre-defined Identifiers
2768 @cindex pre-defined identifiers
2771 Various identifiers are defined in the initialization files to
2772 provide shorthands for some settings. Most of them are in
2773 @file{ly/declarations.ly} and @file{ly/property.ly}.
2776 @item @code{\break}@keyindex{break}
2777 Force a line break in music by using a large argument for the
2778 keyword @code{\penalty}.
2780 @item @code{\nobreak}@keyindex{nobreak}
2781 Prevent a line break in music by using a large negative argument
2782 for the keyword @code{\penalty}.
2784 @item @code{\shiftOff}@keyindex{shiftOff}
2785 Disable horizontal shifting of note heads that collide.
2787 @item @code{\shiftOn}@keyindex{shiftOn}
2788 Enable note heads that collide with other note heads to be
2789 shifted horiztonally. Also @code{\shiftOnn} and @code{\shiftOnnn}
2790 set different shift values.
2792 @item @code{\stemBoth}@keyindex{stemBoth}
2793 Allow stems, beams, and slurs to point either upwards or
2794 downwards, decided automatically by LilyPond.
2796 @item @code{\stemDown}@keyindex{stemDown}
2797 Force stems, beams, and slurs to point down.
2799 @item @code{\stemUp}@keyindex{stemUp}
2800 Force stems, beams and slurs to point up.