3 @c TODO: LilyPond Lilypond lilypond
9 LilyPond prints music from a specification that you, the user, supply.
10 You have to give that specification using a textual @emph{language}.
11 This chapter is a gentle introduction to that language.
13 This tutorial will demonstrate how to use Lilypond by presenting
14 examples of input along with resulting output. We will use English
15 terms for notation. In case you are not familiar with those, you may
16 consult the glossary that is distributed with LilyPond.
18 @cindex examples, tutorial
20 The examples discussed are included in the distribution, in the
21 subdirectory @file{input/tutorial/}@footnote{When we refer
22 to filenames, they are relative to the top directory of the source
23 package. In binary installations you should look in your doc section,
24 eg, @code{/usr/share/doc/lilypond1.3/examples/input/tutorial}
26 }. We recommend that you experiment with writing Lilypond input
27 yourself, to get a feel for how the program behaves.
30 * Running LilyPond:: Getting started
31 * The first tune:: The first tune
32 * Lyrics and chords:: Lyrics and chords
34 * A piano excerpt:: Piano music
35 * An orchestral score::
36 * Other ways to run LilyPond::
37 * Integrating text and music::
38 * end of tutorial:: The end
42 @node Running LilyPond
43 @section Running LilyPond
45 Before we dive into describing the input language of LilyPond, we first
46 show you through the procedure for getting notes on your screen and out
49 The first step is creating an input file. Using your favorite
50 text-editor, create @file{test.ly} containing
54 NOTE: if you're reading this, ie, the Texinfo source itself, test.ly
55 should of course contain:
65 \notes @{ c'4 e' g' @}
69 @unnumberedsubsec Unix
70 @cindex Unix, Running lilypond on
73 On unix, you invoke ly2dvi to compile your lilypond source file (you can
80 You will see the following on your screen:
84 Now processing: `/home/fred/ly/test.ly'
86 Interpreting music...[1]
87 Preprocessing elements...
88 Calculating column positions... [2]
89 paper output to test.tex...
94 PS output to test.ps...
95 DVI output to test.dvi...
98 The results of the ly2dvi run are a ``DeVice Independent'' file
99 (@file{test.dvi}) and a PostScript file (@file{test.ps}).
103 @cindex Viewing music
107 To view the @code{test.dvi} output, run Xdvi (you may omit the
114 @c FIXME: should we say anything on xdvi-gs interaction?
116 You should see the following in a window next to some buttons.
123 When you're satisfied with the result, you can print the
129 If this does not make your printer produce a page of music, you should
130 look into installing and configuring ghostscript. Refer to
131 GhostScript's website at @uref{http://www.ghostscript.com}.
134 @cindex Printing output
140 @unnumberedsubsec Windows
143 On windows, you open a LilyPond shell, and then you invoke ly2dvi
144 compile your lilypond source file, just like on Unix:
150 You will see the following on your screen:
152 @c FIXME: leave this out, just refer to unix section?
153 @c FIXME: commands run in dos shell: we can't redirect output
156 Now processing: `/home/tim/ly/test.ly'
158 Interpreting music...[1]
159 Preprocessing elements...
160 Calculating column positions... [2]
161 paper output to test.tex...
163 This is TeX, Version 3.14159 (MiKTeX 2)
165 Babel <v3.6Z> and hyphenation patterns for english, french, german, ngerman, du
166 mylang, nohyphenation, loaded.
168 (test.latex (C:\cygwin\usr\windows\MiKTeX\tex\latex\base\article.cls
169 Document Class: article 2000/05/19 v1.4b Standard LaTeX document class
170 (C:\cygwin\usr\windows\MiKTeX\tex\latex\base\size10.clo))
171 (C:\cygwin\usr\lilypond-1.3.150.jcn2\share\lilypond\tex\geometry.sty
172 (C:\cygwin\usr\windows\MiKTeX\tex\latex\graphics\keyval.sty))
173 (C:\cygwin\usr\windows\MiKTeX\tex\latex\base\inputenc.sty
174 (C:\cygwin\usr\windows\MiKTeX\tex\latex\base\latin1.def))
175 (C:\cygwin\usr\lilypond-1.3.150.jcn2\share\lilypond\tex\titledefs.tex)
178 (C:\cygwin\usr\lilypond-1.3.150.jcn2\share\lilypond\tex\lilyponddefs.tex
179 (C:\cygwin\usr\lilypond-1.3.150.jcn2\share\lilypond\tex\lilypond-latex.tex
181 (C:\cygwin\usr\lilypond-1.3.150.jcn2\share\lilypond\tex\feta20.tex)
182 (C:\cygwin\usr\lilypond-1.3.150.jcn2\share\lilypond\tex\lily-ps-defs.tex)
184 Overfull \hbox (15.0pt too wide) in paragraph at lines 20--24
187 Overfull \vbox (0.7539pt too high) has occurred while \output is active
189 (see the transcript file for additional information)
190 Output written on test.dvi (1 page, 4292 bytes).
191 Transcript written on test.log.
192 This is dvips(k) 5.86 Copyright 1999 Radical Eye Software (www.radicaleye.com)
193 ' TeX output 2001.04.25:0015' -> test.ps
194 <texc.pro><special.pro>. [1]
196 Analyzing test.tex...
197 PS output to test.ps...
198 DVI output to test.dvi...
201 To view the @code{test.dvi} output, run Yap
207 You should see the following in a window
214 @c FIXME: talk about newer Yap versions, proper gs installation?
215 When you're satisfied with the result, you can print from within Yap
216 (File/Print). Note that Yap may not display embedded PostScript symbols
217 such as beams and slurs. Don't worry, they'll be printed anyway.
219 You can also print the PostScript file directly from the
220 command line using GSview:
229 @section The first tune
232 To demonstrate what LilyPond input looks like, we start off with a
233 full-fledged, yet simple example. It is a convoluted version
234 of the famous minuet in J. S. Bach's @emph{Klavierb@"uchlein}. The file
235 is included in the distribution as @file{minuet.ly}.
236 @cindex Bach, Johann Sebastian
239 % all text after a percent sign is a comment
240 % and is ignored by Lilypond
241 \include "paper16.ly"
244 \relative c'' \sequential {
249 d4 g,8 a b c d4 g, g |
250 e'4 c8 d e fis g4 g, g |
251 c4 d8( )c b a( )b4 c8 b a g |
252 a4 [b8 a] [g fis] g2. |
257 g4 e8 fis g d cis4 b8 cis a4 |
258 a8-. b-. cis-. d-. e-. fis-.
265 % standard settings are too wide for a book
271 We will analyse the input, line by line.
274 % all text after a percent sign is a comment
275 % and is ignored by Lilypond
277 The percent sign, @code{%}, introduces a line comment. You can also
278 comment out a block of several lines, by enclosing them in
279 @code{%@{} and @code{%@}}.
281 @cindex block comment
286 \include "paper16.ly"
289 @cindex @code{\include}
290 @cindex point, printer's
291 @cindex staff size setting
292 By default, LilyPond will typeset the music in a size such that each
293 staff is 20 point@footnote{A point is the standard measure of length for
294 printing; one point is 1/72.27 inch.} high. We want smaller
295 output (16 point staff height), so we must import the settings for that
296 size, which is done here.
303 Music is printed by combining a piece of music with directions for
304 outputting it. This combination is formed in the @code{\score} block.
311 Prepare LilyPond for accepting notes.
312 @cindex octaves, choosing
321 As we will see, each note is described by its note name, duration,
322 octave and possibly a chromatic alteration. In this setup, the octave
323 is indicated by using high quotes (@code{'}) and ``lowered quotes''
324 (commas: @code{,}). The central C is denoted by @code{c'}. The C one
325 octave higher is @code{c''}. One and two octaves below the central C is
326 denoted by @code{c} and @code{c,} respectively.
328 Even though a piece of music often spans a range of several octaves, it
329 mostly moves in small intervals. LilyPond has a special entry mode to
330 save typing in this situation. In this ``relative'' octave mode,
331 octaves of notes without quotes are chosen such that a note is as close
332 as possible (graphically, on the staff) to the preceding note. If you
333 add a high-quote an extra octave is added. A lowered quote (a comma)
334 will subtract an extra octave.
336 Because the first note has no predecessor,
337 you have to give the (absolute) pitch of the note to start with.
344 What follows is sequential music, i.e.,
345 @cindex sequential music
346 notes that are to be played and printed after each other.
353 @cindex time signature, setting
355 Set (or change) the time signature of the current piece: a 3/4 sign is
356 printed. The time signature setting is also used to generate bar lines
364 @cindex key signature, setting
366 Set (or change) the current key signature to G-major. Although in this
367 example, the @code{\key} command happened to be entered after the
368 @code{\time} command, in the output the time signature will be printed
369 after the key signature; LilyPond knows about music typesetting
377 The following piece of music is played twice. The first argument
378 indicates the type of repeat. In this case, @code{"volta"} means that
379 prima volta/secunda volta brackets are used for the alternative
380 endings---if there were any.
387 The subject of the repeat is again sequential music. Since
388 @code{\sequential} is such a common construct, a shorthand is provided:
389 just leave off @code{\sequential}, and the result is the same.
396 Two notes. The first note is a quarter note with relative pitch
397 @code{d}. The relative music was started with a @code{c''}, so the real
398 pitch of this note is @code{d''}. The duration of a note is designated
399 by a number; the @code{4} here represents a quarter note.
401 The second note is an eight note with relative pitch @code{g,}. The
402 pitch is taken relative to the previous @code{d''}, making this
403 note have real pitch @code{g'}. The @code{8} represents an eight note.
410 Two more notes, with pitch @code{a} and @code{b}. Because their
411 duration is the same as the @code{g,8}, there is no need to enter the
412 duration, but you may enter it anyway, i.e., @code{a4 b4}
421 @cindex errors, finding
422 Three more notes. The @code{|} character is a ``bar check''. LilyPond
423 will verify that bar checks are found at the start of a measure. This can
424 help you track down typing errors.
426 @cindex alteration, chromatic
427 @cindex chromatic alteration
434 So far, no notes were chromatically altered. Here is the first one that
435 is: @code{fis}. Lilypond by default uses Dutch@footnote{Note names are
436 available in several languages, but we find the Dutch names quite
437 convenient.} note names, and ``Fis'' is the Dutch note name for ``F
438 sharp''. However, there is no sharp sign in the output. The program
439 keeps track of key signatures, and will only print accidentals if they
442 For groups of eighth notes and shorter, LilyPond can determine how the
443 notes should form a beam. In this case, the 4 eights are automatically
448 c4 d8( )c b a( )b4 c8 b a g |
451 The beginning and ending notes of a slur are marked with parentheses,
452 @code{(} and @code{)} for start and end respectively. The line above
453 indicates two slurs. These slur markers (parentheses) are entered
454 between the slurred notes.
461 Automatic beaming can be overridden by inserting beam marks, @code{[}
462 and @code{]}. These beam markers (brackets) are put around the notes
470 @cindex augmentation dot
472 A period adds an augmentation dot to the note.
479 The end of the sequential music to be repeated. LilyPond will typeset a
487 Accidentals are printed whenever necessary: the first C sharp of the bar
488 will be printed with an accidental, the second one without.
492 a8-. b-. cis-. d-. e-. fis-.
496 You can enter articulation signs either in a verbose form or using a
497 shorthand. Here we demonstrate the shorthand: it is formed by a dash
498 and the character for the articulation to use, e.g. @code{-.} for
499 staccato as shown above.
507 Rests are denoted by the special notename @code{r}.
514 All articulations have a verbose form, like @code{\fermata}. The
515 command @code{\fermata} is not part of the core of the language, but it
516 is a shorthand for a more complicated description of a fermata symbol.
517 @code{\fermata} names that description and is therefore called an
520 @cindex @code{\fermata}
526 Here the music ends. LilyPond does not automatically typeset and end
527 bar, we must explicitely request one, using @code{"|."}.
537 The @code{\paper} block specifies how entered music should be converted
538 to notation output. Most of the details of the conversion (font sizes,
539 dimensions, etc.) have been taken care of, but to fit the output in this
540 document, it has to be narrower. We do this by setting the line width
541 to 14 centimeters (approximately 5.5 inches).
548 The last brace ends the @code{\score} block.
553 @node Lyrics and chords
554 @section Lyrics and chords
556 In this section we show how to typeset a song. This file is
557 included as @file{flowing.ly}.
561 title = "The river is flowing"
562 composer = "Traditional"
564 \include "paper16.ly"
565 melody = \notes \relative c' @{
569 c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
570 c4 c8 d [es () d] c4 | d4 es8 d c4.
575 The ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
576 ri -- ver is flo -- wing down to the sea.
579 accompaniment =\chords @{
581 c2:3- f:3-.7 d:min es4 c8:min r8
582 c2:min f:min7 g:7^3.5 c:min @}
587 \context ChordNames \accompaniment
590 \context Staff = mel @{
591 \property Staff.noAutoBeaming = ##t
592 \property Staff.automaticMelismata = ##t
595 \context Lyrics \text
597 \midi @{ \tempo 4=72 @}
598 \paper @{ linewidth = 10.0\cm @}
603 The result would look this.@footnote{The titling and font size shown
604 may differ, since the titling in this document is not generated by
607 @center @strong{The river is flowing}
612 title = "The river is flowing"
613 composer = "Traditional"
615 \include "paper16.ly"
616 melody = \notes \relative c' {
620 c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
621 c4 c8 d [es () d] c4 | d4 es8 d c4.
626 The ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
627 ri -- ver is flo -- wing down to the sea.
630 accompaniment =\chords {
632 c2:3- f:3-.7 d:min es4 c8:min r8
633 c2:min f:min7 g:7^3.5 c:min }
638 \context ChordNames \accompaniment
641 \context Staff = mel {
642 \property Staff.noAutoBeaming = ##t
643 \property Staff.automaticMelismata = ##t
646 \context Lyrics \text
648 \midi { \tempo 4=72 }
649 \paper { linewidth = 10.0\cm }
653 Again, we will dissect the file line by line.
660 @cindex @code{\header}
661 Information about the music you are about to typeset goes into a
662 @code{\header} block. The information in this block is not used by
663 LilyPond, but it is passed into the output. @file{ly2dvi} uses this
664 information to print titles above the music.
668 title = "The river is flowing"
669 composer = "Traditional (?)"
672 @cindex identifier assignment
673 the @code{\header} block contains assignments. In each assignment, a
674 variable is set to a value. Lexically, both the variable name and the
675 assigned value are strings. The values have to be quoted here, because
676 they contain spaces, the variable names could also be put within quotes
677 but it is not necessary.
681 \include "paper16.ly"
684 Smaller size for inclusion in a book.
688 melody = \notes \relative c' @{
691 The structure of the file will be the same as the previous one, a
692 @code{\score} block with music in it. To keep things readable, we will
693 give names to the different parts of music, and use the names to
694 construct the music within the score block.
701 @cindex @code{\partial}
703 The piece starts with an anacrusis of one eighth.
708 The key is C minor: we have three flats.
713 c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
714 c4 c8 d [es () d] c4 | d4 es8 d c4.
719 @cindex manual beaming
720 @cindex automatic beaming, turning off
721 We use explicit beaming. Since this is a song, we turn automatic
722 beams off, and use explicit beaming where needed.
729 This ends the definition of @code{melody}.
738 @cindex identifier assignment
739 @cindex syllables, entering
740 Another identifier assignment. This one is for the lyrics.
741 Lyrics are formed by syllables that have duration, and not by
742 notes. To make LilyPond parse words as syllables, switch it into
743 lyrics mode with @code{\lyrics}. Again, the brace after @code{\lyrics}
744 is a shorthand for @code{\sequential @{}.
748 The4 ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
749 ri- ver is flo- __ wing down to the sea.
753 @cindex extenders, lyric
754 @cindex hyphens, lyric
755 The syllables themselves are separated by spaces. You can get syllable
756 extenders by entering @code{__}, and centered hyphens with
757 @code{-}@code{-}. We enter the syllables as if they are all quarter notes
758 in length (hence the @code{4}), and use a feature to align the
759 syllables to the music, which obviously isn't all quarter notes.
763 accompaniment =\chords @{
768 We'll put chords over the music. To enter them, there is a special mode
769 analogous to @code{\lyrics} and @code{\notes} mode, where you can give
770 the names of the chords you want, instead of listing the notes
771 comprising the chord.
778 There is no accompaniment during the anacrusis.
787 @cindex chord modifier
788 @cindex modifier, chord
789 A chord is started by the tonic of the chord. The
790 first one lasts a half note. An unadorned note creates a major
791 triad. Since a minor triad is wanted, @code{3-} is added to modify the
792 third to be small. @code{7} modifies (adds) a seventh, which is small by
793 default to create the @code{f a c es} chord. Multiple modifiers must be
802 Some modifiers have predefined names, eg. @code{min} is the same as
803 @code{3-}, so @code{d-min} is a minor @code{d} chord.
807 c2:min f:min7 g:7^3.5 c:min @}
810 @cindex named modifier
812 A named modifier @code{min} and a normal modifier @code{7} do not have
813 to be separated by a dot. Tones from a chord are removed with chord
814 subtractions. Subtractions are started with a caret, and they are
815 also separated by dots. In this example, @code{g:7^3.5} produces a
816 minor seventh. The brace ends the sequential music.
824 We assemble the music in the @code{\score} block. Melody, lyrics and
825 accompaniment have to sound at the same time, so they should be
826 @code{\simultaneous}.
827 @cindex @code{\simultaneous}
834 Chord mode generates notes grouped in @code{\simultaneous} music. If
835 you remove the comment sign, you can see the chords in normal
836 notation: they will be printed as note heads on a separate
837 staff. To print them as chords names, they have to be interpreted as
838 being chords, not notes. This is done with the following command:
842 \context ChordNames \accompaniment
846 @cindex interpretation context
847 @cindex notation context
850 Normally, the notes that you enter are transformed into note heads.
851 Note heads alone make no sense, they need surrounding information: a key
852 signature, a clef, staff lines, etc. They need @emph{context}. In
853 LilyPond, these symbols are created by objects called `interpretation
854 contexts'. Interpretation contexts exist for generating notation
855 (`notation context') and for generating sound (`performance
856 context'). These objects only exist during a run of LilyPond.
858 By default, LilyPond will create a Staff context for you. If you would
859 remove the @code{%} sign in the previous line, you would see that
862 We don't want that default here, because we want chord names. The
863 command above explicitly creates an interpretation context of
864 @code{ChordNames} type to interpret the music @code{\accompaniment}.
871 @cindex @code{\addlyrics}
872 @cindex lyrics and melody, combining
873 @cindex combining lyrics and melody
875 The lyrics should be aligned with the melody. This is done by
876 combining both with @code{\addlyrics}. @code{\addlyrics} takes two
877 pieces of music (usually a melody and lyrics, in that order) and
878 aligns the syllables of the second piece under the notes of the
879 first piece. If you would reverse the order, the notes would be
880 aligned on the lyrics, which is not very useful, and looks
885 \context Staff = mel @{
889 The second argument of @code{\addlyrics} is the melody. We instantiate
890 a @code{Staff} context explicitly: should you choose to remove the
891 comment before the ``note heads'' version of the accompaniment, the
892 accompaniment will be on a nameless staff. The melody has to be on
893 staff different from the accompaniment. This is accomplished by giving
894 the melody and accompaniment staffs different names.
898 \property Staff.noAutoBeaming = ##t
902 @cindex context variables
903 @cindex setting context variables
904 An interpretation context has variables, called properties, that tune
905 its behaviour. One of the variables is @code{noAutoBeaming}. Setting
906 this Staff's property to @code{##t}, which is the boolean value @var{true},
907 turns the automatic beaming mechanism off for the current staff.
910 @cindex accessing Scheme
911 @cindex evaluating Scheme
914 LilyPond internally uses GUILE, a Scheme-interpreter. Scheme is a
915 language from the LISP family. You can learn more about Scheme at
916 @uref{http://www.scheme.org}. It is used to represent data throughout
917 the whole program. The hash-sign (@code{#}) accesses GUILE directly: the
918 code following the hash-sign is evaluated as Scheme. The boolean value
919 @var{true} is @code{#t} in Scheme, so for LilyPond @var{true} looks like
922 If Scheme scares you, don't worry. You don't need to know Scheme to
923 create beautiful sheet music.
930 \property Staff.automaticMelismata = ##t
933 @cindex automaticMelismata
935 @cindex @code{\addlyrics} and slurs
936 Similarly, we don't want to print a syllable when there is
937 a slur. This sets up @code{\addlyrics} to not put lyrics under each
938 separate note while there is a slur.
946 Finally, we put the melody on the current staff. Note that the
947 @code{\property} directives and @code{\melody} are grouped in sequential
948 music, so the property settings are done before the melody is
953 \context Lyrics \text
956 The second argument of @code{\addlyrics} is the text. The text also
957 should not land on a Staff, but on a interpretation context for
958 syllables, extenders, hyphens etc. This context is called
963 \midi @{ \tempo 4=72@}
966 MIDI (Musical Instrument Digital Interface) is a standard for
967 connecting and recording digital instruments. So a MIDI file is like a
968 tape recording of an instrument. The @code{\midi} block causes makes the
969 music go to a MIDI file, so you can listen to the music you entered. It
970 is great for checking the music. Whenever you hear something weird, you
971 probably hear a typing error.
973 Syntactically, @code{\midi} is similar to @code{\paper @{ @}}, since it
974 also specifies an output method. You can specify the tempo using the
975 @code{\tempo} command, in this case the tempo of quarter notes is set to
980 \paper @{ linewidth = 10.0\cm @}
983 We also want notation output. The linewidth is short so the piece
984 will be set in two lines.
987 @section More movements
989 [FIXME: merge here with, or move this to: Other ways to run LilyPond]
991 You probably ran @file{ly2dvi} on the last example, and ended up with a
992 viewable @file{.dvi} file. However, between there are a few steps of
993 which LilyPond is only one. To enhance your understanding of what's
994 happening under the hood when you run @code{ly2dvi}, we explain what
997 @code{ly2dvi} is a program that calls a number of programs in sequence.
998 The first thing it does, is running LilyPond on the input file. After
999 some calculations, a @file{.tex} is produced. The contents
1000 of this file are very low-level instructions.
1002 For example, the following file (@file{miniatures.ly})
1006 \header @{ title = "Two miniatures" @}
1008 #(set! point-and-click line-column-location)
1010 \paper @{ linewidth = -1.0 @}
1013 \notes @{ c'4 d'4 @}
1019 \notes @{ d'4 c'4 @}
1026 The titling in this manual was not generated by ly2dvi, so we can't
1027 exactly show it would look, but the result should resemble this:
1029 @center @strong{Two miniatures}
1039 \paper { linewidth = -1.0 }
1051 \paper { linewidth = -1.0 }
1055 This file is produced by ly2dvi in a few stages, with the help of text
1056 formatting tools. LilyPond produces two output files, @file{miniatures.tex}
1057 and @file{miniatures-1.tex}. They both look like this:
1061 \placebox@{-5 \outputscale @}%
1062 @{ 8.7229 \outputscale @}%
1063 @{\magfontWXGEomMMBo\char90 @}%
1065 \placebox@{-4 \outputscale @}%
1066 @{ 81.0647 \outputscale @}%
1070 @file{ly2dvi} looks at what output LilyPond produces, and generates a
1071 file called @file{ly2dvi.out.tex}. This file contains formatting
1072 instructions for the title and page layout. A fragment might look like
1076 \def\lilypondopus@{Opus 1.@}
1077 \def\lilypondpiece@{Up@}
1078 \def\mustmakelilypondtitle@{@}
1079 \input miniatures.tex
1080 \def\lilypondtitle@{Two miniatures@}
1084 @file{ly2dvi} runs it through LaTeX. LaTeX is a text-formatting system
1085 built on top of @TeX{}. It's very popular in the academic world. If LaTeX
1086 is successful, this will produce a @file{.dvi} file, containing both the
1087 titling and the actual music. @code{ly2dvi} completes its task by
1088 deleting the two temporary files, leaving only @file{miniatures.dvi}.
1090 Next, now we'll look at the example line by line to explain new things.
1096 Lilypond and its language are still under development, and occasionally,
1097 details of the syntax are changed. This fragment indicates for which
1098 version the input file was written. When you compile this file, the
1099 version number will be checked, and you will get a warning when the file
1102 This version number is also used by the @code{convert-ly} program (See
1103 @ref{convert-ly}), which uses it to update the file to the latest lily
1108 \header @{ title = "Two miniatures" @}
1110 This sets the titling information for the entire file.
1114 #(set! point-and-click line-column-location)
1117 This piece of Scheme code sets the Scheme variable
1118 @code{point-and-click} to the value @var{line-column-location} (which
1119 itself is a Scheme procedure).
1121 Editing input files can be quite complicated if you're working with
1122 large files: if you're digitizing existing music, you have to
1123 synchronize the .ly file, the sheet music on your lap and the sheet
1124 music on the screen. The point-and-click mechanism makes it easy to
1125 find the origin of an error in the .ly file: when you view the file with
1126 Xdvi and click on a note, your editor will jump to the spot where that
1127 note was entered. For more information, see @ref{Point and click}.
1134 The @code{\score} blocks that follow in the file don't have
1135 @code{\paper} sections, so the settings of this block are substituted: A
1136 paper block, at top-level, i.e. not in a @code{\score} block sets the
1137 default page layout.
1146 The variable @code{linewidth} normally sets the length of the systems on
1147 the page. However, a negative value has a special meaning. If
1148 @code{linewidth} is less than 0, no line breaks are inserted into the
1149 score, and the spacing is set to natural length: a short phrase takes up
1150 little space, a longer phrase more space.
1155 \notes @{ c'4 d'4 @}
1158 In previous examples, notes were specified in relative octaves,
1159 i.e. each note was put in the octave that would put it closest to its
1160 predecessor. Besides relative, there is also absolute octave
1161 specification, which you get when you don't specify @code{\relative}. In
1162 this input mode, the central C is denoted by @code{c'}. Going down, you
1163 get @code{c} @code{c,} @code{c,,} etc. Going up, you get @code{c''}
1166 When you're copying music from existing sheet music, relative octaves
1167 are probably the easiest to use: it's less typing work and errors are
1168 easily spotted. However, if you write LilyPond input, either by hand
1169 (ie. composing) or by computer, absolute octaves are probably less work.
1177 The @code{\header} is normally at the top of the file, where it sets
1178 values for the rest of the file. If you want to typeset different pieces
1179 from one file (for example, if there are multiple movements, or if
1180 you're making an exercise book), you can put different @code{\score}
1181 blocks into the input file. ly2dvi will assemble all LilyPond output
1182 files into a big document. The contents of \header blocks specified
1183 within each score, are used for the titling of each movement.
1189 For example, the Opus number is put at the right, and the piece string
1190 will be at the left.
1194 @node A piano excerpt
1195 @section A piano excerpt
1197 Our fourth subject is a piece of piano music. The fragment in the input
1198 file is a piano reduction of the G major Sinfonia by Giovanni Battista
1199 Sammartini. It was composed around 1740. It's in the source package
1200 under the name @file{sammartini.ly}.
1203 \include "paper16.ly"
1205 stemDown = \property Voice.Stem \override #'direction = #-1
1206 stemUp = \property Voice.Stem \override #'direction = #1
1207 stemBoth = \property Voice.Stem \revert #'direction
1209 viola = \notes \relative c' \context Voice = viola {
1210 <c4-\f-\arpeggio g' c>
1216 oboes = \notes \relative c'' \context Voice = oboe {
1217 \stemUp s4 g8. b,16 c8 r <e'8.^\p g> <f16 a>
1218 \grace <e8( g> <d4 )f> <c2 e>
1219 \times 2/3 { <d8 \< f> <e g> <f a> }
1221 { \times 2/3 { a8 g c } \! c2 }
1222 \context Voice = oboeTwo {
1225 \property Grace.Stem \override #'direction = #-1
1231 \grace <c,8( e> <)b8. d8.-\trill> <c16 e> |
1232 [<d ( f> < )f8. a>] <)b,8 d> r [<d16( f> <f8. )a>] <b,8 d> r |
1233 [<c16( e> < )e8. g>] <c8 e,>
1236 hoomPah = \repeat unfold 8 \notes
1237 \transpose c' { \stemUp c8 \stemBoth \stemDown c'8 \stemBoth }
1239 bassvoices = \notes \relative c' {
1241 \autochange Staff \hoomPah
1242 \translator Staff = down
1243 \stemDown [c8 c'8] r4
1245 < {\stemUp r2 <e4 c'> <c8 g'> }
1246 \context Voice = reallyLow {\stemDown g2 ~ | g4 c8 } >
1250 \context PianoStaff \notes <
1251 \context Staff = up < \time 2/2
1255 \context Staff = down < \time 2/2 \clef bass
1262 linewidth = 15.0 \cm }
1266 If this looks like incomprehensible gibberish to you, you are right.
1267 This example has been doctored to have as many quirks as possible.
1269 As you can see, this example features multiple voices on one staff. To
1270 make room for those voices, their notes have to be stemmed in opposite
1273 Printed symbols are internally represented by so-called Graphical
1274 Objects (more colloquially: Grobs). These statements concern the
1275 grob called `Stem'. Each grob is described by a bunch of settings. These
1276 setting determine the fonts, offsets, sub-routines to be called on the
1277 grob, etc. The initial values of these settings are set in the Scheme
1278 file @file{scm/grob-description.scm}.
1282 stemDown = \property Voice.Stem \override #'direction = #-1
1285 Set a proprerty for all Stem grobs in the current Voice:
1286 @code{direction} is set to @code{-1}, which encodes down. The setting
1287 remains in effect until it is reverted.
1291 \property Voice.Stem \revert #'direction
1294 Revert the to the previous setting. The effect of precisely one
1295 @code{\stemDown} or @code{\stemUp} is neutralised.
1298 LilyPond includes the identifiers @code{\stemUp}, @code{\stemDown} along
1299 with some other commonly used formatting instructions, but to explain how
1300 it works, we wrote our own here. Of course, you should use predefined
1301 identifiers like these if possible: then you will be affected less by
1302 the implementation changes we occasionally make.
1306 viola = \notes \relative c' \context Voice = viola @{
1308 In this example, you can see multiple parts on a staff. Each part is
1309 associated with one notation context. This notation context handles
1310 stems and dynamics (among others). The name of this context is
1311 @code{Voice}. For each part we have to make sure that there is
1312 precisely one @code{Voice} context, so we give it an unique name
1317 <c4-\f-\arpeggio g' c>
1319 The delimiters @code{<} and @code{>} are shorthands for
1320 @code{\simultaneous @{} and @code{@}}. The expression enclosed in
1321 @code{<} and @code{>} is a chord.
1328 @code{\f} places a forte symbol under the chord. The forte applies to
1329 the whole chord, but the syntax requires that commands like forte and
1330 arpeggio are attached to a note, so here we attach them to the first
1333 @code{\arpeggio} typesets an arpeggio sign (a wavy vertical line) before
1346 Relative octaves work a little differently with chords. The starting
1347 point for the note following a chord is the first note of the chord. So
1348 the @code{g} gets an octave up quote: it is a fifth above the starting
1349 note of the previous chord (the central C).
1355 @code{s} is a spacer rest. It does not print anything, but it does have
1356 the duration of a rest. It is useful for filling up voices that
1357 temporarily don't play. In this case, the viola doesn't come until one
1358 and a half measure later.
1362 oboes = \notes \relative c'' \context Voice = oboe @{
1364 Now comes a part for two oboes. They play homophonically, so we
1365 print the notes as one voice that makes chords. Again, we insure that
1366 these notes are indeed processed by precisely one context with
1370 \stemUp s4 g8. b,16 c8 r <e'8.-\p g> <f16 a>
1372 @code{\stemUp} is a reference to the @code{\property \override} command
1376 \grace <e8 g> < d4 f> <c2 e>
1378 @cindex @code{\grace}
1382 @code{\grace} introduces grace notes. It takes one argument, in this
1386 The slur started on the @code{e} of the chord
1387 will be attached to the next note.@footnote{LilyPond will squirm
1388 about unended Slurs. In this case, you can ignore the warning}.
1396 Tuplets are made with the @code{\times} keyword. It takes two
1397 arguments: a fraction and a piece of music. The duration of the piece
1398 of music is multiplied by the fraction. Triplets make notes occupy 2/3
1399 of their notated duration, so in this case the fraction is 2/3.
1402 @{ <d8 \< f> <e g> <f a> @}
1404 The piece of music to be `tripletted' is sequential music containing
1405 three notes. On the first chord, a crescendo is started with
1406 @code{\<}. To be precise, the crescendo start is syntactically attached
1407 to the preceding note, the @code{d}.
1417 At this point, the homophonic music splits into two rhythmically
1418 different parts. We can't use a sequence of chords to enter this, so
1419 we make a `chord' of sequences to do it. We start with the upper
1420 voice, which continues with upward stems:
1423 @{ \times 2/3 @{ a8 g c @} \! c2 @}
1428 The crescendo is ended at the half note by the escaped exclamation
1432 \context Voice = oboeTwo @{
1435 We can't share stems with the other voice, so we have to create a new
1436 @code{Voice} context. We give it the name @code{oboeTwo} to distinguish
1437 it from the other context. Stems go down in this voice.
1442 @cindex Grace context
1443 When a grace section is processed, a @code{Grace} context is
1444 created. This context acts like a miniature score of its own. It has
1445 its own time bookkeeping, and you can make notes, beams, slurs
1446 etc. Here we fiddle with a property and make a beam. The argument of
1447 @code{\grace} is sequential music.
1451 \property Grace.Stem \override #'direction = #-1
1455 Normally, grace notes are always stem up, but in this case, the upper
1456 voice interferes. We set the stems down here.
1458 As far as relative mode is concerned, the previous note is the
1459 @code{c'''2} of the upper voice, so we have to go an octave down for
1467 This ends the two-part section.
1471 \grace <c,8( e> <)b8. d8.-\trill> <c16 e> |
1476 @code{\stemBoth} ends the forced stem directions. From here, stems are
1477 positioned as if it were single part music.
1479 The bass has a little hoom-pah melody to demonstrate parts switching
1480 between staffs. Since it is repetitive, we use repeats:
1483 hoomPah = \repeat unfold 8
1485 @cindex unfolded @code{\repeat}
1486 The unfolded repeat prints the notes in its argument as if they were
1487 written out in full eight times.
1490 \notes \transpose c' @{
1493 @cindex relative mode and transposing
1495 Transposing can be done with @code{\transpose}. It takes two arguments
1496 the first specifies what central C should be transposed to. The second
1497 is the to-be-transposed music. As you can see, in this case, the
1498 transposition has no effect, as central C stays at central C.
1500 The purpose of this no-op is circumventing relative mode. Relative mode
1501 can not be used together with transposition, so @code{\relative} will
1502 leave the contents of @code{\hoomPah} alone. We can use it without
1503 having to worry about getting the motive in a wrong octave.
1506 bassvoices = \notes \relative c' @{
1508 \autochange Staff \hoomPah
1510 @cindex staff switch, automatic
1511 @cindex cross staff voice, automatic
1512 @cindex @code{\autochange}
1514 Voices can switch between staffs. The easiest way to get this, is to use
1515 @code{\autochange}. This command looks at the pitch of each note, and if
1516 necessary, will cross to the other staff. For this to work, the two
1517 staffs must be called @code{"up"} and @code{"down"}.
1520 \translator Staff = down
1522 @cindex staff switch
1523 @cindex cross staff voice
1524 We want the remaining part of this melody on the lower staff, so we do a
1525 manual staff switch here.
1530 \context Voice = reallyLow @{\stemDown g2 ~ | g4 c8 @} >
1534 After skipping some lines, we see @code{~}. This mark makes ties. Note
1535 that ties and slurs are different things. A tie can only connect two
1536 note heads of the same pitch, whereas a slur can connect many chords
1543 A special context is needed to get cross staff beaming right. This
1544 context is called @code{PianoStaff}.
1547 \context Staff = bottom < \time 2/2 \clef bass
1549 The bottom staff must have a different clef.
1554 To make some more room on the line, the first (in this case the only)
1555 line is not indented. The line still looks very cramped, but that is due
1556 to the page layout of this document.
1562 * font-size, multi-stanza.
1564 * Simple part combining in a Hymn
1568 @node An orchestral score
1569 @section An orchestral score
1573 * Extracting an individual part::
1577 Our last two examples show a way to setup the music for an orchestral
1578 score. When typesetting a piece for several instruments, you'll want to
1579 create a conductor's full score, alongside several individual parts.
1581 LilyPond is well suited for this task. We will declare the music for
1582 each instrument individually, giving the music of each instrument its
1583 own name. These pieces of music are then combined in different
1584 @code{\score} blocks to produce different combinations of the score.
1586 This orchestral score example consists of three input files. In the
1587 first file, @file{os-music.ly}, we define the music for all instruments.
1588 This file will be used both for producing the score and the separate
1591 If you were to run lilypond on this file, no printable output would be
1597 title = "Zo, goed lieverd?"
1598 subtitle = "How's, this babe?"
1607 Key = \notes \key as \major
1608 flautoI = \notes\relative c'' @{
1610 bes as bes as bes as bes as
1612 flautoII = \notes\relative c'' @{
1613 as8 bes as bes R1 d4 ~ d
1615 tromboI = \notes\relative c'' @{
1616 c4. c8 c8 c4. es4 r as, r
1618 tromboII = \notes\relative c'' @{
1619 as4. as8 as8 as4. R1*1/2 as4 es'
1621 timpani = \notes\relative c, @{
1622 \times 2/3 @{ f4 f f @}
1623 \times 4/5 @{ as8 as as as as @}
1626 corno = \notes\relative c' @{
1627 bes4 d f, bes d f, bes d
1631 We will not go through the input line by line, but only indicate and
1632 explain the new elements.
1639 \skip 2*4 \bar "|.";
1643 Declare setting to be used globally. The @code{\skip} command produces
1644 no output, but moves forward in time: in this case, the duration of a
1645 half note (@code{2}), and that four times (@code{*4}). This brings us
1646 to the end of the piece, and we can set the end bar.
1650 Key = \notes \key as \major
1652 Declare the key signature of the piece and assign it to the identifier
1653 @var{Key}. Lateron, we'll use @code{\Key} for all staffs except those
1654 for transposing instruments.
1656 @node The full score
1657 @subsection The full score
1660 The second file, @file{os-score.ly} reads the definitions of the first
1661 (@file{os-music.ly}), and defines the @code{\score} block for the full
1667 \include "os-music.ly"
1668 \include "paper13.ly"
1670 #(set! point-and-click line-column-location)
1671 #(define text-flat '((font-relative-size . -2)
1672 (music "accidentals--1")))
1677 \property Score.BarNumber \override #'padding = #3
1678 \context StaffGroup = woodwind <
1679 \context Staff = flauti <
1680 \property Staff.midiInstrument = #"flute"
1681 \property Staff.instrument = "2 Flauti"
1682 \property Staff.instr = "Fl."
1684 \context Voice=one @{ \voiceOne \flautoI @}
1685 \context Voice=two @{ \voiceTwo \flautoII @}
1688 \context StaffGroup = timpani <
1689 \context Staff = timpani <
1690 \property Staff.midiInstrument = #"timpani"
1691 \property Staff.instrument = #'(lines "Timpani" "(C-G)")
1692 \property Staff.instr = #"Timp."
1698 \context StaffGroup = brass <
1699 \context Staff = trombe <
1700 \property Staff.midiInstrument = #"trumpet"
1701 \property Staff.instrument = #`(lines "2 Trombe" "(C)")
1702 \property Staff.instr = #`(lines "Tbe." "(C)")
1704 \context Voice=one \partcombine Voice
1705 \context Thread=one \tromboI
1706 \context Thread=two \tromboII
1708 \context Staff = corni <
1709 \property Staff.midiInstrument = #"french horn"
1710 \property Staff.instrument = #`(lines "Corno"
1711 (columns "(E" ,text-flat ")"))
1712 \property Staff.instr = #`(lines "Cor."
1713 (columns "(E" ,text-flat ")"))
1714 \property Staff.transposing = #3
1715 \notes \key bes \major
1716 \context Voice=one \corno
1721 indent = 15 * \staffspace
1722 linewidth = 60 * \staffspace
1723 textheight = 90 * \staffspace
1726 \consists "Multi_measure_rest_engraver"
1729 \HaraKiriStaffContext
1730 \remove "Multi_measure_rest_engraver"
1739 @center @strong{Zo, goed lieverd?}
1741 @center How's, this babe?
1749 @lilypondfile{os-score.ly}
1753 \include "os-music.ly"
1755 First, we need to include the music definitions we made in
1760 #(set! point-and-click line-column-location)
1762 In a large orchestral score like this you're bound to make some small
1763 mistakes, so we enable point and click (See @ref{Point and click})
1768 #(define text-flat '((font-relative-size . -2)
1769 (music "accidentals--1")))
1772 When naming the tuning of the french horn, we'll need a piece of text
1773 with a flat sign. LilyPond has a mechanism for font selection and
1774 kerning called Scheme markup text (See @ref{Text markup}). The flat
1775 sign is taken from the music font, and its name is @code{accidentals--1}
1776 (The sharp sign is called @code{accidentals-+1}). The default font is
1777 too big for text, so we select a relative size of @code{-2}.
1784 Of course, all staffs are simultaneous and use the same global settings.
1788 \property Score.BarNumber \override #'padding = #3
1790 LilyPond prints bar numbers at the start of each line, but
1791 unfortunately, they end up a bit too close to the staff in this example.
1792 A bar number internally is a Grob called @var{BarNumber}. BarNumber
1793 Grobs can be manipulated through their @var{side-position-interface}. One
1794 of the properties of a @var{side-position-interface} that can be tweaked
1795 is the @var{padding}: the amount of extra space that is put between this
1796 Grob and other Grobs. We set the padding to three staff spaces.
1798 You can find all this kind of information in LilyPond's automatically
1799 generated documentation in
1801 @ref{ (lilypond-internals)lilypond-internals, LilyPond Internals}.
1804 the online documentation.
1809 \context StaffGroup = woodwind <
1810 \context Staff = flauti <
1812 A new notation context: the StaffGroup. StaffGroup can hold one or more
1813 Staffs, and will print a big bracket at the left of the score. Start a
1814 new staff group for the woodwind section (just the flutes in this case).
1815 Immediately after that, we start the staff for the two flutes, that also
1816 play simultaneously.
1820 \property Staff.midiInstrument = #"flute"
1822 Specify the instrument for MIDI output (see @ref{MIDI instrument
1827 \property Staff.instrument = "2 Flauti"
1828 \property Staff.instr = "Fl."
1830 And define the instrument names to be printed in the margin,
1831 @code{instrument} for the first line of the score, @code{instr} for the
1838 The flutes play in the default key.
1842 \context Voice=one @{ \voiceOne \flautoI @}
1843 \context Voice=two @{ \voiceTwo \flautoII @}
1845 Last come the actual flute parts. Remember that we're still in
1846 simultaneous mode. We name both voices differently, so that LilyPond
1847 will actually create two Voice contexts. The flute parts are simple, so
1848 we specify manually which voice is which: @code{\voiceOne} forces the
1849 direction of stems, beams, slurs and ties up, @code{\voiceTwo} sets
1857 Close the flutes staff and woodwind staff group.
1861 \property Staff.instrument = #'(lines "Timpani" "(C-G)")
1863 The timpani staff only shows a new piece of scheme markup, it sets two
1868 \context Voice=one \partcombine Voice
1869 \context Thread=one \tromboI
1870 \context Thread=two \tromboII
1872 You have seen the notation contexts Staff and Voice, but here's a new
1873 one: Thread. One or more Threads can be part of a Voice. The Thread
1874 takes care of note heads and rests, the Voice combine note heads onto a
1877 For the trumpets we use the automatic part combiner (see @ref{Automatic
1878 part combining}) to combine the two simultaneous trumpet parts onto the
1879 trumpet staff. Each trumpet gets its own Thread context, which must be
1880 named @code{one} and @code{two}). The part combiner makes these two
1881 threads share a Voice when they're similar, and splits the threads up
1882 when they're different.
1886 \property Staff.instrument = #`(lines "Corno"
1887 (columns "(E" ,text-flat ")"))
1889 The french horn has the most complex scheme markup name, made up of two
1890 lines of text. The second line has two elements (columns), the @code{E}
1891 and the flat sign @code{text-flat} that we defined before.
1895 \property Staff.transposing = #3
1897 The french horn is to be tuned in E-flat, so we tell the MIDI backend to
1898 transpose this staff by three steps.
1900 Note how we can choose different tuning for entering, printing and
1901 playing, using @code{\transpose} and the MIDI Staff proprerty
1906 \notes \key bes \major
1908 Therefore, it has a different key.
1912 indent = 15 * \staffspace
1913 linewidth = 60 * \staffspace
1915 We specify a big indent for the first line and a small linewidth for this
1920 Usually, LilyPond's predefined setup of notation contexts (Thread,
1921 Voice, Staff, Staffgroup, Score) is just fine. But in this case, we
1922 want a different type of Staff context.
1924 In orchestral scores, it often happens that one instrument has only
1925 rests during one line of the score. The @code{HaraKiriStaffContext} can
1926 be used as a regular @code{StaffContext} drop-in and will take care of
1927 the automatic removing of empty staffs.
1929 @node Extracting an individual part
1930 @subsection Extracting an individual part
1932 The third file, @file{os-flute-2.ly} also reads the definitions of the
1933 first (@file{os-music.ly}), and defines the @code{\score} block for the
1937 \include "os-music.ly"
1938 \include "paper16.ly"
1942 \property Score.skipBars = ##t
1943 \property Staff.midiInstrument = #"flute"
1949 instrument = "Flauto II"
1952 linewidth = 80 * \staffspace
1953 textheight = 200 * \staffspace
1961 @center @strong{Zo, goed lieverd?}
1963 @center How's, this babe?
1964 @center @emph{Flauto II}
1971 @lilypondfile{os-flute-2.ly}
1974 Because we separated the music definitions from the @code{\score}
1975 instantiations, we can easily define a second score from the music of
1976 the second flute. This then is the part for the second flute player.
1977 Of course, we make separate parts for all individual instruments.
1983 In this individual part the second flute has a whole staff for itself,
1984 so we don't want to force stem or tie directions.
1989 instrument = "Flauto II"
1992 The @code{\header} definitions were also read from @file{os-music.ly},
1993 but we need to set the instrument for this particular score.
1997 \property Score.skipBars = ##t
1999 In the conductor's full score, all bars with rests are printed, but for
2000 the individual parts, we want to contract pieces of consecutive empty
2001 bars. LilyPond will do this if Score's @var{skipBars} property to
2005 @node Other ways to run LilyPond
2006 @section Other ways to run LilyPond
2008 Until now, you have been using @file{ly2dvi} to invoke LilyPond.
2009 There are three other routes. Firstly, there is a script called
2010 @code{lilypond-book}, that allows you to freely mix LilyPond input with
2011 Texinfo or LaTeX input. For example, this manual was written using
2012 @code{lilypond-book}. It is discussed in @ref{lilypond-book}.
2015 Secondly, you can generate PostScript directly. This is useful if you
2016 can not or do not want to run @TeX{} on your system. To obtain direct
2017 PostScript output, invoke LilyPond as follows:
2018 @cindex PostScript output
2020 lilypond -f ps test.ly
2022 You have to set some environment variables to view or print this
2023 output. More information can be found in @ref{Invoking
2027 Thirdly, if you want to do special things with your output, you can run
2028 invoke lilypond directly:
2032 to produce plain @TeX{} output. Note that La@TeX{} will not work on the
2033 resulting @file{test.tex}. You must run plain @TeX{} on it.
2041 @node Integrating text and music
2042 @section Integrating text and music
2044 Sometimes, you might want to use music examples in a text that you are
2045 writing. For example, if you are writing a musicological treatise, a
2046 songbook, or (like us) the LilyPond manual. You can make such texts by
2047 hand, simply by importing a PostScript figure into your wordprocessor.
2048 However, there is a also an automated procedure:
2050 If you use La@TeX{} or texinfo, you can mix text and lilypond code. A
2051 script called @code{lilypond-book} will extract the music fragments, run
2052 lilypond on them, and put back the resulting notation. lilypond-book is
2053 described fully in @ref{lilypond-book}, but here we show a small
2054 example. Since the example also contains explanatory text, we won't
2055 comment on the contents.
2058 \documentclass[a4paper]@{article@}
2061 In a lilypond-book document, you can freely mix music and text. For
2064 \score @{ \notes \relative c' @{
2065 c2 g'2 \times 2/3 @{ f8 e d @} c'2 g4
2068 Notice that the music line length matches the margin settings of the
2071 If you have no \verb+\score+ block in the fragment,
2072 \texttt@{lilypond-book@} will supply one:
2078 In the example you see here, a number of things happened: a
2079 \verb+\score+ block was added, and the line width was set to natural
2080 length. You can specify many more options using \LaTeX style options
2083 \begin[verbatim,11pt,singleline,
2084 fragment,relative,intertext="hi there!"]@{lilypond@}
2088 \texttt@{verbatim@} also shows the lilypond code, \texttt@{11pt@} selects
2089 the default music size, \texttt@{fragment@} adds a score block,
2090 \texttt@{relative@} uses relative mode for the fragment, and
2091 \texttt@{intertext@} specifies what to print between the
2092 \texttt@{verbatim@} code and the music.
2094 If you include large examples into the text, it may be more convenient
2095 to put the example in a separate file:
2097 \lilypondfile[printfilename]@{sammartini.ly@}
2099 The \texttt@{printfilename@} option adds the file name to the output.
2104 Under Unix, you can view the results as follows.
2107 $ lilypond-book --outdir=out/ lilbook.tex
2108 lilypond-book (GNU LilyPond) 1.3.146
2109 Reading `/home/hanwen/usr/src/lilypond-1.3.146/input/tutorial/lilbook.tex'
2111 `/home/hanwen/usr/src/lilypond-1.3.146/input/tutorial/sammartini.ly'
2112 @var{lots of stuff deleted}
2113 Writing `out/lilbook.latex'
2115 $ latex lilbook.latex
2116 @var{lots of stuff deleted}
2120 Notice the @code{outdir} option to lilypond-book. Running lilypond-book
2121 and running latex creates a lot of temporary files, and you wouldn't
2122 those to clutter up your working directory. Hence, we have them created
2123 in a separate subdirectory.
2125 The result more or less looks like this:
2129 In a lilypond-book document, you can freely mix music and text. For
2132 \score { \notes \relative c' {
2133 c2 g'2 \times 2/3 { f8 e d } c'2 g4
2136 Notice that the music line length matches the margin settings of the
2139 If you have no @code{\score} block in the fragment,
2140 @code{lilypond-book} will supply one:
2146 In the example you see here, a number of things happened: a
2147 @code{\score} block was added, and the line width was set to natural
2148 length. You can specify many more options using La@TeX{} style options
2151 @lilypond[verbatim,11pt,singleline,
2152 fragment,relative,intertext="hi there!"]
2156 @code{verbatim} also shows the lilypond code, @code{11pt} selects
2157 the default music size, @code{fragment} adds a score block,
2158 @code{relative} uses relative mode for the fragment, and
2159 @code{intertext} specifies what to print between the
2160 @code{verbatim} code and the music.
2162 If you include large examples into the text, it may be more convenient
2163 to put the example in a separate file:
2165 @lilypondfile[printfilename]{sammartini.ly}
2167 The @code{printfilename} option adds the file name to the output.
2168 @node end of tutorial
2171 That's all folks. From here, you can either try fiddling with input
2172 files, or you can read the reference manual. You can find more example
2173 files in @file{input} and @file{input/test}. You can also look at some
2174 real music. Have a look at the @uref{Mutopia project,
2175 http://www.mutopiaproject.org}.
2183 this should be on mutopia website.
2188 @c waar deze info? is uiteindelijk wel handig, schat ik.
2191 If you have a big music project, or just a lot of LilyPond input files,
2192 all generated output from LilyPond, @TeX{} and metafont will clutter
2193 your working directory. LilyPond comes with a one-size-fits-all
2194 pre-cooked makefile that helps you manage producing output. It will
2195 produce all output in the directory @file{out} , generate and track
2196 dependencies. Also, it helps in preparing your submission to @ref{Mutopia
2203 cp /usr/share/lilypond/make/ly.make GNUmakefile
2204 cp /usr/share/doc/lilypond/examples/input/tutorial/minuet.ly .
2207 Generated out/minuet.ps for target minuet.
2210 Type @samp{make help} to see possible targets.
2213 @file{/usr/share/lilypond/doc/lilypond/examples/input/mutopia-header.ly}
2219 [TODO: rewrite completely.]
2222 * Songs with additional verses::