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
11 @node Reference Manual
12 @chapter Reference Manual
16 * Top level:: Top level
17 * Pitch names:: Pitch names
18 * Lexical conventions:: Lexical conventions
19 * Other languages:: Note names in various languages
20 * Lexical modes:: modes
22 * Music expressions:: Music expressions
23 * Atomic music expressions:: Atomic music expressions
24 * Note specification:: notedesc
26 * Manual beams:: Manual beam
27 * stem tremolo:: tremolo
28 * Compound music expressions:: Compound music expressions
31 * transpose:: transpose
32 * Ambiguities:: Ambiguities
33 * Notation conversion specifics:: Notation conversion specifics
34 * Automatic Beaming:: Automatic Beaming
35 * Chord Names:: Chord Names
36 * lyricprint:: lyricprint
37 * Notation Contexts:: Notation Contexts
38 * Properties:: Changing formatting
39 * Page layout:: Layout
40 * contextdefs:: contextdefs
41 * Sound output:: Sound output
43 * Pre-defined Identifiers:: Pre-defined Identifiers
44 @c May be fragile. Better make single link to generated doco?
45 * Interpretation contexts:(lilypond-internals)LilyPond interpretation contexts.
46 * Engravers:(lilypond-internals)LilyPond engravers.
47 * Backend:(lilypond-internals)LilyPond backend.
56 This document@footnote{This document has been revised for LilyPond 1.2.}
57 describes the the GNU LilyPond input format This format represents a
58 piece of music in an elegant way, but contains enough information for
59 both automatic typesetting and automatic performances.
62 LilyPond input can be classified into three types:
64 @item musical expressions: a musical expression is some combination of
66 @item output definitions: recipes for translating those musical
67 expressions into performances (MIDI) or graphics (eg. PostScript).
69 @item declarations: by declaring and naming musical expressions, you
70 can enter and edit them in manageable chunks.
76 This section describes what you may enter at top level.
80 @cindex score definition
82 The output is generated combining a music expression with an output
83 definition. A score block has the following syntax:
86 \score @{ @var{musicexpr} @var{outputdefs} @}
89 @var{outputdefs} are zero or more output definitions. If no output
90 definition is supplied, the default @code{\paper} block will be added.
99 \header @{ @var{key1} = @var{val1};
100 @var{key2} = @var{val2}; @dots{} @}
103 A header describes the file's contents. It can also appear in a
104 @code{\score} block. Tools like @code{ly2dvi}@indexcode{ly2dvi} can use this
105 information for generating titles. Key values that are used by
106 @code{ly2dvi} are: title, subtitle, composer, opus, poet, instrument,
107 metre, arranger, piece and tagline.
109 It is customary to put the @code{\header} at the top of the file.
117 @cindex chord modifier names
119 Note names and chord modifiers can be customised for nationalities.
120 languages and conventions. The syntax is as follows.
122 \pitchnames @keyindex{pitchnames} @var{scheme-alist}
123 \chordmodifiers@keyindex{chordmodifiers} @var{scheme-alist}
126 See @file{ly/nederlands.ly} and @file{ly/chord-modifiers.ly} for
127 specific examples how to do this. tables can be tailored specified
128 using. Some national note names have been provided, see
129 section @ref{Other languages}.
130 A @code{\paper} block at top level sets the default paper block. A
131 @code{\midi} block at top level works similarly.
133 Identifier assignments may appear at top level. Semicolons are
134 forbidden after top level assignments.
138 @node Lexical conventions
139 @section Lexical conventions
141 @cindex lexical conventions
144 @unnumberedsubsec Comments
150 A one line comment is introduced by a `@code{%}' character.
151 Block comments are started by `@code{%@{}' and ended by `@code{%@}}'.
152 They cannot be nested.
154 @unnumberedsubsec Scheme
158 LilyPond contains a Scheme interpreter (the GUILE library) for
159 internal use. The interpreter is accessed by the pound sign:
163 @cindex Scheme, in-line code
165 Whereever the syntax allows Scheme expressions, you may enter one as
171 Evaluates the specified Scheme code. If this is used at toplevel, then
172 the result is discarded. Example:
174 \property Staff.TestObject \override #'symbol = #(+ 1 2)
177 (in this case, @code{\override} expects two Scheme expressions.
179 [refer appendix/ online intro on Scheme]
181 @unnumberedsubsec Keywords
185 Keywords start with a backslash, followed by a number of lower case
186 alphabetic characters. These are all the keywords.
189 apply arpeggio autochange spanrequest commandspanrequest
190 simultaneous sequential accepts alternative bar breathe
191 char chordmodifiers chords clef cm consists consistsend
192 context denies duration dynamicscript elementdescriptions
193 font grace header in lyrics key mark musicalpitch
194 time times midi mm name pitchnames notes outputproperty
195 override set revert partial paper penalty property pt
196 relative remove repeat addlyrics partcombine score
197 script stylesheet skip textscript tempo translator
201 @unnumberedsubsec Integers
205 Formed from an optional minus sign followed by digits. Arithmetic
206 operations cannot be done with integers, and integers cannot be mixed
209 @unnumberedsubsec Reals
214 Formed from an optional minus sign and a sequence of digits followed
215 by a @emph{required} decimal point and an optional exponent such as
216 @code{-1.2e3}. Reals can be built up using the usual operations:
217 `@code{+}@indexcode{+}', `@code{-}@indexcode{-}', `@code{*}@indexcode{*}', and
218 `@code{/}@indexcode{/}', with parentheses for grouping.
220 A real constant can be followed by one of the dimension
223 @code{\mm}@keyindex{mm},
224 @code{\pt}@keyindex{pt}, @code{\in}@keyindex{in}, or
225 @code{\cm}@keyindex{cm}, for millimeters, points, inches and
226 centimeters, respectively. This converts the number to a real that
227 is the internal representation of dimensions.
233 Begins and ends with the `@code{"}' character. To include a `@code{"}'
234 character in a string write `@code{\"}'. Various other backslash
235 sequences have special interpretations as in the C language. A string
236 that contains no spaces can be written without the quotes. See
237 @ref{Lexical modes} for details on unquoted strings; their interpretation varies
238 depending on the situation. Strings can be concatenated with the
241 The tokenizer accepts the following commands. They have no grammatical
242 function, hence they can appear anywhere in the input.
245 \maininput@keyindex{maininput}
248 This command is used in init files to signal that the user file must
249 be read. This command cannot be used in a user file.
251 @unnumberedsubsec file inclusion
254 \include@keyindex{include} @var{file}
257 Include @var{file}. The argument @var{file} may be a quoted string (an
258 unquoted string will not work here!) or a string identifier. The full
259 filename including the @file{.ly} extension must be given,
261 @unnumberedsubsec Version information
264 \version@keyindex{version} @var{string} ;
267 Specify the version of LilyPond that a file was written for. The
268 argument is a version string in quotes, for example @code{"1.2.0"}.
269 This is used to detect invalid input, and to aid
270 @code{convert-ly}, a tool that automatically upgrades input files.
273 @node Other languages
274 @section Other languages
275 @cindex Note names, international
277 Note name definitions have been provided in various languages.
278 Simply include the language specific init file. For example:
279 `@code{\include "english.ly"}'. The available language files and the
280 names they define are:
283 Note Names sharp flat
284 nederlands.ly c d e f g a bes b -is -es
285 english.ly c d e f g a bf b -s/-sharp -f/-flat
286 deutsch.ly c d e f g a b h -is -es
287 norsk.ly c d e f g a b h -iss/-is -ess/-es
288 svenska.ly c d e f g a b h -iss -ess
289 italiano.ly do re mi fa sol la sib si -d -b
290 catalan.ly do re mi fa sol la sib si -d/-s -b
293 Pitch names can be redefined using the @code{\pitchnames} command, see
297 @section Lexical modes
298 @cindex Lexical modes
302 To simplify entering notes, lyrics, and chords, @emph{Lilypond} has three
303 special input modes on top of the default mode. In each mode, words
304 are identified on the input. If @code{"word"} is encountered, it is
305 treated as a string. If @code{\word} is encountered, it is treated as
306 a keyword or as an identifier. The behavior of the modes differs in
307 two ways: Different modes treat unquoted words differently, and
308 different modes have different rules for deciding what is a word.
314 At the start of parsing, @emph{Lilypond} is in Normal mode. In Normal
315 mode, a word is an alphabetic character followed by alphanumeric
316 characters. If @code{word} is encountered on the input it is
322 Note mode is introduced by the keyword
323 @code{\notes}@keyindex{notes}. In Note mode, words can only
324 contain alphabetic characters. If @code{word} is encountered,
325 LilyPond first checks for a notename of @code{word}. If no
326 notename is found, then @code{word} is treated as a string.
328 Since combinations of numbers and dots are used for indicating
329 durations, it is not possible to enter real numbers in this mode.
334 Chord mode is introduced by the keyword
335 @code{\chords}@keyindex{chords}. It is similar to Note mode, but
336 words are also looked up in a chord modifier table (containing
337 @code{maj}, @code{dim}, etc).
339 Since combinations of numbers and dots are used for indicating
340 durations, you can not enter real numbers in this mode. Dashes
341 and carets are used to indicate chord additions and subtractions,
342 so scripts can not be entered in Chord mode.
347 Lyrics mode is introduced by the keyword
348 @code{\lyrics}@keyindex{lyrics}. This mode has rules that make it
349 easy to include punctuation and diacritical marks in words. A
350 word in Lyrics mode begins with: an alphabetic character,
351 `@code{_}', `@code{?}', `@code{!}', `@code{:}', `@code{'}', the
352 control characters @code{^A} through @code{^F}, @code{^Q} through
353 @code{^W}, @code{^Y}, @code{^^}, any 8-bit character with ASCII code
354 over 127, or a two-character combination of a backslash followed
355 by one of `@code{`}', `@code{'}', `@code{"}', or
356 `@code{^}'.@footnote{The purpose of Lyrics mode is that you can
357 enter lyrics in @TeX{} format or a standard encoding without
358 needing quotes. The precise definition of this mode indeed is
359 ludicrous. This will remain so until the authors of LilyPond
360 acquire a deeper understanding of character encoding, or someone
361 else steps up to fix this.}
363 Subsequent characters of a word can be any character that is not
364 a digit and not white space. One important consequence of this
365 is that a word can end with `@code{@}}', which may be confusing if
366 you thought the closing brace was going to terminate Lyrics
367 mode.@footnote{LilyPond will issue a warning, though.} Any
368 `@code{_}' character which appears in an unquoted word is
369 converted to a space. This provides a mechanism for introducing
370 spaces into words without using quotes. Quoted words can also be
371 used in Lyrics mode to specify words that cannot be written with
372 the above rules. Here are some examples. Not all of these words
373 are printable by @TeX{}.
377 2B_||_!2B % not a word because it starts with a digit
378 ``Hello'' % not a word because it starts with `
379 _ _ _ _ % 4 words, each one a space
382 Since combinations of numbers and dots are used for indicating
383 durations, you can not enter real numbers in this mode.
386 [todo: include short table showign differences]
393 [say something about types]
395 All of the information in a LilyPond input file, is represented as a
396 Scheme value. In addition to normal Scheme data types (such as pair,
397 number, boolean, etc.), LilyPond has a number of specialized data types,
402 @item Music: see @ref{Music expressions}
404 @item Translator_def:
405 See section @ref{contextdefs} for more information
410 @item Music_output_def (TODO: this is not really a Scheme object
411 yet. Nevertheless, you can use identifiers to make references to them )
412 @item Moment (rational number)
415 LilyPond also includes some transient object types. Objects of these
416 types are built during a LilyPond run, and do not `exist' per se within
417 your input file. These objects are created as a result of your input
418 file, so you can include commands in the input to manipulate them,
419 during a lilypond run.
422 @item Grob: short for Graphical object. See @ref{Grobs}.
423 @item Molecule: device-independent page output object,
424 including dimensions. Produced by some Grob functions
426 @item Translator: object that produces audio objects or Grobs.
427 @item Font_metric: object representing a font. (Not yet user
430 @c @item Audio_element: (todo, smobme)
433 Identifiers allow objects to be assigned to names during the parse
434 stage. To assign an identifier, you use `@var{name}=@var{value}' and to
435 refer to an identifier, you preceed its name with a backslash:
436 `@code{\}@var{name}'. Identifier assignments must appear at top level
437 in the @emph{Lilypond} file. Semicolons are forbidden after assignments
438 appearing at top level but they are obligatory after assignments
439 appearing in the @code{\paper} block, see Section @ref{Page layout}.
441 @var{value} is any valid Scheme value or any of the input-types listed
444 An identifier can be created with any string for its name, but you will
445 only be able to refer to identifiers whose names begin with a letter,
446 being entirely alphanumeric. It is impossible to refer to an identifier
447 whose name is the same as the name of a keyword.
449 The right hand side of an identifier assignment is parsed completely
450 before the assignment is done, so it is allowed to redefine an
451 identifier in terms of its old value, e.g.
457 When an identifier is referenced, the information it points to is
458 copied. For this reason, an identifier reference must always be the
459 first item in a block.
463 \paperIdent % wrong and invalid
467 \paperIdent % correct
473 @node Music expressions
474 @section Music expressions
476 @cindex music expressions
478 Music in @emph{Lilypond} is entered as a music expression. Notes, rests,
479 lyric syllables are music expressions (the atomic
481 @cindex atomic music expressions
482 and you can combine music expressions to form new ones. This example
483 forms a compound expressions out of the quarter @code{c} note and a
487 \sequential @{ c4 d4 @}
490 The meaning of this compound expression is to play the `@code{c}'
491 first, and then the `@code{d}' (as opposed to playing them
492 simultaneously, for instance).
494 Atomic music expression are discussed in
495 subsection @ref{Atomic music expressions}. Compound music expressions are
496 discussed in subsection @ref{Compound music expressions}.
500 @node Atomic music expressions
501 @section Atomic music expressions
511 The syntax for pitch specification is
515 \musicalpitch@keyindex{musicalpitch} @{ @var{octave} @var{note} @var{shift} @}
518 @var{octave} is specified by an integer, zero for the octave
519 containing middle C. @var{note} is a number from 0 to 7, with 0
520 corresponding to C and 7 corresponding to B. The shift is zero for a
521 natural, negative to add flats, or positive to add sharps.
523 In Note and Chord mode, pitches may be designated by names. See
524 section @ref{Other languages} for pitch names in different languages.
526 The syntax for duration specification is
529 \duration@keyindex{duration}
530 @{ @var{length} @var{dotcount} @}
533 @var{length} is the negative logarithm (base 2) of the duration:
534 1 is a half note, 2 is a quarter note, 3 is an eighth
535 note, etc. The number of dots after the note is given by
538 In Note, Chord, and Lyrics mode, durations may be designated by
542 @node Note specification
543 @section Note specification
544 @cindex Note specification
548 @cindex entering notes
550 A note specification has the form
553 @var{pitch}[@var{octavespec}][!][?][@var{duration}]
556 The pitch of the note is specified by the note's name.
559 The default names are the Dutch note names. The notes are specified
560 by the letters `@code{c}' through `@code{b}', where `@code{c}' is an
561 octave below middle C and the letters span the octave above that C.
563 @cindex notenames!Dutch
564 a sharp is formed by adding `@code{-is}' to the end of a pitch name. A
565 flat is formed by adding `@code{-es}'. Double sharps and double flats
566 are obtained by adding `@code{-isis}' or `@code{-eses}'. `@code{aes}'
567 and `@code{ees}' are contracted to `@code{as}' and `@code{es}' in Dutch,
568 but both forms will be accepted.
570 LilyPond has predefined sets of notenames for various languages. See
571 section @ref{Other languages}.
573 The optional octave specification takes the form of a series of
574 single quote (`@code{'}@indexcode{'}') characters or a series of comma
575 (`@code{,}@indexcode{,}') characters. Each @code{'} raises the pitch by one
576 octave; each @code{,} lowers the pitch by an octave.
578 @lilypond[fragment,verbatim,center]
579 c' d' e' f' g' a' b' c''
582 @lilypond[fragment,verbatim,center]
583 cis' dis' eis' fis' gis' ais' bis'
586 @lilypond[fragment,verbatim,center]
587 ces' des' es' fes' ges' as' bes'
590 @lilypond[fragment,verbatim,center]
591 cisis' eisis' gisis' aisis' beses'
594 @lilypond[fragment,verbatim,center]
595 ceses' eses' geses' ases' beses'
598 Whenever a C-sharp is desired, you must specify a C-sharp. LilyPond
599 will determine what accidentals to typeset depending on the key and
600 context. A reminder accidental
601 @cindex reminder accidental
602 can be forced by adding an exclamation mark `@code{!}' after the pitch.
603 A cautionary accidental,
604 @cindex cautionary accidental
605 i.e., an accidental within parentheses can be obtained by adding the
606 question mark `@code{?}@indexcode{?}' after the pitch.
608 @lilypond[fragment,verbatim,center]
609 cis' d' e' cis' c'? d' e' c'!
615 Durations are entered as their reciprocal values. For notes longer
616 than a whole note, use identifiers.
622 c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64
631 \notes \relative c'' {
633 a1 a2 a4 a8 a16 a32 a64 a64
638 \remove "Clef_engraver";
639 \remove "Staff_symbol_engraver";
650 r1 r2 r4 r8 r16 r32 r64 r64
659 \notes \relative c'' {
661 r1 r2 r4 r8 r16 r32 r64 r64
664 loose_column_distance = 2.5 * \staffspace;
668 \remove "Clef_engraver";
669 \remove "Staff_symbol_engraver";
670 \remove "Bar_engraver";
677 If the duration is omitted then it is set equal to the previous
678 duration. If there is no previous duration, a quarter note is
679 assumed. The duration can be followed by a dot (`@code{.}@indexcode{.}')
680 to obtain dotted note lengths.
682 @lilypond[fragment,verbatim,center]
686 You can alter the length of duration by writing
687 `@code{*}@var{fraction}' after it. This will not affect the
688 appearance of note heads or rests.
691 Rests are entered like notes, with note name `@code{r}@indexcode{r}', or
692 `@code{R}@indexcode{R}'. There is also a note name
693 `@code{s}@indexcode{s}', which produces a space of the specified
694 duration. `@code{R}' is specifically meant for entering parts: the
695 @code{R} rest can expand to fill a score with rests, or it can be
696 printed as a single multimeasure rest.
698 You can control the expansion by setting the property
699 @code{Score.skipBars}. If this is set to true, Lily will not expand
700 empty measures, and the multimeasure rests automatically adds the
703 Note that there is currently no way to condense multiple rests into a
704 single multimeasure rest.
708 @cindex lyrics expressions
710 Syllables are entered like notes, with pitches replaced by text. For
711 example, `@code{Twin-4 kle4 twin-4 kle4}' enters four syllables, each
712 with quarter note duration. Note that the hyphen has no special
713 meaning for lyrics, and does not introduce special symbols. See
714 section @ref{Lexical modes} for a description of what is interpreted as
717 Spaces can be introduced into a lyric either by using quotes
718 (`@code{"}') or by using an underscore without quotes: `@code{He_could4
719 not4}'. All unquoted underscores are converted to spaces. Printing
720 lyrics is discussed in section @ref{lyricprint}.
727 \property@keyindex{property}
728 @var{contextname}.@var{propname} = @var{value}
731 Sets the @var{propname} property of the context @var{contextname} to
732 the specified @var{value}. All three arguments are strings.
733 Depending on the context, it may be necessary to quote the strings or
734 to leave space on both sides of the dot.
738 @cindex translator switches
741 \translator@keyindex{translator}
742 @var{contexttype} = @var{name}
745 A music expression indicating that the context which is a direct
746 child of the a context of type @var{contexttype} should be shifted to
747 a context of type @var{contexttype} and the specified name.
749 Usually this is used to switch staffs in Piano music, e.g.
752 \translator Staff = top @var{Music}
756 @cindex output properties
759 These allow you to tweak what is happening in the back-end
760 directly. If you want to control every detail of the output
761 formatting, this is the feature to use. The downside to this is that
762 you need to know exactly how the backend works. Example:
765 @lilypond[fragment,verbatim]
767 \context Staff \outputproperty
768 #(make-type-checker 'Note_head)
769 #'extra-offset = #'(5.0 . 7.5)
773 This selects all note heads occurring at current staff level, and sets
774 the extra-offset of those heads to (5,7.5), shifting them up and
777 Use of this feature is entirely on your own risk: if you use this, the
778 result will depend very heavily on the implementation of the backend,
779 which we change regularly and unscrupulously.
784 Commands are music expressions that have no duration.
788 @code{\key}@keyindex{key} @var{pitch} @var{type} @code{;}
791 Change the key signature. @var{type} should be
792 @code{\major}@keyindex{major} or @code{\minor}@keyindex{minor} to get
793 @var{pitch}-major or @var{pitch}-minor, respectively. The second
794 argument is optional; the default is major keys. The @var{\context}
795 argument can also be given as an integer, which tells the number of
796 semitones that should be added to the pitch given in the subsequent
797 @code{\key}@keyindex{key} commands to get the corresponding major key,
798 e.g., @code{\minor}@keyindex{minor} is defined as 3. The standard
799 mode names @code{\ionian}@keyindex{ionian},
800 @code{\locrian}@keyindex{locrian}, @code{\aeolian}@keyindex{aeolian},
801 @code{\mixolydian}@keyindex{mixolydian}, @code{\lydian}@keyindex{lydian},
802 @code{\phrygian}@keyindex{phrygian}, and @code{\dorian}@keyindex{dorian}
807 \mark@keyindex{mark} @var{unsigned};
811 Prints a mark over or under the staff. You must add
812 @code{Mark_engraver}@indexcode{Mark_engraver} to the Score context for
819 \bar@keyindex{bar} @var{bartype};
822 This is a short-cut for doing
824 \property Score.whichBar = @var{bartype}
827 You are encouraged to use @code{\repeat} for repetitions. See
828 @ref{Repeats}, and the documentation of @code{whichBar} in
829 @ref{(lilypond-internals)LilyPond context properties}.
833 \time@keyindex{time} @var{numerator}@code{/}@var{denominator} @code{;}
836 A short-cut for doing
838 \property Score.timeSignatureFraction = #'(@var{numerator} . @var{denominator})
841 See the documentation of @code{timeSignatureFraction}
845 \tempo@keyindex{tempo} @var{duration} = @var{perminute} @code{;}
848 Used to specify the tempo. For example, `@code{\tempo 4 = 76;}'
849 requests output with 76 quarter notes per minute.
852 \partial@keyindex{partial} @var{duration} @code{;}
858 \property Score.measurePosition = @var{length of duration}
861 See the documentation of @code{measurePosition}.
869 @code{|}@indexcode{|}
874 @cindex shorten measures
878 `@code{|}' is a bar check. Whenever a bar check is encountered during
879 interpretation, a warning message is issued if it doesn't fall at a
880 measure boundary. This can help you finding errors in the input.
881 Depending on the value of @code{barCheckNoSynchronize}
882 @indexcode{barCheckNoSynchronize} The beginning of the measure will be
883 relocated, so this can also be used to shorten measures.
887 \penalty@keyindex{penalty} @var{int} @code{;}
890 Discourage or encourage line breaks. See identifiers
891 @code{\break}@keyindex{break} and @code{\nobreak}@keyindex{nobreak} in
892 section [on identifiers] [FIXME].
895 \clef@keyindex{clef} @var{clefname} @code{;}
901 \property Clef.clefGlyph = @var{symbol associated with clefname}
902 \property Clef.clefPosition = @var{clef Y-position for clefname}
903 \property Clef.clefOctavation = @var{extra pitch of clefname}
906 Supported clef-names include
912 \skip@keyindex{skip} @var{duration} @code{;}
915 Skips the amount of time specified by @var{duration}. If no other
916 music is played, a gap will be left for the skipped time with no
917 notes printed. It works in Note Mode or Lyrics Mode. In Note mode,
918 this has the same effect as the space rest `@code{s}'.
922 @section Manual beams
925 A beam is specified by surrounding the beamed notes with brackets
926 `@code{[}@indexcode{[}' and `@code{]}@indexcode{]}'.
928 @lilypond[fragment,verbatim,center]
929 [a'8 a'] [a'16 a' a' a']
932 Some more elaborate constructions:
934 @lilypond[fragment,verbatim,center]
935 [a'16 <a' c''> c'' <a' c''>]
936 \times 2/3 { [e'8 f' g'] }
939 Beaming can be generated automatically; see section @ref{Automatic Beaming}.
942 To place tremolo marks between notes, use @code{\repeat} with tremolo
944 @cindex tremolo beams
945 To create tremolo beams on a single note, simply attach
946 `@code{:}@var{length}' to the note itself.
948 @lilypond[fragment,verbatim,center]
949 \repeat "tremolo" 8 { c16 d16 }
950 \repeat "tremolo" 4 { c16 d16 }
953 @lilypond[fragment,verbatim,center]
958 @cindex --@@@code{-}@code{-}
966 The syntax for an extender mark is `@code{__}'. This syntax can only
967 be used within lyrics mode. The syntax for a spanning hyphen (i.e.,
968 a hyphen that will be printed between two lyric syllables) is
974 A tie connects two adjacent note heads of the same pitch. When used
975 with chords, it connects all of the note heads whose pitches match.
976 Ties are indicated using the tilde symbol `@code{~}@indexcode{~}'.
977 If you try to tie together chords which have no common pitches, a
978 warning message will appear and no ties will be created.
980 @lilypond[fragment,verbatim,center]
981 e' ~ e' <c' e' g'> ~ <c' e' g'>
984 @cindex articulations
990 A variety of symbols can appear above and below notes to indicate
991 different characteristics of the performance. These symbols can be
992 added to a note with `@var{note}@code{-\}@var{name}'. Numerous symbols
993 are defined in @file{script.ly} and @file{script.scm}. Symbols can be
994 forced to appear above or below the note by writing
995 `@var{note}@code{^\}@var{name}' and `@var{note}@code{_\}@var{name}'
996 respectively. Here is a chart showing symbols above notes, with the
997 name of the corresponding symbol appearing underneath.
1003 c''-\accent c''-\marcato c''-\staccatissimo c''-\fermata
1004 c''-\stopped c''-\staccato c''-\tenuto c''-\upbow
1005 c''-\downbow c''^\lheel c''-\rheel c''^\ltoe
1006 c''-\rtoe c''-\turn c''-\open c''-\flageolet
1007 c''-\reverseturn c''-\trill c''-\prall c''-\mordent
1008 c''-\prallprall c''-\prallmordent c''-\upprall c''-\downprall
1009 c''-\thumb c''-\segno c''-\coda
1011 \context Lyrics \lyrics {
1012 accent__ marcato__ staccatissimo__ fermata
1013 stopped__ staccato__ tenuto__ upbow
1014 downbow__ lheel__ rheel__ ltoe
1015 rtoe__ turn__ open__ flageolet
1016 reverseturn__ trill__ prall__ mordent
1017 prallprall__ prallmordent__ uprall__ downprall
1018 thumb__ segno__ coda
1022 linewidth = 5.875\in;
1029 In addition, it is possible to place arbitrary strings of text or
1030 @TeX{} above or below notes by using a string instead of an
1031 identifier: `@code{c^"text"}'. Fingerings
1033 can be placed by simply using digits. All of these note ornaments
1034 appear in the printed output but have no effect on the MIDI rendering of
1037 To save typing, fingering instructions (digits 0 to 9 are
1038 supported) and single characters shorthands exist for a few
1045 \property Voice.TextScript \set #'font-style = #'typewriter
1051 c''4-^_"c-\\^{ }" s4
1058 linewidth = 5.875 \in;
1065 Dynamic marks are specified by using an identifier after a note:
1066 `@code{c4-\ff}' (the dash is optional for dynamics: `@code{c4 \ff})'.
1067 The available dynamic marks are:
1068 @code{\ppp}@keyindex{ppp},
1069 @code{\pp}@keyindex{pp}, @code{\p}@keyindex{p}, @code{\mp}@keyindex{mp},
1070 @code{\mf}@keyindex{mf}, @code{\f}@keyindex{f}, @code{\ff}@keyindex{ff},
1071 @code{\fff}@keyindex{fff}, @code{\fff}@keyindex{ffff},
1072 @code{\fp}@keyindex{fp}, @code{\sf}@keyindex{sf},
1073 @code{\sff}@keyindex{sff}, @code{\sp}@keyindex{sp},
1074 @code{\spp}@keyindex{spp}, @code{\sfz}@keyindex{sfz}, and
1075 @code{\rfz}@keyindex{rfz}.
1080 \textscript@keyindex{textscript} @var{text} @var{style}
1083 Defines a text to be printed over or under a note. @var{style} is a
1084 string that may be one of @code{roman}, @code{italic}, @code{typewriter},
1085 @code{bold}, @code{Large}, @code{large}, @code{dynamic} or @code{finger}.
1087 You can attach a general textscript request using this syntax:
1092 c4-\textscript "6" "finger"
1093 c4-\textscript "foo" "normal"
1098 This is equivalent to `@code{c4-6 c4-"foo"}'.
1104 \script@keyindex{script} @var{alias}
1107 Prints a symbol above or below a note. The argument is a string
1108 which points into the script-alias table defined in @file{script.scm}.
1109 The scheme definitions specify whether the symbol follows notes into
1110 the staff, dependence of symbol placement on staff direction, and a
1111 priority for placing several symbols over one note. Usually the
1112 @code{\script}@keyindex{script} keyword is not used directly. Various
1113 helpful identifier definitions appear in @file{script.ly}.
1118 Slurs connects chords and try to avoid crossing stems. A slur is
1119 started with `@code{(}' and stopped with `@code{)}'. The
1120 starting `@code{(}' appears to the right of the first note in
1121 the slur. The terminal `@code{)}' appears to the left of the
1122 first note in the slur. This makes it possible to put a note in
1123 slurs from both sides:
1125 @lilypond[fragment,verbatim,center]
1126 f'()g'()a' [a'8 b'(] a'4 g'2 )f'4
1132 A crescendo mark is started with @code{\cr}@keyindex{cr} and terminated
1133 with @code{\rc}@keyindex{rc}. A decrescendo mark is started with
1134 @code{\decr}@keyindex{decr} and terminated with
1135 @code{\rced}@keyindex{rced}. There are also shorthands for these
1136 marks. A crescendo can be started with @code{\<}@keyindex{<} and a
1137 decrescendo can be started with @code{\>}@keyindex{>}. Either one can
1138 be terminated with @code{\!}@keyindex{"!}. Note that @code{\!}
1139 must go before the last note of the dynamic mark whereas @code{\rc}
1140 and @code{\rced} go after the last note. Because these marks are
1141 bound to notes, if you want to get several marks during one note, you
1142 must use spacer notes.
1144 @lilypond[fragment,verbatim,center]
1145 c'' \< \! c'' d'' \decr e'' \rced
1146 < f''1 { s4 \< \! s2 \> \! s4 } >
1152 \spanrequest@keyindex{spanrequest} @var{startstop} @var{type}
1155 Define a spanning request. The @var{startstop} parameter is either -1
1156 (@code{\start}@keyindex{start}) or 1 (@code{\stop}@keyindex{stop}) and
1157 @var{type} is a string that describes what should be started.
1158 Supported types are @code{crescendo}, @code{decrescendo},
1159 @code{beam}, @code{slur}. This is an internal command. Users should
1160 use the shorthands which are defined in the initialization file
1163 You can attach a (general) span request to a note using
1165 @lilypond[fragment,verbatim,center]
1166 c'4-\spanrequest \start "slur"
1167 c'4-\spanrequest \stop "slur"
1170 The slur syntax with parentheses is a shorthand for this.
1174 @section stem tremolo
1175 @cindex tremolo marks
1177 Tremolo marks can be printed on a single note by adding
1178 `@code{:}[@var{length}]' after the note. The length must be at
1179 least 8. A @var{length} value of 8 gives one line across
1180 the note stem. If the length is omitted, then the last value is
1181 used, or the value of the @code{tremoloFlags}@indexcode{tremoloFlags} property if there was
1184 @lilypond[verbatim,fragment,center]
1190 @node Compound music expressions
1191 @section Compound music expressions
1193 @cindex compound music expressions
1195 Music expressions are compound data structures. You can nest music
1196 expressions any way you like. This simple example shows how three
1197 chords can be expressed in two different ways:
1199 @lilypond[fragment,verbatim,center]
1200 \notes \context Staff {
1202 <a c'> <b d' > <c' e'>
1203 < { a b c' } { c' d' e' } >
1207 @cindex context selection
1208 @c @keyindex{context}
1211 \context @var{contexttype} [= @var{contextname}] @var{musicexpr}
1214 Interpret @var{musicexpr} within a context of type @var{contexttype}.
1215 If the context does not exist, it will be created. The new context
1216 can optionally be given a name.
1222 Mode switching keywords form compound music expressions: @code{\notes}
1223 @keyindex{notes} @var{musicexpr}, @code{\chords} @keyindex{chords}
1224 @var{musicexpr}, and @code{\lyrics} @keyindex{lyrics} @var{musicexpr}.
1225 These expressions do not add anything to the meaning of their
1226 arguments. They are just a way to indicate that the arguments should
1227 be parsed in indicated mode. See @ref{Lexical modes} for more
1228 information on modes.
1230 @cindex sequential music
1236 \sequential@keyindex{sequential}
1237 @code{@{} @var{musicexprlist} @code{@}}
1240 This means that list should be played or written in sequence, i.e.,
1241 the second after the first, the third after the second. The duration
1242 of sequential music is the the sum of the durations of the elements.
1243 There is a shorthand, which leaves out the keyword:
1247 @code{@{} @var{musicexprlist} @code{@}}
1252 @cindex simultaneous music
1259 \simultaneous@keyindex{simultaneous}
1260 @code{@{} @var{musicexprlist} @code{@}}
1263 It constructs a music expression where all of its arguments start at
1264 the same moment. The duration is the maximum of the durations of the
1265 elements. The following shorthand is a common idiom:
1269 @code{<} @var{musicexprlist} @code{>}
1272 If you try to use a chord as the first thing in your score, you might
1273 get multiple staffs instead of a chord.
1275 @lilypond[verbatim,center]
1284 This happens because the chord is interpreted by a score context.
1285 Each time a note is encountered a default Voice context (along with a
1286 Staff context) is created. The solution is to explicitly instantiate
1289 @lilypond[verbatim,center]
1291 \notes\context Voice <c''4 e''>
1303 @cindex relative pitch specification
1305 It is easy to get confused by octave changing marks and accidentally
1306 putting a pitch in the wrong octave. A much better way of entering a
1307 note's octave is `the relative octave' mode.
1311 \relative@keyindex{relative} @var{startpitch} @var{musicexpr}
1314 The octave of notes that appear in @var{musicexpr} are calculated as
1315 follows: If no octave changing marks are used, the basic interval
1316 between this and the last note is always taken to be a fourth or
1317 less.@footnote{The interval is determined without regarding
1318 accidentals. A @code{fisis} following a @code{ceses} will be put above
1319 the @code{ceses}.} The octave changing marks `@code{'}' and `@code{,}'
1320 can then be added to raise or lower the pitch by an extra octave.
1321 Upon entering relative mode, an absolute starting pitch must be
1322 specified that will act as the predecessor of the first note of
1325 Entering scales is straightforward in relative mode.
1327 @lilypond[fragment,verbatim,center]
1333 And octave changing marks are used for intervals greater than a fourth.
1335 @lilypond[fragment,verbatim,center]
1337 c g c f, c' a, e'' }
1340 If the preceding item is a chord, the first note of the chord is used
1341 to determine the first note of the next chord. But other notes
1342 within the second chord are determined by looking at the immediately
1345 @lilypond[fragment,verbatim,center]
1353 The pitch after the @code{\relative} contains a notename. To parse
1354 the pitch as a notename, you have to be in note mode, so there must
1355 be a surrounding @code{\notes}@keyindex{notes} keyword (which is not
1358 The relative conversion will not affect @code{\transpose} or
1359 @code{\relative} sections in its argument. If you want to use
1360 relative within transposed music, you must place an additional
1361 @code{\relative} inside the @code{\transpose}.
1363 It is strongly recommended to use relative pitch mode: less work,
1364 less error-prone, and more readable.
1368 Chord names are a way to generate simultaneous music expressions that
1369 correspond with traditional chord names. It can only be used in
1370 Chord mode (see section @ref{Lexical modes}).
1374 @var{tonic}[@var{duration}][@code{-}@var{modifiers}][@code{^}@var{subtractions}][@code{/}@var{inversion}][@code{/+}@var{bass}].
1377 @var{tonic} should be the tonic note of the chord, and @var{duration}
1378 is the chord duration in the usual notation. There are two kinds of
1379 modifiers. One type is @emph{chord additions}, which are obtained by
1380 listing intervals separated by dots. An interval is written by its
1381 number with an optional `@code{+}' or `@code{-}' to indicate raising or
1382 lowering by half a step. Chord additions has two effects: It adds
1383 the specified interval and all lower odd numbered intervals to the
1384 chord, and it may lower or raise the specified interval. Intervals
1385 must be separated by a dot (`@code{.}').
1389 @lilypond[fragment,verbatim]
1393 c:9 c:9-.5+.7+ c:3-.5- c:4.6.8
1400 The second type of modifier that may appear after the `@code{:}' is a
1401 named modifier. Named modifiers are listed in the file
1402 @file{chord-modifiers.ly}. The available modifiers are `@code{m}' and
1403 `@code{min}' which lower the 3rd half a step, `@code{aug}@indexcode{aug}' which
1404 raises the 5th, `@code{dim}@indexcode{dim}' which lowers the 5th,
1405 `@code{maj}@indexcode{maj}' which adds a raised 7th, and `@code{sus}@indexcode{sus}'
1406 which replaces the 5th with a 4th.
1410 @lilypond[fragment,verbatim]
1413 c1:m c:min7 c:maj c:aug c:dim c:sus
1421 Chord subtractions are used to eliminate notes from a chord. The
1422 notes to be subtracted are listed after a `@code{^}' character,
1425 @lilypond[fragment,verbatim,center]
1433 Chord inversions can be specified by appending `@code{/}@indexcode{/}' and
1434 the name of a single note to a chord. This has the effect of
1435 lowering the specified note by an octave so it becomes the lowest
1436 note in the chord. If the specified note is not in the chord, a
1437 warning will be printed.
1439 @lilypond[fragment,verbatim,center]
1448 Bass notes can be added by `@code{/+}@indexcode{/+}' and
1449 the name of a single note to a chord. This has the effect of
1450 adding the specified note to the chord, lowered by an octave,
1451 so it becomes the lowest note in the chord.
1453 @lilypond[fragment,verbatim,center]
1462 Throughout these examples, chords have been shifted around the staff
1463 using @code{\transpose}.
1465 You should not combine @code{\relative} with named chords.
1471 Tuplets are made out of a music expression by multiplying their
1472 duration with a fraction.
1476 \times@keyindex{times} @var{fraction} @var{musicexpr}
1479 The duration of @var{musicexpr} will be multiplied by the fraction.
1480 In print, the fraction's denominator will be printed over the notes,
1481 optionally with a bracket. The most common tuplet is the triplet in
1482 which 3 notes have the length of 2, so the notes are 2/3 of
1483 their written length:
1485 @lilypond[fragment,verbatim,center]
1486 g'4 \times 2/3 {c'4 c' c'} d'4 d'4
1495 \grace@keyindex{grace} @var{musicexpr}
1498 A grace note expression has duration 0; the next real note is
1499 assumed to be the main note.
1502 You cannot have the grace note after the main note, in terms of
1503 duration, and main notes, but you can typeset the grace notes to the
1504 right of the main note using the property
1505 @code{graceAlignPosition}@indexcode{graceAlignPosition}.
1507 When grace music is interpreted, a score-within-a-score is set up:
1508 @var{musicexpr} has its own time bookkeeping, and you could (for
1509 example) have a separate time signature within grace notes. While in
1510 this score-within-a-score, you can create notes, beams, slurs, etc.
1511 Unbeamed eighth notes and shorter by default have a slash through the
1512 stem. This behavior can be controlled with the
1513 @code{flagStyle}@indexcode{flagStyle} property.
1517 @lilypond[fragment,verbatim]
1519 \grace c8 c4 \grace { [c16 c16] } c4
1520 \grace { \property Grace.flagStyle = "" c16 } c4
1526 At present, nesting @code{\grace}@keyindex{grace} notes, e.g.
1530 @code{\grace @{ \grace c32 c16 @} c4}
1533 may result in run-time errors of LilyPond. Since the meaning of such
1534 a construct is unclear, we don't consider this a loss. Similarly,
1535 juxtaposing two @code{\grace} sections is syntactically valid, but
1536 makes no sense and may cause runtime errors.
1538 Ending a staff or score with grace notes may also generate a run-time
1539 error, since there will be no main note to attach the grace notes to.
1548 In order to specify repeats, use the @code{\repeat}@keyindex{repeat}
1549 keyword. Since repeats look and sound differently when played or
1550 printed, there are a few different variants of repeats.
1554 Repeated music is fully written (played) out. Useful for MIDI
1558 This is the normal notation: Repeats are not written out, but
1559 alternative endings (voltas) are printed, left to right.
1562 Alternative endings are written stacked, which is useful for
1566 The syntax for repeats is
1570 \repeat @var{variant} @var{repeatcount} @var{repeatbody}
1573 If you have alternative endings, you may add
1577 \alternative@keyindex{alternative}
1578 @code{@{} @var{alternative1}
1580 @var{alternative3} @dots{} @code{@}}
1583 where each @var{alternative} is a Music expression.
1585 Normal notation repeats are used like this:
1589 @lilypond[fragment,verbatim]
1591 \repeat volta 2 { c'4 d' e' f' }
1592 \repeat volta 2 { f' e' d' c' }
1597 With alternative endings:
1601 @lilypond[fragment,verbatim]
1603 \repeat volta 2 {c'4 d' e' f'}
1604 \alternative { {d'2 d'} {f' f} }
1609 Folded repeats look like this:@footnote{Folded repeats offer little
1610 more over simultaneous music. However, it is to be expected that
1611 more functionality -- especially for the MIDI backend -- will be
1616 @lilypond[fragment,verbatim]
1618 \repeat fold 2 {c'4 d' e' f'}
1619 \alternative { {d'2 d'} {f' f} }
1626 @lilypond[fragment,verbatim]
1630 \repeat volta 2 { e | c2 d2 | e2 f2 | }
1631 \alternative { { g4 g g } { a | a a a a | b1 } }
1638 If you don't give enough alternatives for all of the repeats, then
1639 the first alternative is assumed to be repeated often enough to equal
1640 the specified number of repeats.
1644 @lilypond[fragment,verbatim]
1647 \repeat volta 3 { \partial 4; e | c2 d2 | e2 f2 | }
1648 \alternative { { g4 g g }
1649 {\partial 1; e4 e e }
1650 {\partial 1; a a a a | b1 } }
1657 It is possible to nest @code{\repeat}. This is not entirely
1658 supported: the notes will come be in the right places, but the repeat
1666 @cindex transposition of pitches
1668 A music expression can be transposed with
1669 @code{\transpose}@keyindex{transpose}. The syntax is
1673 \transpose @var{pitch} @var{musicexpr}
1676 This means that middle C in @var{musicexpr} is transposed to
1679 @code{\transpose} distinguishes between enharmonic pitches: both
1680 @code{\transpose cis'} or @code{\transpose des'} will transpose up half
1681 a tone. The first version will print sharps and the second version
1686 @lilypond[fragment,verbatim]
1689 { \key e \major; c d e f }
1691 \transpose des'' { \key e \major; c d e f }
1692 \transpose cis'' { \key e \major; c d e f }
1698 If you want to use both @code{\transpose} and @code{\relative}, then
1699 you must use @code{\transpose} first. @code{\relative} will have no
1700 effect music that appears inside a @code{\transpose}.
1704 @cindex automatic lyric durations
1706 If you have lyrics that are set to a melody, you can import the
1707 rhythm of that melody into the lyrics using @code{\addlyrics}.
1708 @keyindex{addlyrics} The syntax for this is
1712 \addlyrics @var{musicexpr1 musicexpr2}
1715 This means that both @var{musicexpr1} and @var{musicexpr2} are
1716 interpreted, but that every non-command atomic music expression
1717 (``every syllable'') in @var{musicexpr2} is interpreted using timing
1718 of @var{musicexpr1}.
1720 If the property @code{automaticMelismata}@indexcode{automaticMelismata} is set in the
1721 context of @var{musicexpr1}, no lyrics will be put on slurred or tied
1726 @lilypond[verbatim,fragment]
1729 \property Voice.automaticMelismata = ##t
1730 c8 () cis d8. e16 f2
1732 \context Lyrics \lyrics {
1738 You should use a single rhythm melody, and single rhythm lyrics (a
1739 constant duration is the obvious choice). If you do not, you will get
1740 undesired effects when using multiple stanzas:
1744 @lilypond[verbatim,fragment]
1747 c8 () cis d8. e16 f2
1749 \context Lyrics \lyrics
1756 It is valid (but probably not very useful) to use notes instead of
1757 lyrics for @var{musicexpr2}.
1763 @section Ambiguities
1767 The grammar contains a number of ambiguities.@footnote{The authors
1768 hope to resolve them at a later time.}
1771 @item The assignment
1777 can be interpreted as making a string identifier @code{\foo}
1778 containing @code{"bar"}, or a music identifier @code{\foo}
1779 containing the syllable `bar'.
1781 @item The assignment
1787 can be interpreted as making an integer identifier
1788 containing -6, or a Request identifier containing the
1789 fingering `6' (with neutral direction).
1791 @item If you do a nested repeat like
1803 then it is ambiguous to which @code{\repeat} the
1804 @code{\alternative} belongs. This is the classic if-then-else
1805 dilemma. It may be solved by using braces.
1807 @item (an as yet unidentified ambiguity :-)
1812 @node Notation conversion specifics
1813 @section Notation conversion specifics
1816 @node Automatic Beaming
1817 @section Automatic Beaming
1818 @cindex automatic beam generation
1821 @c beamAuto vs autoBeam ?
1823 By default, LilyPond will generate beams automatically. This feature
1824 can be disabled by setting the
1825 @code{Voice.beamAuto}@indexcode{Voice.beamAuto} property to false.
1826 It can be overridden for specific cases by specifying explicit beams.
1829 A large number of Voice properties are used to decide how to generate
1830 beams. Their default values appear in @file{scm/auto-beam.scm}. In
1831 general, beams can begin anywhere, but their ending location is
1832 significant. Beams can end on a beat, or at durations specified by the
1834 @code{Voice.autoBeamSettings}@indexcode{Voice.autoBeamSettings}.
1835 To end beams every quarter note, for example, you could set the property
1836 @code{(end * * * *)} @indexcode{(end * * * *)} to `@code{(make-moment 1
1837 4)}'. To end beams at every three eighth notes you would set
1838 it to `@code{(make-moment 1 8)}'.
1839 The same syntax can be used to specify beam
1840 starting points using
1841 @code{(begin * * * *)}@indexcode{(begin * * * *)}, eg:
1844 \property Voice.autoBeamSettings \override
1845 #'(end * * * *) = #(make-moment 1 4)
1846 \property Voice.autoBeamSettings \override
1847 #'(begin * * * *) = #(make-moment 1 8)
1851 To allow different settings for different time signatures, instead of
1852 the first two asterisks @code{* *} you can specify a time signature; use
1853 @code{(end N M * *)} to restrict the definition to
1854 `@var{N}@code{/}@var{M}' time. For example, to specify beams ending
1855 only for 6/8 time you would use the property @code{(end 6 8 * *)}.
1857 To allow different endings for notes of different durations, instead of
1858 th last two asterisks you can specify a duration; use @code{(end * * N
1859 M)} to restrict the definition to beams that contain notes of
1860 `@var{N}@code{/}@var{M}' duration.
1862 For example, to specify beam endings for beams that contain 32nd notes,
1863 you would use @code{(end * * 1 32)}.
1867 @section Chord Names
1871 @cindex printing!chord names
1873 For displaying printed chord names, use the
1874 @code{ChordNames}@indexcode{ChordNames} and
1875 @code{ChordNameVoice}@indexcode{ChordNameVoice} contexts. The chords
1876 may be entered either using the notation described above, or directly
1877 using simultaneous music.
1882 \chords {a1 b c} <d f g> <e g b>
1886 \context ChordNamesVoice \scheme
1887 \context Staff \transpose c'' \scheme
1889 \paper { linewidth = -1.; }
1895 You can make the chord changes stand out more by setting property
1896 @code{ChordNames.chordChanges} to true. This will only display
1897 chord names when there's a change in the chords scheme, but always
1898 display the chord name after a line break:
1904 % \property ChordNames.chordChanges = ##t
1905 c1:m \break c:m c:m c:m d
1910 \context ChordNamesVoice \scheme
1911 \context Staff \transpose c'' \scheme
1914 linewidth = 40 * \staffspace;
1922 LilyPond examines chords specified as lists of notes to determine a
1923 name to give the chord. LilyPond will not try to
1924 identify chord inversions or added base, which may result in strange
1925 chord names when chords are entered as a list of pitches:
1928 @lilypond[verbatim,center]
1937 \context ChordNamesVoice \scheme
1938 \context Staff \scheme
1940 \paper { linewidth = -1.; }
1945 To specify chord inversions, append @code{/<notename>}. To specify an
1946 added bass note, append @code{/+<notename}:
1949 @lilypond[verbatim,center]
1956 \context ChordNames \scheme
1957 \context Staff \transpose c'' \scheme
1959 \paper { linewidth = -1.; }
1964 The chord names that LilyPond should print are fully customisable. The
1965 default code can be found in @file{scm/chord-name.scm}. Chord names are
1966 based on Banter style naming, which is unambiguous and has a logical
1967 structure. Typical American style chord names are implemented as a
1968 variation on Banter names, they can be selected by setting poperty
1969 @code{ChordName.style} to @code{american}:
1973 \include "english.ly"
1978 df:m5- % Diminished triad
1979 c:5^3 % Root-fifth chord
1980 c:4^3 % Suspended fourth triad
1981 c:5+ % Augmented triad
1983 c:m5-.7- % Diminished seventh
1984 c:7+ % Major seventh
1985 c:7.4^3 % Dominant seventh suspended fourth
1986 c:5+.7 % Augmented dominant seventh
1987 c:m5-.7 % "Half" diminished seventh
1988 c:5-.7 % Dominant seventh flat fifth
1989 c:5-.7+ % Major seventh flat fifth
1990 c:m7+ % Minor-major seventh
1991 c:m7 % Minor seventh
1992 c:7 % Dominant seventh
1995 c:9^7 % Major triad w/added ninth
1996 c:6.9^7 % Six/Nine chord
1997 c:9 % Dominant ninth
1998 c:7+.9 % Major ninth
1999 c:m7.9 % Minor ninth
2004 \context ChordNames \scheme
2005 \context Staff \transpose c'' \scheme
2010 ChordName \override #'word-space = #1
2011 ChordName \override #'style = #'american
2018 Similarly, Jazz style chord names are implemented as a variation on
2019 American style names:
2025 c:6 % 6 = major triad with added sixth
2026 c:maj % triangle = maj
2031 c:m % m = minor triad
2032 c:m.6 % m6 = minor triad with added sixth
2033 c:m.7+ % m triangle = minor major seventh chord
2041 c:7.5+ % +7 = augmented dominant
2042 c:7.5- % 7b5 = hard diminished dominant
2049 c:13.9-^11 % 7(b9,13)
2050 c:13.9+^11 % 7(#9,13)
2052 c:13-.9-^11 % 7(b9,b13)
2053 c:13-.9+^11 % 7(#9,b13)
2055 % half diminished chords
2056 c:m5-.7 % slashed o = m7b5
2057 c:9.3-.5- % o/7(pure 9)
2060 c:m5-.7- % o = diminished seventh chord
2065 \context ChordNames \scheme
2066 \context Staff \transpose c'' \scheme
2071 ChordName \override #'word-space = #1
2072 ChordName \override #'style = #'jazz
2084 @cindex printing!lyrics
2087 Lyric syllables must be interpreted within a @code{Lyrics} context
2089 @cindex context!Lyrics
2092 Here is a full example:
2098 \notes \transpose c'' {
2100 e f g2 | e4 f g2 \bar "|.";
2102 \context Lyrics \lyrics {
2103 Va-4 der Ja- cob Va- der Ja- cob
2104 Slaapt gij nog?2 Slaapt4 gij nog?2
2112 You may want a continuous line after the syllables to show melismata.
2113 To achieve this effect, add a `@code{__}' lyric as a separate word
2114 after the lyric to be extended. This will create an extender, a line
2115 that extends over the entire duration of the lyric. This line will
2116 run all the way to the start of the next lyric, so you may want to
2117 shorten it by using a blank lyric (using `@code{_}').
2124 \notes \relative c'' {
2125 a4 () b () c () d | c () d () b () a | c () d () b () a
2127 \context Lyrics \lyrics {
2128 foo1 __ | bar2. __ _4 | baz1 __
2137 If you want to have hyphens centered between syllables (rather than
2138 attached to the end of the first syllable) you can use the special
2139 `@code{-}@code{-}' lyric as a separate word between syllables. This
2140 will result in a hyphen which length varies depending on the space
2141 between syllables, and which will be centered between the syllables.
2149 \notes \transpose c'' {
2151 e f g2 | e4 f g2 \bar "|.";
2153 \context Lyrics \lyrics {
2154 Va4 -- der Ja -- cob | Va -- der Ja -- cob |
2155 Slaapt gij nog?2 | Slaapt4 gij nog?2
2165 @node Notation Contexts
2166 @section Notation Contexts
2168 @cindex notation contexts
2170 Notation contexts are objects that only exist during a run of
2171 LilyPond. During the interpretation phase of LilyPond, the Music
2172 expression contained in a @code{\score} block is interpreted in time
2173 order. This is the order in which humans read, play, and write
2176 A context is an object that holds the reading state of the
2177 expression; it contains information like
2180 @item What notes are playing at this point?
2181 @item What symbols will be printed at this point?
2182 @item In what style will they printed?
2183 @item What is the current key signature, time signature, point within
2187 Contexts are grouped hierarchically: A @code{Voice} context is
2188 contained in a @code{Staff} context (because a staff can contain
2189 multiple voices at any point), a @code{Staff} context is contained in
2190 a @code{Score}, @code{StaffGroup}, or @code{ChoirStaff} context (because
2191 these can all contain multiple staffs).
2193 Contexts associated with sheet music output are called @emph{notation
2194 contexts}, those for sound output are called playing contexts.
2196 Contexts are created either manually or automatically. Initially,
2197 the top level music expression is interpreted by the top level
2198 context (the @code{Score} context). When a atomic music expression
2199 (i.e. a note, a rest, @code{\bar}, or @code{\time} commands), a nested
2200 set of contexts is created that can process these atomic expressions,
2206 \score @{ \notes < c4 > @}
2211 The sequential music, `@code{@{ c4 @}}' is interpreted by @code{Score}
2212 context. When the note `@code{c4}' itself is interpreted, a set of
2213 contexts is needed that will accept notes. The default for this is a
2214 @code{Voice} context, contained in a @code{Staff} context. Creation of
2215 these contexts results in the staff being printed.
2220 You can also create contexts manually, and you probably have to do so
2221 if you want to typeset complicated multiple part material. If a
2222 `@code{\context} @var{name} @var{musicexpr}' expression is encountered
2223 during the interpretation phase, the @var{musicexpr} argument will be
2224 interpreted with a context of type @var{name}. If you specify a name,
2225 the specific context with that name is searched.
2227 If a context of the specified type and name can not be found, a new
2228 one is created. For example,
2234 \notes \relative c'' {
2235 c4 <d4 \context Staff = "another" e4> f
2242 In this example, the @code{c} and @code{d} are printed on the
2243 default staff. For the @code{e}, a context Staff called
2244 `@code{another}' is specified; since that does not exist, a new
2245 context is created. Within @code{another}, a (default) Voice context
2246 is created for the @code{e4}. When all music referring to a
2247 context is finished, the context is ended as well. So after the
2248 third quarter, @code{another} is removed.
2250 Almost all music expressions inherit their interpretation context
2251 from their parent. In other words, suppose that the syntax for a
2256 \keyword @var{musicexpr1} @var{musicexpr2} @dots{}
2259 When the interpretation of this music expression starts, the context
2260 for @var{musicexpr1}, @var{musicexpr2}, etc. is that of the total
2263 Lastly, you may wonder, why this:
2269 \notes \relative c'' @{
2277 doesn't result in this:
2282 \notes \relative c'' {
2289 For the @code{c4}, a default @code{Staff} (with a contained
2290 @code{Voice}) context is created. After the @code{c4} ends, no
2291 music refers to this default staff, so it would be ended, with the
2292 result shown. To prevent this inconvenient behavior, the context to
2293 which the sequential music refers is adjusted during the
2294 interpretation. So after the @code{c4} ends, the context of the
2295 sequential music is also the default @code{Voice} context.
2296 The @code{d4} gets interpreted in the same context
2299 Properties that are set in one context are inherited by all of the
2300 contained contexts. This means that a property valid for the
2301 @code{Voice} context can be set in the @code{Score} context (for
2302 example) and thus take effect in all @code{Voice} contexts.
2304 Properties can be preset within the @code{\translator} block
2305 corresponding to the appropriate context. In this case, the syntax
2309 @var{propname} @code{=} @var{value}
2312 This assignment happens before interpretation starts, so a
2313 @code{\property} expression will override any predefined settings.
2315 The property settings are used during the interpretation phase. They
2316 are read by the LilyPond modules where interpretation contexts are
2317 built of. These modules are called @emph{translators}. Translators for
2318 notation are called @emph{engravers}, and translators for sound are
2319 called @emph{performers}.
2322 @mbinclude properties.itely
2325 @section Page layout
2327 @subsection Paper block
2329 The most important output definition is the @code{\paper} block, for
2330 music notation. The syntax is
2333 @code{\paper @{} [@var{paperidentifier}] @var{items} @code{@}}
2336 where each of the items is one of
2339 @item An assignment. The assignment must be terminated by a
2342 @item A context definition. See section @ref{contextdefs} for
2343 more information on context definitions.
2352 A margin shape declaration. The syntax is
2356 \shape @var{indent1}@code{,} @var{width1}@code{,}
2357 @var{indent2}@code{,} @var{width2} @dots{} @code{;}
2362 Each pair of @var{indent} and @var{width} values is a dimension
2363 specifying how far to indent and how wide to make the line.
2364 The indentation and width of successive lines are specified by
2365 the successive pairs of dimensions. The last pair of
2366 dimensions will define the characeristics of all lines beyond
2367 those explicitly specified.
2370 @item \stylesheet declaration. Its syntax is
2372 \stylesheet @var{alist}
2375 See @file{font.scm} for details of @var{alist}.
2379 @subsection Paper variables
2381 The paper block has some variables you may want to use or change:
2384 @item @code{indent}@indexcode{indent}
2385 The indentation of the first line of music.
2387 @item @code{staffspace}@indexcode{staffspace}
2388 The distance between two staff lines, calculated from the center
2389 of the lines. You should use either this or @code{rulethickness}
2390 as a unit for distances you modify.
2392 @item @code{linewidth}@indexcode{linewidth}
2393 Sets the width of the lines. If set to -1.0, a single
2394 unjustified line is produced. If you use this variable, you
2395 probably want to define it in staff spaces, ie
2397 linewidth = 30 * \staffspace;
2400 @item @code{textheight}@indexcode{textheight}
2401 Sets the total height of the music on each page. Only used by
2404 @item @code{interscoreline}@indexcode{interscoreline}
2405 Sets the spacing between the score lines. Defaults to 16 pt.
2407 @item @code{interscorelinefill}@indexcode{interscorelinefill}
2408 If set to a positive number, the distance between the score
2409 lines will stretch in order to fill the full page. In that
2410 case @code{interscoreline} specifies the minimum spacing.
2413 @item @code{stafflinethickness}@indexcode{stafflinethickness}
2414 Determines the thickness of staff lines, and also acts as a scaling
2415 parameter for other line thicknesses.
2419 @subsection Line breaks
2422 @cindex breaking lines
2424 Line breaks are normally computed automatically. They are chosen such
2425 that the resulting spacing has low variation, and looks neither cramped
2428 Occasionally you might want to override the automatic breaks; you can do
2429 this by specifying @code{\break} (see also @ref{Pre-defined
2430 Identifiers}). This will force a line break at this point. Do remember
2431 that line breaks can only occur at places where there are barlines. If
2432 you want to have a line break where there is no barline, you can force a
2433 barline by entering @code{\bar "";}.
2435 @subsection Page breaks
2437 Page breaks are normally computed by @TeX{}, so they are not under direct
2438 control. However, you can insert a commands into the .tex output to
2439 instruct @TeX{} where to break pages. For more details, see the
2440 example file @file{input/test/between-systems.ly}
2444 @cindex breaking pages
2447 @subsection Font size
2452 The Feta font provides musical symbols at six different sizes. These
2453 fonts are 11 point, 13 point, 16 point, 20 point,
2454 23 point, and 26 point. The point size of a font is the
2455 height of the five lines in a staff when displayed in the font.
2457 Definitions for these sizes are the files @file{paperSZ.ly}, where
2458 @code{SZ} is one of 11, 13, 16, 20, 23 and 26. If you include any of
2459 these files, the identifiers @code{paperEleven}, @code{paperThirteen},
2460 @code{paperSixteen}, @code{paperTwenty}, @code{paperTwentythree}, and
2461 @code{paperTwentysix} are defined respectively. The default
2462 @code{\paper} block is also set.
2464 The font definitions are generated using a Scheme function. For more
2465 details, see the file @file{font.scm}.
2467 @subsection paper size
2472 To change the paper size, you must first set the
2473 @code{papersize}@indexcode{papersize} variable at top level. Set it to
2474 the strings @code{a4}, @code{letter}, or @code{legal}. After this
2475 specification, you must set the font as described above. If you want
2476 the default font, then use the 20 point font. The new paper size will
2477 not take effect if the font is not loaded and selected afterwards.
2481 \include "paper16.ly"
2485 \paper @{ \paperSixteen @}
2489 The file "paper16.ly" will now include a file named @file{a4.ly}, which
2490 will set the paper variables @code{hsize} and @code{vsize} (used by
2494 @section contextdefs
2496 @cindex context definition
2497 @cindex translator definition
2498 @cindex engraver hacking
2501 A notation contexts is defined by the following information
2506 @item The LilyPond modules that do the actual conversion of music to
2507 notation. Each module is a so-called
2512 @item How these modules should cooperate, i.e. which ``cooperation
2513 module'' should be used. This cooperation module is a special
2516 @item What other contexts the context can contain,
2518 @item What properties are defined.
2521 A context definition has this syntax:
2525 \translator @code{@{}
2526 @var{translatorinit} @var{translatormodifierlist}
2530 @var{translatorinit} can be an identifier or of the form
2534 \type @var{typename} @code{;}
2537 @var{typename} is one of
2540 @item @code{Engraver_group_engraver}@indexcode{Engraver_group_engraver}
2541 The standard cooperation engraver.
2543 @item @code{Score_engraver}@indexcode{Score_engraver}
2544 This is cooperation module that should be in the top level context.
2546 @item @code{Grace_engraver_group}@indexcode{Grace_engraver_group}
2547 This is a special cooperation module (resembling
2548 @code{Score_engraver}) that is used to created an embedded
2552 @var{translatormodifierlist} is a list of items where each item is
2556 @item @code{\consists} @var{engravername} @code{;}
2557 Add @var{engravername} to the list of modules in this context.
2558 The order of engravers added with @code{\consists} is
2561 @item @code{\consistsend} @var{engravername} @code{;}
2562 Analogous to @code{\consists}, but makes sure that
2563 @var{engravername} is always added to the end of the list of
2566 Some engraver types need to be at the end of the list; this
2567 insures they are put there, and stay there, if a user adds or
2568 removes engravers. This command is usually not needed for
2571 @item @code{\accepts} @var{contextname} @code{;}
2572 Add @var{contextname} to the list of context this context can
2573 contain. The first listed context is the context to create by
2576 @item @code{\denies}. The opposite of @code{\accepts}. Added for
2577 completeness, but is never used in practice.
2580 @item @code{\remove} @var{engravername} @code{;}
2581 Remove a previously added (with @code{\consists}) engraver.
2583 @item @code{\name} @var{contextname} @code{;}
2584 This sets name of the context, e.g. @code{Staff}, @code{Voice}. If
2585 the name is not specified, the translator won't do anything.
2587 @item @var{propname} @code{=} @var{value} @code{;}
2588 A property assignment. It is allowed to use reals for
2592 In the @code{\paper} block, it is also possible to define translator
2593 identifiers. Like other block identifiers, the identifier can only
2594 be used as the very first item of a translator. In order to define
2595 such an identifier outside of @code{\score}, you must do
2601 foo = \translator @{ @dots{} @}
2608 \translator @{ \foo @dots{} @}
2616 @cindex paper types, engravers, and pre-defined translators
2618 Some pre-defined identifiers can simplify modification of
2619 translators. The pre-defined identifiers are:
2622 @item @code{StaffContext}@indexcode{StaffContext}
2623 Default Staff context.
2625 @item @code{RhythmicStaffContext}@indexcode{RhythmicStaffContext}
2626 Default RhythmicStaff context.
2628 @item @code{VoiceContext}@indexcode{VoiceContext}
2629 Default Voice context.
2631 @item @code{ScoreContext}@indexcode{ScoreContext}
2632 Default Score context.
2634 @item @code{ScoreWithNumbers}@indexcode{ScoreWithNumbers}
2635 Score context with numbering at the Score level.
2637 @item @code{BarNumberingStaffContext}@indexcode{BarNumberingStaffContext}
2638 Staff context with numbering at the Staff level.
2640 @item @code{HaraKiriStaffContext}@indexcode{HaraKiriStaffContext}
2641 Staff context that does not print if it only contains rests.
2642 Useful for orchestral scores.@footnote{Harakiri, also called
2643 Seppuku, is the ritual suicide of the Samourai.}
2645 @item @code{OrchestralPartStaffContext}@indexcode{OrchestralPartStaffContext}
2647 @item @code{OrchestralScoreContext}@indexcode{OrchestralScoreContext}
2650 Using these pre-defined values, you can remove or add items to the
2659 \remove Some_engraver;
2660 \consists Different_engraver;
2669 @section Sound output
2671 The MIDI block is analogous to the paper block, but it is somewhat
2672 simpler. The @code{\midi} block can contain:
2676 @item a @code{\tempo} definition
2677 @item context definitions
2680 Assignments in the @code{\midi} block are not allowed.
2684 @cindex context definition
2686 Context definitions follow precisely the same syntax as within the
2687 \paper block. Translation modules for sound are called performers.
2688 The contexts for MIDI output are defined in @file{ly/performer.ly}.
2692 @cindex MIDI instrument names
2697 The MIDI instrument name is set by the
2698 @code{Staff.midiInstrument}@indexcode{Staff.midiInstrument} property or,
2699 if that property is not set, the
2700 @code{Staff.instrument}@indexcode{Staff.instrument} property. The
2701 instrument name should be chosen from the following list. If the
2702 selected string does not exactly match, then LilyPond uses the default
2708 "acoustic grand" "contrabass" "lead 7 (fifths)"
2709 "bright acoustic" "tremolo strings" "lead 8 (bass+lead)"
2710 "electric grand" "pizzicato strings" "pad 1 (new age)"
2711 "honky-tonk" "orchestral strings" "pad 2 (warm)"
2712 "electric piano 1" "timpani" "pad 3 (polysynth)"
2713 "electric piano 2" "string ensemble 1" "pad 4 (choir)"
2714 "harpsichord" "string ensemble 2" "pad 5 (bowed)"
2715 "clav" "synthstrings 1" "pad 6 (metallic)"
2716 "celesta" "synthstrings 2" "pad 7 (halo)"
2717 "glockenspiel" "choir aahs" "pad 8 (sweep)"
2718 "music box" "voice oohs" "fx 1 (rain)"
2719 "vibraphone" "synth voice" "fx 2 (soundtrack)"
2720 "marimba" "orchestra hit" "fx 3 (crystal)"
2721 "xylophone" "trumpet" "fx 4 (atmosphere)"
2722 "tubular bells" "trombone" "fx 5 (brightness)"
2723 "dulcimer" "tuba" "fx 6 (goblins)"
2724 "drawbar organ" "muted trumpet" "fx 7 (echoes)"
2725 "percussive organ" "french horn" "fx 8 (sci-fi)"
2726 "rock organ" "brass section" "sitar"
2727 "church organ" "synthbrass 1" "banjo"
2728 "reed organ" "synthbrass 2" "shamisen"
2729 "accordion" "soprano sax" "koto"
2730 "harmonica" "alto sax" "kalimba"
2731 "concertina" "tenor sax" "bagpipe"
2732 "acoustic guitar (nylon)" "baritone sax" "fiddle"
2733 "acoustic guitar (steel)" "oboe" "shanai"
2734 "electric guitar (jazz)" "english horn" "tinkle bell"
2735 "electric guitar (clean)" "bassoon" "agogo"
2736 "electric guitar (muted)" "clarinet" "steel drums"
2737 "overdriven guitar" "piccolo" "woodblock"
2738 "distorted guitar" "flute" "taiko drum"
2739 "guitar harmonics" "recorder" "melodic tom"
2740 "acoustic bass" "pan flute" "synth drum"
2741 "electric bass (finger)" "blown bottle" "reverse cymbal"
2742 "electric bass (pick)" "skakuhachi" "guitar fret noise"
2743 "fretless bass" "whistle" "breath noise"
2744 "slap bass 1" "ocarina" "seashore"
2745 "slap bass 2" "lead 1 (square)" "bird tweet"
2746 "synth bass 1" "lead 2 (sawtooth)" "telephone ring"
2747 "synth bass 2" "lead 3 (calliope)" "helicopter"
2748 "violin" "lead 4 (chiff)" "applause"
2749 "viola" "lead 5 (charang)" "gunshot"
2750 "cello" "lead 6 (voice)"
2756 @node Pre-defined Identifiers
2758 @section Pre-defined Identifiers
2760 @cindex pre-defined identifiers
2763 Various identifiers are defined in the initialization files to
2764 provide shorthands for some settings. Most of them are in
2765 @file{ly/declarations.ly} and @file{ly/property.ly}.
2768 @item @code{\break}@keyindex{break}
2769 Force a line break in music by using a large argument for the
2770 keyword @code{\penalty}.
2772 @item @code{\nobreak}@keyindex{nobreak}
2773 Prevent a line break in music by using a large negative argument
2774 for the keyword @code{\penalty}.
2776 @item @code{\shiftOff}@keyindex{shiftOff}
2777 Disable horizontal shifting of note heads that collide.
2779 @item @code{\shiftOn}@keyindex{shiftOn}
2780 Enable note heads that collide with other note heads to be
2781 shifted horiztonally. Also @code{\shiftOnn} and @code{\shiftOnnn}
2782 set different shift values.
2784 @item @code{\stemBoth}@keyindex{stemBoth}
2785 Allow stems, beams, and slurs to point either upwards or
2786 downwards, decided automatically by LilyPond.
2788 @item @code{\stemDown}@keyindex{stemDown}
2789 Force stems, beams, and slurs to point down.
2791 @item @code{\stemUp}@keyindex{stemUp}
2792 Force stems, beams and slurs to point up.