3 @c TODO: LilyPond Lilypond lilypond
10 * Running LilyPond:: Getting started
12 * The first tune:: The first tune
13 * Lyrics and chords:: Lyrics and chords
15 * A piano excerpt:: Piano music
16 * An orchestral score::
17 * Other ways to run LilyPond::
18 * Integrating text and music::
19 * end of tutorial:: The end
23 @node Running LilyPond
24 @section Running LilyPond
26 You make music notation with LilyPond as follows: first you edit a text
27 file containing a description of the notes. Then you run LilyPond on the
28 file. This leaves you with an output file, which you can view or print.
30 In this section we explain how to run LilyPond, and view or print the
31 output. If you want to test your setup of LilyPond, or try to run an
32 example file yourself, then read this section. Otherwise, you can skip
33 to the next section, which explains how to
36 The instructions that follow are for Unix. Windows instructions are
37 given at the end of this section. Start with opening a terminal window,
38 and start up a text editor. For example, start an xterm and execute
39 @code{joe}. Enter the following
40 input, and save the file as @file{test.ly}.
43 \notes @{ c'4 e' g' @}
46 If this code looks intimidating you, then don't worry, we explain all
47 about it in the next section.
51 @c dit is dus raar, dat je ly2dvi draait om lelie te draaien
52 @c (therefore name change proposal)
54 Invoke the program @code{ly2dvi} to run lilypond on your source file:
59 You will see the following on your screen:
62 Now processing: `/home/fred/ly/test.ly'
64 Interpreting music...[1]
65 @emph{ ... more interesting stuff ... }
66 PS output to `test.ps'...
67 DVI output to `test.dvi'...
74 The results of the ly2dvi run are two files, @file{test.dvi} and
75 @file{test.ps}. The PS file (@file{test.ps}) is the one you can
76 print. You can view the PS file using the program ghostview. If a
77 version of ghostview is installed on your system, one of these commands
78 will produce a window with some music notation on your screen.
85 When you're satisfied with the result, you can print the PS file by
86 clicking File/Print inside ghostview.
88 The DVI file (@file{test.dvi}) contains the same sheet music in a
89 different format. DVI files are more easily processed by the computer,
90 so viewing them usually is quicker. Execute @code{xdvi test}
93 If your DVI viewer does not have a "Print" button, you can print the
94 file by executing @code{lpr test.ps}.
96 @c volgende alinea schrappen?
98 If you can't get the examples to print, then you should look into
99 installing and configuring ghostscript. Refer to GhostScript's website
100 at @uref{http://www.ghostscript.com}.
104 @cindex Printing output
108 Windows users start the terminal by clicking on the lilypond icon.
109 Notepad is sufficient for editing the lilypond file. Viewing the PS file
110 can be done with @code{gsview32 test.ps}. Viewing DVI files can be done
111 with @code{yap test}. The "print" button in Yap will print files. You
112 can also print from the command line by executing @code{gsview32 /s
121 Let's try to explain this example:
123 The basics of any piece of music are notes.Notes are entered
124 with letters @code{a} to @code{g} followed by a
125 number that represents the duration: a @code{2} is a half note, a
126 @code{4} is a quarter note. A period is used for augmentation dots, so
127 entering @code{2.} gives a dotted half note.
132 \property Score.timing = ##f
133 \property Staff.TimeSignature = \turnOff
134 \property Staff.Clef = \turnOff
137 If you don't specify a duration, then the duration last entered is used:
143 \property Score.timing = ##f
144 \property Staff.TimeSignature = \turnOff
145 \property Staff.Clef = \turnOff
146 \clef bass f4 e d c2.
148 The time signature can be set with a command of the form @code{\time},
149 and the clef with @code{\clef} as follows:
160 The commands together with the notes are combined to form a snippet of
161 music. They are combined by enclosing them with @code{\notes @{ @}}.
171 This snippet is ready to be printed. This is done by combining the music
172 with a printing command. The printing command is the so-called
173 @code{\paper} block. The music and paper block are combined by
174 enclosing them in @code{\score}.
189 The @code{\paper} block looks empty, which means that we get default. That is because we did not contains page layout settings, such as the linewidth and
190 the staff size. For now, we'll use standard settings, hence the paper
191 block is empty (its braces enclose a blank space).
194 Rests are entered just like notes with the name @code{r}
195 @lilypond[fragment,verbatim]
199 Octaves are entered by adding apostrophes or commas to note names. For
200 example, the central C is entered as @code{c'}.
202 Pitches can be octaviated by adding apostrophes or commas. The central C is
203 @code{c'}. Going up octave by octave we get @code{c''},
204 @code{c'''}. Going down from central C, we get @code{c} @code{c,}
207 @lilypond[verbatim,fragment]
211 LilyPond uses Dutch note names: you can make a note sharp by appending
212 @code{is} to the name, and flat by appending @code{es} to the name.
213 @lilypond[verbatim,fragment]
217 Ties are created by entering a tilde (@code{~}) between the notes to be
219 @lilypond[fragment,verbatim]
222 Ties look almost the same as slurs, but they are different. Ties can
223 only indicate the extension of a note. Ties connect two note heads with
224 the same pitch. Slurs on the other hand, can be drawn across many
225 notes, and indicate bound articulation.
227 The key signature is set with the command @code{\key}:
228 @lilypond[fragment,verbatim]
235 The next example shows octave marks, ties, and rests in action.
242 r4 r8 d''8 cis''4 e''
244 cis''4 cis''8 cis'' bis'4 d''8 cis'' ~
250 There is one interesting point to note in this example: accidentals
251 don't have to be marked explicitly. You just enter the pitch, and
252 LilyPond determines wether or not to print an accidental.
254 Managing larger pieces.
256 If you look at the last piece, it is already apparent that entering
257 octaves using quotes is not very convenient. A score written in high
258 register will be encoded using lots quotes. This makes the input file
259 unreadable, and it also is a source of many errors.
261 This problem is solved by relative octave mode. In this mode, the quotes
262 are used to mark large jumps in the melody. Without any quotes or
263 commas, the interval between a note and its predecessor is assumed to be
264 a fourth or less. Quotes and commas add octaves in up and down
265 direction. Relative octaves are introduced by @code{\relative} followed
267 @lilypond[fragment,verbatim]
268 \relative c'' { c4 d4 b4 e4 a,4 f'4 g,4 a'4 }
271 Slurs (not to be confused with ties) are entered with parentheses. You
272 mark the starting note and ending note with a @code{(} and a
273 @code{)} respectively.
275 @lilypond[fragment,relative 2, verbatim]
279 If you need two slurs at the same time (one for articulation, one for
280 phrasing), you can also make phrasing slurs with @code{\(} and
284 @lilypond[fragment,relative 1, verbatim]
285 a8(\( ais b ) c cis2 b'2 a4 cis, \) c
288 Beams are drawn automatically, but if you don't like the choices, you
289 can enter beams by hand. Surround the notes to be grouped with @code{[}
291 @lilypond[fragment,relative 1, verbatim]
295 You can make more than one staff, by specifying @code{\context Staff} before
296 snippets of music, and combining those snippets in @code{<} and
297 @code{>}, as is demonstrated here:
299 @lilypond[fragment,verbatim]
300 < \context Staff = staffA { \clef treble c'' }
301 \context Staff = staffB { \clef bass c }
304 Here, @code{staffA} and @code{staffB} are names that you give to the
305 staff. For now, it doesn't matter what names you give, as long as they
308 We can typeset a melody with two staffs now:
313 < \context Staff = staffA {
316 \relative c'' { e2 ( d4 c2 b4 [a8 a] [b b] [g g] )a2. }
318 \context Staff = staffB {
328 Notice that the time signature is specified in one melody staff only
329 (the top staff), but is printed on both. LilyPond knows that the time
330 signature should be the same for all staffs.
332 [TODO add some more here
337 * dynamics , articulation
345 This is the end of the simple tutorial. What follows is also a manual in
346 tutorial-style, but it is much more in-depth, and alas more
347 intimidating. You should read it if you want to know about the more
348 advanced features of lilypond, such as producing orchestral scores and
349 parts, fine tuning output, writing polyphonic music, etc.
354 @section The first tune
357 This tutorial will demonstrate how to use Lilypond by presenting
358 examples of input along with resulting output. We will use English
359 terms for notation. In case you are not familiar with those, you may
360 consult the glossary that is distributed with LilyPond.
362 The examples discussed are included in the distribution, in the
363 subdirectory @file{input/tutorial/}@footnote{When we refer to filenames,
364 they are relative to the top directory of the source package. }
367 To demonstrate what LilyPond input looks like, we start off with a
368 full-fledged, yet simple example. It is a convoluted version
369 of the famous minuet in J. S. Bach's @emph{Klavierb@"uchlein}. The file
370 is included in the distribution as @file{minuet.ly}.
371 @cindex Bach, Johann Sebastian
374 % all text after a percent sign is a comment
375 % and is ignored by Lilypond
376 \include "paper16.ly"
379 \relative c'' \sequential {
384 d4 g,8 a b c d4 g, g |
385 e'4 c8 d e fis g4 g, g |
386 c4 d8( )c b a( )b4 c8 b a g |
387 a4 [b8 a] [g fis] g2. |
392 g4 e8 fis g d cis4 b8 cis a4 |
393 a8-. b-. cis-. d-. e-. fis-.
400 % standard settings are too wide for a book
406 We will analyse the input, line by line.
409 % all text after a percent sign is a comment
410 % and is ignored by Lilypond
412 The percent sign, @code{%}, introduces a line comment. You can also
413 comment out a block of several lines, by enclosing them in
414 @code{%@{} and @code{%@}}.
416 @cindex block comment
421 \include "paper16.ly"
424 @cindex @code{\include}
425 @cindex point, printer's
426 @cindex staff size setting
427 By default, LilyPond will typeset the music in a size such that each
428 staff is 20 point@footnote{A point is the standard measure of length for
429 printing; one point is 1/72.27 inch.} high. We want smaller
430 output (16 point staff height), so we must import the settings for that
431 size, which is done here.
438 Music is printed by combining a piece of music with directions for
439 outputting it. This combination is formed in the @code{\score} block.
446 Prepare LilyPond for accepting notes.
447 @cindex octaves, choosing
456 As we will see, each note is described by its note name, duration,
457 octave and possibly a chromatic alteration. In this setup, the octave
458 is indicated by using high quotes (@code{'}) and ``lowered quotes''
459 (commas: @code{,}). The central C is denoted by @code{c'}. The C one
460 octave higher is @code{c''}. One and two octaves below the central C is
461 denoted by @code{c} and @code{c,} respectively.
463 Even though a piece of music often spans a range of several octaves, it
464 mostly moves in small intervals. LilyPond has a special entry mode to
465 save typing in this situation. In this ``relative'' octave mode,
466 octaves of notes without quotes are chosen such that a note is as close
467 as possible (graphically, on the staff) to the preceding note. If you
468 add a high-quote an extra octave is added. A lowered quote (a comma)
469 will subtract an extra octave.
471 Because the first note has no predecessor,
472 you have to give the (absolute) pitch of the note to start with.
479 What follows is sequential music, i.e.,
480 @cindex sequential music
481 notes that are to be played and printed after each other.
488 @cindex time signature, setting
490 Set (or change) the time signature of the current piece: a 3/4 sign is
491 printed. The time signature setting is also used to generate bar lines
499 @cindex key signature, setting
501 Set (or change) the current key signature to G-major. Although in this
502 example, the @code{\key} command happened to be entered after the
503 @code{\time} command, in the output the time signature will be printed
504 after the key signature; LilyPond knows about music typesetting
512 The following piece of music is played twice. The first argument
513 indicates the type of repeat. In this case, @code{"volta"} means that
514 prima volta/secunda volta brackets are used for the alternative
515 endings---if there were any.
522 The subject of the repeat is again sequential music. Since
523 @code{\sequential} is such a common construct, a shorthand is provided:
524 just leave off @code{\sequential}, and the result is the same.
531 Two notes. The first note is a quarter note with relative pitch
532 @code{d}. The relative music was started with a @code{c''}, so the real
533 pitch of this note is @code{d''}. The duration of a note is designated
534 by a number; the @code{4} here represents a quarter note.
536 The second note is an eight note with relative pitch @code{g,}. The
537 pitch is taken relative to the previous @code{d''}, making this
538 note have real pitch @code{g'}. The @code{8} represents an eight note.
545 Two more notes, with pitch @code{a} and @code{b}. Because their
546 duration is the same as the @code{g,8}, there is no need to enter the
547 duration, but you may enter it anyway, i.e., @code{a4 b4}
556 @cindex errors, finding
557 Three more notes. The @code{|} character is a ``bar check''. LilyPond
558 will verify that bar checks are found at the start of a measure. This can
559 help you track down typing errors.
561 @cindex alteration, chromatic
562 @cindex chromatic alteration
569 So far, no notes were chromatically altered. Here is the first one that
570 is: @code{fis}. Lilypond by default uses Dutch@footnote{Note names are
571 available in several languages, but we find the Dutch names quite
572 convenient.} note names, and ``Fis'' is the Dutch note name for ``F
573 sharp''. However, there is no sharp sign in the output. The program
574 keeps track of key signatures, and will only print accidentals if they
577 For groups of eighth notes and shorter, LilyPond can determine how the
578 notes should form a beam. In this case, the 4 eights are automatically
583 c4 d8( )c b a( )b4 c8 b a g |
586 The beginning and ending notes of a slur are marked with parentheses,
587 @code{(} and @code{)} for start and end respectively. The line above
588 indicates two slurs. These slur markers (parentheses) are entered
589 between the slurred notes.
596 Automatic beaming can be overridden by inserting beam marks, @code{[}
597 and @code{]}. These beam markers (brackets) are put around the notes
605 @cindex augmentation dot
607 A period adds an augmentation dot to the note.
614 The end of the sequential music to be repeated. LilyPond will typeset a
622 Accidentals are printed whenever necessary: the first C sharp of the bar
623 will be printed with an accidental, the second one without.
627 a8-. b-. cis-. d-. e-. fis-.
631 You can enter articulation signs either in a verbose form or using a
632 shorthand. Here we demonstrate the shorthand: it is formed by a dash
633 and the character for the articulation to use, e.g. @code{-.} for
634 staccato as shown above.
642 Rests are denoted by the special notename @code{r}.
649 All articulations have a verbose form, like @code{\fermata}. The
650 command @code{\fermata} is not part of the core of the language, but it
651 is a shorthand for a more complicated description of a fermata symbol.
652 @code{\fermata} names that description and is therefore called an
655 @cindex @code{\fermata}
661 Here the music ends. LilyPond does not automatically typeset and end
662 bar, we must explicitely request one, using @code{"|."}.
672 The @code{\paper} block specifies how entered music should be converted
673 to notation output. Most of the details of the conversion (font sizes,
674 dimensions, etc.) have been taken care of, but to fit the output in this
675 document, it has to be narrower. We do this by setting the line width
676 to 14 centimeters (approximately 5.5 inches).
683 The last brace ends the @code{\score} block.
688 @node Lyrics and chords
689 @section Lyrics and chords
691 In this section we show how to typeset a song. This file is
692 included as @file{flowing.ly}.
696 title = "The river is flowing"
697 composer = "Traditional"
699 \include "paper16.ly"
700 melody = \notes \relative c' @{
704 c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
705 c4 c8 d [es () d] c4 | d4 es8 d c4.
710 The ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
711 ri -- ver is flo -- wing down to the sea.
714 accompaniment =\chords @{
716 c2:3- f:3-.7 d:min es4 c8:min r8
717 c2:min f:min7 g:7^3.5 c:min @}
722 \context ChordNames \accompaniment
725 \context Staff = mel @{
726 \property Staff.noAutoBeaming = ##t
727 \property Staff.automaticMelismata = ##t
730 \context Lyrics \text
732 \midi @{ \tempo 4=72 @}
733 \paper @{ linewidth = 10.0\cm @}
738 The result would look this.@footnote{The titling and font size shown
739 may differ, since the titling in this document is not generated by
742 @center @strong{The river is flowing}
747 title = "The river is flowing"
748 composer = "Traditional"
750 \include "paper16.ly"
751 melody = \notes \relative c' {
755 c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
756 c4 c8 d [es () d] c4 | d4 es8 d c4.
761 The ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
762 ri -- ver is flo -- wing down to the sea.
765 accompaniment =\chords {
767 c2:3- f:3-.7 d:min es4 c8:min r8
768 c2:min f:min7 g:7^3.5 c:min }
773 \context ChordNames \accompaniment
776 \context Staff = mel {
777 \property Staff.noAutoBeaming = ##t
778 \property Staff.automaticMelismata = ##t
781 \context Lyrics \text
783 \midi { \tempo 4=72 }
784 \paper { linewidth = 10.0\cm }
788 Again, we will dissect the file line by line.
795 @cindex @code{\header}
796 Information about the music you are about to typeset goes into a
797 @code{\header} block. The information in this block is not used by
798 LilyPond, but it is passed into the output. @file{ly2dvi} uses this
799 information to print titles above the music.
803 title = "The river is flowing"
804 composer = "Traditional (?)"
807 @cindex identifier assignment
808 the @code{\header} block contains assignments. In each assignment, a
809 variable is set to a value. Lexically, both the variable name and the
810 assigned value are strings. The values have to be quoted here, because
811 they contain spaces, the variable names could also be put within quotes
812 but it is not necessary.
816 \include "paper16.ly"
819 Smaller size for inclusion in a book.
823 melody = \notes \relative c' @{
826 The structure of the file will be the same as the previous one, a
827 @code{\score} block with music in it. To keep things readable, we will
828 give names to the different parts of music, and use the names to
829 construct the music within the score block.
836 @cindex @code{\partial}
838 The piece starts with an anacrusis of one eighth.
843 The key is C minor: we have three flats.
848 c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
849 c4 c8 d [es () d] c4 | d4 es8 d c4.
854 @cindex manual beaming
855 @cindex automatic beaming, turning off
856 We use explicit beaming. Since this is a song, we turn automatic
857 beams off, and use explicit beaming where needed.
864 This ends the definition of @code{melody}.
873 @cindex identifier assignment
874 @cindex syllables, entering
875 Another identifier assignment. This one is for the lyrics.
876 Lyrics are formed by syllables that have duration, and not by
877 notes. To make LilyPond parse words as syllables, switch it into
878 lyrics mode with @code{\lyrics}. Again, the brace after @code{\lyrics}
879 is a shorthand for @code{\sequential @{}.
883 The4 ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
884 ri- ver is flo- __ wing down to the sea.
888 @cindex extenders, lyric
889 @cindex hyphens, lyric
890 The syllables themselves are separated by spaces. You can get syllable
891 extenders by entering @code{__}, and centered hyphens with
892 @code{-}@code{-}. We enter the syllables as if they are all quarter notes
893 in length (hence the @code{4}), and use a feature to align the
894 syllables to the music, which obviously isn't all quarter notes.
898 accompaniment =\chords @{
903 We'll put chords over the music. To enter them, there is a special mode
904 analogous to @code{\lyrics} and @code{\notes} mode, where you can give
905 the names of the chords you want, instead of listing the notes
906 comprising the chord.
913 There is no accompaniment during the anacrusis.
922 @cindex chord modifier
923 @cindex modifier, chord
924 A chord is started by the tonic of the chord. The
925 first one lasts a half note. An unadorned note creates a major
926 triad. Since a minor triad is wanted, @code{3-} is added to modify the
927 third to be small. @code{7} modifies (adds) a seventh, which is small by
928 default to create the @code{f a c es} chord. Multiple modifiers must be
937 Some modifiers have predefined names, eg. @code{min} is the same as
938 @code{3-}, so @code{d-min} is a minor @code{d} chord.
942 c2:min f:min7 g:7^3.5 c:min @}
945 @cindex named modifier
947 A named modifier @code{min} and a normal modifier @code{7} do not have
948 to be separated by a dot. Tones from a chord are removed with chord
949 subtractions. Subtractions are started with a caret, and they are
950 also separated by dots. In this example, @code{g:7^3.5} produces a
951 minor seventh. The brace ends the sequential music.
959 We assemble the music in the @code{\score} block. Melody, lyrics and
960 accompaniment have to sound at the same time, so they should be
961 @code{\simultaneous}.
962 @cindex @code{\simultaneous}
969 Chord mode generates notes grouped in @code{\simultaneous} music. If
970 you remove the comment sign, you can see the chords in normal
971 notation: they will be printed as note heads on a separate
972 staff. To print them as chords names, they have to be interpreted as
973 being chords, not notes. This is done with the following command:
977 \context ChordNames \accompaniment
981 @cindex interpretation context
982 @cindex notation context
985 Normally, the notes that you enter are transformed into note heads.
986 Note heads alone make no sense, they need surrounding information: a key
987 signature, a clef, staff lines, etc. They need @emph{context}. In
988 LilyPond, these symbols are created by objects called `interpretation
989 contexts'. Interpretation contexts exist for generating notation
990 (`notation context') and for generating sound (`performance
991 context'). These objects only exist during a run of LilyPond.
993 By default, LilyPond will create a Staff context for you. If you would
994 remove the @code{%} sign in the previous line, you would see that
997 We don't want that default here, because we want chord names. The
998 command above explicitly creates an interpretation context of
999 @code{ChordNames} type to interpret the music @code{\accompaniment}.
1006 @cindex @code{\addlyrics}
1007 @cindex lyrics and melody, combining
1008 @cindex combining lyrics and melody
1010 The lyrics should be aligned with the melody. This is done by
1011 combining both with @code{\addlyrics}. @code{\addlyrics} takes two
1012 pieces of music (usually a melody and lyrics, in that order) and
1013 aligns the syllables of the second piece under the notes of the
1014 first piece. If you would reverse the order, the notes would be
1015 aligned on the lyrics, which is not very useful, and looks
1020 \context Staff = mel @{
1024 The second argument of @code{\addlyrics} is the melody. We instantiate
1025 a @code{Staff} context explicitly: should you choose to remove the
1026 comment before the ``note heads'' version of the accompaniment, the
1027 accompaniment will be on a nameless staff. The melody has to be on
1028 staff different from the accompaniment. This is accomplished by giving
1029 the melody and accompaniment staffs different names.
1033 \property Staff.noAutoBeaming = ##t
1037 @cindex context variables
1038 @cindex setting context variables
1039 An interpretation context has variables, called properties, that tune
1040 its behaviour. One of the variables is @code{noAutoBeaming}. Setting
1041 this Staff's property to @code{##t}, which is the boolean value @var{true},
1042 turns the automatic beaming mechanism off for the current staff.
1045 @cindex accessing Scheme
1046 @cindex evaluating Scheme
1049 LilyPond internally uses GUILE, a Scheme-interpreter. Scheme is a
1050 language from the LISP family. You can learn more about Scheme at
1051 @uref{http://www.scheme.org}. It is used to represent data throughout
1052 the whole program. The hash-sign (@code{#}) accesses GUILE directly: the
1053 code following the hash-sign is evaluated as Scheme. The boolean value
1054 @var{true} is @code{#t} in Scheme, so for LilyPond @var{true} looks like
1057 If Scheme scares you, don't worry. You don't need to know Scheme to
1058 create beautiful sheet music.
1065 \property Staff.automaticMelismata = ##t
1068 @cindex automaticMelismata
1070 @cindex @code{\addlyrics} and slurs
1071 Similarly, we don't want to print a syllable when there is
1072 a slur. This sets up @code{\addlyrics} to not put lyrics under each
1073 separate note while there is a slur.
1081 Finally, we put the melody on the current staff. Note that the
1082 @code{\property} directives and @code{\melody} are grouped in sequential
1083 music, so the property settings are done before the melody is
1088 \context Lyrics \text
1091 The second argument of @code{\addlyrics} is the text. The text also
1092 should not land on a Staff, but on a interpretation context for
1093 syllables, extenders, hyphens etc. This context is called
1098 \midi @{ \tempo 4=72@}
1101 MIDI (Musical Instrument Digital Interface) is a standard for
1102 connecting and recording digital instruments. So a MIDI file is like a
1103 tape recording of an instrument. The @code{\midi} block causes makes the
1104 music go to a MIDI file, so you can listen to the music you entered. It
1105 is great for checking the music. Whenever you hear something weird, you
1106 probably hear a typing error.
1108 Syntactically, @code{\midi} is similar to @code{\paper @{ @}}, since it
1109 also specifies an output method. You can specify the tempo using the
1110 @code{\tempo} command, in this case the tempo of quarter notes is set to
1111 72 beats per minute.
1115 \paper @{ linewidth = 10.0\cm @}
1118 We also want notation output. The linewidth is short so the piece
1119 will be set in two lines.
1121 @node More movements
1122 @section More movements
1124 [FIXME: merge here with, or move this to: Other ways to run LilyPond]
1126 You probably ran @file{ly2dvi} on the last example, and ended up with a
1127 viewable @file{.dvi} file. However, between there are a few steps of
1128 which LilyPond is only one. To enhance your understanding of what's
1129 happening under the hood when you run @code{ly2dvi}, we explain what
1132 @code{ly2dvi} is a program that calls a number of programs in sequence.
1133 The first thing it does, is running LilyPond on the input file. After
1134 some calculations, a @file{.tex} is produced. The contents
1135 of this file are very low-level instructions.
1137 For example, the following file (@file{miniatures.ly})
1141 \header @{ title = "Two miniatures" @}
1143 #(set! point-and-click line-column-location)
1145 \paper @{ linewidth = -1.0 @}
1148 \notes @{ c'4 d'4 @}
1154 \notes @{ d'4 c'4 @}
1161 The titling in this manual was not generated by ly2dvi, so we can't
1162 exactly show it would look, but the result should resemble this:
1164 @center @strong{Two miniatures}
1174 \paper { linewidth = -1.0 }
1186 \paper { linewidth = -1.0 }
1190 This file is produced by ly2dvi in a few stages, with the help of text
1191 formatting tools. LilyPond produces two output files, @file{miniatures.tex}
1192 and @file{miniatures-1.tex}. They both look like this:
1196 \placebox@{-5 \outputscale @}%
1197 @{ 8.7229 \outputscale @}%
1198 @{\magfontWXGEomMMBo\char90 @}%
1200 \placebox@{-4 \outputscale @}%
1201 @{ 81.0647 \outputscale @}%
1205 @file{ly2dvi} looks at what output LilyPond produces, and generates a
1206 file called @file{ly2dvi.out.tex}. This file contains formatting
1207 instructions for the title and page layout. A fragment might look like
1211 \def\lilypondopus@{Opus 1.@}
1212 \def\lilypondpiece@{Up@}
1213 \def\mustmakelilypondtitle@{@}
1214 \input miniatures.tex
1215 \def\lilypondtitle@{Two miniatures@}
1219 @file{ly2dvi} runs it through LaTeX. LaTeX is a text-formatting system
1220 built on top of @TeX{}. It's very popular in the academic world. If LaTeX
1221 is successful, this will produce a @file{.dvi} file, containing both the
1222 titling and the actual music. @code{ly2dvi} completes its task by
1223 deleting the two temporary files, leaving only @file{miniatures.dvi}.
1225 Next, now we'll look at the example line by line to explain new things.
1231 Lilypond and its language are still under development, and occasionally,
1232 details of the syntax are changed. This fragment indicates for which
1233 version the input file was written. When you compile this file, the
1234 version number will be checked, and you will get a warning when the file
1237 This version number is also used by the @code{convert-ly} program (See
1238 @ref{convert-ly}), which uses it to update the file to the latest lily
1243 \header @{ title = "Two miniatures" @}
1245 This sets the titling information for the entire file.
1249 #(set! point-and-click line-column-location)
1252 This piece of Scheme code sets the Scheme variable
1253 @code{point-and-click} to the value @var{line-column-location} (which
1254 itself is a Scheme procedure).
1256 Editing input files can be quite complicated if you're working with
1257 large files: if you're digitizing existing music, you have to
1258 synchronize the .ly file, the sheet music on your lap and the sheet
1259 music on the screen. The point-and-click mechanism makes it easy to
1260 find the origin of an error in the .ly file: when you view the file with
1261 Xdvi and click on a note, your editor will jump to the spot where that
1262 note was entered. For more information, see @ref{Point and click}.
1269 The @code{\score} blocks that follow in the file don't have
1270 @code{\paper} sections, so the settings of this block are substituted: A
1271 paper block, at top-level, i.e. not in a @code{\score} block sets the
1272 default page layout.
1281 The variable @code{linewidth} normally sets the length of the systems on
1282 the page. However, a negative value has a special meaning. If
1283 @code{linewidth} is less than 0, no line breaks are inserted into the
1284 score, and the spacing is set to natural length: a short phrase takes up
1285 little space, a longer phrase more space.
1290 \notes @{ c'4 d'4 @}
1293 In previous examples, notes were specified in relative octaves,
1294 i.e. each note was put in the octave that would put it closest to its
1295 predecessor. Besides relative, there is also absolute octave
1296 specification, which you get when you don't specify @code{\relative}. In
1297 this input mode, the central C is denoted by @code{c'}. Going down, you
1298 get @code{c} @code{c,} @code{c,,} etc. Going up, you get @code{c''}
1301 When you're copying music from existing sheet music, relative octaves
1302 are probably the easiest to use: it's less typing work and errors are
1303 easily spotted. However, if you write LilyPond input, either by hand
1304 (ie. composing) or by computer, absolute octaves are probably less work.
1312 The @code{\header} is normally at the top of the file, where it sets
1313 values for the rest of the file. If you want to typeset different pieces
1314 from one file (for example, if there are multiple movements, or if
1315 you're making an exercise book), you can put different @code{\score}
1316 blocks into the input file. ly2dvi will assemble all LilyPond output
1317 files into a big document. The contents of \header blocks specified
1318 within each score, are used for the titling of each movement.
1324 For example, the Opus number is put at the right, and the piece string
1325 will be at the left.
1329 @node A piano excerpt
1330 @section A piano excerpt
1332 Our fourth subject is a piece of piano music. The fragment in the input
1333 file is a piano reduction of the G major Sinfonia by Giovanni Battista
1334 Sammartini. It was composed around 1740. It's in the source package
1335 under the name @file{sammartini.ly}.
1338 \include "paper16.ly"
1340 stemDown = \property Voice.Stem \override #'direction = #-1
1341 stemUp = \property Voice.Stem \override #'direction = #1
1342 stemBoth = \property Voice.Stem \revert #'direction
1344 viola = \notes \relative c' \context Voice = viola {
1345 <c4-\f-\arpeggio g' c>
1351 oboes = \notes \relative c'' \context Voice = oboe {
1352 \stemUp s4 g8. b,16 c8 r <e'8.^\p g> <f16 a>
1353 \grace <e8( g> <d4 )f> <c2 e>
1354 \times 2/3 { <d8 \< f> <e g> <f a> }
1356 { \times 2/3 { a8 g c } \! c2 }
1357 \context Voice = oboeTwo {
1360 \property Grace.Stem \override #'direction = #-1
1366 \grace <c,8( e> <)b8. d8.-\trill> <c16 e> |
1367 [<d ( f> < )f8. a>] <)b,8 d> r [<d16( f> <f8. )a>] <b,8 d> r |
1368 [<c16( e> < )e8. g>] <c8 e,>
1371 hoomPah = \repeat unfold 8 \notes
1372 \transpose c' { \stemUp c8 \stemBoth \stemDown c'8 \stemBoth }
1374 bassvoices = \notes \relative c' {
1376 \autochange Staff \hoomPah
1377 \translator Staff = down
1378 \stemDown [c8 c'8] r4
1380 < {\stemUp r2 <e4 c'> <c8 g'> }
1381 \context Voice = reallyLow {\stemDown g2 ~ | g4 c8 } >
1385 \context PianoStaff \notes <
1386 \context Staff = up < \time 2/2
1390 \context Staff = down < \time 2/2 \clef bass
1397 linewidth = 15.0 \cm }
1401 If this looks like incomprehensible gibberish to you, you are right.
1402 This example has been doctored to have as many quirks as possible.
1404 As you can see, this example features multiple voices on one staff. To
1405 make room for those voices, their notes have to be stemmed in opposite
1408 Printed symbols are internally represented by so-called Graphical
1409 Objects (more colloquially: Grobs). These statements concern the
1410 grob called `Stem'. Each grob is described by a bunch of settings. These
1411 setting determine the fonts, offsets, sub-routines to be called on the
1412 grob, etc. The initial values of these settings are set in the Scheme
1413 file @file{scm/grob-description.scm}.
1417 stemDown = \property Voice.Stem \override #'direction = #-1
1420 Set a proprerty for all Stem grobs in the current Voice:
1421 @code{direction} is set to @code{-1}, which encodes down. The setting
1422 remains in effect until it is reverted.
1426 \property Voice.Stem \revert #'direction
1429 Revert the to the previous setting. The effect of precisely one
1430 @code{\stemDown} or @code{\stemUp} is neutralised.
1433 LilyPond includes the identifiers @code{\stemUp}, @code{\stemDown} along
1434 with some other commonly used formatting instructions, but to explain how
1435 it works, we wrote our own here. Of course, you should use predefined
1436 identifiers like these if possible: then you will be affected less by
1437 the implementation changes we occasionally make.
1441 viola = \notes \relative c' \context Voice = viola @{
1443 In this example, you can see multiple parts on a staff. Each part is
1444 associated with one notation context. This notation context handles
1445 stems and dynamics (among others). The name of this context is
1446 @code{Voice}. For each part we have to make sure that there is
1447 precisely one @code{Voice} context, so we give it an unique name
1452 <c4-\f-\arpeggio g' c>
1454 The delimiters @code{<} and @code{>} are shorthands for
1455 @code{\simultaneous @{} and @code{@}}. The expression enclosed in
1456 @code{<} and @code{>} is a chord.
1463 @code{\f} places a forte symbol under the chord. The forte applies to
1464 the whole chord, but the syntax requires that commands like forte and
1465 arpeggio are attached to a note, so here we attach them to the first
1468 @code{\arpeggio} typesets an arpeggio sign (a wavy vertical line) before
1481 Relative octaves work a little differently with chords. The starting
1482 point for the note following a chord is the first note of the chord. So
1483 the @code{g} gets an octave up quote: it is a fifth above the starting
1484 note of the previous chord (the central C).
1490 @code{s} is a spacer rest. It does not print anything, but it does have
1491 the duration of a rest. It is useful for filling up voices that
1492 temporarily don't play. In this case, the viola doesn't come until one
1493 and a half measure later.
1497 oboes = \notes \relative c'' \context Voice = oboe @{
1499 Now comes a part for two oboes. They play homophonically, so we
1500 print the notes as one voice that makes chords. Again, we insure that
1501 these notes are indeed processed by precisely one context with
1505 \stemUp s4 g8. b,16 c8 r <e'8.-\p g> <f16 a>
1507 @code{\stemUp} is a reference to the @code{\property \override} command
1511 \grace <e8 g> < d4 f> <c2 e>
1513 @cindex @code{\grace}
1517 @code{\grace} introduces grace notes. It takes one argument, in this
1521 The slur started on the @code{e} of the chord
1522 will be attached to the next note.@footnote{LilyPond will squirm
1523 about unended Slurs. In this case, you can ignore the warning}.
1531 Tuplets are made with the @code{\times} keyword. It takes two
1532 arguments: a fraction and a piece of music. The duration of the piece
1533 of music is multiplied by the fraction. Triplets make notes occupy 2/3
1534 of their notated duration, so in this case the fraction is 2/3.
1537 @{ <d8 \< f> <e g> <f a> @}
1539 The piece of music to be `tripletted' is sequential music containing
1540 three notes. On the first chord, a crescendo is started with
1541 @code{\<}. To be precise, the crescendo start is syntactically attached
1542 to the preceding note, the @code{d}.
1552 At this point, the homophonic music splits into two rhythmically
1553 different parts. We can't use a sequence of chords to enter this, so
1554 we make a `chord' of sequences to do it. We start with the upper
1555 voice, which continues with upward stems:
1558 @{ \times 2/3 @{ a8 g c @} \! c2 @}
1563 The crescendo is ended at the half note by the escaped exclamation
1567 \context Voice = oboeTwo @{
1570 We can't share stems with the other voice, so we have to create a new
1571 @code{Voice} context. We give it the name @code{oboeTwo} to distinguish
1572 it from the other context. Stems go down in this voice.
1577 @cindex Grace context
1578 When a grace section is processed, a @code{Grace} context is
1579 created. This context acts like a miniature score of its own. It has
1580 its own time bookkeeping, and you can make notes, beams, slurs
1581 etc. Here we fiddle with a property and make a beam. The argument of
1582 @code{\grace} is sequential music.
1586 \property Grace.Stem \override #'direction = #-1
1590 Normally, grace notes are always stem up, but in this case, the upper
1591 voice interferes. We set the stems down here.
1593 As far as relative mode is concerned, the previous note is the
1594 @code{c'''2} of the upper voice, so we have to go an octave down for
1602 This ends the two-part section.
1606 \grace <c,8( e> <)b8. d8.-\trill> <c16 e> |
1611 @code{\stemBoth} ends the forced stem directions. From here, stems are
1612 positioned as if it were single part music.
1614 The bass has a little hoom-pah melody to demonstrate parts switching
1615 between staffs. Since it is repetitive, we use repeats:
1618 hoomPah = \repeat unfold 8
1620 @cindex unfolded @code{\repeat}
1621 The unfolded repeat prints the notes in its argument as if they were
1622 written out in full eight times.
1625 \notes \transpose c' @{
1628 @cindex relative mode and transposing
1630 Transposing can be done with @code{\transpose}. It takes two arguments
1631 the first specifies what central C should be transposed to. The second
1632 is the to-be-transposed music. As you can see, in this case, the
1633 transposition has no effect, as central C stays at central C.
1635 The purpose of this no-op is circumventing relative mode. Relative mode
1636 can not be used together with transposition, so @code{\relative} will
1637 leave the contents of @code{\hoomPah} alone. We can use it without
1638 having to worry about getting the motive in a wrong octave.
1641 bassvoices = \notes \relative c' @{
1643 \autochange Staff \hoomPah
1645 @cindex staff switch, automatic
1646 @cindex cross staff voice, automatic
1647 @cindex @code{\autochange}
1649 Voices can switch between staffs. The easiest way to get this, is to use
1650 @code{\autochange}. This command looks at the pitch of each note, and if
1651 necessary, will cross to the other staff. For this to work, the two
1652 staffs must be called @code{"up"} and @code{"down"}.
1655 \translator Staff = down
1657 @cindex staff switch
1658 @cindex cross staff voice
1659 We want the remaining part of this melody on the lower staff, so we do a
1660 manual staff switch here.
1665 \context Voice = reallyLow @{\stemDown g2 ~ | g4 c8 @} >
1669 After skipping some lines, we see @code{~}. This mark makes ties. Note
1670 that ties and slurs are different things. A tie can only connect two
1671 note heads of the same pitch, whereas a slur can connect many chords
1678 A special context is needed to get cross staff beaming right. This
1679 context is called @code{PianoStaff}.
1682 \context Staff = bottom < \time 2/2 \clef bass
1684 The bottom staff must have a different clef.
1689 To make some more room on the line, the first (in this case the only)
1690 line is not indented. The line still looks very cramped, but that is due
1691 to the page layout of this document.
1697 * font-size, multi-stanza.
1699 * Simple part combining in a Hymn
1703 @node An orchestral score
1704 @section An orchestral score
1708 * Extracting an individual part::
1712 Our last two examples show a way to setup the music for an orchestral
1713 score. When typesetting a piece for several instruments, you'll want to
1714 create a conductor's full score, alongside several individual parts.
1716 LilyPond is well suited for this task. We will declare the music for
1717 each instrument individually, giving the music of each instrument its
1718 own name. These pieces of music are then combined in different
1719 @code{\score} blocks to produce different combinations of the score.
1721 This orchestral score example consists of three input files. In the
1722 first file, @file{os-music.ly}, we define the music for all instruments.
1723 This file will be used both for producing the score and the separate
1726 If you were to run lilypond on this file, no printable output would be
1732 title = "Zo, goed lieverd?"
1733 subtitle = "How's, this babe?"
1742 Key = \notes \key as \major
1743 flautoI = \notes\relative c'' @{
1745 bes as bes as bes as bes as
1747 flautoII = \notes\relative c'' @{
1748 as8 bes as bes R1 d4 ~ d
1750 tromboI = \notes\relative c'' @{
1751 c4. c8 c8 c4. es4 r as, r
1753 tromboII = \notes\relative c'' @{
1754 as4. as8 as8 as4. R1*1/2 as4 es'
1756 timpani = \notes\relative c, @{
1757 \times 2/3 @{ f4 f f @}
1758 \times 4/5 @{ as8 as as as as @}
1761 corno = \notes\relative c' @{
1762 bes4 d f, bes d f, bes d
1766 We will not go through the input line by line, but only indicate and
1767 explain the new elements.
1774 \skip 2*4 \bar "|.";
1778 Declare setting to be used globally. The @code{\skip} command produces
1779 no output, but moves forward in time: in this case, the duration of a
1780 half note (@code{2}), and that four times (@code{*4}). This brings us
1781 to the end of the piece, and we can set the end bar.
1785 Key = \notes \key as \major
1787 Declare the key signature of the piece and assign it to the identifier
1788 @var{Key}. Lateron, we'll use @code{\Key} for all staffs except those
1789 for transposing instruments.
1791 @node The full score
1792 @subsection The full score
1795 The second file, @file{os-score.ly} reads the definitions of the first
1796 (@file{os-music.ly}), and defines the @code{\score} block for the full
1802 \include "os-music.ly"
1803 \include "paper13.ly"
1805 #(set! point-and-click line-column-location)
1806 #(define text-flat '((font-relative-size . -2)
1807 (music "accidentals--1")))
1812 \property Score.BarNumber \override #'padding = #3
1813 \context StaffGroup = woodwind <
1814 \context Staff = flauti <
1815 \property Staff.midiInstrument = #"flute"
1816 \property Staff.instrument = "2 Flauti"
1817 \property Staff.instr = "Fl."
1819 \context Voice=one @{ \voiceOne \flautoI @}
1820 \context Voice=two @{ \voiceTwo \flautoII @}
1823 \context StaffGroup = timpani <
1824 \context Staff = timpani <
1825 \property Staff.midiInstrument = #"timpani"
1826 \property Staff.instrument = #'(lines "Timpani" "(C-G)")
1827 \property Staff.instr = #"Timp."
1833 \context StaffGroup = brass <
1834 \context Staff = trombe <
1835 \property Staff.midiInstrument = #"trumpet"
1836 \property Staff.instrument = #`(lines "2 Trombe" "(C)")
1837 \property Staff.instr = #`(lines "Tbe." "(C)")
1839 \context Voice=one \partcombine Voice
1840 \context Thread=one \tromboI
1841 \context Thread=two \tromboII
1843 \context Staff = corni <
1844 \property Staff.midiInstrument = #"french horn"
1845 \property Staff.instrument = #`(lines "Corno"
1846 (columns "(E" ,text-flat ")"))
1847 \property Staff.instr = #`(lines "Cor."
1848 (columns "(E" ,text-flat ")"))
1849 \property Staff.transposing = #3
1850 \notes \key bes \major
1851 \context Voice=one \corno
1856 indent = 15 * \staffspace
1857 linewidth = 60 * \staffspace
1858 textheight = 90 * \staffspace
1861 \consists "Multi_measure_rest_engraver"
1864 \HaraKiriStaffContext
1865 \remove "Multi_measure_rest_engraver"
1874 @center @strong{Zo, goed lieverd?}
1876 @center How's, this babe?
1884 @lilypondfile{os-score.ly}
1888 \include "os-music.ly"
1890 First, we need to include the music definitions we made in
1895 #(set! point-and-click line-column-location)
1897 In a large orchestral score like this you're bound to make some small
1898 mistakes, so we enable point and click (See @ref{Point and click})
1903 #(define text-flat '((font-relative-size . -2)
1904 (music "accidentals--1")))
1907 When naming the tuning of the french horn, we'll need a piece of text
1908 with a flat sign. LilyPond has a mechanism for font selection and
1909 kerning called Scheme markup text (See @ref{Text markup}). The flat
1910 sign is taken from the music font, and its name is @code{accidentals--1}
1911 (The sharp sign is called @code{accidentals-+1}). The default font is
1912 too big for text, so we select a relative size of @code{-2}.
1919 Of course, all staffs are simultaneous and use the same global settings.
1923 \property Score.BarNumber \override #'padding = #3
1925 LilyPond prints bar numbers at the start of each line, but
1926 unfortunately, they end up a bit too close to the staff in this example.
1927 A bar number internally is a Grob called @var{BarNumber}. BarNumber
1928 Grobs can be manipulated through their @var{side-position-interface}. One
1929 of the properties of a @var{side-position-interface} that can be tweaked
1930 is the @var{padding}: the amount of extra space that is put between this
1931 Grob and other Grobs. We set the padding to three staff spaces.
1933 You can find all this kind of information in LilyPond's automatically
1934 generated documentation in
1936 @ref{ (lilypond-internals)lilypond-internals, LilyPond Internals}.
1939 the online documentation.
1944 \context StaffGroup = woodwind <
1945 \context Staff = flauti <
1947 A new notation context: the StaffGroup. StaffGroup can hold one or more
1948 Staffs, and will print a big bracket at the left of the score. Start a
1949 new staff group for the woodwind section (just the flutes in this case).
1950 Immediately after that, we start the staff for the two flutes, that also
1951 play simultaneously.
1955 \property Staff.midiInstrument = #"flute"
1957 Specify the instrument for MIDI output (see @ref{MIDI instrument
1962 \property Staff.instrument = "2 Flauti"
1963 \property Staff.instr = "Fl."
1965 And define the instrument names to be printed in the margin,
1966 @code{instrument} for the first line of the score, @code{instr} for the
1973 The flutes play in the default key.
1977 \context Voice=one @{ \voiceOne \flautoI @}
1978 \context Voice=two @{ \voiceTwo \flautoII @}
1980 Last come the actual flute parts. Remember that we're still in
1981 simultaneous mode. We name both voices differently, so that LilyPond
1982 will actually create two Voice contexts. The flute parts are simple, so
1983 we specify manually which voice is which: @code{\voiceOne} forces the
1984 direction of stems, beams, slurs and ties up, @code{\voiceTwo} sets
1992 Close the flutes staff and woodwind staff group.
1996 \property Staff.instrument = #'(lines "Timpani" "(C-G)")
1998 The timpani staff only shows a new piece of scheme markup, it sets two
2003 \context Voice=one \partcombine Voice
2004 \context Thread=one \tromboI
2005 \context Thread=two \tromboII
2007 You have seen the notation contexts Staff and Voice, but here's a new
2008 one: Thread. One or more Threads can be part of a Voice. The Thread
2009 takes care of note heads and rests, the Voice combine note heads onto a
2012 For the trumpets we use the automatic part combiner (see @ref{Automatic
2013 part combining}) to combine the two simultaneous trumpet parts onto the
2014 trumpet staff. Each trumpet gets its own Thread context, which must be
2015 named @code{one} and @code{two}). The part combiner makes these two
2016 threads share a Voice when they're similar, and splits the threads up
2017 when they're different.
2021 \property Staff.instrument = #`(lines "Corno"
2022 (columns "(E" ,text-flat ")"))
2024 The french horn has the most complex scheme markup name, made up of two
2025 lines of text. The second line has two elements (columns), the @code{E}
2026 and the flat sign @code{text-flat} that we defined before.
2030 \property Staff.transposing = #3
2032 The french horn is to be tuned in E-flat, so we tell the MIDI backend to
2033 transpose this staff by three steps.
2035 Note how we can choose different tuning for entering, printing and
2036 playing, using @code{\transpose} and the MIDI Staff proprerty
2041 \notes \key bes \major
2043 Therefore, it has a different key.
2047 indent = 15 * \staffspace
2048 linewidth = 60 * \staffspace
2050 We specify a big indent for the first line and a small linewidth for this
2055 Usually, LilyPond's predefined setup of notation contexts (Thread,
2056 Voice, Staff, Staffgroup, Score) is just fine. But in this case, we
2057 want a different type of Staff context.
2059 In orchestral scores, it often happens that one instrument has only
2060 rests during one line of the score. The @code{HaraKiriStaffContext} can
2061 be used as a regular @code{StaffContext} drop-in and will take care of
2062 the automatic removing of empty staffs.
2064 @node Extracting an individual part
2065 @subsection Extracting an individual part
2067 The third file, @file{os-flute-2.ly} also reads the definitions of the
2068 first (@file{os-music.ly}), and defines the @code{\score} block for the
2072 \include "os-music.ly"
2073 \include "paper16.ly"
2077 \property Score.skipBars = ##t
2078 \property Staff.midiInstrument = #"flute"
2084 instrument = "Flauto II"
2087 linewidth = 80 * \staffspace
2088 textheight = 200 * \staffspace
2096 @center @strong{Zo, goed lieverd?}
2098 @center How's, this babe?
2099 @center @emph{Flauto II}
2106 @lilypondfile{os-flute-2.ly}
2109 Because we separated the music definitions from the @code{\score}
2110 instantiations, we can easily define a second score from the music of
2111 the second flute. This then is the part for the second flute player.
2112 Of course, we make separate parts for all individual instruments.
2118 In this individual part the second flute has a whole staff for itself,
2119 so we don't want to force stem or tie directions.
2124 instrument = "Flauto II"
2127 The @code{\header} definitions were also read from @file{os-music.ly},
2128 but we need to set the instrument for this particular score.
2132 \property Score.skipBars = ##t
2134 In the conductor's full score, all bars with rests are printed, but for
2135 the individual parts, we want to contract pieces of consecutive empty
2136 bars. LilyPond will do this if Score's @var{skipBars} property to
2140 @node Other ways to run LilyPond
2141 @section Other ways to run LilyPond
2143 Until now, you have been using @file{ly2dvi} to invoke LilyPond.
2144 There are three other routes. Firstly, there is a script called
2145 @code{lilypond-book}, that allows you to freely mix LilyPond input with
2146 Texinfo or LaTeX input. For example, this manual was written using
2147 @code{lilypond-book}. It is discussed in @ref{lilypond-book}.
2150 Secondly, you can generate PostScript directly. This is useful if you
2151 can not or do not want to run @TeX{} on your system. To obtain direct
2152 PostScript output, invoke LilyPond as follows:
2153 @cindex PostScript output
2155 lilypond -f ps test.ly
2157 You have to set some environment variables to view or print this
2158 output. More information can be found in @ref{Invoking
2162 Thirdly, if you want to do special things with your output, you can run
2163 invoke lilypond directly:
2167 to produce plain @TeX{} output. Note that La@TeX{} will not work on the
2168 resulting @file{test.tex}. You must run plain @TeX{} on it.
2176 @node Integrating text and music
2177 @section Integrating text and music
2179 Sometimes, you might want to use music examples in a text that you are
2180 writing. For example, if you are writing a musicological treatise, a
2181 songbook, or (like us) the LilyPond manual. You can make such texts by
2182 hand, simply by importing a PostScript figure into your wordprocessor.
2183 However, there is a also an automated procedure:
2185 If you use La@TeX{} or texinfo, you can mix text and lilypond code. A
2186 script called @code{lilypond-book} will extract the music fragments, run
2187 lilypond on them, and put back the resulting notation. lilypond-book is
2188 described fully in @ref{lilypond-book}, but here we show a small
2189 example. Since the example also contains explanatory text, we won't
2190 comment on the contents.
2193 \documentclass[a4paper]@{article@}
2196 In a lilypond-book document, you can freely mix music and text. For
2199 \score @{ \notes \relative c' @{
2200 c2 g'2 \times 2/3 @{ f8 e d @} c'2 g4
2203 Notice that the music line length matches the margin settings of the
2206 If you have no \verb+\score+ block in the fragment,
2207 \texttt@{lilypond-book@} will supply one:
2213 In the example you see here, a number of things happened: a
2214 \verb+\score+ block was added, and the line width was set to natural
2215 length. You can specify many more options using \LaTeX style options
2218 \begin[verbatim,11pt,singleline,
2219 fragment,relative,intertext="hi there!"]@{lilypond@}
2223 \texttt@{verbatim@} also shows the lilypond code, \texttt@{11pt@} selects
2224 the default music size, \texttt@{fragment@} adds a score block,
2225 \texttt@{relative@} uses relative mode for the fragment, and
2226 \texttt@{intertext@} specifies what to print between the
2227 \texttt@{verbatim@} code and the music.
2229 If you include large examples into the text, it may be more convenient
2230 to put the example in a separate file:
2232 \lilypondfile[printfilename]@{sammartini.ly@}
2234 The \texttt@{printfilename@} option adds the file name to the output.
2239 Under Unix, you can view the results as follows.
2242 $ lilypond-book --outdir=out/ lilbook.tex
2243 lilypond-book (GNU LilyPond) 1.3.146
2244 Reading `/home/hanwen/usr/src/lilypond-1.3.146/input/tutorial/lilbook.tex'
2246 `/home/hanwen/usr/src/lilypond-1.3.146/input/tutorial/sammartini.ly'
2247 @var{lots of stuff deleted}
2248 Writing `out/lilbook.latex'
2250 $ latex lilbook.latex
2251 @var{lots of stuff deleted}
2255 Notice the @code{outdir} option to lilypond-book. Running lilypond-book
2256 and running latex creates a lot of temporary files, and you wouldn't
2257 those to clutter up your working directory. Hence, we have them created
2258 in a separate subdirectory.
2260 The result more or less looks like this:
2264 In a lilypond-book document, you can freely mix music and text. For
2267 \score { \notes \relative c' {
2268 c2 g'2 \times 2/3 { f8 e d } c'2 g4
2271 Notice that the music line length matches the margin settings of the
2274 If you have no @code{\score} block in the fragment,
2275 @code{lilypond-book} will supply one:
2281 In the example you see here, a number of things happened: a
2282 @code{\score} block was added, and the line width was set to natural
2283 length. You can specify many more options using La@TeX{} style options
2286 @lilypond[verbatim,11pt,singleline,
2287 fragment,relative,intertext="hi there!"]
2291 @code{verbatim} also shows the lilypond code, @code{11pt} selects
2292 the default music size, @code{fragment} adds a score block,
2293 @code{relative} uses relative mode for the fragment, and
2294 @code{intertext} specifies what to print between the
2295 @code{verbatim} code and the music.
2297 If you include large examples into the text, it may be more convenient
2298 to put the example in a separate file:
2300 @lilypondfile[printfilename]{sammartini.ly}
2302 The @code{printfilename} option adds the file name to the output.
2303 @node end of tutorial
2306 That's all folks. From here, you can either try fiddling with input
2307 files, or you can read the reference manual. You can find more example
2308 files in @file{input} and @file{input/test}. You can also look at some
2309 real music. Have a look at the @uref{Mutopia project,
2310 http://www.mutopiaproject.org}.
2318 this should be on mutopia website.
2323 @c waar deze info? is uiteindelijk wel handig, schat ik.
2326 If you have a big music project, or just a lot of LilyPond input files,
2327 all generated output from LilyPond, @TeX{} and metafont will clutter
2328 your working directory. LilyPond comes with a one-size-fits-all
2329 pre-cooked makefile that helps you manage producing output. It will
2330 produce all output in the directory @file{out} , generate and track
2331 dependencies. Also, it helps in preparing your submission to @ref{Mutopia
2338 cp /usr/share/lilypond/make/ly.make GNUmakefile
2339 cp /usr/share/doc/lilypond/examples/input/tutorial/minuet.ly .
2342 Generated out/minuet.ps for target minuet.
2345 Type @samp{make help} to see possible targets.
2348 @file{/usr/share/lilypond/doc/lilypond/examples/input/mutopia-header.ly}
2354 [TODO: rewrite completely.]
2357 * Songs with additional verses::