3 @c TODO: LilyPond LilyPond LilyPond
10 * First steps:: Music language of LilyPond
11 * Simple legend:: Small table of music language symbols
12 * Running LilyPond:: Printing music
13 * The first tune:: The first tune
14 * Lyrics and chords:: Lyrics and chords
15 * More movements :: Joining separate pieces of music
16 * A piano excerpt:: Piano music
17 * An orchestral score:: Conductor's score and individual parts
18 * Other ways to run LilyPond:: Other ways to run LilyPond
19 * Integrating text and music:: Integrating text and music
20 * End of tutorial:: The end
24 The music is described in a text file, using a simple music language.
25 LilyPond reads that text file and generates music that you can print or
28 Therefore, creating music notation with LilyPond is done in two steps.
29 Using a text editor, you write down the notes to print. Then, you run
30 LilyPond to get your printed output.
32 This tutorial starts with a small introduction to the LilyPond music
33 language. After this first contact, we will show you how to run
34 LilyPond to produce printed output; you should then be able to create
35 your first sheets of music.
37 The tutorial continues with a bit more elaborate example of real music.
38 This piece introduces and explains some finer details of LilyPond.
39 Then, a number of more complex examples follow, that will help you to
40 produce most complex music with LilyPond.
48 @c @node Music language of LilyPond
49 @c @section Music language of LilyPond
51 This section shows how easy writing music with LilyPond actually is. If
52 you have not seen LilyPond input source before, this section is for you.
54 The next section has a table (see @ref{Simple legend}) of all symbols
55 that are introduced here, you may want to keep an eye on that.
57 Writing music with LilyPond is explained below by a number of small
58 examples. Each example has a small piece of text; the LilyPond input
59 that you should type, with the resulting music printed below it.
61 You get a simple note by typing its note name, from @code{a} through
70 \property Score.timing = ##f
71 \property Staff.TimeSignature = \turnOff
72 \transpose c'' { c d e f g a b }
77 The length of a note is specified by adding a number, ``@code{1}'' for a
78 whole note, ``@code{2}'' for a halve note, and so on:
85 @c missing clef seems to raise more questions than actual pitch of notes,
86 @c as these are snippets anyway
88 \property Score.timing = ##f
89 \property Staff.TimeSignature = \turnOff
90 \property Staff.noAutoBeaming = ##t
91 %\property Staff.Clef = \turnOff
92 \transpose c'' { a1 a2 a4 a16 a32 }
98 If you don't specify a duration, the previous duration is used:
105 @c missing clef seems to raise more questions than actual pitch of notes,
106 @c as these are snippets anyway
108 \property Score.timing = ##f
109 \property Staff.TimeSignature = \turnOff
110 %\property Staff.Clef = \turnOff
111 \transpose c'' { a a a2 a }
117 A sharp (@texisharp{}) is made by adding ``@code{is}'', a flat
118 (@texiflat{}) by adding ``@code{es}'':
126 \property Score.timing = ##f
127 \property Staff.TimeSignature = \turnOff
128 \transpose c'' { cis1 ees fisis aeses }
134 Add a dot ``@code{.}'' after the duration to get a dotted note:
140 @c missing clef seems to raise more questions than actual pitch of notes,
141 @c as these are snippets anyway
143 \property Score.timing = ##f
144 \property Staff.TimeSignature = \turnOff
145 %\property Staff.Clef = \turnOff
146 \transpose c'' { a2. a4 a8. a16 }
152 The meter (or time signature) can be set with the ``@code{\time}'' command:
161 @c a clef here may lead to confusion
163 \property Staff.Clef = \turnOff
174 The clef can be set using the ``@code{\clef}'' command:
176 @c what is more common name treble or violin?
177 @c in Dutch, its violin.
187 \property Score.timing = ##f
188 \property Staff.TimeSignature = \turnOff
201 From these commands and notes, a piece of music can be formed. A piece
202 of music is made by enclosing it in ``@code{\notes @{ ... @}}''.
203 LilyPond then knows that music follows (and not lyrics, for example):
217 At this point, the piece of music is ready to be printed. This is done
218 by combining the music with a printing command.
220 The printing command is the so-called ``@code{\paper}'' block. You will
221 see later that the \paper block is necessary to customize all kinds of
222 printing specifics. The music and the \paper block are combined by
223 enclosing them in ``@code{\score @{ ... @}}''. This is what a full
224 LilyPond source file looks like:
247 \paper { linewidth = 60 * \staffspace }
254 We continue with the introduction of the remaining musical constructs.
256 @c maybe legend here?
258 Rests are entered just like notes with the name ``@code{r}'':
266 \property Score.timing = ##f
267 \property Staff.Clef = \turnOff
268 \property Staff.TimeSignature = \turnOff
275 @c Tim wants to move this quotes example just before the: quotes-don't-work
276 @c score, but we'd need to remove quotes from the other two (key and
279 @c better to have this just before the `octaves are bad' snipped
280 @c but we'd need to remove the ', from \key and tie
281 To raise a note by an octave, add a high quote @code{'} (apostrophe) to
282 the note name, to lower a note one octave, add a ``low quote'' @code{,}
283 (a comma). The central C is @code{c'}:
287 c'4 c'' c''' \clef bass c c,
291 \property Score.timing = ##f
292 \property Staff.TimeSignature = \turnOff
293 c'4 c'' c''' \clef bass c c,
298 A tie is created by entering a tilde ``@code{~}'' between the notes to
299 be tied. A tie between two notes means that the second note must not be
300 played separately, but just makes the first note sound longer:
303 @lilypond[fragment,verbatim]
309 The key signature is set with the command ``@code{\key}'':
319 \property Staff.TimeSignature = \turnOff
328 @c bit on the long/complex/scary taste
329 @c cheating a bit: two lines makes for a friendlier look
330 This example shows notes, ties, octave marks, and rests in action.
331 Don't worry about all the quotes.
340 r4 r8 d''8 cis''4 e''
342 cis''4 cis''8 cis'' bis'4 d''8 cis'' ~
355 r4 r8 d''8 cis''4 e''
357 cis''4 cis''8 cis'' bis'4 d''8 cis'' ~
360 \paper { linewidth = 50*\staffspace }
366 There are some interesting points to note in this example. Firstly,
367 accidentals (sharps and flats) don't have to be marked explicitly: you
368 just enter the note name, and LilyPond determines whether or not to
369 print an accidental. Secondly, bar lines and beams are drawn
370 automatically. Thirdly, LilyPond calculates line breaks for you; it
371 doesn't matter where you make new lines in the source file.
373 The example also indicates that a piece of music written in a high
374 register needs lots of quotes. This makes the input a bit unreadable,
375 and is therefore also a potential source of errors.
379 The solution is to use ``relative octave'' mode. In practice, most
380 music is entered using this mode.
382 To use relative mode, add @code{\relative} before the piece of music.
383 You must also give a note from which relative starts, in this case
386 @c In relative ocatave mode, quotes are used to mark large jumps in the
387 @c melody. Without any quotes or commas, the interval between a note and
388 @c its predecessor is assumed to be a fourth or less. Quotes and commas
389 @c add octaves in up and down direction.
391 If you type no octaviation quotes, relative mode chooses the note that
392 is closest to the previous one, which is often just the one you need.
393 @c don't use commas or quotes in this sentence
394 For example: @code{c f} goes up; @code{c g} goes down:
404 \property Score.timing = ##f
405 \property Staff.TimeSignature = \turnOff
413 @c needed better, maybe even redundant explanation
414 @c grappig: Pa vond het heel logies, en slim toen-i eenmaal begreep.
415 @c in eerste instantie drong het `relative' niet door zonder extra uitleg.
416 You can make a large interval by adding octaviation quotes. Note that
417 quotes or commas do not determine the absolote height of a note;
418 the height of a note is relative to the previous one.
419 @c don't use commas or quotes in this sentence
420 For example: @code{c f,} goes down; @code{f, f} are both the same;
421 @code{c c'} are the same; and @code{c g'} goes up:
431 \property Score.timing = ##f
432 \property Staff.TimeSignature = \turnOff
440 A slur is drawn across many notes, and indicates bound articulation
441 (legato). The starting note and ending note are marked with a
442 ``@code{(}'' and a ``@code{)}'' respectively:
445 @lilypond[fragment,relative 1, verbatim]
446 d4( )c16( cis d e c cis d )e( )d4
451 If you need two slurs at the same time (one for articulation, one for
452 phrasing), you can also make a phrasing slur with @code{\(} and
457 @lilypond[fragment,relative 1, verbatim]
458 a8(\( ais b ) c cis2 b'2 a4 cis, \) c
463 Beams are drawn automatically, but if you don't like the choices, you
464 can enter beams by hand. Surround the notes to be grouped with @code{[}
467 @lilypond[fragment,relative 1, verbatim]
473 To print more than one staff, each piece of music that makes up a staff
474 is marked by adding @code{\context Staff} before it. These staffs can
475 be grouped inside @code{<} and @code{>}, as is demonstrated here:
478 @lilypond[fragment,verbatim]
480 \context Staff = staffA { \clef violin c'' }
481 \context Staff = staffB { \clef bass c }
486 In this example, @code{staffA} and @code{staffB} are names that are
487 given to the staffs. For now, it doesn't matter what names you give, as
488 long as each staff has a unique name.
492 We can typeset a melody with two staffs now:
498 < \context Staff = staffA {
501 \relative c'' { e2 ( d4 c2 b4 [a8 a] [b b] [g g] )a2. }
503 \context Staff = staffB {
514 Notice that the time signature is specified in one melody staff only
515 (the top staff), but is printed on both. LilyPond knows that the time
516 signature should be the same for all staffs.
520 Common accents can be added to a note using @code{-.}, @code{--}, @code{->}:
522 @lilypond[verbatim,relative 1]
528 Dynamic signs are made by adding the markings to the note:
530 @lilypond[verbatim,relative 1]
536 Crescendi are started with the commands @code{\<} and @code{\>}. The
537 command @code{\!} finishes a crescendo on the following.
539 @lilypond[verbatim,relative 1]
540 c2\< \!c2-\ff \>c2 \!c2
545 Chords can be made by surrounding notes with @code{<} and @code{>}:
547 @lilypond[relative 0, fragment,verbatim]
555 @c hmm, te losjes, iig
556 In general, @code{ < @var{stuff} > } is used when @var{stuff} all
557 happens at the same time, like in chords, or (like in the two-staff
558 example above) in a bunch of stacked staffs.
561 Of course, you can combine beams and ties with chords. Notice that
562 beam and tie markings are placed outside the chord markers:
564 @lilypond[relative 0, fragment,verbatim]
565 r4 [<c8 e g> <c8 f a>] ~ <c8 f a>
569 When you want to combine chords with slurs and dynamics, an annoying
570 technical detail crops up: you have type these commands next to the
571 notes, which means that they have to be inside the @code{< >}:
574 @lilypond[relative 0, fragment,verbatim]
575 r4 <c8 e g \> ( > <c e g> <c e g> < ) \! c8 f a>
580 A nasty technical detail also crops up when you start a score with a
584 @lilypond[verbatim,singleline]
585 \score { \notes <c'1 e'1> }
590 The program can not guess that you want the notes on only one staff. To
591 force the chord on a staff, add @code{\context Staff} like this:
594 @lilypond[verbatim,singleline]
595 \score { \notes \context Staff <c'1 e'1> }
604 [TODO add some more here
615 This is the end of the simple tutorial. You know the basic ingredients
616 of a music file, so this is the right moment to try your at hand at
617 doing it yourself: try to type some simple examples, and experiment a
620 When you're comfortable with the basics, then you might want to read the
621 rest of this chapter. It also a manual in tutorial-style, but it is much
622 more in-depth. It will also be very intimidating if you're not familiar
623 with the basics. It deals with some of the more advanced features of
624 LilyPond. Topics include lyrics, chords, orchestral scores and parts,
625 fine tuning output, polyphonic music, and integrating text and music.
628 @c refer to this section
630 @section Simple legend
633 @c need texinfo-4.0a or later for this
636 @c both Tim and my father came independently with a request for a
637 @c `legend' like this.
639 @c what should be in it?
644 @multitable @columnfractions .10 .20 .40
649 @lilypond[fragment, relative 1]
650 \property Score.timing = ##f
651 \property Staff.TimeSignature = \turnOff
652 \property Staff.noAutoBeaming = ##t
653 \property Staff.Clef = \turnOff
660 @lilypond[fragment, relative 1]
661 \property Score.timing = ##f
662 \property Staff.TimeSignature = \turnOff
663 \property Staff.noAutoBeaming = ##t
664 \property Staff.Clef = \turnOff
671 @lilypond[fragment, relative 1]
672 \property Score.timing = ##f
673 \property Staff.TimeSignature = \turnOff
674 \property Staff.noAutoBeaming = ##t
675 \property Staff.Clef = \turnOff
681 @lilypond[fragment, relative 1]
682 \property Score.timing = ##f
683 \property Staff.TimeSignature = \turnOff
684 \property Staff.noAutoBeaming = ##t
685 \property Staff.Clef = \turnOff
692 @lilypond[fragment, relative 1]
693 \property Score.timing = ##f
694 \property Staff.TimeSignature = \turnOff
695 \property Staff.noAutoBeaming = ##t
696 \property Staff.Clef = \turnOff
703 @lilypond[fragment, relative 1]
704 \property Score.timing = ##f
705 \property Staff.TimeSignature = \turnOff
706 \property Staff.noAutoBeaming = ##t
707 \property Staff.Clef = \turnOff
708 \context Voice { <a c> }
714 @lilypond[fragment, relative 1]
715 \property Score.timing = ##f
716 \property Staff.TimeSignature = \turnOff
717 \property Staff.noAutoBeaming = ##t
718 \property Staff.Clef = \turnOff
725 @lilypond[fragment, relative 1]
726 \property Score.timing = ##f
727 \property Staff.TimeSignature = \turnOff
728 \property Staff.noAutoBeaming = ##t
729 \property Staff.Clef = \turnOff
738 @node Running LilyPond
739 @section Running LilyPond
741 You write music with LilyPond as follows: first you edit a text file
742 containing a description of the notes. Then you run LilyPond on the
743 file. This leaves you with an output file, which you can view or print.
745 In this section we explain how to run LilyPond, and view or print the
746 output. If you have not used LilyPond before, want to test your setup
747 of LilyPond, or try to run an example file yourself, then read this
750 The instructions that follow are for running LilyPond on Unix-like
751 systems. Some additional instructions for running LilyPond on Windows
752 are given at the end of this section.
754 You begin with opening a terminal window, and start up a text editor.
755 For example, open an xterm and execute @code{joe}. In your text editor,
756 enter the following input, and save the file as @file{test.ly}:
761 \notes @{ c'4 e' g' @}
768 @c now this is weird, running ly2dvi to run LilyPond
769 @c (therefore name change proposal)
771 To run LilyPond, you invoke ly2dvi to compile your LilyPond source file:
779 You will see the following on your screen:
784 Now processing: `/home/fred/ly/test.ly'
786 Interpreting music...[1]
787 @emph{ ... more interesting stuff ... }
788 PS output to `test.ps'...
789 DVI output to `test.dvi'...
793 @cindex Viewing music
796 The results of the ly2dvi run are two files, @file{test.dvi} and
797 @file{test.ps}. The PS file (@file{test.ps}) is the one you can print.
798 You can view the PS file using the program ghostview. If a version of
799 ghostview is installed on your system, one of these commands will
800 produce a window with some music notation on your screen:
810 If you are satisfied with the looks of the music displayed on your
811 screen, you can print the PS file by clicking File/Print inside
814 The DVI file (@file{test.dvi}) contains the same sheet music in a
815 different format. DVI files are more easily processed by the computer,
816 so viewing them usually is quicker. Execute @code{xdvi test.dvi}
817 to view the DVI file.
819 If your DVI viewer does not have a "Print" button, you can print the
820 file by executing @code{lpr test.ps}.
822 @c volgende alinea schrappen?
824 If you can't get the examples to print, then you should look into
825 installing and configuring ghostscript. Refer to GhostScript's website
826 at @uref{http://www.ghostscript.com}.
830 @cindex Printing output
833 @unnumberedsubsec Windows users
834 Windows users start the terminal by clicking on the LilyPond icon.
835 Notepad is sufficient for editing the LilyPond file. Viewing the PS file
836 can be done with @code{gsview32 test.ps}. Viewing DVI files can be done
837 with @code{yap test.dvi}. The "print" button in Yap will print files.
838 You can also print from the command line by executing @code{gsview32 /s
843 @section The first tune
846 This tutorial will demonstrate how to use Lilypond by presenting
847 examples of input along with resulting output. We will use English
848 terms for notation. In case you are not familiar with those, you may
849 consult the glossary that is distributed with LilyPond.
851 The examples discussed are included in the distribution, in the
852 subdirectory @file{input/tutorial/}@footnote{When we refer to filenames,
853 they are relative to the top directory of the source package. }
855 To demonstrate what LilyPond input looks like, we start off with a
856 full-fledged, yet simple example. It is a convoluted version
857 of the famous minuet in J. S. Bach's @emph{Klavierb@"uchlein}. The file
858 is included in the distribution as @file{minuet.ly}.
859 @cindex Bach, Johann Sebastian
862 % all text after a percent sign is a comment
863 % and is ignored by LilyPond
864 \include "paper16.ly"
867 \relative c'' \sequential {
872 d4 g,8 a b c d4 g, g |
873 e'4 c8 d e fis g4 g, g |
874 c4 d8( )c b a( )b4 c8 b a g |
875 a4 [b8 a] [g fis] g2. |
880 g4 e8 fis g d cis4 b8 cis a4 |
881 a8-. b-. cis-. d-. e-. fis-.
888 % standard settings are too big and wide for a book
895 We will analyse the input, line by line.
898 % all text after a percent sign is a comment
899 % and is ignored by LilyPond
901 Percent signs introduce comments: everything after a percent sign is
902 ignored. You can use this to write down mental notes to yourself. You
903 can also make longer comments by enclosing text in @code{%@{} and
906 @cindex block comment
911 \include "paper16.ly"
914 @cindex @code{\include}
915 @cindex point, printer's
916 @cindex staff size setting
917 By default, LilyPond will typeset the music in a size such that each
918 staff is 20 point (0.7 cm, or 0.27 inch) high. We want smaller output
919 (16 point staff height), so we must import the settings for that size,
927 Music is printed by combining a piece of music with directions for
928 outputting it. This combination is formed in the @code{\score} block.
935 Prepare LilyPond for accepting notes.
936 @cindex octaves, choosing
945 As we will see, each note is described by its note name, duration,
946 octave and possibly a chromatic alteration. In this setup, the octave
947 is indicated by using high quotes (@code{'}) and ``lowered quotes''
948 (commas: @code{,}). The central C is denoted by @code{c'}. The C one
949 octave higher is @code{c''}. One and two octaves below the central C is
950 denoted by @code{c} and @code{c,} respectively.
952 Even though a piece of music often spans a range of several octaves, it
953 mostly moves in small intervals. LilyPond has a special entry mode to
954 save typing in this situation. In this ``relative'' octave mode,
955 octaves of notes without quotes are chosen such that a note is as close
956 as possible (graphically, on the staff) to the preceding note. If you
957 add a high-quote an extra octave is added. A lowered quote (a comma)
958 will subtract an extra octave.
960 Because the first note has no predecessor,
961 you have to give the (absolute) pitch of the note to start with.
968 What follows is sequential music, i.e.,
969 @cindex sequential music
970 notes that are to be played and printed after each other.
977 @cindex time signature, setting
979 Set (or change) the time signature of the current piece: a 3/4 sign is
980 printed. The time signature setting is also used to generate bar lines
988 @cindex key signature, setting
990 Set (or change) the current key signature to G-major. Although in this
991 example, the @code{\key} command happened to be entered after the
992 @code{\time} command, in the output the time signature will be printed
993 after the key signature; LilyPond knows about music typesetting
1001 The following piece of music is played twice. The first argument
1002 indicates the type of repeat. In this case, @code{"volta"} means that
1003 prima volta/secunda volta brackets are used for the alternative
1004 endings---if there were any.
1011 The subject of the repeat is again sequential music. Since
1012 @code{\sequential} is such a common construct, a shorthand is provided:
1013 just leave off @code{\sequential}, and the result is the same.
1020 Two notes. The first note is a quarter note with relative pitch
1021 @code{d}. The relative music was started with a @code{c''}, so the real
1022 pitch of this note is @code{d''}. The duration of a note is designated
1023 by a number; the @code{4} here represents a quarter note.
1025 The second note is an eight note with relative pitch @code{g,}. The
1026 pitch is taken relative to the previous @code{d''}, making this
1027 note have real pitch @code{g'}. The @code{8} represents an eight note.
1034 Two more notes, with pitch @code{a} and @code{b}. Because their
1035 duration is the same as the @code{g,8}, there is no need to enter the
1036 duration, but you may enter it anyway, i.e., @code{a4 b4}
1045 @cindex errors, finding
1046 Three more notes. The @code{|} character is a ``bar check''. LilyPond
1047 will verify that bar checks are found at the start of a measure. This can
1048 help you track down typing errors.
1050 @cindex alteration, chromatic
1051 @cindex chromatic alteration
1058 So far, no notes were chromatically altered. Here is the first one that
1059 is: @code{fis}. LilyPond by default uses Dutch@footnote{Note names are
1060 available in several languages, but we find the Dutch names quite
1061 convenient.} note names, and ``Fis'' is the Dutch note name for ``F
1062 sharp''. However, there is no sharp sign in the output. The program
1063 keeps track of key signatures, and will only print accidentals if they
1066 For groups of eighth notes and shorter, LilyPond can determine how the
1067 notes should form a beam. In this case, the 4 eights are automatically
1072 c4 d8( )c b a( )b4 c8 b a g |
1075 The beginning and ending notes of a slur are marked with parentheses,
1076 @code{(} and @code{)} for start and end respectively. The line above
1077 indicates two slurs. These slur markers (parentheses) are entered
1078 between the slurred notes.
1085 Automatic beaming can be overridden by inserting beam marks, @code{[}
1086 and @code{]}. These beam markers (brackets) are put around the notes
1094 @cindex augmentation dot
1096 A period adds a dot to the note.
1103 The end of the sequential music to be repeated. LilyPond will typeset a
1111 Accidentals are printed whenever necessary: the first C sharp of the bar
1112 will be printed with an accidental, the second one without.
1116 a8-. b-. cis-. d-. e-. fis-.
1119 @cindex articulation
1120 You can enter articulation signs either in a verbose form or using a
1121 shorthand. Here we demonstrate the shorthand: it is formed by a dash
1122 and the character for the articulation to use, e.g. @code{-.} for
1123 staccato as shown above.
1131 Rests are denoted by the special notename @code{r}.
1138 All articulations have a verbose form, like @code{\fermata}. The
1139 command @code{\fermata} is not part of the core of the language, but it
1140 is a shorthand for a more complicated description of a fermata symbol.
1141 @code{\fermata} names that description and is therefore called an
1144 @cindex @code{\fermata}
1150 Here the music ends. LilyPond does not automatically typeset and end
1151 bar, we must explicitely request one, using @code{"|."}.
1157 % standard settings are too big and wide for a book
1163 The @code{\paper} block specifies how entered music should be converted
1164 to notation output. Most of the details of the conversion (font sizes,
1165 dimensions, etc.) have been taken care of, but to fit the output in this
1166 document, it has to be narrower. We do this by setting the line width
1167 to 14 centimeters (approximately 5.5 inches).
1174 The last brace ends the @code{\score} block.
1179 @node Lyrics and chords
1180 @section Lyrics and chords
1182 In this section we show how to typeset a song. This file is
1183 included as @file{flowing.ly}.
1187 title = "The river is flowing"
1188 composer = "Traditional"
1190 \include "paper16.ly"
1191 melody = \notes \relative c' @{
1195 c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
1196 c4 c8 d [es () d] c4 | d4 es8 d c4.
1201 The ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
1202 ri -- ver is flo -- wing down to the sea.
1205 accompaniment =\chords @{
1207 c2:3- f:3-.7 d:min es4 c8:min r8
1208 c2:min f:min7 g:7^3.5 c:min @}
1213 \context ChordNames \accompaniment
1216 \context Staff = mel @{
1217 \property Staff.noAutoBeaming = ##t
1218 \property Staff.automaticMelismata = ##t
1221 \context Lyrics \text
1223 \midi @{ \tempo 4=72 @}
1224 \paper @{ linewidth = 10.0\cm @}
1229 The result would look this.@footnote{The titling and font size shown
1230 may differ, since the titling in this document is not generated by
1233 @center @strong{The river is flowing}
1238 title = "The river is flowing"
1239 composer = "Traditional"
1241 \include "paper16.ly"
1242 melody = \notes \relative c' {
1246 c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
1247 c4 c8 d [es () d] c4 | d4 es8 d c4.
1252 The ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
1253 ri -- ver is flo -- wing down to the sea.
1256 accompaniment =\chords {
1258 c2:3- f:3-.7 d:min es4 c8:min r8
1259 c2:min f:min7 g:7^3.5 c:min }
1264 \context ChordNames \accompaniment
1267 \context Staff = mel {
1268 \property Staff.noAutoBeaming = ##t
1269 \property Staff.automaticMelismata = ##t
1272 \context Lyrics \text
1274 \midi { \tempo 4=72 }
1275 \paper { linewidth = 10.0\cm }
1279 Again, we will dissect the file line by line.
1286 @cindex @code{\header}
1287 Information about the music you are about to typeset goes into a
1288 @code{\header} block. The information in this block is not used by
1289 LilyPond, but it is passed into the output. @file{ly2dvi} uses this
1290 information to print titles above the music.
1294 title = "The river is flowing"
1295 composer = "Traditional (?)"
1298 @cindex identifier assignment
1299 the @code{\header} block contains assignments. In each assignment, a
1300 variable is set to a value. Lexically, both the variable name and the
1301 assigned value are strings. The values have to be quoted here, because
1302 they contain spaces, the variable names could also be put within quotes
1303 but it is not necessary.
1307 \include "paper16.ly"
1310 Smaller size for inclusion in a book.
1314 melody = \notes \relative c' @{
1317 The structure of the file will be the same as the previous one, a
1318 @code{\score} block with music in it. To keep things readable, we will
1319 give names to the different parts of music, and use the names to
1320 construct the music within the score block.
1327 @cindex @code{\partial}
1329 The piece starts with an anacrusis of one eighth.
1334 The key is C minor: we have three flats.
1339 c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
1340 c4 c8 d [es () d] c4 | d4 es8 d c4.
1345 @cindex manual beaming
1346 @cindex automatic beaming, turning off
1347 We use explicit beaming. Since this is a song, we turn automatic
1348 beams off, and use explicit beaming where needed.
1355 This ends the definition of @code{melody}.
1364 @cindex identifier assignment
1365 @cindex syllables, entering
1366 Another identifier assignment. This one is for the lyrics.
1367 Lyrics are formed by syllables that have duration, and not by
1368 notes. To make LilyPond parse words as syllables, switch it into
1369 lyrics mode with @code{\lyrics}. Again, the brace after @code{\lyrics}
1370 is a shorthand for @code{\sequential @{}.
1374 The4 ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
1375 ri- ver is flo- __ wing down to the sea.
1379 @cindex extenders, lyric
1380 @cindex hyphens, lyric
1381 The syllables themselves are separated by spaces. You can get syllable
1382 extenders by entering @code{__}, and centered hyphens with
1383 @code{-}@code{-}. We enter the syllables as if they are all quarter notes
1384 in length (hence the @code{4}), and use a feature to align the
1385 syllables to the music, which obviously isn't all quarter notes.
1389 accompaniment =\chords @{
1393 @cindex mode, chords
1394 We'll put chords over the music. To enter them, there is a special mode
1395 analogous to @code{\lyrics} and @code{\notes} mode, where you can give
1396 the names of the chords you want, instead of listing the notes
1397 comprising the chord.
1404 There is no accompaniment during the anacrusis.
1413 @cindex chord modifier
1414 @cindex modifier, chord
1415 A chord is started by the tonic of the chord. The
1416 first one lasts a half note. An unadorned note creates a major
1417 triad. Since a minor triad is wanted, @code{3-} is added to modify the
1418 third to be small. @code{7} modifies (adds) a seventh, which is small by
1419 default to create the @code{f a c es} chord. Multiple modifiers must be
1428 Some modifiers have predefined names, eg. @code{min} is the same as
1429 @code{3-}, so @code{d-min} is a minor @code{d} chord.
1433 c2:min f:min7 g:7^3.5 c:min @}
1436 @cindex named modifier
1438 A named modifier @code{min} and a normal modifier @code{7} do not have
1439 to be separated by a dot. Tones from a chord are removed with chord
1440 subtractions. Subtractions are started with a caret, and they are
1441 also separated by dots. In this example, @code{g:7^3.5} produces a
1442 minor seventh. The brace ends the sequential music.
1450 We assemble the music in the @code{\score} block. Melody, lyrics and
1451 accompaniment have to sound at the same time, so they should be
1452 @code{\simultaneous}.
1453 @cindex @code{\simultaneous}
1460 Chord mode generates notes grouped in @code{\simultaneous} music. If
1461 you remove the comment sign, you can see the chords in normal
1462 notation: they will be printed as note heads on a separate
1463 staff. To print them as chords names, they have to be interpreted as
1464 being chords, not notes. This is done with the following command:
1468 \context ChordNames \accompaniment
1472 @cindex interpretation context
1473 @cindex notation context
1476 Normally, the notes that you enter are transformed into note heads.
1477 Note heads alone make no sense, they need surrounding information: a key
1478 signature, a clef, staff lines, etc. They need @emph{context}. In
1479 LilyPond, these symbols are created by objects called `interpretation
1480 contexts'. Interpretation contexts exist for generating notation
1481 (`notation context') and for generating sound (`performance
1482 context'). These objects only exist during a run of LilyPond.
1484 By default, LilyPond will create a Staff context for you. If you would
1485 remove the @code{%} sign in the previous line, you would see that
1486 mechanism in action.
1488 We don't want that default here, because we want chord names. The
1489 command above explicitly creates an interpretation context of
1490 @code{ChordNames} type to interpret the music @code{\accompaniment}.
1497 @cindex @code{\addlyrics}
1498 @cindex lyrics and melody, combining
1499 @cindex combining lyrics and melody
1501 The lyrics should be aligned with the melody. This is done by
1502 combining both with @code{\addlyrics}. @code{\addlyrics} takes two
1503 pieces of music (usually a melody and lyrics, in that order) and
1504 aligns the syllables of the second piece under the notes of the
1505 first piece. If you would reverse the order, the notes would be
1506 aligned on the lyrics, which is not very useful, and looks
1511 \context Staff = mel @{
1515 The second argument of @code{\addlyrics} is the melody. We instantiate
1516 a @code{Staff} context explicitly: should you choose to remove the
1517 comment before the ``note heads'' version of the accompaniment, the
1518 accompaniment will be on a nameless staff. The melody has to be on
1519 staff different from the accompaniment. This is accomplished by giving
1520 the melody and accompaniment staffs different names.
1524 \property Staff.noAutoBeaming = ##t
1528 @cindex context variables
1529 @cindex setting context variables
1530 An interpretation context has variables, called properties, that tune
1531 its behaviour. One of the variables is @code{noAutoBeaming}. Setting
1532 this Staff's property to @code{##t}, which is the boolean value @var{true},
1533 turns the automatic beaming mechanism off for the current staff.
1536 @cindex accessing Scheme
1537 @cindex evaluating Scheme
1540 LilyPond internally uses GUILE, a Scheme-interpreter. Scheme is a
1541 language from the LISP family. You can learn more about Scheme at
1542 @uref{http://www.scheme.org}. It is used to represent data throughout
1543 the whole program. The hash-sign (@code{#}) accesses GUILE directly: the
1544 code following the hash-sign is evaluated as Scheme. The boolean value
1545 @var{true} is @code{#t} in Scheme, so for LilyPond @var{true} looks like
1548 If Scheme scares you, don't worry. You don't need to know Scheme to
1549 create beautiful sheet music.
1556 \property Staff.automaticMelismata = ##t
1559 @cindex automaticMelismata
1561 @cindex @code{\addlyrics} and slurs
1562 Similarly, we don't want to print a syllable when there is
1563 a slur. This sets up @code{\addlyrics} to not put lyrics under each
1564 separate note while there is a slur.
1572 Finally, we put the melody on the current staff. Note that the
1573 @code{\property} directives and @code{\melody} are grouped in sequential
1574 music, so the property settings are done before the melody is
1579 \context Lyrics \text
1582 The second argument of @code{\addlyrics} is the text. The text also
1583 should not land on a Staff, but on a interpretation context for
1584 syllables, extenders, hyphens etc. This context is called
1589 \midi @{ \tempo 4=72@}
1592 MIDI (Musical Instrument Digital Interface) is a standard for
1593 connecting and recording digital instruments. So a MIDI file is like a
1594 tape recording of an instrument. The @code{\midi} block causes makes the
1595 music go to a MIDI file, so you can listen to the music you entered. It
1596 is great for checking the music. Whenever you hear something weird, you
1597 probably hear a typing error.
1599 Syntactically, @code{\midi} is similar to @code{\paper @{ @}}, since it
1600 also specifies an output method. You can specify the tempo using the
1601 @code{\tempo} command, in this case the tempo of quarter notes is set to
1602 72 beats per minute.
1606 \paper @{ linewidth = 10.0\cm @}
1609 We also want notation output. The linewidth is short so the piece
1610 will be set in two lines.
1612 @node More movements
1613 @section More movements
1615 [FIXME: merge here with, or move this to: Other ways to run LilyPond]
1617 You probably ran @file{ly2dvi} on the last example, and ended up with a
1618 viewable @file{.dvi} file. However, between there are a few steps of
1619 which LilyPond is only one. To enhance your understanding of what's
1620 happening under the hood when you run @code{ly2dvi}, we explain what
1623 @code{ly2dvi} is a program that calls a number of programs in sequence.
1624 The first thing it does, is running LilyPond on the input file. After
1625 some calculations, a @file{.tex} is produced. The contents
1626 of this file are very low-level instructions.
1628 For example, the following file (@file{miniatures.ly})
1633 title = "Two miniatures"
1634 tagline = "small is beautiful"
1637 #(set! point-and-click line-column-location)
1639 \paper @{ linewidth = -1.0 @}
1642 \notes @{ c'4 d'4 @}
1648 \notes @{ d'4 c'4 @}
1655 The titling in this manual was not generated by ly2dvi, so we can't
1656 exactly show it would look, but the result should resemble this:
1658 @center @strong{Two miniatures}
1668 \paper { linewidth = -1.0 }
1680 \paper { linewidth = -1.0 }
1684 This file is produced by ly2dvi in a few stages, with the help of text
1685 formatting tools. LilyPond produces two output files,
1686 @file{miniatures.tex} and @file{miniatures-1.tex}. Both files contain
1687 only graphical music notation. @file{ly2dvi} looks at what output
1688 LilyPond produces, and adds page layout and titling to those files. The
1689 result is a DVI file called @file{miniatures.dvi}.
1691 Next, now we'll look at the example line by line to explain new things.
1697 Lilypond and its language are still under development, and occasionally,
1698 details of the syntax are changed. This fragment indicates for which
1699 version the input file was written. When you compile this file, the
1700 version number will be checked, and you will get a warning when the file
1703 This version number is also used by the @code{convert-ly} program (See
1704 @ref{convert-ly}), which uses it to update the file to the latest lily
1710 title = "Two miniatures" @}
1712 This sets the titling information for the entire file.
1715 tagline = "small is beautiful"
1717 A signature line is printed at the bottom of the last page.
1718 This signature is produced from the @code{tagline} field of
1719 @code{\header}. Many people find the default "Lily was here,
1720 @var{version number}" too droll. If that is the case, assign
1721 something else to @code{tagline}, as shown above.
1724 #(set! point-and-click line-column-location)
1727 This piece of Scheme code sets the Scheme variable
1728 @code{point-and-click} to the value @var{line-column-location} (which
1729 itself is a Scheme procedure).
1731 Editing input files can be quite complicated if you're working with
1732 large files: if you're digitizing existing music, you have to
1733 synchronize the .ly file, the sheet music on your lap and the sheet
1734 music on the screen. The point-and-click mechanism makes it easy to
1735 find the origin of an error in the LY file: when you view the file with
1736 Xdvi and click on a note, your editor will jump to the spot where that
1737 note was entered. For more information, see @ref{Point and click}.
1744 The @code{\score} blocks that follow in the file don't have
1745 @code{\paper} sections, so the settings of this block are substituted: A
1746 paper block, at top-level, i.e. not in a @code{\score} block sets the
1747 default page layout.
1756 The variable @code{linewidth} normally sets the length of the systems on
1757 the page. However, a negative value has a special meaning. If
1758 @code{linewidth} is less than 0, no line breaks are inserted into the
1759 score, and the spacing is set to natural length: a short phrase takes up
1760 little space, a longer phrase more space.
1765 \notes @{ c'4 d'4 @}
1768 In previous examples, notes were specified in relative octaves,
1769 i.e. each note was put in the octave that would put it closest to its
1770 predecessor. Besides relative, there is also absolute octave
1771 specification, which you get when you don't specify @code{\relative}. In
1772 this input mode, the central C is denoted by @code{c'}. Going down, you
1773 get @code{c} @code{c,} @code{c,,} etc. Going up, you get @code{c''}
1776 When you're copying music from existing sheet music, relative octaves
1777 are probably the easiest to use: it's less typing work and errors are
1778 easily spotted. However, if you write LilyPond input directly, either by
1779 hand (i.e. composing) or by computer, absolute octaves are easier to use.
1787 The @code{\header} is normally at the top of the file, where it sets
1788 values for the rest of the file. If you want to typeset different pieces
1789 from one file (for example, if there are multiple movements, or if
1790 you're making an exercise book), you can put different @code{\score}
1791 blocks into the input file. ly2dvi will assemble all LilyPond output
1792 files into a big document. The contents of \header blocks specified
1793 within each score, are used for the titling of each movement.
1799 For example, the Opus number is put at the right, and the piece string
1800 will be at the left.
1804 @node A piano excerpt
1805 @section A piano excerpt
1807 Our fourth subject is a piece of piano music. The fragment in the input
1808 file is a piano reduction of the G major Sinfonia by Giovanni Battista
1809 Sammartini. It was composed around 1740. It's in the source package
1810 under the name @file{sammartini.ly}.
1813 \include "paper16.ly"
1815 stemDown = \property Voice.Stem \override #'direction = #-1
1816 stemUp = \property Voice.Stem \override #'direction = #1
1817 stemBoth = \property Voice.Stem \revert #'direction
1819 viola = \notes \relative c' \context Voice = viola {
1820 <c4-\f-\arpeggio g' c>
1826 oboes = \notes \relative c'' \context Voice = oboe {
1827 \stemUp s4 g8. b,16 c8 r <e'8.^\p g> <f16 a>
1828 \grace <e8( g> <d4 )f> <c2 e>
1829 \times 2/3 { <d8 \< f> <e g> <f a> }
1831 { \times 2/3 { a8 g c } \! c2 }
1832 \context Voice = oboeTwo {
1835 \property Grace.Stem \override #'direction = #-1
1841 \grace <c,8( e> <)b8. d8.-\trill> <c16 e> |
1842 [<d ( f> < )f8. a>] <)b,8 d> r [<d16( f> <f8. )a>] <b,8 d> r |
1843 [<c16( e> < )e8. g>] <c8 e,>
1846 hoomPah = \repeat unfold 8 \notes
1847 \transpose c' { \stemUp c8 \stemBoth \stemDown c'8 \stemBoth }
1849 bassvoices = \notes \relative c' {
1851 \autochange Staff \hoomPah
1852 \translator Staff = down
1853 \stemDown [c8 c'8] r4
1855 < {\stemUp r2 <e4 c'> <c8 g'> }
1856 \context Voice = reallyLow {\stemDown g2 ~ | g4 c8 } >
1860 \context PianoStaff \notes <
1861 \context Staff = up < \time 2/2
1865 \context Staff = down < \time 2/2 \clef bass
1872 linewidth = 15.0 \cm }
1876 If this looks like incomprehensible gibberish to you, you are right.
1877 This example has been doctored to have as many quirks as possible.
1879 As you can see, this example features multiple voices on one staff. To
1880 make room for those voices, their notes have to be stemmed in opposite
1883 Printed symbols are internally represented by so-called Graphical
1884 Objects (more colloquially: Grobs). These statements concern the
1885 grob called `Stem'. Each grob is described by a bunch of settings. These
1886 setting determine the fonts, offsets, sub-routines to be called on the
1887 grob, etc. The initial values of these settings are set in the Scheme
1888 file @file{scm/grob-description.scm}.
1892 stemDown = \property Voice.Stem \override #'direction = #-1
1895 Set a proprerty for all Stem grobs in the current Voice:
1896 @code{direction} is set to @code{-1}, which encodes down. The setting
1897 remains in effect until it is reverted.
1901 \property Voice.Stem \revert #'direction
1904 Revert the to the previous setting. The effect of precisely one
1905 @code{\stemDown} or @code{\stemUp} is neutralised.
1908 LilyPond includes the identifiers @code{\stemUp}, @code{\stemDown} along
1909 with some other commonly used formatting instructions, but to explain how
1910 it works, we wrote our own here. Of course, you should use predefined
1911 identifiers like these if possible: then you will be affected less by
1912 the implementation changes we occasionally make.
1916 viola = \notes \relative c' \context Voice = viola @{
1918 In this example, you can see multiple parts on a staff. Each part is
1919 associated with one notation context. This notation context handles
1920 stems and dynamics (among others). The name of this context is
1921 @code{Voice}. For each part we have to make sure that there is
1922 precisely one @code{Voice} context, so we give it an unique name
1927 <c4-\f-\arpeggio g' c>
1929 The delimiters @code{<} and @code{>} are shorthands for
1930 @code{\simultaneous @{} and @code{@}}. The expression enclosed in
1931 @code{<} and @code{>} is a chord.
1938 @code{\f} places a forte symbol under the chord. The forte applies to
1939 the whole chord, but the syntax requires that commands like forte and
1940 arpeggio are attached to a note, so here we attach them to the first
1943 @code{\arpeggio} typesets an arpeggio sign (a wavy vertical line) before
1956 Relative octaves work a little differently with chords. The starting
1957 point for the note following a chord is the first note of the chord. So
1958 the @code{g} gets an octave up quote: it is a fifth above the starting
1959 note of the previous chord (the central C).
1965 @code{s} is a spacer rest. It does not print anything, but it does have
1966 the duration of a rest. It is useful for filling up voices that
1967 temporarily don't play. In this case, the viola doesn't come until one
1968 and a half measure later.
1972 oboes = \notes \relative c'' \context Voice = oboe @{
1974 Now comes a part for two oboes. They play homophonically, so we
1975 print the notes as one voice that makes chords. Again, we insure that
1976 these notes are indeed processed by precisely one context with
1980 \stemUp s4 g8. b,16 c8 r <e'8.-\p g> <f16 a>
1982 @code{\stemUp} is a reference to the @code{\property \override} command
1986 \grace <e8 g> < d4 f> <c2 e>
1988 @cindex @code{\grace}
1992 @code{\grace} introduces grace notes. It takes one argument, in this
1996 The slur started on the @code{e} of the chord
1997 will be attached to the next note.@footnote{LilyPond will squirm
1998 about unended Slurs. In this case, you can ignore the warning}.
2006 Tuplets are made with the @code{\times} keyword. It takes two
2007 arguments: a fraction and a piece of music. The duration of the piece
2008 of music is multiplied by the fraction. Triplets make notes occupy 2/3
2009 of their notated duration, so in this case the fraction is 2/3.
2012 @{ <d8 \< f> <e g> <f a> @}
2014 The piece of music to be `tripletted' is sequential music containing
2015 three notes. On the first chord, a crescendo is started with
2016 @code{\<}. To be precise, the crescendo start is syntactically attached
2017 to the preceding note, the @code{d}.
2027 At this point, the homophonic music splits into two rhythmically
2028 different parts. We can't use a sequence of chords to enter this, so
2029 we make a `chord' of sequences to do it. We start with the upper
2030 voice, which continues with upward stems:
2033 @{ \times 2/3 @{ a8 g c @} \! c2 @}
2038 The crescendo is ended at the half note by the escaped exclamation
2042 \context Voice = oboeTwo @{
2045 We can't share stems with the other voice, so we have to create a new
2046 @code{Voice} context. We give it the name @code{oboeTwo} to distinguish
2047 it from the other context. Stems go down in this voice.
2052 @cindex Grace context
2053 When a grace section is processed, a @code{Grace} context is
2054 created. This context acts like a miniature score of its own. It has
2055 its own time bookkeeping, and you can make notes, beams, slurs
2056 etc. Here we fiddle with a property and make a beam. The argument of
2057 @code{\grace} is sequential music.
2061 \property Grace.Stem \override #'direction = #-1
2065 Normally, grace notes are always stem up, but in this case, the upper
2066 voice interferes. We set the stems down here.
2068 As far as relative mode is concerned, the previous note is the
2069 @code{c'''2} of the upper voice, so we have to go an octave down for
2077 This ends the two-part section.
2081 \grace <c,8( e> <)b8. d8.-\trill> <c16 e> |
2086 @code{\stemBoth} ends the forced stem directions. From here, stems are
2087 positioned as if it were single part music.
2089 The bass has a little hoom-pah melody to demonstrate parts switching
2090 between staffs. Since it is repetitive, we use repeats:
2093 hoomPah = \repeat unfold 8
2095 @cindex unfolded @code{\repeat}
2096 The unfolded repeat prints the notes in its argument as if they were
2097 written out in full eight times.
2100 \notes \transpose c' @{
2103 @cindex relative mode and transposing
2105 Transposing can be done with @code{\transpose}. It takes two arguments
2106 the first specifies what central C should be transposed to. The second
2107 is the to-be-transposed music. As you can see, in this case, the
2108 transposition has no effect, as central C stays at central C.
2110 The purpose of this no-op is circumventing relative mode. Relative mode
2111 can not be used together with transposition, so @code{\relative} will
2112 leave the contents of @code{\hoomPah} alone. We can use it without
2113 having to worry about getting the motive in a wrong octave.
2116 bassvoices = \notes \relative c' @{
2118 \autochange Staff \hoomPah
2120 @cindex staff switch, automatic
2121 @cindex cross staff voice, automatic
2122 @cindex @code{\autochange}
2124 Voices can switch between staffs. The easiest way to get this, is to use
2125 @code{\autochange}. This command looks at the pitch of each note, and if
2126 necessary, will cross to the other staff. For this to work, the two
2127 staffs must be called @code{"up"} and @code{"down"}.
2130 \translator Staff = down
2132 @cindex staff switch
2133 @cindex cross staff voice
2134 We want the remaining part of this melody on the lower staff, so we do a
2135 manual staff switch here.
2140 \context Voice = reallyLow @{\stemDown g2 ~ | g4 c8 @} >
2144 After skipping some lines, we see @code{~}. This mark makes ties. Note
2145 that ties and slurs are different things. A tie can only connect two
2146 note heads of the same pitch, whereas a slur can connect many chords
2153 A special context is needed to get cross staff beaming right. This
2154 context is called @code{PianoStaff}.
2157 \context Staff = bottom < \time 2/2 \clef bass
2159 The bottom staff must have a different clef.
2164 To make some more room on the line, the first (in this case the only)
2165 line is not indented. The line still looks very cramped, but that is due
2166 to the page layout of this document.
2172 * font-size, multi-stanza.
2174 * Simple part combining in a Hymn
2178 @node An orchestral score
2179 @section An orchestral score
2183 * Extracting an individual part::
2187 Our last two examples show a way to setup the music for an orchestral
2188 score. When typesetting a piece for several instruments, you'll want to
2189 create a conductor's full score, alongside several individual parts.
2191 LilyPond is well suited for this task. We will declare the music for
2192 each instrument individually, giving the music of each instrument its
2193 own name. These pieces of music are then combined in different
2194 @code{\score} blocks to produce different combinations of the score.
2196 This orchestral score example consists of three input files. In the
2197 first file, @file{os-music.ly}, we define the music for all instruments.
2198 This file will be used both for producing the score and the separate
2201 If you were to run LilyPond on this file, no printable output would be
2207 title = "Zo, goed lieverd?"
2208 subtitle = "How's, this babe?"
2217 Key = \notes \key as \major
2218 flautoI = \notes\relative c'' @{
2220 bes as bes as bes as bes as
2222 flautoII = \notes\relative c'' @{
2223 as8 bes as bes R1 d4 ~ d
2225 tromboI = \notes\relative c'' @{
2226 c4. c8 c8 c4. es4 r as, r
2228 tromboII = \notes\relative c'' @{
2229 as4. as8 as8 as4. R1*1/2 as4 es'
2231 timpani = \notes\relative c, @{
2232 \times 2/3 @{ f4 f f @}
2233 \times 4/5 @{ as8 as as as as @}
2236 corno = \notes\relative c' @{
2237 bes4 d f, bes d f, bes d
2241 We will not go through the input line by line, but only indicate and
2242 explain the new elements.
2249 \skip 2*4 \bar "|.";
2253 Declare setting to be used globally. The @code{\skip} command produces
2254 no output, but moves forward in time: in this case, the duration of a
2255 half note (@code{2}), and that four times (@code{*4}). This brings us
2256 to the end of the piece, and we can set the end bar.
2260 Key = \notes \key as \major
2262 Declare the key signature of the piece and assign it to the identifier
2263 @var{Key}. Lateron, we'll use @code{\Key} for all staffs except those
2264 for transposing instruments.
2266 @node The full score
2267 @subsection The full score
2270 The second file, @file{os-score.ly} reads the definitions of the first
2271 (@file{os-music.ly}), and defines the @code{\score} block for the full
2277 \include "os-music.ly"
2278 \include "paper13.ly"
2280 #(set! point-and-click line-column-location)
2281 #(define text-flat '((font-relative-size . -2)
2282 (music "accidentals--1")))
2287 \property Score.BarNumber \override #'padding = #3
2288 \context StaffGroup = woodwind <
2289 \context Staff = flauti <
2290 \property Staff.midiInstrument = #"flute"
2291 \property Staff.instrument = "2 Flauti"
2292 \property Staff.instr = "Fl."
2294 \context Voice=one @{ \voiceOne \flautoI @}
2295 \context Voice=two @{ \voiceTwo \flautoII @}
2298 \context StaffGroup = timpani <
2299 \context Staff = timpani <
2300 \property Staff.midiInstrument = #"timpani"
2301 \property Staff.instrument = #'(lines "Timpani" "(C-G)")
2302 \property Staff.instr = #"Timp."
2308 \context StaffGroup = brass <
2309 \context Staff = trombe <
2310 \property Staff.midiInstrument = #"trumpet"
2311 \property Staff.instrument = #`(lines "2 Trombe" "(C)")
2312 \property Staff.instr = #`(lines "Tbe." "(C)")
2314 \context Voice=one \partcombine Voice
2315 \context Thread=one \tromboI
2316 \context Thread=two \tromboII
2318 \context Staff = corni <
2319 \property Staff.midiInstrument = #"french horn"
2320 \property Staff.instrument = #`(lines "Corno"
2321 (columns "(E" ,text-flat ")"))
2322 \property Staff.instr = #`(lines "Cor."
2323 (columns "(E" ,text-flat ")"))
2324 \property Staff.transposing = #3
2325 \notes \key bes \major
2326 \context Voice=one \corno
2331 indent = 15 * \staffspace
2332 linewidth = 60 * \staffspace
2333 textheight = 90 * \staffspace
2336 \consists "Multi_measure_rest_engraver"
2339 \HaraKiriStaffContext
2340 \remove "Multi_measure_rest_engraver"
2349 @center @strong{Zo, goed lieverd?}
2351 @center How's, this babe?
2359 @lilypondfile{os-score.ly}
2363 \include "os-music.ly"
2365 First, we need to include the music definitions we made in
2370 #(set! point-and-click line-column-location)
2372 In a large orchestral score like this you're bound to make some small
2373 mistakes, so we enable point and click (See @ref{Point and click})
2378 #(define text-flat '((font-relative-size . -2)
2379 (music "accidentals--1")))
2382 When naming the tuning of the french horn, we'll need a piece of text
2383 with a flat sign. LilyPond has a mechanism for font selection and
2384 kerning called Scheme markup text (See @ref{Text markup}). The flat
2385 sign is taken from the music font, and its name is @code{accidentals--1}
2386 (The sharp sign is called @code{accidentals-+1}). The default font is
2387 too big for text, so we select a relative size of @code{-2}.
2394 Of course, all staffs are simultaneous and use the same global settings.
2398 \property Score.BarNumber \override #'padding = #3
2400 LilyPond prints bar numbers at the start of each line, but
2401 unfortunately, they end up a bit too close to the staff in this example.
2402 A bar number internally is a Grob called @var{BarNumber}. BarNumber
2403 Grobs can be manipulated through their @var{side-position-interface}. One
2404 of the properties of a @var{side-position-interface} that can be tweaked
2405 is the @var{padding}: the amount of extra space that is put between this
2406 Grob and other Grobs. We set the padding to three staff spaces.
2408 You can find all this kind of information in LilyPond's automatically
2409 generated documentation in
2411 @ref{ (lilypond-internals)lilypond-internals, LilyPond Internals}.
2414 the online documentation.
2419 \context StaffGroup = woodwind <
2420 \context Staff = flauti <
2422 A new notation context: the StaffGroup. StaffGroup can hold one or more
2423 Staffs, and will print a big bracket at the left of the score. Start a
2424 new staff group for the woodwind section (just the flutes in this case).
2425 Immediately after that, we start the staff for the two flutes, that also
2426 play simultaneously.
2430 \property Staff.midiInstrument = #"flute"
2432 Specify the instrument for MIDI output (see @ref{MIDI instrument
2437 \property Staff.instrument = "2 Flauti"
2438 \property Staff.instr = "Fl."
2440 And define the instrument names to be printed in the margin,
2441 @code{instrument} for the first line of the score, @code{instr} for the
2448 The flutes play in the default key.
2452 \context Voice=one @{ \voiceOne \flautoI @}
2453 \context Voice=two @{ \voiceTwo \flautoII @}
2455 Last come the actual flute parts. Remember that we're still in
2456 simultaneous mode. We name both voices differently, so that LilyPond
2457 will actually create two Voice contexts. The flute parts are simple, so
2458 we specify manually which voice is which: @code{\voiceOne} forces the
2459 direction of stems, beams, slurs and ties up, @code{\voiceTwo} sets
2467 Close the flutes staff and woodwind staff group.
2471 \property Staff.instrument = #'(lines "Timpani" "(C-G)")
2473 The timpani staff only shows a new piece of scheme markup, it sets two
2478 \context Voice=one \partcombine Voice
2479 \context Thread=one \tromboI
2480 \context Thread=two \tromboII
2482 You have seen the notation contexts Staff and Voice, but here's a new
2483 one: Thread. One or more Threads can be part of a Voice. The Thread
2484 takes care of note heads and rests, the Voice combine note heads onto a
2487 For the trumpets we use the automatic part combiner (see @ref{Automatic
2488 part combining}) to combine the two simultaneous trumpet parts onto the
2489 trumpet staff. Each trumpet gets its own Thread context, which must be
2490 named @code{one} and @code{two}). The part combiner makes these two
2491 threads share a Voice when they're similar, and splits the threads up
2492 when they're different.
2496 \property Staff.instrument = #`(lines "Corno"
2497 (columns "(E" ,text-flat ")"))
2499 The french horn has the most complex scheme markup name, made up of two
2500 lines of text. The second line has two elements (columns), the @code{E}
2501 and the flat sign @code{text-flat} that we defined before.
2505 \property Staff.transposing = #3
2507 The french horn is to be tuned in E-flat, so we tell the MIDI backend to
2508 transpose this staff by three steps.
2510 Note how we can choose different tuning for entering, printing and
2511 playing, using @code{\transpose} and the MIDI Staff proprerty
2516 \notes \key bes \major
2518 Therefore, it has a different key.
2522 indent = 15 * \staffspace
2523 linewidth = 60 * \staffspace
2525 We specify a big indent for the first line and a small linewidth for this
2530 Usually, LilyPond's predefined setup of notation contexts (Thread,
2531 Voice, Staff, Staffgroup, Score) is just fine. But in this case, we
2532 want a different type of Staff context.
2534 In orchestral scores, it often happens that one instrument has only
2535 rests during one line of the score. The @code{HaraKiriStaffContext} can
2536 be used as a regular @code{StaffContext} drop-in and will take care of
2537 the automatic removing of empty staffs.
2539 @node Extracting an individual part
2540 @subsection Extracting an individual part
2542 The third file, @file{os-flute-2.ly} also reads the definitions of the
2543 first (@file{os-music.ly}), and defines the @code{\score} block for the
2547 \include "os-music.ly"
2548 \include "paper16.ly"
2552 \property Score.skipBars = ##t
2553 \property Staff.midiInstrument = #"flute"
2559 instrument = "Flauto II"
2562 linewidth = 80 * \staffspace
2563 textheight = 200 * \staffspace
2571 @center @strong{Zo, goed lieverd?}
2573 @center How's, this babe?
2574 @center @emph{Flauto II}
2581 @lilypondfile{os-flute-2.ly}
2584 Because we separated the music definitions from the @code{\score}
2585 instantiations, we can easily define a second score from the music of
2586 the second flute. This then is the part for the second flute player.
2587 Of course, we make separate parts for all individual instruments.
2593 In this individual part the second flute has a whole staff for itself,
2594 so we don't want to force stem or tie directions.
2599 instrument = "Flauto II"
2602 The @code{\header} definitions were also read from @file{os-music.ly},
2603 but we need to set the instrument for this particular score.
2607 \property Score.skipBars = ##t
2609 In the conductor's full score, all bars with rests are printed, but for
2610 the individual parts, we want to contract pieces of consecutive empty
2611 bars. LilyPond will do this if Score's @var{skipBars} property to
2615 @node Other ways to run LilyPond
2616 @section Other ways to run LilyPond
2618 Until now, you have been using @file{ly2dvi} to invoke LilyPond.
2619 There are three other routes. Firstly, there is a script called
2620 @code{lilypond-book}, that allows you to freely mix LilyPond input with
2621 Texinfo or LaTeX input. For example, this manual was written using
2622 @code{lilypond-book}. It is discussed in @ref{lilypond-book}.
2625 Secondly, you can generate PostScript directly. This is useful if you
2626 can not or do not want to run @TeX{} on your system. To obtain direct
2627 PostScript output, invoke LilyPond as follows:
2628 @cindex PostScript output
2630 lilypond -f ps test.ly
2632 You have to set some environment variables to view or print this
2633 output. More information can be found in @ref{Invoking
2637 Thirdly, if you want to do special things with your output, you can run
2638 invoke LilyPond directly:
2642 to produce plain @TeX{} output. Note that La@TeX{} will not work on the
2643 resulting @file{test.tex}. You must run plain @TeX{} on it.
2651 @node Integrating text and music
2652 @section Integrating text and music
2654 Sometimes, you might want to use music examples in a text that you are
2655 writing. For example, if you are writing a musicological treatise, a
2656 songbook, or (like us) the LilyPond manual. You can make such texts by
2657 hand, simply by importing a PostScript figure into your wordprocessor.
2658 However, there is a also an automated procedure:
2660 If you use La@TeX{} or texinfo, you can mix text and LilyPond code. A
2661 script called @code{lilypond-book} will extract the music fragments, run
2662 LilyPond on them, and put back the resulting notation. lilypond-book is
2663 described fully in @ref{lilypond-book}, but here we show a small
2664 example. Since the example also contains explanatory text, we won't
2665 comment on the contents.
2668 \documentclass[a4paper]@{article@}
2671 In a lilypond-book document, you can freely mix music and text. For
2674 \score @{ \notes \relative c' @{
2675 c2 g'2 \times 2/3 @{ f8 e d @} c'2 g4
2678 Notice that the music line length matches the margin settings of the
2681 If you have no \verb+\score+ block in the fragment,
2682 \texttt@{lilypond-book@} will supply one:
2688 In the example you see here, a number of things happened: a
2689 \verb+\score+ block was added, and the line width was set to natural
2690 length. You can specify many more options using \LaTeX style options
2693 \begin[verbatim,11pt,singleline,
2694 fragment,relative,intertext="hi there!"]@{lilypond@}
2698 \texttt@{verbatim@} also shows the LilyPond code, \texttt@{11pt@} selects
2699 the default music size, \texttt@{fragment@} adds a score block,
2700 \texttt@{relative@} uses relative mode for the fragment, and
2701 \texttt@{intertext@} specifies what to print between the
2702 \texttt@{verbatim@} code and the music.
2704 If you include large examples into the text, it may be more convenient
2705 to put the example in a separate file:
2707 \lilypondfile[printfilename]@{sammartini.ly@}
2709 The \texttt@{printfilename@} option adds the file name to the output.
2714 Under Unix, you can view the results as follows.
2717 $ lilypond-book --outdir=out/ lilbook.tex
2718 lilypond-book (GNU LilyPond) 1.3.146
2719 Reading `/home/hanwen/usr/src/lilypond-1.3.146/input/tutorial/lilbook.tex'
2721 `/home/hanwen/usr/src/lilypond-1.3.146/input/tutorial/sammartini.ly'
2722 @var{lots of stuff deleted}
2723 Writing `out/lilbook.latex'
2725 $ latex lilbook.latex
2726 @var{lots of stuff deleted}
2730 Notice the @code{outdir} option to lilypond-book. Running lilypond-book
2731 and running latex creates a lot of temporary files, and you wouldn't
2732 those to clutter up your working directory. Hence, we have them created
2733 in a separate subdirectory.
2735 The result more or less looks like this:
2739 In a lilypond-book document, you can freely mix music and text. For
2742 \score { \notes \relative c' {
2743 c2 g'2 \times 2/3 { f8 e d } c'2 g4
2746 Notice that the music line length matches the margin settings of the
2749 If you have no @code{\score} block in the fragment,
2750 @code{lilypond-book} will supply one:
2756 In the example you see here, a number of things happened: a
2757 @code{\score} block was added, and the line width was set to natural
2758 length. You can specify many more options using La@TeX{} style options
2761 @lilypond[verbatim,11pt,singleline,
2762 fragment,relative,intertext="hi there!"]
2766 @code{verbatim} also shows the LilyPond code, @code{11pt} selects
2767 the default music size, @code{fragment} adds a score block,
2768 @code{relative} uses relative mode for the fragment, and
2769 @code{intertext} specifies what to print between the
2770 @code{verbatim} code and the music.
2772 If you include large examples into the text, it may be more convenient
2773 to put the example in a separate file:
2775 @lilypondfile[printfilename]{sammartini.ly}
2777 The @code{printfilename} option adds the file name to the output.
2778 @node End of tutorial
2779 @section End of tutorial
2781 That's all folks. From here, you can either try fiddling with input
2782 files, or you can read the reference manual. You can find more example
2783 files in @file{input} and @file{input/test}. You can also look at some
2784 real music. The website @uref{http://www.mutopiaproject.org} has many
2785 examples of real music typeset by LilyPond.
2793 this should be on mutopia website.
2798 @c waar deze info? is uiteindelijk wel handig, schat ik.
2801 If you have a big music project, or just a lot of LilyPond input files,
2802 all generated output from LilyPond, @TeX{} and metafont will clutter
2803 your working directory. LilyPond comes with a one-size-fits-all
2804 pre-cooked makefile that helps you manage producing output. It will
2805 produce all output in the directory @file{out} , generate and track
2806 dependencies. Also, it helps in preparing your submission to @ref{Mutopia
2813 cp /usr/share/lilypond/make/ly.make GNUmakefile
2814 cp /usr/share/doc/lilypond/examples/input/tutorial/minuet.ly .
2817 Generated out/minuet.ps for target minuet.
2820 Type @samp{make help} to see possible targets.
2823 @file{/usr/share/lilypond/doc/lilypond/examples/input/mutopia-header.ly}
2829 [TODO: rewrite completely.]
2832 * Songs with additional verses::