3 @c TODO: LilyPond Lilypond lilypond
5 FIXME: choose one of: notation context/interpretation context.
11 LilyPond prints music from a specification that you, the user, supply.
12 You have to give that specification using a textual @emph{language}.
13 This chapter is a gentle introduction to that language.
15 This tutorial will demonstrate how to use Lilypond by presenting
16 examples of input along with resulting output. We will use English
17 terms for notation. In case you are not familiar with those, you may
18 consult the glossary that is distributed with LilyPond.
20 @cindex examples, tutorial
22 The examples discussed are included in the distribution, in the
23 subdirectory @file{input/tutorial/}@footnote{When we refer
24 to filenames, they are relative to the top directory of the source
25 package. In binary installations you should look in your doc section,
26 eg, @code{/usr/share/doc/lilypond1.3/examples/input/tutorial}
28 }. We recommend that you experiment with writing Lilypond input
29 yourself, to get a feel for how the program behaves.
32 * Running LilyPond:: Getting started
33 * The first tune:: The first tune
34 * Lyrics and chords:: Lyrics and chords
36 * A piano excerpt:: Piano music
37 * An orchestral score::
38 * Other ways to run LilyPond::
39 * Latex and texinfo integration::
40 * end of tutorial:: The end
44 @node Running LilyPond
45 @section Running LilyPond
47 Before we dive into describing the input language of LilyPond, we first
48 show you through the procedure for getting notes on your screen and out
51 The first step is creating an input file. Using your favorite
52 text-editor, create @file{test.ly} containing
56 NOTE: if you're reading this, ie, the Texinfo source itself, test.ly
57 should of course contain:
67 \notes @{ c'4 e' g' @}
71 @unnumberedsubsec Unix
72 @cindex Unix, Running lilypond on
75 On unix, you invoke ly2dvi to compile your lilypond source file (you can
82 You will see the following on your screen:
86 Now processing: `/home/fred/ly/test.ly'
88 Interpreting music...[1]
89 Preprocessing elements...
90 Calculating column positions... [2]
91 paper output to test.tex...
96 PS output to test.ps...
97 DVI output to test.dvi...
100 The results of the ly2dvi run are a ``DeVice Independent'' file
101 (@file{test.dvi}) and a PostScript file (@file{test.ps}).
105 @cindex Viewing music
109 To view the @code{test.dvi} output, run Xdvi (you may omit the
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
139 @unnumberedsubsec Windows
143 * setting of env vars (TFMFONTS,MFINPUTS,TEXINPUTS)
145 * dvi viewer doesn't display postscript
149 @section The first tune
152 To demonstrate what LilyPond input looks like, we start off with a
153 full-fledged, yet simple example. It is a convoluted version
154 of the famous menuet in J. S. Bach's @emph{Klavierb@"uchlein}. The file
155 is included in the distribution as @file{menuet.ly}.
156 @cindex Bach, Johann Sebastian
159 % all text after a percent sign is a comment
160 % and is ignored by Lilypond
161 \include "paper16.ly"
164 \relative c'' \sequential {
169 d4 g,8 a b c d4 g, g |
170 e'4 c8 d e fis g4 g, g |
171 c4 d8( )c b a( )b4 c8 b a g |
172 a4 [b8 a] [g fis] g2. |
177 g4 e8 fis g d cis4 b8 cis a4 |
178 a8-. b-. cis-. d-. e-. fis-.
185 % standard settings are too wide for a book
191 We will analyse the input, line by line.
194 % all text after a percent sign is a comment
195 % and is ignored by Lilypond
197 The percent sign, @code{%}, introduces a line comment. You can also
198 comment out a block of several lines, by enclosing them in
199 @code{%@{} and @code{%@}}.
201 @cindex block comment
206 \include "paper16.ly"
209 @cindex @code{\include}
210 @cindex point, printer's
211 @cindex staff size setting
212 By default, LilyPond will typeset the music in a size such that each
213 staff is 20 point@footnote{A point is the standard measure of length for
214 printing; one point is 1/72.27 inch.} high. We want smaller
215 output (16 point staff height), so we must import the settings for that
216 size, which is done here.
223 Music is printed by combining a piece of music with directions for
224 outputting it. This combination is formed in the @code{\score} block.
231 Prepare LilyPond for accepting notes.
232 @cindex octaves, choosing
241 As we will see, each note is described by its note name, duration,
242 octave and possibly a chromatic alteration. In this setup, the octave
243 is indicated by using high quotes (@code{'}) and ``lowered quotes''
244 (commas: @code{,}). The central C is denoted by @code{c'}. The C one
245 octave higher is @code{c''}. One and two octaves below the central C is
246 denoted by @code{c} and @code{c,} respectively.
248 Even though a piece of music often spans a range of several octaves, it
249 mostly moves in small intervals. LilyPond has a special entry mode to
250 save typing in this situation. In this ``relative'' octave mode,
251 octaves of notes without quotes are chosen such that a note is as close
252 as possible (graphically, on the staff) to the preceding note. If you
253 add a high-quote an extra octave is added. A lowered quote (a comma)
254 will subtract an extra octave.
256 Because the first note has no predecessor,
257 you have to give the (absolute) pitch of the note to start with.
264 What follows is sequential music, i.e.,
265 @cindex sequential music
266 notes that are to be played and printed after each other.
273 @cindex time signature, setting
275 Set (or change) the time signature of the current piece: a 3/4 sign is
276 printed. The time signature setting is also used to generate bar lines
284 @cindex key signature, setting
286 Set (or change) the current key signature to G-major. Although in this
287 example, the @code{\key} command happened to be entered after the
288 @code{\time} command, in the output the time signature will be printed
289 after the key signature; LilyPond knows about music typesetting
297 The following piece of music is played twice. The first argument
298 indicates the type of repeat. In this case, @code{"volta"} means that
299 prima volta/secunda volta brackets are used for the alternative
300 endings---if there were any.
307 The subject of the repeat is again sequential music. Since
308 @code{\sequential} is such a common construct, a shorthand is provided:
309 just leave off @code{\sequential}, and the result is the same.
316 Two notes. The first note is a quarter note with relative pitch
317 @code{d}. The relative music was started with a @code{c''}, so the real
318 pitch of this note is @code{d''}. The duration of a note is designated
319 by a number; the @code{4} here represents a quarter note.
321 The second note is an eight note with relative pitch @code{g,}. The
322 pitch is taken relative to the previous @code{d''}, making this
323 note have real pitch @code{g'}. The @code{8} represents an eight note.
330 Two more notes, with pitch @code{a} and @code{b}. Because their
331 duration is the same as the @code{g,8}, there is no need to enter the
332 duration, but you may enter it anyway, i.e., @code{a4 b4}
341 @cindex errors, finding
342 Three more notes. The @code{|} character is a ``bar check''. LilyPond
343 will verify that bar checks are found at the start of a measure. This can
344 help you track down typing errors.
346 @cindex alteration, chromatic
347 @cindex chromatic alteration
354 So far, no notes were chromatically altered. Here is the first one that
355 is: @code{fis}. Lilypond by default uses Dutch@footnote{Note names are
356 available in several languages, but we find the Dutch names quite
357 convenient.} note names, and ``Fis'' is the Dutch note name for ``F
358 sharp''. However, there is no sharp sign in the output. The program
359 keeps track of key signatures, and will only print accidentals if they
362 For groups of eighth notes and shorter, LilyPond can determine how the
363 notes should form a beam. In this case, the 4 eights are automatically
368 c4 d8( )c b a( )b4 c8 b a g |
371 The beginning and ending notes of a slur are marked with parentheses,
372 @code{(} and @code{)} for start and end respectively. The line above
373 indicates two slurs. These slur markers (parentheses) are entered
374 between the slurred notes.
381 Automatic beaming can be overridden by inserting beam marks, @code{[}
382 and @code{]}. These beam markers (brackets) are put around the notes
390 @cindex augmentation dot
392 A period adds an augmentation dot to the note.
399 The end of the sequential music to be repeated. LilyPond will typeset a
407 Accidentals are printed whenever necessary: the first C sharp of the bar
408 will be printed with an accidental, the second one without.
412 a8-. b-. cis-. d-. e-. fis-.
416 You can enter articulation signs either in a verbose form or using a
417 shorthand. Here we demonstrate the shorthand: it is formed by a dash
418 and the character for the articulation to use, e.g. @code{-.} for
419 staccato as shown above.
427 Rests are denoted by the special notename @code{r}.
434 All articulations have a verbose form, like @code{\fermata}. The
435 command @code{\fermata} is not part of the core of the language, but it
436 is a shorthand for a more complicated description of a fermata symbol.
437 @code{\fermata} names that description and is therefore called an
440 @cindex @code{\fermata}
446 Here the music ends. LilyPond does not automatically typeset and end
447 bar, we must explicitely request one, using @code{"|."}.
448 @c FIXME: Why not?! better to override \bar "" if not wanted?
457 The @code{\paper} block specifies how entered music should be converted
458 to notation output. Most of the details of the conversion (font sizes,
459 dimensions, etc.) have been taken care of, but to fit the output in this
460 document, it has to be narrower. We do this by setting the line width
461 to 14 centimeters (approximately 5.5 inches).
468 The last brace ends the @code{\score} block.
473 @node Lyrics and chords
474 @section Lyrics and chords
476 In this section we show how to typeset a song. This file is
477 included as @file{flowing.ly}.
481 title = "The river is flowing"
482 composer = "Traditional"
484 \include "paper16.ly"
485 melody = \notes \relative c' @{
489 c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
490 c4 c8 d [es () d] c4 | d4 es8 d c4.
495 The ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
496 ri -- ver is flo -- wing down to the sea.
499 accompaniment =\chords @{
501 c2:3- f:3-.7 d:min es4 c8:min r8
502 c2:min f:min7 g:7^3.5 c:min @}
507 \context ChordNames \accompaniment
510 \context Staff = mel @{
511 \property Staff.noAutoBeaming = ##t
512 \property Staff.automaticMelismata = ##t
515 \context Lyrics \text
517 \midi @{ \tempo 4=72 @}
518 \paper @{ linewidth = 10.0\cm @}
523 The result would look this.@footnote{The titling and font size shown
524 may differ, since the titling in this document is not generated by
527 @center @strong{The river is flowing}
532 title = "The river is flowing"
533 composer = "Traditional"
535 \include "paper16.ly"
536 melody = \notes \relative c' {
540 c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
541 c4 c8 d [es () d] c4 | d4 es8 d c4.
546 The ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
547 ri -- ver is flo -- wing down to the sea.
550 accompaniment =\chords {
552 c2:3- f:3-.7 d:min es4 c8:min r8
553 c2:min f:min7 g:7^3.5 c:min }
558 \context ChordNames \accompaniment
561 \context Staff = mel {
562 \property Staff.noAutoBeaming = ##t
563 \property Staff.automaticMelismata = ##t
566 \context Lyrics \text
568 \midi { \tempo 4=72 }
569 \paper { linewidth = 10.0\cm }
573 Again, we will dissect the file line by line.
580 @cindex @code{\header}
581 Information about the music you are about to typeset goes into a
582 @code{\header} block. The information in this block is not used by
583 LilyPond, but it is passed into the output. @file{ly2dvi} uses this
584 information to print titles above the music.
588 title = "The river is flowing"
589 composer = "Traditional (?)"
592 @cindex identifier assignment
593 the @code{\header} block contains assignments. In each assignment, a
594 variable is set to a value. Lexically, both the variable name and the
595 assigned value are strings. The values have to be quoted here, because
596 they contain spaces, the variable names could also be put within quotes
597 but it is not necessary. Each assignment is finished with a semicolon.
601 \include "paper16.ly"
604 Smaller size for inclusion in a book.
608 melody = \notes \relative c' @{
611 The structure of the file will be the same as the previous one, a
612 @code{\score} block with music in it. To keep things readable, we will
613 give names to the different parts of music, and use the names to
614 construct the music within the score block.
621 @cindex @code{\partial}
623 The piece starts with an anacrusis of one eighth.
628 The key is C minor: we have three flats.
633 c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
634 c4 c8 d [es () d] c4 | d4 es8 d c4.
639 @cindex manual beaming
640 @cindex automatic beaming, turning off
641 We use explicit beaming. Since this is a song, we turn automatic
642 beams off, and use explicit beaming where needed.
649 This ends the definition of @code{melody}. Note that there are no
650 semicolons after assignments at the top level.
652 [FIXME: no longer true for 146?]
661 @cindex identifier assignment
662 @cindex syllables, entering
663 Another identifier assignment. This one is for the lyrics.
664 Lyrics are formed by syllables that have duration, and not by
665 notes. To make LilyPond parse words as syllables, switch it into
666 lyrics mode with @code{\lyrics}. Again, the brace after @code{\lyrics}
667 is a shorthand for @code{\sequential @{}.
671 The4 ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
672 ri- ver is flo- __ wing down to the sea.
676 @cindex extenders, lyric
677 @cindex hyphens, lyric
678 The syllables themselves are separated by spaces. You can get syllable
679 extenders by entering @code{__}, and centered hyphens with
680 @code{-}@code{-}. We enter the syllables as if they are all quarter notes
681 in length (hence the @code{4}), and use a feature to align the
682 syllables to the music, which obviously isn't all quarter notes.
686 accompaniment =\chords @{
691 We'll put chords over the music. To enter them, there is a special mode
692 analogous to @code{\lyrics} and @code{\notes} mode, where you can give
693 the names of the chords you want, instead of listing the notes
694 comprising the chord.
701 There is no accompaniment during the anacrusis.
710 @cindex chord modifier
711 @cindex modifier, chord
712 A chord is started by the tonic of the chord. The
713 first one lasts a half note. An unadorned note creates a major
714 triad. Since a minor triad is wanted, @code{3-} is added to modify the
715 third to be small. @code{7} modifies (adds) a seventh, which is small by
716 default to create the @code{f a c es} chord. Multiple modifiers must be
725 Some modifiers have predefined names, eg. @code{min} is the same as
726 @code{3-}, so @code{d-min} is a minor @code{d} chord.
730 c2:min f:min7 g:7^3.5 c:min @}
733 @cindex named modifier
735 A named modifier @code{min} and a normal modifier @code{7} do not have
736 to be separated by a dot. Tones from a chord are removed with chord
737 subtractions. Subtractions are started with a caret, and they are
738 also separated by dots. In this example, @code{g:7^3.5} produces a
739 minor seventh. The brace ends the sequential music.
747 We assemble the music in the @code{\score} block. Melody, lyrics and
748 accompaniment have to sound at the same time, so they should be
749 @code{\simultaneous}.
750 @cindex @code{\simultaneous}
757 Chord mode generates notes grouped in @code{\simultaneous} music. If
758 you remove the comment sign, you can see the chords in normal
759 notation: they will be printed as note heads on a separate
760 staff. To print them as chords names, they have to be interpreted as
761 being chords, not notes. This is done with the following command:
765 \context ChordNames \accompaniment
769 @cindex interpretation context
770 @cindex notation context
773 Normally, the notes that you enter are transformed into note heads.
774 Note heads alone make no sense, they need surrounding information: a key
775 signature, a clef, staff lines, etc. They need @emph{context}. In
776 LilyPond, these symbols are created by objects called `interpretation
777 contexts'. Interpretation contexts (or `Notation contexts') only exist
778 during a run of LilyPond.
780 By default, LilyPond will create a Staff context for you. If you would
781 remove the @code{%} sign in the previous line, you would see that
784 We don't want that default here, because we want chord names. The
785 command above explicitly creates an interpretation context of
786 @code{ChordNames} type to interpret the music @code{\accompaniment}.
793 @cindex @code{\addlyrics}
794 @cindex lyrics and melody, combining
795 @cindex combining lyrics and melody
797 The lyrics should be aligned with the melody. This is done by
798 combining both with @code{\addlyrics}. @code{\addlyrics} takes two
799 pieces of music (usually a melody and lyrics, in that order) and
800 aligns the syllables of the second piece under the notes of the
801 first piece. If you would reverse the order, the notes would be
802 aligned on the lyrics, which is not very useful, and looks
807 \context Staff = mel @{
811 The second argument of @code{\addlyrics} is the melody. We instantiate
812 a @code{Staff} context explicitly: should you choose to remove the
813 comment before the ``note heads'' version of the accompaniment, the
814 accompaniment will be on a nameless staff. The melody has to be on
815 staff different from the accompaniment. This is accomplished by giving
816 the melody and accompaniment staffs different names.
820 \property Staff.noAutoBeaming = ##t
824 @cindex context variables
825 @cindex setting context variables
826 An interpretation context has variables, called properties, that tune
827 its behaviour. One of the variables is @code{noAutoBeaming}. Setting
828 this Staff's property to @code{##t}, which is the boolean value @var{true},
829 turns the automatic beaming mechanism off for the current staff.
832 @cindex accessing Scheme
833 @cindex evaluating Scheme
836 LilyPond internally uses GUILE, a Scheme-interpreter. Scheme is a
837 language from the LISP family. You can learn more about Scheme at
838 @uref{http://www.scheme.org}. It is used to represent data throughout
839 the whole program. The hash-sign (@code{#}) accesses GUILE directly: the
840 code following the hash-sign is evaluated as Scheme. The boolean value
841 @var{true} is @code{#t} in Scheme, so for LilyPond @var{true} looks like
844 If Scheme scares you, don't worry. You don't need to know Scheme to
845 create beautiful sheet music.
852 \property Staff.automaticMelismata = ##t
855 @cindex automaticMelismata
857 @cindex @code{\addlyrics} and slurs
858 Similarly, we don't want to print a syllable when there is
859 a slur. This sets up @code{\addlyrics} to not put lyrics under each
860 separate note while there is a slur.
868 Finally, we put the melody on the current staff. Note that the
869 @code{\property} directives and @code{\melody} are grouped in sequential
870 music, so the property settings are done before the melody is
875 \context Lyrics \text
878 The second argument of @code{\addlyrics} is the text. The text also
879 should not land on a Staff, but on a interpretation context for
880 syllables, extenders, hyphens etc. This context is called
885 \midi @{ \tempo 4=72@}
888 MIDI (Musical Instrument Digital Interface) is a standard for
889 connecting and recording digital instruments. So a MIDI file is like a
890 tape recording of an instrument. The @code{\midi} block causes makes the
891 music go to a MIDI file, so you can listen to the music you entered. It
892 is great for checking the music. Whenever you hear something weird, you
893 probably hear a typing error.
895 Syntactically, @code{\midi} is similar to @code{\paper @{ @}}, since it
896 also specifies an output method. You can specify the tempo using the
897 @code{\tempo} command, in this case the tempo of quarter notes is set to
902 \paper @{ linewidth = 10.0\cm @}
905 We also want notation output. The linewidth is short so the piece
906 will be set in two lines.
909 @section More movements
911 [FIXME: merge here with, or move this to: Other ways to run LilyPond]
913 You probably ran @file{ly2dvi} on the last example, and ended up with a
914 viewable @file{.dvi} file. However, between there are a few steps of
915 which LilyPond is only one. To enhance your understanding of what's
916 happening under the hood when you run @code{ly2dvi}, we explain what
919 @code{ly2dvi} is a program that calls a number of programs in sequence.
920 The first thing it does, is running LilyPond on the input file. After
921 some calculations, a @file{.tex} is produced. The contents
922 of this file are very low-level instructions.
924 For example, the following file (@file{miniatures.ly})
928 \header @{ title = "Two miniatures" @}
930 #(set! point-and-click line-column-location)
932 \paper @{ linewidth = -1.0 @}
948 The titling in this manual was not generated by ly2dvi, so we can't
949 exactly show it would look, but the result should resemble this:
951 @center @strong{Two miniatures}
961 \paper { linewidth = -1.0 }
973 \paper { linewidth = -1.0 }
977 This file is produced by ly2dvi in a few stages, with the help of text
978 formatting tools. LilyPond produces two output files, @file{miniatures.tex}
979 and @file{miniatures-1.tex}. They both look like this:
983 \placebox@{-5 \outputscale @}%
984 @{ 8.7229 \outputscale @}%
985 @{\magfontWXGEomMMBo\char90 @}%
987 \placebox@{-4 \outputscale @}%
988 @{ 81.0647 \outputscale @}%
992 @file{ly2dvi} looks at what output LilyPond produces, and generates a
993 file called @file{ly2dvi.out.tex}. This file contains formatting
994 instructions for the title and page layout. A fragment might look like
998 \def\lilypondopus@{Opus 1.@}
999 \def\lilypondpiece@{Up@}
1000 \def\mustmakelilypondtitle@{@}
1001 \input miniatures.tex
1002 \def\lilypondtitle@{Two miniatures@}
1006 @file{ly2dvi} runs it through LaTeX. LaTeX is a text-formatting system
1007 built on top of @TeX{}. It's very popular in the academic world. If LaTeX
1008 is successful, this will produce a @file{.dvi} file, containing both the
1009 titling and the actual music. @code{ly2dvi} completes its task by
1010 deleting the two temporary files, leaving only @file{miniatures.dvi}.
1012 Next, now we'll look at the example line by line to explain new things.
1018 Lilypond and its language are still under development, and occasionally,
1019 details of the syntax are changed. This fragment indicates for which
1020 version the input file was written. When you compile this file, the
1021 version number will be checked, and you will get a warning when the file
1024 This version number is also used by the @code{convert-ly} program (See
1025 @ref{convert-ly}), which uses it to update the file to the latest lily
1030 \header @{ title = "Two miniatures" @}
1032 This sets the titling information for the entire file.
1036 #(set! point-and-click line-column-location)
1039 This piece of Scheme code sets the Scheme variable
1040 @code{point-and-click} to the value @var{line-column-location} (which
1041 itself is a Scheme procedure).
1043 Editing input files can be quite complicated if you're working with
1044 large files: if you're digitizing existing music, you have to
1045 synchronize the .ly file, the sheet music on your lap and the sheet
1046 music on the screen. The point-and-click mechanism makes it easy to
1047 find the origin of an error in the .ly file: when you view the file with
1048 Xdvi and click on a note, your editor will jump to the spot where that
1049 note was entered. For more information, see @ref{Point and click}.
1056 The @code{\score} blocks that follow in the file don't have
1057 @code{\paper} sections, so the settings of this block are substituted: A
1058 paper block, at top-level, i.e. not in a @code{\score} block sets the
1059 default page layout.
1068 The variable @code{linewidth} normally sets the length of the systems on
1069 the page. However, a negative value has a special meaning. If
1070 @code{linewidth} is less than 0, no line breaks are inserted into the
1071 score, and the spacing is set to natural length: a short phrase takes up
1072 little space, a longer phrase more space.
1077 \notes @{ c'4 d'4 @}
1080 In previous examples, notes were specified in relative octaves,
1081 i.e. each note was put in the octave that would put it closest to its
1082 predecessor. Besides relative, there is also absolute octave
1083 specification, which you get when you don't specify @code{\relative}. In
1084 this input mode, the central C is denoted by @code{c'}. Going down, you
1085 get @code{c} @code{c,} @code{c,,} etc. Going up, you get @code{c''}
1088 When you're copying music from existing sheet music, relative octaves
1089 are probably the easiest to use: it's less typing work and errors are
1090 easily spotted. However, if you write LilyPond input, either by hand
1091 (ie. composing) or by computer, absolute octaves are probably less work.
1099 The @code{\header} is normally at the top of the file, where it sets
1100 values for the rest of the file. If you want to typeset different pieces
1101 from one file (for example, if there are multiple movements, or if
1102 you're making an exercise book), you can put different @code{\score}
1103 blocks into the input file. ly2dvi will assemble all LilyPond output
1104 files into a big document. The contents of \header blocks specified
1105 within each score, are used for the titling of each movement.
1111 For example, the Opus number is put at the right, and the piece string
1112 will be at the left.
1116 @node A piano excerpt
1117 @section A piano excerpt
1119 Our fourth subject is a piece of piano music. The fragment in the input
1120 file is a piano reduction of the G major Sinfonia by Giovanni Battista
1121 Sammartini. It was composed around 1740. It's in the source package
1122 under the name @file{sammartini.ly}.
1125 \include "paper16.ly"
1127 stemDown = \property Voice.Stem \override #'direction = #-1
1128 stemUp = \property Voice.Stem \override #'direction = #1
1129 stemBoth = \property Voice.Stem \revert #'direction
1131 viola = \notes \relative c' \context Voice = viola {
1132 <c4-\f-\arpeggio g' c>
1138 oboes = \notes \relative c'' \context Voice = oboe {
1139 \stemUp s4 g8. b,16 c8 r <e'8.^\p g> <f16 a>
1140 \grace <e8( g> <d4 )f> <c2 e>
1141 \times 2/3 { <d8 \< f> <e g> <f a> }
1143 { \times 2/3 { a8 g c } \! c2 }
1144 \context Voice = oboeTwo {
1147 \property Grace.Stem \override #'direction = #-1
1153 \grace <c,8( e> <)b8. d8.-\trill> <c16 e> |
1154 [<d ( f> < )f8. a>] <)b,8 d> r [<d16( f> <f8. )a>] <b,8 d> r |
1155 [<c16( e> < )e8. g>] <c8 e,>
1158 hoomPah = \repeat unfold 8 \notes
1159 \transpose c' { \stemUp c8 \stemBoth \stemDown c'8 \stemBoth }
1161 bassvoices = \notes \relative c' {
1163 \autochange Staff \hoomPah
1164 \translator Staff = down
1165 \stemDown [c8 c'8] r4
1167 < {\stemUp r2 <e4 c'> <c8 g'> }
1168 \context Voice = reallyLow {\stemDown g2 ~ | g4 c8 } >
1172 \context PianoStaff \notes <
1173 \context Staff = up < \time 2/2
1177 \context Staff = down < \time 2/2 \clef bass
1184 linewidth = 15.0 \cm }
1188 If this looks like incomprehensible gibberish to you, you are right.
1189 This example has been doctored to have as many quirks as possible.
1191 As you can see, this example features multiple voices on one staff. To
1192 make room for those voices, their notes have to be stemmed in opposite
1195 Printed symbols are internally represented by so-called Graphical
1196 Objects (more colloquially: Grobs). These statements concern the
1197 grob called `Stem'. Each grob is described by a bunch of settings. These
1198 setting determine the fonts, offsets, sub-routines to be called on the
1199 grob, etc. The initial values of these settings are set in the Scheme
1200 file @file{scm/grob-description.scm}.
1204 stemDown = \property Voice.Stem \override #'direction = #-1
1207 Set a proprerty for all Stem grobs in the current Voice:
1208 @code{direction} is set to @code{-1}, which encodes down. The setting
1209 remains in effect until it is reverted.
1213 \property Voice.Stem \revert #'direction
1216 Revert the to the previous setting. The effect of precisely one
1217 @code{\stemDown} or @code{\stemUp} is neutralised.
1220 LilyPond includes the identifiers @code{\stemUp}, @code{\stemDown} along
1221 with some other commonly used formatting instructions, but to explain how
1222 it works, we wrote our own here. Of course, you should use predefined
1223 identifiers like these if possible: then you will be affected less by
1224 the implementation changes we occasionally make.
1228 viola = \notes \relative c' \context Voice = viola @{
1230 In this example, you can see multiple parts on a staff. Each part is
1231 associated with one notation context. This notation context handles
1232 stems and dynamics (among others). The name of this context is
1233 @code{Voice}. For each part we have to make sure that there is
1234 precisely one @code{Voice} context, so we give it an unique name
1239 <c4-\f-\arpeggio g' c>
1241 The delimiters @code{<} and @code{>} are shorthands for
1242 @code{\simultaneous @{} and @code{@}}. The expression enclosed in
1243 @code{<} and @code{>} is a chord.
1250 @code{\f} places a forte symbol under the chord. The forte applies to
1251 the whole chord, but the syntax requires that commands like forte and
1252 arpeggio are attached to a note, so here we attach them to the first
1255 @code{\arpeggio} typesets an arpeggio sign (a wavy vertical line) before
1268 Relative octaves work a little differently with chords. The starting
1269 point for the note following a chord is the first note of the chord. So
1270 the @code{g} gets an octave up quote: it is a fifth above the starting
1271 note of the previous chord (the central C).
1277 @code{s} is a spacer rest. It does not print anything, but it does have
1278 the duration of a rest. It is useful for filling up voices that
1279 temporarily don't play. In this case, the viola doesn't come until one
1280 and a half measure later.
1284 oboes = \notes \relative c'' \context Voice = oboe @{
1286 Now comes a part for two oboes. They play homophonically, so we
1287 print the notes as one voice that makes chords. Again, we insure that
1288 these notes are indeed processed by precisely one context with
1292 \stemUp s4 g8. b,16 c8 r <e'8.-\p g> <f16 a>
1294 @code{\stemUp} is a reference to the @code{\property \override} command
1298 \grace <e8 g> < d4 f> <c2 e>
1300 @cindex @code{\grace}
1304 @code{\grace} introduces grace notes. It takes one argument, in this
1308 The slur started on the @code{e} of the chord
1309 will be attached to the next note.@footnote{LilyPond will squirm
1310 about unended Slurs. In this case, you can ignore the warning}.
1318 Tuplets are made with the @code{\times} keyword. It takes two
1319 arguments: a fraction and a piece of music. The duration of the piece
1320 of music is multiplied by the fraction. Triplets make notes occupy 2/3
1321 of their notated duration, so in this case the fraction is 2/3.
1324 @{ <d8 \< f> <e g> <f a> @}
1326 The piece of music to be `tripletted' is sequential music containing
1327 three notes. On the first chord, a crescendo is started with
1328 @code{\<}. To be precise, the crescendo start is syntactically attached
1329 to the preceding note, the @code{d}.
1339 At this point, the homophonic music splits into two rhythmically
1340 different parts. We can't use a sequence of chords to enter this, so
1341 we make a `chord' of sequences to do it. We start with the upper
1342 voice, which continues with upward stems:
1345 @{ \times 2/3 @{ a8 g c @} \! c2 @}
1350 The crescendo is ended at the half note by the escaped exclamation
1354 \context Voice = oboeTwo @{
1357 We can't share stems with the other voice, so we have to create a new
1358 @code{Voice} context. We give it the name @code{oboeTwo} to distinguish
1359 it from the other context. Stems go down in this voice.
1364 @cindex Grace context
1365 When a grace section is processed, a @code{Grace} context is
1366 created. This context acts like a miniature score of its own. It has
1367 its own time bookkeeping, and you can make notes, beams, slurs
1368 etc. Here we fiddle with a property and make a beam. The argument of
1369 @code{\grace} is sequential music.
1373 \property Grace.Stem \override #'direction = #-1
1377 Normally, grace notes are always stem up, but in this case, the upper
1378 voice interferes. We set the stems down here.
1380 As far as relative mode is concerned, the previous note is the
1381 @code{c'''2} of the upper voice, so we have to go an octave down for
1389 This ends the two-part section.
1393 \grace <c,8( e> <)b8. d8.-\trill> <c16 e> |
1398 @code{\stemBoth} ends the forced stem directions. From here, stems are
1399 positioned as if it were single part music.
1401 The bass has a little hoom-pah melody to demonstrate parts switching
1402 between staffs. Since it is repetitive, we use repeats:
1405 hoomPah = \repeat unfold 8
1407 @cindex unfolded @code{\repeat}
1408 The unfolded repeat prints the notes in its argument as if they were
1409 written out in full eight times.
1412 \notes \transpose c' @{
1415 @cindex relative mode and transposing
1417 Transposing can be done with @code{\transpose}. It takes two arguments
1418 the first specifies what central C should be transposed to. The second
1419 is the to-be-transposed music. As you can see, in this case, the
1420 transposition has no effect, as central C stays at central C.
1422 The purpose of this no-op is circumventing relative mode. Relative mode
1423 can not be used together with transposition, so @code{\relative} will
1424 leave the contents of @code{\hoomPah} alone. We can use it without
1425 having to worry about getting the motive in a wrong octave.
1428 bassvoices = \notes \relative c' @{
1430 \autochange Staff \hoomPah
1432 @cindex staff switch, automatic
1433 @cindex cross staff voice, automatic
1434 @cindex @code{\autochange}
1436 Voices can switch between staffs. The easiest way to get this, is to use
1437 @code{\autochange}. This command looks at the pitch of each note, and if
1438 necessary, will cross to the other staff. For this to work, the two
1439 staffs must be called @code{"up"} and @code{"down"}.
1442 \translator Staff = down
1444 @cindex staff switch
1445 @cindex cross staff voice
1446 We want the remaining part of this melody on the lower staff, so we do a
1447 manual staff switch here.
1452 \context Voice = reallyLow @{\stemDown g2 ~ | g4 c8 @} >
1456 After skipping some lines, we see @code{~}. This mark makes ties. Note
1457 that ties and slurs are different things. A tie can only connect two
1458 note heads of the same pitch, whereas a slur can connect many chords
1465 A special context is needed to get cross staff beaming right. This
1466 context is called @code{PianoStaff}.
1469 \context Staff = bottom < \time 2/2 \clef bass
1471 The bottom staff must have a different clef.
1476 To make some more room on the line, the first (in this case the only)
1477 line is not indented. The line still looks very cramped, but that is due
1478 to the page layout of this document.
1484 * font-size, multi-stanza.
1486 * Simple part combining in a Hymn
1490 @node An orchestral score
1491 @section An orchestral score
1495 * Extracting an individual part::
1499 Our last two examples show a way to setup the music for an orchestral
1500 score. When typesetting a piece for several instruments, you'll want to
1501 create a conductor's full score, alongside several individual parts.
1503 LilyPond is well suited for this task. We will declare the music for
1504 each instrument individually, giving the music of each instrument its
1505 own name. These pieces of music are then combined in different
1506 @code{\score} blocks to produce different combinations of the score.
1508 This orchestral score example consists of three input files. In the
1509 first file, @file{os-music.ly}, we define the music for all instruments.
1510 This file will be used both for producing the score and the separate
1513 If you were to run lilypond on this file, no printable output would be
1519 title = "Zo, goed lieverd?"
1520 subtitle = "How's, this babe?"
1529 Key = \notes \key as \major
1530 flautoI = \notes\relative c'' @{
1532 bes as bes as bes as bes as
1534 flautoII = \notes\relative c'' @{
1535 as8 bes as bes R1 d4 ~ d
1537 tromboI = \notes\relative c'' @{
1538 c4. c8 c8 c4. es4 r as, r
1540 tromboII = \notes\relative c'' @{
1541 as4. as8 as8 as4. R1*1/2 as4 es'
1543 timpani = \notes\relative c, @{
1544 \times 2/3 @{ f4 f f @}
1545 \times 4/5 @{ as8 as as as as @}
1548 corno = \notes\relative c' @{
1549 bes4 d f, bes d f, bes d
1553 We will not go through the input line by line, but only indicate and
1554 explain the new elements.
1561 \skip 2*4 \bar "|.";
1565 Declare setting to be used globally. The @code{\skip} command produces
1566 no output, but moves forward in time: in this case, the duration of a
1567 half note (@code{2}), and that four times (@code{*4}). This brings us
1568 to the end of the piece, and we can set the end bar.
1572 Key = \notes \key as \major
1574 Declare the key signature of the piece and assign it to the identifier
1575 @var{Key}. Lateron, we'll use @code{\Key} for all staffs except those
1576 for transposing instruments.
1578 @node The full score
1579 @subsection The full score
1582 The second file, @file{os-score.ly} reads the definitions of the first
1583 (@file{os-music.ly}), and defines the @code{\score} block for the full
1589 \include "os-music.ly"
1590 \include "paper13.ly"
1592 #(set! point-and-click line-column-location)
1593 #(define text-flat '((font-relative-size . -2)
1594 (music "accidentals--1")))
1599 \property Score.BarNumber \override #'padding = #3
1600 \context StaffGroup = woodwind <
1601 \context Staff = flauti <
1602 \property Staff.midiInstrument = #"flute"
1603 \property Staff.instrument = "2 Flauti"
1604 \property Staff.instr = "Fl."
1606 \context Voice=one @{ \voiceOne \flautoI @}
1607 \context Voice=two @{ \voiceTwo \flautoII @}
1610 \context StaffGroup = timpani <
1611 \context Staff = timpani <
1612 \property Staff.midiInstrument = #"timpani"
1613 \property Staff.instrument = #'(lines "Timpani" "(C-G)")
1614 \property Staff.instr = #"Timp."
1620 \context StaffGroup = brass <
1621 \context Staff = trombe <
1622 \property Staff.midiInstrument = #"trumpet"
1623 \property Staff.instrument = #`(lines "2 Trombe" "(C)")
1624 \property Staff.instr = #`(lines "Tbe." "(C)")
1626 \context Voice=one \partcombine Voice
1627 \context Thread=one \tromboI
1628 \context Thread=two \tromboII
1630 \context Staff = corni <
1631 \property Staff.midiInstrument = #"french horn"
1632 \property Staff.instrument = #`(lines "Corno"
1633 (rows "(E" ,text-flat ")"))
1634 \property Staff.instr = #`(lines "Cor."
1635 (rows "(E" ,text-flat ")"))
1636 \property Staff.transposing = #3
1637 \notes \key bes \major
1638 \context Voice=one \corno
1643 indent = 15 * \staffspace
1644 linewidth = 60 * \staffspace
1645 textheight = 90 * \staffspace
1648 \consists "Multi_measure_rest_engraver"
1651 \HaraKiriStaffContext
1652 \remove "Multi_measure_rest_engraver"
1661 @center @strong{Zo, goed lieverd?}
1663 @center How's, this babe?
1671 @lilypondfile{os-score.ly}
1675 \include "os-music.ly"
1677 First, we need to include the music definitions we made in
1682 #(set! point-and-click line-column-location)
1684 In a large orchestral score like this you're bound to make some small
1685 mistakes, so we enable point and click (See @ref{Point and click})
1690 #(define text-flat '((font-relative-size . -2)
1691 (music "accidentals--1")))
1694 When naming the tuning of the french horn, we'll need a piece of text
1695 with a flat sign. LilyPond has a mechanism for font selection and
1696 kerning called Scheme markup text (See @ref{Text markup}). The flat
1697 sign is taken from the music font, and its name is @code{accidentals--1}
1698 (The sharp sign is called @code{accidentals-+1}). The default font is
1699 too big for text, so we select a relative size of @code{-2}.
1706 Of course, all staffs are simultaneous and use the same global settings.
1710 \property Score.BarNumber \override #'padding = #3
1712 LilyPond prints bar numbers at the start of each line, but
1713 unfortunately, they end up a bit too close to the staff in this example.
1714 A bar number internally is a Grob called @var{BarNumber}. BarNumber
1715 Grobs can be manipulated through their @var{side-position-interface}. One
1716 of the properties of a @var{side-position-interface} that can be tweaked
1717 is the @var{padding}: the amount of extra space that is put between this
1718 Grob and other Grobs. We set the padding to three staff spaces.
1720 You can find all this kind of information in LilyPond's automatically
1721 generated documentation in
1723 @ref{ (lilypond-internals)lilypond-internals, LilyPond Internals}.
1726 the online documentation.
1731 \context StaffGroup = woodwind <
1732 \context Staff = flauti <
1734 A new notation context: the StaffGroup. StaffGroup can hold one or more
1735 Staffs, and will print a big bracket at the left of the score. Start a
1736 new staff group for the woodwind section (just the flutes in this case).
1737 Immediately after that, we start the staff for the two flutes, that also
1738 play simultaneously.
1742 \property Staff.midiInstrument = #"flute"
1744 Specify the instrument for MIDI output (see @ref{MIDI instrument
1749 \property Staff.instrument = "2 Flauti"
1750 \property Staff.instr = "Fl."
1752 And define the instrument names to be printed in the margin,
1753 @code{instrument} for the first line of the score, @code{instr} for the
1760 The flutes play in the default key.
1764 \context Voice=one @{ \voiceOne \flautoI @}
1765 \context Voice=two @{ \voiceTwo \flautoII @}
1767 Last come the actual flute parts. Remember that we're still in
1768 simultaneous mode. We name both voices differently, so that LilyPond
1769 will actually create two Voice contexts. The flute parts are simple, so
1770 we specify manually which voice is which: @code{\voiceOne} forces the
1771 direction of stems, beams, slurs and ties up, @code{\voiceTwo} sets
1779 Close the flutes staff and woodwind staff group.
1783 \property Staff.instrument = #'(lines "Timpani" "(C-G)")
1785 The timpani staff only shows a new piece of scheme markup, it sets two
1790 \context Voice=one \partcombine Voice
1791 \context Thread=one \tromboI
1792 \context Thread=two \tromboII
1794 You have seen the notation contexts Staff and Voice, but here's a new
1795 one: Thread. One or more Threads can be part of a Voice. The Thread
1796 takes care of note heads and rests, the Voice combine note heads onto a
1799 For the trumpets we use the automatic part combiner (see @ref{Automatic
1800 part combining}) to combine the two simultaneous trumpet parts onto the
1801 trumpet staff. Each trumpet gets its own Thread context, which must be
1802 named @code{one} and @code{two}). The part combiner makes these two
1803 threads share a Voice when they're similar, and splits the threads up
1804 when they're different.
1808 \property Staff.instrument = #`(lines "Corno"
1809 (rows "(E" ,text-flat ")"))
1811 The french horn has the most complex scheme markup name, made up of two
1812 lines of text. The second line has two elements (rows), the @code{E}
1813 and the flat sign @code{text-flat} that we defined before.
1817 \property Staff.transposing = #3
1819 The french horn is to be tuned in E-flat, so we tell the MIDI backend to
1820 transpose this staff by three steps.
1822 Note how we can choose different tuning for entering, printing and
1823 playing, using @code{\transpose} and the MIDI Staff proprerty
1828 \notes \key bes \major
1830 Therefore, it has a different key.
1834 indent = 15 * \staffspace
1835 linewidth = 60 * \staffspace
1837 We specify a big indent for the first line and a small linewidth for this
1844 \consists "Multi_measure_rest_engraver"
1847 \HaraKiriStaffContext
1848 \remove "Multi_measure_rest_engraver"
1851 [FIXME: ignoring mmrest moving for now, assuming we'll do that in
1854 Usually, LilyPond's predefined setup of notation contexts (Thread,
1855 Voice, Staff, Staffgroup, Score) is just fine. But in this case, we
1856 want a different type of Staff context.
1858 In orchestral scores, it often happens that one instrument has only
1859 rests during one line of the score. The @code{HaraKiriStaffContext} can
1860 be used as a regular @code{StaffContext} drop-in and will take care of
1861 the automatic removing of empty staffs.
1863 @node Extracting an individual part
1864 @subsection Extracting an individual part
1866 The third file, @file{os-flute-2.ly} also reads the definitions of the
1867 first (@file{os-music.ly}), and defines the @code{\score} block for the
1871 \include "os-music.ly"
1872 \include "paper16.ly"
1876 \property Score.skipBars = ##t
1877 \property Staff.midiInstrument = #"flute"
1883 instrument = "Flauto II"
1886 linewidth = 80 * \staffspace
1887 textheight = 200 * \staffspace
1895 @center @strong{Zo, goed lieverd?}
1897 @center How's, this babe?
1898 @center @emph{Flauto II}
1905 @lilypondfile{os-flute-2.ly}
1908 Because we separated the music definitions from the @code{\score}
1909 instantiations, we can easily define a second score from the music of
1910 the second flute. This then is the part for the second flute player.
1911 Of course, we make separate parts for all individual instruments.
1917 In this individual part the second flute has a whole staff for itself,
1918 so we don't want to force stem or tie directions.
1923 instrument = "Flauto II"
1926 The @code{\header} definitions were also read from @file{os-music.ly},
1927 but we need to set the instrument for this particular score.
1931 \property Score.skipBars = ##t
1933 In the conductor's full score, all bars with rests are printed, but for
1934 the individual parts, we want to contract pieces of consecutive empty
1935 bars. LilyPond will do this if Score's @var{skipBars} property to
1939 @node Other ways to run LilyPond
1940 @section Other ways to run LilyPond
1942 [FIXME: describe all programs involved in one list.]
1944 Until now, you have been using @file{ly2dvi} to invoke LilyPond.
1945 There are three other routes. Firstly, there is a script called
1946 @code{lilypond-book}, that allows you to freely mix LilyPond input with
1947 Texinfo or LaTeX input. For example, this manual was written using
1948 @code{lilypond-book}. It is discussed in @ref{lilypond-book}.
1950 @c FIXME: ly2dvi option?
1951 Secondly, you can generate PostScript directly. This is useful if you
1952 can not or do not want to run @TeX{} on your system. To obtain direct
1953 PostScript output, invoke LilyPond as follows:
1954 @cindex PostScript output
1956 lilypond -f ps test.ly
1958 You have to set some environment variables to view or print this
1959 output. More information can be found in @ref{Invoking
1962 @c FIXME: ly2dvi option?
1963 Thirdly, if you want to do special things with your output, you can run
1964 invoke lilypond directly:
1968 to produce plain @TeX{}@footnote{@TeX{} is a text-typesetting system
1969 that is especially suited for typesetting mathematics.} output. Note
1970 that you must run @TeX{} on the resulting @file{test.tex}, ie, not
1978 @node Latex and texinfo integration
1979 @section Latex and texinfo integration
1982 [TODO: rewrite completely.]
1985 * Songs with additional verses::
1989 So what does this look like? Well, here is an example:
1990 @lilypond[veryverbatim, intertext="produces this music:"]
1994 [e16( g b c a g][e a b d] | )e2 d,8 |
1995 [e16( g b c a g][e a b d] | )b2 [a16( f] |
1996 [e a b d] )e4 c8 | [es16( bes a as g es][d c b! )g] |
1997 [f( a b d b a][f a b d] | )e2
2001 If you are lucky, the above example show a nice feature of LilyPond
2002 and La@TeX{}. Since LilyPond can output the music as @TeX{} graphics,
2003 La@TeX{} can insert pagebreaks between the lines of music.
2005 Notice that there is no @code{\paper} statement in the example
2006 above. Lilypond-book will insert some code for you that defines the
2007 linewidth and the font to use. If you don't want to change the default,
2008 there is no need to put an empty @code{\paper@{@}} inside the @code{\score}.
2009 In the example above, something like this might be inserted before your code:
2011 \include "paper16.ly"
2012 \paper@{ \paper_sixteen
2016 The actual values for linewidth will differ depending on papersize and
2017 number of columns. Also, if you use a different fontsize for the
2018 music, another file than @code{paper16.ly} should be included.
2020 If you want to make the music not so wide, you can insert a
2021 @code{\paper} statement to set the linewidth:
2023 @lilypond[veryverbatim, intertext="produces this music:"]
2027 [e16( g b c a g][e a b d] | )e2 d,8 |
2028 [e16( g b c a g][e a b d] | )b2 [a16( f] |
2029 [e a b d] )e4 c8 | [es16( bes a as g es][d c b! )g] |
2030 [f( a b d b a][f a b d] | )e2
2032 \paper{linewidth = 10.\cm }
2036 Very often, if you mix music and text, the music is often only a
2037 few notes or at most a few bars. This music should be as short as
2038 possible and not stretched to be aligned to the right margin.
2040 If you only write voice-contents in the lilypond block, @command{lilypond-book}
2041 will set the @code{linewidth} variable to -1, so Lilypond
2042 will make the music as short as possible but without breaking the
2043 line. Here is a well know harmonic progression:
2044 @lilypond[veryverbatim, intertext="produce a well known harmonic progression:"]
2045 \context Voice { <c' e g> <b d g> <c2 e g> }
2048 If you want to place music examples in the text,
2050 \context Voice { <c' e g> <b d g> <c2 e g> }
2052 , you can use the @code{eps} option. This will create the music as
2053 eps graphics and include it into the document with the
2054 @code{\includegraphics} command.
2056 The code used look like this:
2059 \context Voice @{ <c' e g> <b d g> <c2 e g> @}
2063 You can also use the @code{eps} option if the block is a complete
2064 lilypond source. This 5 cm long empty line,
2068 \paper{ linewidth = 5.\cm }
2071 was created with this code:
2076 \paper@{ linewidth = 5.\cm@}
2081 To avoid that La@TeX{} places the music on a line of its one, there should
2082 be no empty lines between the normal text and the lilypond
2085 You can also use @code{lilypondfile} (on a separate line, FIXME), to
2086 include another file.
2088 @subsection Fontsize options
2090 You can use all lilypond fontsizes in @command{lilypond-book}. The
2091 default 16pt fontsize is probably to big to be included in the middle of
2092 the text, 11pt or 13pt is probably better.
2094 The code can look like this:
2096 @@lilypond[13pt, eps]
2101 The following options set the fontsize:
2104 @lilypond[11pt, eps]
2106 r16 [c d e][f d e c] [g'8 c][b-\prall c] |
2107 [d16 g, a b][c a b g][d'8 g f-\prall g]
2111 @lilypond[13pt, eps]
2113 r16 [c d e][f d e c] [g'8 c][b-\prall c] |
2114 [d16 g, a b][c a b g][d'8 g f-\prall g]
2118 @lilypond[16pt, eps]
2120 r16 [c d e][f d e c] [g'8 c][b-\prall c] |
2121 [d16 g, a b][c a b g][d'8 g f-\prall g]
2125 @lilypond[20pt, eps]
2127 r16 [c d e][f d e c] [g'8 c][b-\prall c] |
2128 [d16 g, a b][c a b g][d'8 g f-\prall g]
2132 @lilypond[26pt, eps]
2134 r16 [c d e][f d e c] [g'8 c][b-\prall c] |
2140 @subsection More options
2143 @item The @code{singleline} option sets @code{linewidth} to -1.0.
2144 @item The @code{multiline} option sets @code{linewidth} to a value letting
2145 the music be aligned to the right margin. The music can span several
2149 @subsection Just in case...
2150 The options @code{fragment} and @code{nofragment} will override
2151 @command{lilypond-book} when it scans the lilypond code to see if it is voice
2152 contents or complete code. This might be useful if @command{lilypond-book} choose
2155 Since there is no finder's fee which doubles every year, there is no
2156 need to wait for the price money to grow. So send a bug report today
2157 if you need this one of these options.
2159 @subsection Examples
2161 This was all options to @code{\begin}. The rest of the lilypond
2162 document will show some ways you can use lilypond in
2163 La@TeX{} documents. It will also act as a simple test-suite for
2164 lilypond-book. You can place @code{eps} lilypond in and marginspars just
2165 as any other included eps graphics.
2171 r4-\fermata [b16-.( )b-.] [f'8-- dis16-.( )dis-. gis8--]
2172 [f16-.( )f-. dis8-- gis16-.( )gis-.] cis4.-\fermata |
2174 r4.-\fermata [cis,16 cis g'8 f16 f b8][g16 g f8 b16 b] dis4.-\fermata
2176 \paper{linewidth = 7.\cm}
2181 To the right you can see some bars from the trumpet fanfara from the
2182 beginning of the fantastic street opera ``Houdini the Great'', by the
2183 Danish composer Andy Pape. The music is put inside a
2184 @code{floatingfigure} environment, and the music will be aligned by
2185 the right margin if you set floatingfigure width and lilypond linewidth
2186 to the same value. The code looks like this:
2192 r4.-\fermata [b16-.( )b-.] [f'8-- dis16-.( )dis-. gis8--]
2193 [f16-.( )f-. dis8-- gis16-.( )gis-.] cis8.-\fermata |
2195 r4.-\fermata [cis,16 cis g'8 f16 f b8]
2196 [g16 g f8 b16 b] dis4.-\fermata
2198 \paper{linewidth = 7.\cm }
2202 If you have a lot of small music examples like this in the middle of
2203 your text, you might get a nicer look by using ``double'' line
2204 spacing. Put the @code{\linespread@{1.6@}} command into the preamble of
2205 your document. Then the line spacing will not be increased between the
2206 lines where you have music printed with the smallest font size.
2208 Lilypond-book does know about @code{\onecolumn} and @code{\twocolumn}.
2209 So the music will be adjusted to the new linewidth:
2211 Verbatim environments will also ignore the page margins. That is
2212 a feature of La@TeX{}. (But you usually put things inside a verbatim
2213 environment when you don't want La@TeX{} to do any linebreaking)
2215 @node Songs with additional verses
2216 @subsection Songs with additional verses
2218 With lilypond-book, you can typeset songs with additional verses. To
2219 make lilypond-book print titles like ly2dvi, add
2221 [TODO: merge with lilypond-book tutorial]
2227 \input titledefs.tex
2228 \def\preLilypondExample@{\def\mustmakelilypondtitle@{@}@}
2231 just before the music fragment.
2233 @c urg: can't show, won't work for .texi docs
2236 % generate standard lilypond titles
2237 \input titledefs.tex
2238 \def\preLilypondExample@{\def\mustmakelilypondtitle@{@}@}
2243 subtitle = "Subtitle"
2244 subsubtitle = "Subsubtitle"
2247 composer = "Composer"
2249 instrument = "instrument"
2251 \paper @{ linewidth = -1. @}
2253 \notes \relative c'' @{ a b c d @}
2258 \item Verse one. aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa
2259 \item Verse two. bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb
2265 @node end of tutorial
2268 That's all folks. From here, you can either try fiddling with input
2269 files, or you can read the reference manual. You can find more example
2270 files in @file{input} and @file{input/test}. You can also look at some
2271 Real Music (TM), have a look at the @ref{Mutopia project}.
2279 this should be on mutopia website.
2284 @c waar deze info? is uiteindelijk wel handig, schat ik.
2287 If you have a big music project, or just a lot of LilyPond input files,
2288 all generated output from LilyPond, @TeX{} and metafont will clutter
2289 your working directory. LilyPond comes with a one-size-fits-all
2290 pre-cooked makefile that helps you manage producing output. It will
2291 produce all output in the directory @file{out} , generate and track
2292 dependencies. Also, it helps in preparing your submission to @ref{Mutopia
2299 cp /usr/share/lilypond/make/ly.make GNUmakefile
2300 cp /usr/share/doc/lilypond/examples/input/tutorial/menuet.ly .
2303 Generated out/menuet.ps for target menuet.
2306 Type @samp{make help} to see possible targets.
2309 @file{/usr/share/lilypond/doc/lilypond/examples/input/mutopia-header.ly}