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: `C:\cygwin\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:\Program Files\MiKTeX\tex\latex\base\article.cls
169 Document Class: article 2000/05/19 v1.4b Standard LaTeX document class
170 (C:\Program Files\MiKTeX\tex\latex\base\size10.clo))
171 (C:\cygwin\usr\lilypond-1.3.147\share\lilypond\tex\geometry.sty
172 (C:\Program Files\MiKTeX\tex\latex\graphics\keyval.sty))
173 (C:\Program Files\MiKTeX\tex\latex\base\inputenc.sty
174 (C:\Program Files\MiKTeX\tex\latex\base\latin1.def))
175 (C:\cygwin\usr\lilypond-1.3.147\share\lilypond\tex\titledefs.tex)
178 (C:\cygwin\usr\lilypond-1.3.147\share\lilypond\tex\lilyponddefs.tex
179 (C:\cygwin\usr\lilypond-1.3.147\share\lilypond\tex\lilypond-latex.tex
181 (C:\cygwin\usr\lilypond-1.3.147\share\lilypond\tex\feta20.tex)
182 (C:\cygwin\usr\lilypond-1.3.147\share\lilypond\tex\lily-ps-defs.tex)
184 (C:\cygwin\usr\lilypond-1.3.147\share\lilypond\tex\fetdefs.tex)))
185 Overfull \hbox (15.0pt too wide) in paragraph at lines 22--26
188 (see the transcript file for additional information)
189 Output written on test.dvi (1 page, 4292 bytes).
190 Transcript written on test.log.
191 This is dvips(k) 5.86 Copyright 1999 Radical Eye Software (www.radicaleye.com)
192 ' TeX output 2001.04.12:0033' -> test.ps
193 <texc.pro><special.pro>. [1]
195 Analyzing test.tex...
198 PS output to test.ps...
199 DVI output to test.dvi...
202 To view the @code{test.dvi} output, run Yap
208 You should see the following in a window
215 @c FIXME: talk about newer Yap versions, proper gs installation?
216 When you're satisfied with the result, you can print from within Yap
217 (File/Print). Note that Yap may not display embedded PostScript symbols
218 such as beams and slurs. Don't worry, they'll be printed anyway.
220 You can also print the PostScript file directly from the
221 command line using GSview:
230 @section The first tune
233 To demonstrate what LilyPond input looks like, we start off with a
234 full-fledged, yet simple example. It is a convoluted version
235 of the famous minuet in J. S. Bach's @emph{Klavierb@"uchlein}. The file
236 is included in the distribution as @file{minuet.ly}.
237 @cindex Bach, Johann Sebastian
240 % all text after a percent sign is a comment
241 % and is ignored by Lilypond
242 \include "paper16.ly"
245 \relative c'' \sequential {
250 d4 g,8 a b c d4 g, g |
251 e'4 c8 d e fis g4 g, g |
252 c4 d8( )c b a( )b4 c8 b a g |
253 a4 [b8 a] [g fis] g2. |
258 g4 e8 fis g d cis4 b8 cis a4 |
259 a8-. b-. cis-. d-. e-. fis-.
266 % standard settings are too wide for a book
272 We will analyse the input, line by line.
275 % all text after a percent sign is a comment
276 % and is ignored by Lilypond
278 The percent sign, @code{%}, introduces a line comment. You can also
279 comment out a block of several lines, by enclosing them in
280 @code{%@{} and @code{%@}}.
282 @cindex block comment
287 \include "paper16.ly"
290 @cindex @code{\include}
291 @cindex point, printer's
292 @cindex staff size setting
293 By default, LilyPond will typeset the music in a size such that each
294 staff is 20 point@footnote{A point is the standard measure of length for
295 printing; one point is 1/72.27 inch.} high. We want smaller
296 output (16 point staff height), so we must import the settings for that
297 size, which is done here.
304 Music is printed by combining a piece of music with directions for
305 outputting it. This combination is formed in the @code{\score} block.
312 Prepare LilyPond for accepting notes.
313 @cindex octaves, choosing
322 As we will see, each note is described by its note name, duration,
323 octave and possibly a chromatic alteration. In this setup, the octave
324 is indicated by using high quotes (@code{'}) and ``lowered quotes''
325 (commas: @code{,}). The central C is denoted by @code{c'}. The C one
326 octave higher is @code{c''}. One and two octaves below the central C is
327 denoted by @code{c} and @code{c,} respectively.
329 Even though a piece of music often spans a range of several octaves, it
330 mostly moves in small intervals. LilyPond has a special entry mode to
331 save typing in this situation. In this ``relative'' octave mode,
332 octaves of notes without quotes are chosen such that a note is as close
333 as possible (graphically, on the staff) to the preceding note. If you
334 add a high-quote an extra octave is added. A lowered quote (a comma)
335 will subtract an extra octave.
337 Because the first note has no predecessor,
338 you have to give the (absolute) pitch of the note to start with.
345 What follows is sequential music, i.e.,
346 @cindex sequential music
347 notes that are to be played and printed after each other.
354 @cindex time signature, setting
356 Set (or change) the time signature of the current piece: a 3/4 sign is
357 printed. The time signature setting is also used to generate bar lines
365 @cindex key signature, setting
367 Set (or change) the current key signature to G-major. Although in this
368 example, the @code{\key} command happened to be entered after the
369 @code{\time} command, in the output the time signature will be printed
370 after the key signature; LilyPond knows about music typesetting
378 The following piece of music is played twice. The first argument
379 indicates the type of repeat. In this case, @code{"volta"} means that
380 prima volta/secunda volta brackets are used for the alternative
381 endings---if there were any.
388 The subject of the repeat is again sequential music. Since
389 @code{\sequential} is such a common construct, a shorthand is provided:
390 just leave off @code{\sequential}, and the result is the same.
397 Two notes. The first note is a quarter note with relative pitch
398 @code{d}. The relative music was started with a @code{c''}, so the real
399 pitch of this note is @code{d''}. The duration of a note is designated
400 by a number; the @code{4} here represents a quarter note.
402 The second note is an eight note with relative pitch @code{g,}. The
403 pitch is taken relative to the previous @code{d''}, making this
404 note have real pitch @code{g'}. The @code{8} represents an eight note.
411 Two more notes, with pitch @code{a} and @code{b}. Because their
412 duration is the same as the @code{g,8}, there is no need to enter the
413 duration, but you may enter it anyway, i.e., @code{a4 b4}
422 @cindex errors, finding
423 Three more notes. The @code{|} character is a ``bar check''. LilyPond
424 will verify that bar checks are found at the start of a measure. This can
425 help you track down typing errors.
427 @cindex alteration, chromatic
428 @cindex chromatic alteration
435 So far, no notes were chromatically altered. Here is the first one that
436 is: @code{fis}. Lilypond by default uses Dutch@footnote{Note names are
437 available in several languages, but we find the Dutch names quite
438 convenient.} note names, and ``Fis'' is the Dutch note name for ``F
439 sharp''. However, there is no sharp sign in the output. The program
440 keeps track of key signatures, and will only print accidentals if they
443 For groups of eighth notes and shorter, LilyPond can determine how the
444 notes should form a beam. In this case, the 4 eights are automatically
449 c4 d8( )c b a( )b4 c8 b a g |
452 The beginning and ending notes of a slur are marked with parentheses,
453 @code{(} and @code{)} for start and end respectively. The line above
454 indicates two slurs. These slur markers (parentheses) are entered
455 between the slurred notes.
462 Automatic beaming can be overridden by inserting beam marks, @code{[}
463 and @code{]}. These beam markers (brackets) are put around the notes
471 @cindex augmentation dot
473 A period adds an augmentation dot to the note.
480 The end of the sequential music to be repeated. LilyPond will typeset a
488 Accidentals are printed whenever necessary: the first C sharp of the bar
489 will be printed with an accidental, the second one without.
493 a8-. b-. cis-. d-. e-. fis-.
497 You can enter articulation signs either in a verbose form or using a
498 shorthand. Here we demonstrate the shorthand: it is formed by a dash
499 and the character for the articulation to use, e.g. @code{-.} for
500 staccato as shown above.
508 Rests are denoted by the special notename @code{r}.
515 All articulations have a verbose form, like @code{\fermata}. The
516 command @code{\fermata} is not part of the core of the language, but it
517 is a shorthand for a more complicated description of a fermata symbol.
518 @code{\fermata} names that description and is therefore called an
521 @cindex @code{\fermata}
527 Here the music ends. LilyPond does not automatically typeset and end
528 bar, we must explicitely request one, using @code{"|."}.
538 The @code{\paper} block specifies how entered music should be converted
539 to notation output. Most of the details of the conversion (font sizes,
540 dimensions, etc.) have been taken care of, but to fit the output in this
541 document, it has to be narrower. We do this by setting the line width
542 to 14 centimeters (approximately 5.5 inches).
549 The last brace ends the @code{\score} block.
554 @node Lyrics and chords
555 @section Lyrics and chords
557 In this section we show how to typeset a song. This file is
558 included as @file{flowing.ly}.
562 title = "The river is flowing"
563 composer = "Traditional"
565 \include "paper16.ly"
566 melody = \notes \relative c' @{
570 c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
571 c4 c8 d [es () d] c4 | d4 es8 d c4.
576 The ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
577 ri -- ver is flo -- wing down to the sea.
580 accompaniment =\chords @{
582 c2:3- f:3-.7 d:min es4 c8:min r8
583 c2:min f:min7 g:7^3.5 c:min @}
588 \context ChordNames \accompaniment
591 \context Staff = mel @{
592 \property Staff.noAutoBeaming = ##t
593 \property Staff.automaticMelismata = ##t
596 \context Lyrics \text
598 \midi @{ \tempo 4=72 @}
599 \paper @{ linewidth = 10.0\cm @}
604 The result would look this.@footnote{The titling and font size shown
605 may differ, since the titling in this document is not generated by
608 @center @strong{The river is flowing}
613 title = "The river is flowing"
614 composer = "Traditional"
616 \include "paper16.ly"
617 melody = \notes \relative c' {
621 c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
622 c4 c8 d [es () d] c4 | d4 es8 d c4.
627 The ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
628 ri -- ver is flo -- wing down to the sea.
631 accompaniment =\chords {
633 c2:3- f:3-.7 d:min es4 c8:min r8
634 c2:min f:min7 g:7^3.5 c:min }
639 \context ChordNames \accompaniment
642 \context Staff = mel {
643 \property Staff.noAutoBeaming = ##t
644 \property Staff.automaticMelismata = ##t
647 \context Lyrics \text
649 \midi { \tempo 4=72 }
650 \paper { linewidth = 10.0\cm }
654 Again, we will dissect the file line by line.
661 @cindex @code{\header}
662 Information about the music you are about to typeset goes into a
663 @code{\header} block. The information in this block is not used by
664 LilyPond, but it is passed into the output. @file{ly2dvi} uses this
665 information to print titles above the music.
669 title = "The river is flowing"
670 composer = "Traditional (?)"
673 @cindex identifier assignment
674 the @code{\header} block contains assignments. In each assignment, a
675 variable is set to a value. Lexically, both the variable name and the
676 assigned value are strings. The values have to be quoted here, because
677 they contain spaces, the variable names could also be put within quotes
678 but it is not necessary.
682 \include "paper16.ly"
685 Smaller size for inclusion in a book.
689 melody = \notes \relative c' @{
692 The structure of the file will be the same as the previous one, a
693 @code{\score} block with music in it. To keep things readable, we will
694 give names to the different parts of music, and use the names to
695 construct the music within the score block.
702 @cindex @code{\partial}
704 The piece starts with an anacrusis of one eighth.
709 The key is C minor: we have three flats.
714 c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
715 c4 c8 d [es () d] c4 | d4 es8 d c4.
720 @cindex manual beaming
721 @cindex automatic beaming, turning off
722 We use explicit beaming. Since this is a song, we turn automatic
723 beams off, and use explicit beaming where needed.
730 This ends the definition of @code{melody}.
739 @cindex identifier assignment
740 @cindex syllables, entering
741 Another identifier assignment. This one is for the lyrics.
742 Lyrics are formed by syllables that have duration, and not by
743 notes. To make LilyPond parse words as syllables, switch it into
744 lyrics mode with @code{\lyrics}. Again, the brace after @code{\lyrics}
745 is a shorthand for @code{\sequential @{}.
749 The4 ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
750 ri- ver is flo- __ wing down to the sea.
754 @cindex extenders, lyric
755 @cindex hyphens, lyric
756 The syllables themselves are separated by spaces. You can get syllable
757 extenders by entering @code{__}, and centered hyphens with
758 @code{-}@code{-}. We enter the syllables as if they are all quarter notes
759 in length (hence the @code{4}), and use a feature to align the
760 syllables to the music, which obviously isn't all quarter notes.
764 accompaniment =\chords @{
769 We'll put chords over the music. To enter them, there is a special mode
770 analogous to @code{\lyrics} and @code{\notes} mode, where you can give
771 the names of the chords you want, instead of listing the notes
772 comprising the chord.
779 There is no accompaniment during the anacrusis.
788 @cindex chord modifier
789 @cindex modifier, chord
790 A chord is started by the tonic of the chord. The
791 first one lasts a half note. An unadorned note creates a major
792 triad. Since a minor triad is wanted, @code{3-} is added to modify the
793 third to be small. @code{7} modifies (adds) a seventh, which is small by
794 default to create the @code{f a c es} chord. Multiple modifiers must be
803 Some modifiers have predefined names, eg. @code{min} is the same as
804 @code{3-}, so @code{d-min} is a minor @code{d} chord.
808 c2:min f:min7 g:7^3.5 c:min @}
811 @cindex named modifier
813 A named modifier @code{min} and a normal modifier @code{7} do not have
814 to be separated by a dot. Tones from a chord are removed with chord
815 subtractions. Subtractions are started with a caret, and they are
816 also separated by dots. In this example, @code{g:7^3.5} produces a
817 minor seventh. The brace ends the sequential music.
825 We assemble the music in the @code{\score} block. Melody, lyrics and
826 accompaniment have to sound at the same time, so they should be
827 @code{\simultaneous}.
828 @cindex @code{\simultaneous}
835 Chord mode generates notes grouped in @code{\simultaneous} music. If
836 you remove the comment sign, you can see the chords in normal
837 notation: they will be printed as note heads on a separate
838 staff. To print them as chords names, they have to be interpreted as
839 being chords, not notes. This is done with the following command:
843 \context ChordNames \accompaniment
847 @cindex interpretation context
848 @cindex notation context
851 Normally, the notes that you enter are transformed into note heads.
852 Note heads alone make no sense, they need surrounding information: a key
853 signature, a clef, staff lines, etc. They need @emph{context}. In
854 LilyPond, these symbols are created by objects called `interpretation
855 contexts'. Interpretation contexts exist for generating notation
856 (`notation context') and for generating sound (`performance
857 context'). These objects only exist during a run of LilyPond.
859 By default, LilyPond will create a Staff context for you. If you would
860 remove the @code{%} sign in the previous line, you would see that
863 We don't want that default here, because we want chord names. The
864 command above explicitly creates an interpretation context of
865 @code{ChordNames} type to interpret the music @code{\accompaniment}.
872 @cindex @code{\addlyrics}
873 @cindex lyrics and melody, combining
874 @cindex combining lyrics and melody
876 The lyrics should be aligned with the melody. This is done by
877 combining both with @code{\addlyrics}. @code{\addlyrics} takes two
878 pieces of music (usually a melody and lyrics, in that order) and
879 aligns the syllables of the second piece under the notes of the
880 first piece. If you would reverse the order, the notes would be
881 aligned on the lyrics, which is not very useful, and looks
886 \context Staff = mel @{
890 The second argument of @code{\addlyrics} is the melody. We instantiate
891 a @code{Staff} context explicitly: should you choose to remove the
892 comment before the ``note heads'' version of the accompaniment, the
893 accompaniment will be on a nameless staff. The melody has to be on
894 staff different from the accompaniment. This is accomplished by giving
895 the melody and accompaniment staffs different names.
899 \property Staff.noAutoBeaming = ##t
903 @cindex context variables
904 @cindex setting context variables
905 An interpretation context has variables, called properties, that tune
906 its behaviour. One of the variables is @code{noAutoBeaming}. Setting
907 this Staff's property to @code{##t}, which is the boolean value @var{true},
908 turns the automatic beaming mechanism off for the current staff.
911 @cindex accessing Scheme
912 @cindex evaluating Scheme
915 LilyPond internally uses GUILE, a Scheme-interpreter. Scheme is a
916 language from the LISP family. You can learn more about Scheme at
917 @uref{http://www.scheme.org}. It is used to represent data throughout
918 the whole program. The hash-sign (@code{#}) accesses GUILE directly: the
919 code following the hash-sign is evaluated as Scheme. The boolean value
920 @var{true} is @code{#t} in Scheme, so for LilyPond @var{true} looks like
923 If Scheme scares you, don't worry. You don't need to know Scheme to
924 create beautiful sheet music.
931 \property Staff.automaticMelismata = ##t
934 @cindex automaticMelismata
936 @cindex @code{\addlyrics} and slurs
937 Similarly, we don't want to print a syllable when there is
938 a slur. This sets up @code{\addlyrics} to not put lyrics under each
939 separate note while there is a slur.
947 Finally, we put the melody on the current staff. Note that the
948 @code{\property} directives and @code{\melody} are grouped in sequential
949 music, so the property settings are done before the melody is
954 \context Lyrics \text
957 The second argument of @code{\addlyrics} is the text. The text also
958 should not land on a Staff, but on a interpretation context for
959 syllables, extenders, hyphens etc. This context is called
964 \midi @{ \tempo 4=72@}
967 MIDI (Musical Instrument Digital Interface) is a standard for
968 connecting and recording digital instruments. So a MIDI file is like a
969 tape recording of an instrument. The @code{\midi} block causes makes the
970 music go to a MIDI file, so you can listen to the music you entered. It
971 is great for checking the music. Whenever you hear something weird, you
972 probably hear a typing error.
974 Syntactically, @code{\midi} is similar to @code{\paper @{ @}}, since it
975 also specifies an output method. You can specify the tempo using the
976 @code{\tempo} command, in this case the tempo of quarter notes is set to
981 \paper @{ linewidth = 10.0\cm @}
984 We also want notation output. The linewidth is short so the piece
985 will be set in two lines.
988 @section More movements
990 [FIXME: merge here with, or move this to: Other ways to run LilyPond]
992 You probably ran @file{ly2dvi} on the last example, and ended up with a
993 viewable @file{.dvi} file. However, between there are a few steps of
994 which LilyPond is only one. To enhance your understanding of what's
995 happening under the hood when you run @code{ly2dvi}, we explain what
998 @code{ly2dvi} is a program that calls a number of programs in sequence.
999 The first thing it does, is running LilyPond on the input file. After
1000 some calculations, a @file{.tex} is produced. The contents
1001 of this file are very low-level instructions.
1003 For example, the following file (@file{miniatures.ly})
1007 \header @{ title = "Two miniatures" @}
1009 #(set! point-and-click line-column-location)
1011 \paper @{ linewidth = -1.0 @}
1014 \notes @{ c'4 d'4 @}
1020 \notes @{ d'4 c'4 @}
1027 The titling in this manual was not generated by ly2dvi, so we can't
1028 exactly show it would look, but the result should resemble this:
1030 @center @strong{Two miniatures}
1040 \paper { linewidth = -1.0 }
1052 \paper { linewidth = -1.0 }
1056 This file is produced by ly2dvi in a few stages, with the help of text
1057 formatting tools. LilyPond produces two output files, @file{miniatures.tex}
1058 and @file{miniatures-1.tex}. They both look like this:
1062 \placebox@{-5 \outputscale @}%
1063 @{ 8.7229 \outputscale @}%
1064 @{\magfontWXGEomMMBo\char90 @}%
1066 \placebox@{-4 \outputscale @}%
1067 @{ 81.0647 \outputscale @}%
1071 @file{ly2dvi} looks at what output LilyPond produces, and generates a
1072 file called @file{ly2dvi.out.tex}. This file contains formatting
1073 instructions for the title and page layout. A fragment might look like
1077 \def\lilypondopus@{Opus 1.@}
1078 \def\lilypondpiece@{Up@}
1079 \def\mustmakelilypondtitle@{@}
1080 \input miniatures.tex
1081 \def\lilypondtitle@{Two miniatures@}
1085 @file{ly2dvi} runs it through LaTeX. LaTeX is a text-formatting system
1086 built on top of @TeX{}. It's very popular in the academic world. If LaTeX
1087 is successful, this will produce a @file{.dvi} file, containing both the
1088 titling and the actual music. @code{ly2dvi} completes its task by
1089 deleting the two temporary files, leaving only @file{miniatures.dvi}.
1091 Next, now we'll look at the example line by line to explain new things.
1097 Lilypond and its language are still under development, and occasionally,
1098 details of the syntax are changed. This fragment indicates for which
1099 version the input file was written. When you compile this file, the
1100 version number will be checked, and you will get a warning when the file
1103 This version number is also used by the @code{convert-ly} program (See
1104 @ref{convert-ly}), which uses it to update the file to the latest lily
1109 \header @{ title = "Two miniatures" @}
1111 This sets the titling information for the entire file.
1115 #(set! point-and-click line-column-location)
1118 This piece of Scheme code sets the Scheme variable
1119 @code{point-and-click} to the value @var{line-column-location} (which
1120 itself is a Scheme procedure).
1122 Editing input files can be quite complicated if you're working with
1123 large files: if you're digitizing existing music, you have to
1124 synchronize the .ly file, the sheet music on your lap and the sheet
1125 music on the screen. The point-and-click mechanism makes it easy to
1126 find the origin of an error in the .ly file: when you view the file with
1127 Xdvi and click on a note, your editor will jump to the spot where that
1128 note was entered. For more information, see @ref{Point and click}.
1135 The @code{\score} blocks that follow in the file don't have
1136 @code{\paper} sections, so the settings of this block are substituted: A
1137 paper block, at top-level, i.e. not in a @code{\score} block sets the
1138 default page layout.
1147 The variable @code{linewidth} normally sets the length of the systems on
1148 the page. However, a negative value has a special meaning. If
1149 @code{linewidth} is less than 0, no line breaks are inserted into the
1150 score, and the spacing is set to natural length: a short phrase takes up
1151 little space, a longer phrase more space.
1156 \notes @{ c'4 d'4 @}
1159 In previous examples, notes were specified in relative octaves,
1160 i.e. each note was put in the octave that would put it closest to its
1161 predecessor. Besides relative, there is also absolute octave
1162 specification, which you get when you don't specify @code{\relative}. In
1163 this input mode, the central C is denoted by @code{c'}. Going down, you
1164 get @code{c} @code{c,} @code{c,,} etc. Going up, you get @code{c''}
1167 When you're copying music from existing sheet music, relative octaves
1168 are probably the easiest to use: it's less typing work and errors are
1169 easily spotted. However, if you write LilyPond input, either by hand
1170 (ie. composing) or by computer, absolute octaves are probably less work.
1178 The @code{\header} is normally at the top of the file, where it sets
1179 values for the rest of the file. If you want to typeset different pieces
1180 from one file (for example, if there are multiple movements, or if
1181 you're making an exercise book), you can put different @code{\score}
1182 blocks into the input file. ly2dvi will assemble all LilyPond output
1183 files into a big document. The contents of \header blocks specified
1184 within each score, are used for the titling of each movement.
1190 For example, the Opus number is put at the right, and the piece string
1191 will be at the left.
1195 @node A piano excerpt
1196 @section A piano excerpt
1198 Our fourth subject is a piece of piano music. The fragment in the input
1199 file is a piano reduction of the G major Sinfonia by Giovanni Battista
1200 Sammartini. It was composed around 1740. It's in the source package
1201 under the name @file{sammartini.ly}.
1204 \include "paper16.ly"
1206 stemDown = \property Voice.Stem \override #'direction = #-1
1207 stemUp = \property Voice.Stem \override #'direction = #1
1208 stemBoth = \property Voice.Stem \revert #'direction
1210 viola = \notes \relative c' \context Voice = viola {
1211 <c4-\f-\arpeggio g' c>
1217 oboes = \notes \relative c'' \context Voice = oboe {
1218 \stemUp s4 g8. b,16 c8 r <e'8.^\p g> <f16 a>
1219 \grace <e8( g> <d4 )f> <c2 e>
1220 \times 2/3 { <d8 \< f> <e g> <f a> }
1222 { \times 2/3 { a8 g c } \! c2 }
1223 \context Voice = oboeTwo {
1226 \property Grace.Stem \override #'direction = #-1
1232 \grace <c,8( e> <)b8. d8.-\trill> <c16 e> |
1233 [<d ( f> < )f8. a>] <)b,8 d> r [<d16( f> <f8. )a>] <b,8 d> r |
1234 [<c16( e> < )e8. g>] <c8 e,>
1237 hoomPah = \repeat unfold 8 \notes
1238 \transpose c' { \stemUp c8 \stemBoth \stemDown c'8 \stemBoth }
1240 bassvoices = \notes \relative c' {
1242 \autochange Staff \hoomPah
1243 \translator Staff = down
1244 \stemDown [c8 c'8] r4
1246 < {\stemUp r2 <e4 c'> <c8 g'> }
1247 \context Voice = reallyLow {\stemDown g2 ~ | g4 c8 } >
1251 \context PianoStaff \notes <
1252 \context Staff = up < \time 2/2
1256 \context Staff = down < \time 2/2 \clef bass
1263 linewidth = 15.0 \cm }
1267 If this looks like incomprehensible gibberish to you, you are right.
1268 This example has been doctored to have as many quirks as possible.
1270 As you can see, this example features multiple voices on one staff. To
1271 make room for those voices, their notes have to be stemmed in opposite
1274 Printed symbols are internally represented by so-called Graphical
1275 Objects (more colloquially: Grobs). These statements concern the
1276 grob called `Stem'. Each grob is described by a bunch of settings. These
1277 setting determine the fonts, offsets, sub-routines to be called on the
1278 grob, etc. The initial values of these settings are set in the Scheme
1279 file @file{scm/grob-description.scm}.
1283 stemDown = \property Voice.Stem \override #'direction = #-1
1286 Set a proprerty for all Stem grobs in the current Voice:
1287 @code{direction} is set to @code{-1}, which encodes down. The setting
1288 remains in effect until it is reverted.
1292 \property Voice.Stem \revert #'direction
1295 Revert the to the previous setting. The effect of precisely one
1296 @code{\stemDown} or @code{\stemUp} is neutralised.
1299 LilyPond includes the identifiers @code{\stemUp}, @code{\stemDown} along
1300 with some other commonly used formatting instructions, but to explain how
1301 it works, we wrote our own here. Of course, you should use predefined
1302 identifiers like these if possible: then you will be affected less by
1303 the implementation changes we occasionally make.
1307 viola = \notes \relative c' \context Voice = viola @{
1309 In this example, you can see multiple parts on a staff. Each part is
1310 associated with one notation context. This notation context handles
1311 stems and dynamics (among others). The name of this context is
1312 @code{Voice}. For each part we have to make sure that there is
1313 precisely one @code{Voice} context, so we give it an unique name
1318 <c4-\f-\arpeggio g' c>
1320 The delimiters @code{<} and @code{>} are shorthands for
1321 @code{\simultaneous @{} and @code{@}}. The expression enclosed in
1322 @code{<} and @code{>} is a chord.
1329 @code{\f} places a forte symbol under the chord. The forte applies to
1330 the whole chord, but the syntax requires that commands like forte and
1331 arpeggio are attached to a note, so here we attach them to the first
1334 @code{\arpeggio} typesets an arpeggio sign (a wavy vertical line) before
1347 Relative octaves work a little differently with chords. The starting
1348 point for the note following a chord is the first note of the chord. So
1349 the @code{g} gets an octave up quote: it is a fifth above the starting
1350 note of the previous chord (the central C).
1356 @code{s} is a spacer rest. It does not print anything, but it does have
1357 the duration of a rest. It is useful for filling up voices that
1358 temporarily don't play. In this case, the viola doesn't come until one
1359 and a half measure later.
1363 oboes = \notes \relative c'' \context Voice = oboe @{
1365 Now comes a part for two oboes. They play homophonically, so we
1366 print the notes as one voice that makes chords. Again, we insure that
1367 these notes are indeed processed by precisely one context with
1371 \stemUp s4 g8. b,16 c8 r <e'8.-\p g> <f16 a>
1373 @code{\stemUp} is a reference to the @code{\property \override} command
1377 \grace <e8 g> < d4 f> <c2 e>
1379 @cindex @code{\grace}
1383 @code{\grace} introduces grace notes. It takes one argument, in this
1387 The slur started on the @code{e} of the chord
1388 will be attached to the next note.@footnote{LilyPond will squirm
1389 about unended Slurs. In this case, you can ignore the warning}.
1397 Tuplets are made with the @code{\times} keyword. It takes two
1398 arguments: a fraction and a piece of music. The duration of the piece
1399 of music is multiplied by the fraction. Triplets make notes occupy 2/3
1400 of their notated duration, so in this case the fraction is 2/3.
1403 @{ <d8 \< f> <e g> <f a> @}
1405 The piece of music to be `tripletted' is sequential music containing
1406 three notes. On the first chord, a crescendo is started with
1407 @code{\<}. To be precise, the crescendo start is syntactically attached
1408 to the preceding note, the @code{d}.
1418 At this point, the homophonic music splits into two rhythmically
1419 different parts. We can't use a sequence of chords to enter this, so
1420 we make a `chord' of sequences to do it. We start with the upper
1421 voice, which continues with upward stems:
1424 @{ \times 2/3 @{ a8 g c @} \! c2 @}
1429 The crescendo is ended at the half note by the escaped exclamation
1433 \context Voice = oboeTwo @{
1436 We can't share stems with the other voice, so we have to create a new
1437 @code{Voice} context. We give it the name @code{oboeTwo} to distinguish
1438 it from the other context. Stems go down in this voice.
1443 @cindex Grace context
1444 When a grace section is processed, a @code{Grace} context is
1445 created. This context acts like a miniature score of its own. It has
1446 its own time bookkeeping, and you can make notes, beams, slurs
1447 etc. Here we fiddle with a property and make a beam. The argument of
1448 @code{\grace} is sequential music.
1452 \property Grace.Stem \override #'direction = #-1
1456 Normally, grace notes are always stem up, but in this case, the upper
1457 voice interferes. We set the stems down here.
1459 As far as relative mode is concerned, the previous note is the
1460 @code{c'''2} of the upper voice, so we have to go an octave down for
1468 This ends the two-part section.
1472 \grace <c,8( e> <)b8. d8.-\trill> <c16 e> |
1477 @code{\stemBoth} ends the forced stem directions. From here, stems are
1478 positioned as if it were single part music.
1480 The bass has a little hoom-pah melody to demonstrate parts switching
1481 between staffs. Since it is repetitive, we use repeats:
1484 hoomPah = \repeat unfold 8
1486 @cindex unfolded @code{\repeat}
1487 The unfolded repeat prints the notes in its argument as if they were
1488 written out in full eight times.
1491 \notes \transpose c' @{
1494 @cindex relative mode and transposing
1496 Transposing can be done with @code{\transpose}. It takes two arguments
1497 the first specifies what central C should be transposed to. The second
1498 is the to-be-transposed music. As you can see, in this case, the
1499 transposition has no effect, as central C stays at central C.
1501 The purpose of this no-op is circumventing relative mode. Relative mode
1502 can not be used together with transposition, so @code{\relative} will
1503 leave the contents of @code{\hoomPah} alone. We can use it without
1504 having to worry about getting the motive in a wrong octave.
1507 bassvoices = \notes \relative c' @{
1509 \autochange Staff \hoomPah
1511 @cindex staff switch, automatic
1512 @cindex cross staff voice, automatic
1513 @cindex @code{\autochange}
1515 Voices can switch between staffs. The easiest way to get this, is to use
1516 @code{\autochange}. This command looks at the pitch of each note, and if
1517 necessary, will cross to the other staff. For this to work, the two
1518 staffs must be called @code{"up"} and @code{"down"}.
1521 \translator Staff = down
1523 @cindex staff switch
1524 @cindex cross staff voice
1525 We want the remaining part of this melody on the lower staff, so we do a
1526 manual staff switch here.
1531 \context Voice = reallyLow @{\stemDown g2 ~ | g4 c8 @} >
1535 After skipping some lines, we see @code{~}. This mark makes ties. Note
1536 that ties and slurs are different things. A tie can only connect two
1537 note heads of the same pitch, whereas a slur can connect many chords
1544 A special context is needed to get cross staff beaming right. This
1545 context is called @code{PianoStaff}.
1548 \context Staff = bottom < \time 2/2 \clef bass
1550 The bottom staff must have a different clef.
1555 To make some more room on the line, the first (in this case the only)
1556 line is not indented. The line still looks very cramped, but that is due
1557 to the page layout of this document.
1563 * font-size, multi-stanza.
1565 * Simple part combining in a Hymn
1569 @node An orchestral score
1570 @section An orchestral score
1574 * Extracting an individual part::
1578 Our last two examples show a way to setup the music for an orchestral
1579 score. When typesetting a piece for several instruments, you'll want to
1580 create a conductor's full score, alongside several individual parts.
1582 LilyPond is well suited for this task. We will declare the music for
1583 each instrument individually, giving the music of each instrument its
1584 own name. These pieces of music are then combined in different
1585 @code{\score} blocks to produce different combinations of the score.
1587 This orchestral score example consists of three input files. In the
1588 first file, @file{os-music.ly}, we define the music for all instruments.
1589 This file will be used both for producing the score and the separate
1592 If you were to run lilypond on this file, no printable output would be
1598 title = "Zo, goed lieverd?"
1599 subtitle = "How's, this babe?"
1608 Key = \notes \key as \major
1609 flautoI = \notes\relative c'' @{
1611 bes as bes as bes as bes as
1613 flautoII = \notes\relative c'' @{
1614 as8 bes as bes R1 d4 ~ d
1616 tromboI = \notes\relative c'' @{
1617 c4. c8 c8 c4. es4 r as, r
1619 tromboII = \notes\relative c'' @{
1620 as4. as8 as8 as4. R1*1/2 as4 es'
1622 timpani = \notes\relative c, @{
1623 \times 2/3 @{ f4 f f @}
1624 \times 4/5 @{ as8 as as as as @}
1627 corno = \notes\relative c' @{
1628 bes4 d f, bes d f, bes d
1632 We will not go through the input line by line, but only indicate and
1633 explain the new elements.
1640 \skip 2*4 \bar "|.";
1644 Declare setting to be used globally. The @code{\skip} command produces
1645 no output, but moves forward in time: in this case, the duration of a
1646 half note (@code{2}), and that four times (@code{*4}). This brings us
1647 to the end of the piece, and we can set the end bar.
1651 Key = \notes \key as \major
1653 Declare the key signature of the piece and assign it to the identifier
1654 @var{Key}. Lateron, we'll use @code{\Key} for all staffs except those
1655 for transposing instruments.
1657 @node The full score
1658 @subsection The full score
1661 The second file, @file{os-score.ly} reads the definitions of the first
1662 (@file{os-music.ly}), and defines the @code{\score} block for the full
1668 \include "os-music.ly"
1669 \include "paper13.ly"
1671 #(set! point-and-click line-column-location)
1672 #(define text-flat '((font-relative-size . -2)
1673 (music "accidentals--1")))
1678 \property Score.BarNumber \override #'padding = #3
1679 \context StaffGroup = woodwind <
1680 \context Staff = flauti <
1681 \property Staff.midiInstrument = #"flute"
1682 \property Staff.instrument = "2 Flauti"
1683 \property Staff.instr = "Fl."
1685 \context Voice=one @{ \voiceOne \flautoI @}
1686 \context Voice=two @{ \voiceTwo \flautoII @}
1689 \context StaffGroup = timpani <
1690 \context Staff = timpani <
1691 \property Staff.midiInstrument = #"timpani"
1692 \property Staff.instrument = #'(lines "Timpani" "(C-G)")
1693 \property Staff.instr = #"Timp."
1699 \context StaffGroup = brass <
1700 \context Staff = trombe <
1701 \property Staff.midiInstrument = #"trumpet"
1702 \property Staff.instrument = #`(lines "2 Trombe" "(C)")
1703 \property Staff.instr = #`(lines "Tbe." "(C)")
1705 \context Voice=one \partcombine Voice
1706 \context Thread=one \tromboI
1707 \context Thread=two \tromboII
1709 \context Staff = corni <
1710 \property Staff.midiInstrument = #"french horn"
1711 \property Staff.instrument = #`(lines "Corno"
1712 (columns "(E" ,text-flat ")"))
1713 \property Staff.instr = #`(lines "Cor."
1714 (columns "(E" ,text-flat ")"))
1715 \property Staff.transposing = #3
1716 \notes \key bes \major
1717 \context Voice=one \corno
1722 indent = 15 * \staffspace
1723 linewidth = 60 * \staffspace
1724 textheight = 90 * \staffspace
1727 \consists "Multi_measure_rest_engraver"
1730 \HaraKiriStaffContext
1731 \remove "Multi_measure_rest_engraver"
1740 @center @strong{Zo, goed lieverd?}
1742 @center How's, this babe?
1750 @lilypondfile{os-score.ly}
1754 \include "os-music.ly"
1756 First, we need to include the music definitions we made in
1761 #(set! point-and-click line-column-location)
1763 In a large orchestral score like this you're bound to make some small
1764 mistakes, so we enable point and click (See @ref{Point and click})
1769 #(define text-flat '((font-relative-size . -2)
1770 (music "accidentals--1")))
1773 When naming the tuning of the french horn, we'll need a piece of text
1774 with a flat sign. LilyPond has a mechanism for font selection and
1775 kerning called Scheme markup text (See @ref{Text markup}). The flat
1776 sign is taken from the music font, and its name is @code{accidentals--1}
1777 (The sharp sign is called @code{accidentals-+1}). The default font is
1778 too big for text, so we select a relative size of @code{-2}.
1785 Of course, all staffs are simultaneous and use the same global settings.
1789 \property Score.BarNumber \override #'padding = #3
1791 LilyPond prints bar numbers at the start of each line, but
1792 unfortunately, they end up a bit too close to the staff in this example.
1793 A bar number internally is a Grob called @var{BarNumber}. BarNumber
1794 Grobs can be manipulated through their @var{side-position-interface}. One
1795 of the properties of a @var{side-position-interface} that can be tweaked
1796 is the @var{padding}: the amount of extra space that is put between this
1797 Grob and other Grobs. We set the padding to three staff spaces.
1799 You can find all this kind of information in LilyPond's automatically
1800 generated documentation in
1802 @ref{ (lilypond-internals)lilypond-internals, LilyPond Internals}.
1805 the online documentation.
1810 \context StaffGroup = woodwind <
1811 \context Staff = flauti <
1813 A new notation context: the StaffGroup. StaffGroup can hold one or more
1814 Staffs, and will print a big bracket at the left of the score. Start a
1815 new staff group for the woodwind section (just the flutes in this case).
1816 Immediately after that, we start the staff for the two flutes, that also
1817 play simultaneously.
1821 \property Staff.midiInstrument = #"flute"
1823 Specify the instrument for MIDI output (see @ref{MIDI instrument
1828 \property Staff.instrument = "2 Flauti"
1829 \property Staff.instr = "Fl."
1831 And define the instrument names to be printed in the margin,
1832 @code{instrument} for the first line of the score, @code{instr} for the
1839 The flutes play in the default key.
1843 \context Voice=one @{ \voiceOne \flautoI @}
1844 \context Voice=two @{ \voiceTwo \flautoII @}
1846 Last come the actual flute parts. Remember that we're still in
1847 simultaneous mode. We name both voices differently, so that LilyPond
1848 will actually create two Voice contexts. The flute parts are simple, so
1849 we specify manually which voice is which: @code{\voiceOne} forces the
1850 direction of stems, beams, slurs and ties up, @code{\voiceTwo} sets
1858 Close the flutes staff and woodwind staff group.
1862 \property Staff.instrument = #'(lines "Timpani" "(C-G)")
1864 The timpani staff only shows a new piece of scheme markup, it sets two
1869 \context Voice=one \partcombine Voice
1870 \context Thread=one \tromboI
1871 \context Thread=two \tromboII
1873 You have seen the notation contexts Staff and Voice, but here's a new
1874 one: Thread. One or more Threads can be part of a Voice. The Thread
1875 takes care of note heads and rests, the Voice combine note heads onto a
1878 For the trumpets we use the automatic part combiner (see @ref{Automatic
1879 part combining}) to combine the two simultaneous trumpet parts onto the
1880 trumpet staff. Each trumpet gets its own Thread context, which must be
1881 named @code{one} and @code{two}). The part combiner makes these two
1882 threads share a Voice when they're similar, and splits the threads up
1883 when they're different.
1887 \property Staff.instrument = #`(lines "Corno"
1888 (columns "(E" ,text-flat ")"))
1890 The french horn has the most complex scheme markup name, made up of two
1891 lines of text. The second line has two elements (columns), the @code{E}
1892 and the flat sign @code{text-flat} that we defined before.
1896 \property Staff.transposing = #3
1898 The french horn is to be tuned in E-flat, so we tell the MIDI backend to
1899 transpose this staff by three steps.
1901 Note how we can choose different tuning for entering, printing and
1902 playing, using @code{\transpose} and the MIDI Staff proprerty
1907 \notes \key bes \major
1909 Therefore, it has a different key.
1913 indent = 15 * \staffspace
1914 linewidth = 60 * \staffspace
1916 We specify a big indent for the first line and a small linewidth for this
1921 Usually, LilyPond's predefined setup of notation contexts (Thread,
1922 Voice, Staff, Staffgroup, Score) is just fine. But in this case, we
1923 want a different type of Staff context.
1925 In orchestral scores, it often happens that one instrument has only
1926 rests during one line of the score. The @code{HaraKiriStaffContext} can
1927 be used as a regular @code{StaffContext} drop-in and will take care of
1928 the automatic removing of empty staffs.
1930 @node Extracting an individual part
1931 @subsection Extracting an individual part
1933 The third file, @file{os-flute-2.ly} also reads the definitions of the
1934 first (@file{os-music.ly}), and defines the @code{\score} block for the
1938 \include "os-music.ly"
1939 \include "paper16.ly"
1943 \property Score.skipBars = ##t
1944 \property Staff.midiInstrument = #"flute"
1950 instrument = "Flauto II"
1953 linewidth = 80 * \staffspace
1954 textheight = 200 * \staffspace
1962 @center @strong{Zo, goed lieverd?}
1964 @center How's, this babe?
1965 @center @emph{Flauto II}
1972 @lilypondfile{os-flute-2.ly}
1975 Because we separated the music definitions from the @code{\score}
1976 instantiations, we can easily define a second score from the music of
1977 the second flute. This then is the part for the second flute player.
1978 Of course, we make separate parts for all individual instruments.
1984 In this individual part the second flute has a whole staff for itself,
1985 so we don't want to force stem or tie directions.
1990 instrument = "Flauto II"
1993 The @code{\header} definitions were also read from @file{os-music.ly},
1994 but we need to set the instrument for this particular score.
1998 \property Score.skipBars = ##t
2000 In the conductor's full score, all bars with rests are printed, but for
2001 the individual parts, we want to contract pieces of consecutive empty
2002 bars. LilyPond will do this if Score's @var{skipBars} property to
2006 @node Other ways to run LilyPond
2007 @section Other ways to run LilyPond
2009 Until now, you have been using @file{ly2dvi} to invoke LilyPond.
2010 There are three other routes. Firstly, there is a script called
2011 @code{lilypond-book}, that allows you to freely mix LilyPond input with
2012 Texinfo or LaTeX input. For example, this manual was written using
2013 @code{lilypond-book}. It is discussed in @ref{lilypond-book}.
2016 Secondly, you can generate PostScript directly. This is useful if you
2017 can not or do not want to run @TeX{} on your system. To obtain direct
2018 PostScript output, invoke LilyPond as follows:
2019 @cindex PostScript output
2021 lilypond -f ps test.ly
2023 You have to set some environment variables to view or print this
2024 output. More information can be found in @ref{Invoking
2028 Thirdly, if you want to do special things with your output, you can run
2029 invoke lilypond directly:
2033 to produce plain @TeX{} output. Note that La@TeX{} will not work on the
2034 resulting @file{test.tex}. You must run plain @TeX{} on it.
2042 @node Integrating text and music
2043 @section Integrating text and music
2045 Sometimes, you might want to use music examples in a text that you are
2046 writing. For example, if you are writing a musicological treatise, a
2047 songbook, or (like us) the LilyPond manual. You can make such texts by
2048 hand, simply by importing a PostScript figure into your wordprocessor.
2049 However, there is a also an automated procedure:
2051 If you use La@TeX{} or texinfo, you can mix text and lilypond code. A
2052 script called @code{lilypond-book} will extract the music fragments, run
2053 lilypond on them, and put back the resulting notation. lilypond-book is
2054 described fully in @ref{lilypond-book}, but here we show a small
2055 example. Since the example also contains explanatory text, we won't
2056 comment on the contents.
2059 \documentclass[a4paper]@{article@}
2062 In a lilypond-book document, you can freely mix music and text. For
2065 \score @{ \notes \relative c' @{
2066 c2 g'2 \times 2/3 @{ f8 e d @} c'2 g4
2069 Notice that the music line length matches the margin settings of the
2072 If you have no \verb+\score+ block in the fragment,
2073 \texttt@{lilypond-book@} will supply one:
2079 In the example you see here, a number of things happened: a
2080 \verb+\score+ block was added, and the line width was set to natural
2081 length. You can specify many more options using \LaTeX style options
2084 \begin[verbatim,11pt,singleline,
2085 fragment,relative,intertext="hi there!"]@{lilypond@}
2089 \texttt@{verbatim@} also shows the lilypond code, \texttt@{11pt@} selects
2090 the default music size, \texttt@{fragment@} adds a score block,
2091 \texttt@{relative@} uses relative mode for the fragment, and
2092 \texttt@{intertext@} specifies what to print between the
2093 \texttt@{verbatim@} code and the music.
2095 If you include large examples into the text, it may be more convenient
2096 to put the example in a separate file:
2098 \lilypondfile[printfilename]@{sammartini.ly@}
2100 The \texttt@{printfilename@} option adds the file name to the output.
2105 Under Unix, you can view the results as follows.
2108 $ lilypond-book --outdir=out/ lilbook.tex
2109 lilypond-book (GNU LilyPond) 1.3.146
2110 Reading `/home/hanwen/usr/src/lilypond-1.3.146/input/tutorial/lilbook.tex'
2112 `/home/hanwen/usr/src/lilypond-1.3.146/input/tutorial/sammartini.ly'
2113 @var{lots of stuff deleted}
2114 Writing `out/lilbook.latex'
2116 $ latex lilbook.latex
2117 @var{lots of stuff deleted}
2121 Notice the @code{outdir} option to lilypond-book. Running lilypond-book
2122 and running latex creates a lot of temporary files, and you wouldn't
2123 those to clutter up your working directory. Hence, we have them created
2124 in a separate subdirectory.
2126 The result more or less looks like this:
2130 In a lilypond-book document, you can freely mix music and text. For
2133 \score { \notes \relative c' {
2134 c2 g'2 \times 2/3 { f8 e d } c'2 g4
2137 Notice that the music line length matches the margin settings of the
2140 If you have no @code{\score} block in the fragment,
2141 @code{lilypond-book} will supply one:
2147 In the example you see here, a number of things happened: a
2148 @code{\score} block was added, and the line width was set to natural
2149 length. You can specify many more options using La@TeX{} style options
2152 @lilypond[verbatim,11pt,singleline,
2153 fragment,relative,intertext="hi there!"]
2157 @code{verbatim} also shows the lilypond code, @code{11pt} selects
2158 the default music size, @code{fragment} adds a score block,
2159 @code{relative} uses relative mode for the fragment, and
2160 @code{intertext} specifies what to print between the
2161 @code{verbatim} code and the music.
2163 If you include large examples into the text, it may be more convenient
2164 to put the example in a separate file:
2166 @lilypondfile[printfilename]{sammartini.ly}
2168 The @code{printfilename} option adds the file name to the output.
2169 @node end of tutorial
2172 That's all folks. From here, you can either try fiddling with input
2173 files, or you can read the reference manual. You can find more example
2174 files in @file{input} and @file{input/test}. You can also look at some
2175 real music. Have a look at the @uref{Mutopia project,
2176 http://www.mutopiaproject.org}.
2184 this should be on mutopia website.
2189 @c waar deze info? is uiteindelijk wel handig, schat ik.
2192 If you have a big music project, or just a lot of LilyPond input files,
2193 all generated output from LilyPond, @TeX{} and metafont will clutter
2194 your working directory. LilyPond comes with a one-size-fits-all
2195 pre-cooked makefile that helps you manage producing output. It will
2196 produce all output in the directory @file{out} , generate and track
2197 dependencies. Also, it helps in preparing your submission to @ref{Mutopia
2204 cp /usr/share/lilypond/make/ly.make GNUmakefile
2205 cp /usr/share/doc/lilypond/examples/input/tutorial/minuet.ly .
2208 Generated out/minuet.ps for target minuet.
2211 Type @samp{make help} to see possible targets.
2214 @file{/usr/share/lilypond/doc/lilypond/examples/input/mutopia-header.ly}
2220 [TODO: rewrite completely.]
2223 * Songs with additional verses::