1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond.tely
4 @c A menu is needed before every deeper *section nesting of @node's; run
5 @c M-x texinfo-all-menus-update
6 @c to automatically fill in these menus before saving changes
8 @node Non-musical notation
9 @chapter Non-musical notation
11 This section deals with general lilypond issues, rather than
16 * A single music expression::
17 * Titles and headers::
18 * Multiple movements::
20 * Displaying LilyPond notation::
21 * Skipping corrected music::
28 The main format of input for LilyPond are text files. By convention,
29 these files end with ``@code{.ly}''.
32 * File structure (introduction)::
34 * Including LilyPond files::
39 @node File structure (introduction)
40 @subsection File structure (introduction)
42 A basic example of a lilypond input file is
47 @{ @} % this is a single music expression;
48 % all the music goes in here.
56 There are many variations of this basic pattern, but this
57 example serves as a useful starting place.
59 The major part of this manual is concerned with entering various
60 forms of music in LilyPond. However, many music expressions are not
61 valid input on their own, for example, a @code{.ly} file containing
68 will result in a parsing error. Instead, music should be inside other
69 expressions, which may be put in a file by themselves. Such
70 expressions are called toplevel expressions. The next section enumerates
75 @subsection File structure
77 A @code{.ly} file contains any number of toplevel expressions, where a
78 toplevel expression is one of the following
82 An output definition, such as @code{\paper}, @code{\midi}, and
83 @code{\layout}. Such a definition at the toplevel changes the default
84 settings for the block entered.
87 A direct scheme expression, such as
88 @code{#(set-default-paper-size "a7" 'landscape)} or
89 @code{#(ly:set-option 'point-and-click #f)}.
92 A @code{\header} block. This sets the global header block. This
93 is the block containing the definitions for book-wide settings, like
97 An @code{\addquote} statement. See @ref{Quoting other voices}
101 A @code{\score} block. This score will be collected with other
102 toplevel scores, and combined as a single @code{\book}.
104 This behavior can be changed by setting the variable
105 @code{toplevel-score-handler} at toplevel. The default handler is
106 defined in the init file @file{scm/@/lily@/.scm}.
108 The @code{\score} must begin with a music expression, and may
109 contain only one music expression.
112 A @code{\book} block logically combines multiple movements
113 (i.e., multiple @code{\score} blocks) in one document. If there are
114 a number of @code{\scores}, a single output file will be created
115 in which all movements are concatenated.
117 This behavior can be changed by setting the variable
118 @code{toplevel-book-handler} at toplevel. The default handler is
119 defined in the init file @file{scm/@/lily@/.scm}.
122 A compound music expression, such as
127 This will add the piece in a @code{\score} and format it in a
128 single book together with all other toplevel @code{\score}s and music
129 expressions. In other words, a file containing only the above
130 music expression will be translated into
146 This behavior can be changed by setting the variable
147 @code{toplevel-music-handler} at toplevel. The default handler is
148 defined in the init file @file{scm/@/lily@/.scm}.
151 A markup text, a verse for example
154 2. The first line verse two.
158 Markup texts are rendered above, between or below the scores or music
159 expressions, wherever they appear.
162 An identifier, such as
167 This can be used later on in the file by entering @code{\foo}. The
168 name of an identifier should have alphabetic characters only; no
169 numbers, underscores or dashes.
173 The following example shows three things that may be entered at
178 % movements are non-justified by default
190 At any point in a file, any of the following lexical instructions can
194 @item @code{\version}
195 @item @code{\include}
196 @item @code{\renameinput}
200 @node Including LilyPond files
201 @subsection Including LilyPond files
204 @cindex including files
206 A large project may be split up into separate files. To refer to another
210 \include "otherfile.ly"
213 The line @code{\include "file.ly"} is equivalent to pasting the contents
214 of file.ly into the current file at the place where you have the
215 \include. For example, for a large project you might write separate files
216 for each instrument part and create a ``full score'' file which brings
217 together the individual instrument files.
219 The initialization of LilyPond is done in a number of files that are
220 included by default when you start the program, normally transparent to the
221 user. Run lilypond --verbose to see a list of paths and files that Lily
224 Files placed in directory @file{PATH/TO/share/lilypond/VERSION/ly/} (where
225 VERSION is in the form ``2.6.1'') are on the path and available to
226 @code{\include}. Files in the
227 current working directory are available to \include, but a file of the same
228 name in LilyPond's installation takes precedence. Files are
229 available to \include from directories in the search path specified as an
230 option when invoking @code{lilypond --include=DIR} which adds DIR to the
233 The @code{\include} statement can use full path information, but with the Unix
234 convention @code{"/"} rather than the DOS/Windows @code{"\"}. For example,
235 if @file{stuff.ly} is located one directory higher than the current working
239 \include "../stuff.ly"
244 @subsection Text encoding
246 LilyPond uses the Pango library to format multi-lingual texts, and
247 does not perform any input-encoding conversions. This means that any
248 text, be it title, lyric text, or musical instruction containing
249 non-ASCII characters, must be utf-8. The easiest way to enter such text is
250 by using a Unicode-aware editor and saving the file with utf-8 encoding. Most
251 popular modern editors have utf-8 support, for example, vim, Emacs,
254 Depending on the fonts installed, the following fragment shows Hebrew
261 @lilypondfile[fontload]{utf-8.ly}
263 The @TeX{} backend does not handle encoding specially at all. Strings
264 in the input are put in the output as-is. Extents of text items in the
265 @TeX{} backend, are determined by reading a file created via the
266 @file{texstr} backend,
269 lilypond -b texstr input/les-nereides.ly
270 latex les-nereides.texstr
273 The last command produces @file{les-nereides.textmetrics}, which is
274 read when you execute
277 lilypond -b tex input/les-nereides.ly
280 Both @file{les-nereides.texstr} and @file{les-nereides.tex} need
281 suitable LaTeX wrappers to load appropriate La@TeX{} packages for
282 interpreting non-ASCII strings.
284 To use a Unicode escape sequence, use
287 #(ly:export (ly:wide-char->utf-8 #x2014))
293 @inputfileref{input/regression,utf-8.ly}
297 @node A single music expression
298 @section A single music expression
300 A @code{\score} must contain a single music expression. However,
301 this music expression may be of any size. Recall that music
302 expressions may be included inside other expressions to form
303 larger expressions. All of these examples are single music
304 expressions; note the curly braces @{ @} or angle brackets <<
305 >> at the beginning and ending of the music.
311 @lilypond[ragged-right,verbatim,quote]
318 @lilypond[ragged-right,verbatim,quote]
320 \new Staff { c'4 c' c' c' }
321 \new Staff { d'4 d' d' d' }
329 \new Staff @{ \flute @}
330 \new Staff @{ \oboe @}
333 \new Staff @{ \violinI @}
334 \new Staff @{ \violinII @}
341 @node Titles and headers
342 @section Titles and headers
344 Almost all printed music includes a title and the composer's name;
345 some pieces include a lot more information.
353 @node Creating titles
354 @subsection Creating titles
356 Titles are created for each @code{\score} block, and over a
359 The contents of the titles are taken from the @code{\header} blocks.
360 The header block for a book supports the following
366 The dedicatee of the music, centered at the top of the first page.
370 The title of the music, centered just below the dedication.
374 Subtitle, centered below the title.
378 Subsubtitle, centered below the subtitle.
382 Name of the poet, flush-left below the subtitle.
386 Name of the composer, flush-right below the subtitle.
390 Meter string, flush-left below the poet.
394 Name of the opus, flush-right below the composer.
398 Name of the arranger, flush-right below the opus.
402 Name of the instrument, centered below the arranger. Also
403 centered at the top of pages (other than the first page).
407 Name of the piece, flush-left below the instrument.
409 @cindex page breaks, forcing
412 This forces the title to start on a new page (set to ##t or ##f).
416 Copyright notice, centered at the bottom of the first page. To
417 insert the copyright symbol, see @ref{Text encoding}.
421 Centered at the bottom of the last page.
425 Here is a demonstration of the fields available. Note that you
426 may use any @ref{Text markup} commands in the header.
428 @lilypond[quote,verbatim,line-width=11.0\cm]
431 paper-height = 10.0\cm
436 dedication = "dedicated to me"
437 title = \markup \center-align { "Title first line" "Title second line,
439 subtitle = "the subtitle,"
440 subsubtitle = #(string-append "subsubtitle LilyPond version "
443 composer = \markup \center-align { "composer" \small "(1847-1973)" }
444 texttranslator = "Text Translator"
445 meter = \markup { \teeny "m" \tiny "e" \normalsize "t" \large "e" \huge
447 arranger = \markup { \fontsize #8.5 "a" \fontsize #2.5 "r" \fontsize
448 #-2.5 "r" \fontsize #-5.3 "a" \fontsize #7.5 "nger" }
449 instrument = \markup \bold \italic "instrument"
473 As demonstrated before, you can use multiple @code{\header} blocks.
474 When same fields appear in different blocks, the latter is used.
475 Here is a short example.
479 composer = "Composer"
487 piece = "New piece" % overwrite previous one
492 If you define the @code{\header} inside the @code{\score} block, then
493 normally only the @code{piece} and @code{opus} headers will be printed.
494 Note that the music expression must come before the @code{\header}.
496 @lilypond[quote,verbatim,line-width=11.0\cm]
500 title = "title" % not printed
507 @findex printallheaders
509 You may change this behavior (and print all the headers when defining
510 @code{\header} inside @code{\score}) by using
520 @subsection Custom titles
522 A more advanced option is to change the definitions of the following
523 variables in the @code{\paper} block. The init file
524 @file{ly/titling-init.ly} lists the default layout.
527 @findex bookTitleMarkup
528 @item bookTitleMarkup
529 This is the title put over an entire @code{\book} block. Typically,
530 it has the composer and the title of the piece
532 @findex scoreTitleMarkup
533 @item scoreTitleMarkup
534 This is the title put over a @code{\score} block within a
535 @code{\book}. Typically, it has the name of the movement (@code{piece}
538 @findex oddHeaderMarkup
539 @item oddHeaderMarkup
540 This is the page header for odd-numbered pages.
542 @findex evenHeaderMarkup
543 @item evenHeaderMarkup
544 This is the page header for even-numbered pages. If unspecified,
545 the odd header is used instead.
547 By default, headers are defined such that the page number is on the
548 outside edge, and the instrument is centered.
550 @findex oddFooterMarkup
551 @item oddFooterMarkup
552 This is the page footer for odd-numbered pages.
554 @findex evenFotterMarkup
555 @item evenFooterMarkup
556 This is the page footer for even-numbered pages. If unspecified,
557 the odd header is used instead.
559 By default, the footer has the copyright notice on the first, and
560 the tagline on the last page.
570 The following definition will put the title flush left, and the
571 composer flush right on a single line.
575 bookTitleMarkup = \markup {
577 \fromproperty #'header:title
578 \fromproperty #'header:composer
587 The @code{breakbefore=##t} header requires that there is a @code{piece}
588 header as well. It may be used as a normal header, or left blank
589 (@code{=""}) as in the example above, but it must be present.
593 @node Multiple movements
594 @section Multiple movements
596 @cindex bibliographic information
599 @cindex Music engraving by LilyPond
601 A document may contain multiple pieces of music and texts. Examples
602 of these are an etude book, or an orchestral part with multiple
603 movements. Each movement is entered with a @code{\score} block,
611 and texts are entered with a @code{\markup} block,
621 The movements and texts are combined together in a @code{\book} block,
639 The header for each piece of music can be put inside the @code{\score}
640 block. The @code{piece} name from the header will be printed before
641 each movement. The title for the entire book can be put inside the
642 @code{\book}, but if it is not present, the @code{\header} which is at
643 the top of the file is inserted.
645 @cindex Engraved by LilyPond
646 @cindex signature line
651 title = "Eight miniatures"
652 composer = "Igor Stravinsky"
656 \header @{ piece = "Romanze" @}
659 ..text of second verse..
662 ..text of third verse..
666 \header @{ piece = "Menuetto" @}
679 MIDI (Musical Instrument Digital Interface) is a standard for
680 connecting and controlling digital instruments. A MIDI file is a
681 series of notes in a number of tracks. It is not an actual
682 sound file; you need special software to translate between the
683 series of notes and actual sounds.
685 Pieces of music can be converted to MIDI files, so you can listen to
686 what was entered. This is convenient for checking the music; octaves
687 that are off or accidentals that were mistyped stand out very much
688 when listening to the MIDI output.
692 Many musically interesting effects, such as swing, articulation,
693 slurring, etc., are not translated to midi.
695 The midi output allocates a channel for each staff, and one for global
696 settings. Therefore the midi file should not have more than 15 staves
697 (or 14 if you do not use drums). Other staves will remain silent.
699 Not all midi players correctly handle tempo changes in the midi
700 output. Players that are known to work include
701 @uref{http://@/timidity@/.sourceforge@/.net/,timidity}.
704 * Creating MIDI files::
706 * MIDI instrument names::
709 @node Creating MIDI files
710 @subsection Creating MIDI files
712 To create a MIDI from a music piece of music, add a @code{\midi} block
713 to a score, for example,
718 \midi @{ \tempo 4=72 @}
722 The tempo is specified using the @code{\tempo} command. In this
723 example the tempo of quarter notes is set to 72 beats per minute.
726 If there is a @code{\midi} command in a @code{\score}, only MIDI will
727 be produced. When notation is needed too, a @code{\layout} block must
733 \midi @{ \tempo 4=72 @}
741 Ties, dynamics, and tempo changes are interpreted. Dynamic marks,
742 crescendi and decrescendi translate into MIDI volume levels. Dynamic
743 marks translate to a fixed fraction of the available MIDI volume
744 range, crescendi and decrescendi make the volume vary linearly between
745 their two extremes. The fractions can be adjusted by
746 @code{dynamicAbsoluteVolumeFunction} in @internalsref{Voice} context.
747 For each type of MIDI instrument, a volume range can be defined. This
748 gives a basic equalizer control, which can enhance the quality of
749 the MIDI output remarkably. The equalizer can be controlled by
750 setting @code{instrumentEqualizer}, or by setting
753 \set Staff.midiMinimumVolume = #0.2
754 \set Staff.midiMaximumVolume = #0.8
757 To remove dynamics from the MIDI output, insert the following lines
758 in the @code{\midi@{@}} section.
765 \remove "Dynamic_performer"
766 \remove "Span_dynamic_performer"
774 Unterminated (de)crescendos will not render properly in the midi file,
775 resulting in silent passages of music. The workaround is to explicitly
776 terminate the (de)crescendo. For example,
783 will not work properly but
794 @subsection MIDI block
798 The MIDI block is analogous to the layout block, but it is somewhat
799 simpler. The @code{\midi} block can contain
803 @item a @code{\tempo} definition, and
804 @item context definitions.
807 A number followed by a period is interpreted as a real number, so
808 for setting the tempo for dotted notes, an extra space should be
809 inserted, for example
812 \midi @{ \tempo 4 . = 120 @}
816 @cindex context definition
818 Context definitions follow precisely the same syntax as within the
819 \layout block. Translation modules for sound are called performers.
820 The contexts for MIDI output are defined in @file{ly/@/performer@/-init@/.ly}.
823 @node MIDI instrument names
824 @subsection MIDI instrument names
826 @cindex instrument names
827 @findex Staff.midiInstrument
829 The MIDI instrument name is set by the @code{Staff.midiInstrument}
830 property. The instrument name should be chosen from the list in
831 @ref{MIDI instruments}.
834 \set Staff.midiInstrument = "glockenspiel"
838 If the selected instrument does not exactly match an instrument from
839 the list of MIDI instruments, the Grand Piano (@code{"acoustic grand"})
843 @c Yes, this is a cop-out; this info doesn't belong in the Scheme
844 @c chapter, but I'm not certain where to stick it.
845 @c I think I'll eventually split this chapter into a "paper/layout"
846 @c chapter and a "misc issues" chapter. -gp
847 @node Displaying LilyPond notation
848 @section Displaying LilyPond notation
850 @findex \displayLilyMusc
851 Displaying a music expression in LilyPond notation can be
852 done using the music function @code{\displayLilyMusic}. For example,
856 \displayLilyMusic \transpose c a, @{ c e g a bes @}
866 By default, LilyPond will print these messages to the console along
867 with all the other messages. To split up these messages and save
868 the results of @code{\display@{STUFF@}}, redirect the output to
872 lilypond file.ly >display.txt
876 @node Skipping corrected music
877 @section Skipping corrected music
880 @findex skipTypesetting
881 @findex showLastLength
883 When entering or copying music, usually only the music near the end (where
885 are adding notes) is interesting to view and correct. To speed up
886 this correction process, it is possible to skip typesetting of all but
887 the last few measures. This is achieved by putting
890 showLastLength = R1*5
895 in your source file. This will render only the last 5 measures
896 (assuming 4/4 time signature) of every @code{\score} in the input
897 file. For longer pieces, rendering only a small part is often an order
898 of magnitude quicker than rendering it completely
900 Skipping parts of a score can be controlled in a more fine-grained
901 fashion with the property @code{Score.skipTypesetting}. When it is
902 set, no typesetting is performed at all.
904 This property is also used to control output to the MIDI file. Note that
905 it skips all events, including tempo and instrument changes. You have
908 @lilypond[quote,fragment,ragged-right,verbatim]
911 \set Score.skipTypesetting = ##t
913 \set Score.skipTypesetting = ##f
917 In polyphonic music, @code{Score.skipTypesetting} will affect all
918 voices and staves, saving even more time.