]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/tutorial.itely
patch::: 1.3.152.jcn3
[lilypond.git] / Documentation / user / tutorial.itely
1 @c -*-texinfo-*-
2
3 @c TODO: LilyPond Lilypond lilypond
4
5
6 @node Tutorial
7 @chapter Tutorial
8   
9 @menu
10 * Running LilyPond::            Getting started
11 * First steps::                 
12 * The first tune::              The first tune
13 * Lyrics and chords::           Lyrics and chords
14 * More movements ::             
15 * A piano excerpt::             Piano music
16 * An orchestral score::         
17 * Other ways to run LilyPond::  
18 * Integrating text and music::  
19 * end of tutorial::             The end
20 @end menu
21
22
23 @node Running LilyPond
24 @section Running LilyPond
25
26 You make music notation with LilyPond as follows: first you edit a text
27 file containing a description of the notes. Then you run LilyPond on the
28 file. This leaves you with an output file, which you can view or print.
29
30 In this section we explain how to run LilyPond, and view or print the
31 output.  If you want to test your setup of LilyPond, or try to run an
32 example file yourself, then read this section. Otherwise, you can skip
33 to the next section, which explains how to
34 write LilyPond input.
35
36 The instructions that follow are for Unix. Windows instructions are
37 given at the end of this section. Start with opening a terminal window,
38 and start up a text editor.  For example, start an xterm and execute
39 @code{joe}.   Enter the following
40 input, and save the file as @file{test.ly}.
41 @example
42 \score @{
43   \notes @{ c'4 e' g' @}
44 @} 
45 @end example
46 If this code looks intimidating you, then don't worry, we explain all
47 about it in the next section.
48
49 @cindex ly2dvi
50
51 @c dit is dus raar, dat je ly2dvi draait om lelie te draaien
52 @c (therefore name change proposal) 
53
54 Invoke the program  @code{ly2dvi} to run lilypond on your source file:
55 @example
56 ly2dvi -P test
57 @end example
58
59 You will see the following on your screen:
60 @example
61 GNU LilyPond 1.4.0
62 Now processing: `/home/fred/ly/test.ly'
63 Parsing...
64 Interpreting music...[1]
65  @emph{ ... more interesting stuff ... }
66 PS output to `test.ps'...
67 DVI output to `test.dvi'...
68 @end example
69
70 @cindex DVI file
71 @cindex Viewing music
72 @cindex xdvi
73
74 The results of the ly2dvi run are two files, @file{test.dvi} and
75 @file{test.ps}.  The PS file (@file{test.ps}) is the one you can
76 print. You can view the PS file using the program ghostview.  If a
77 version of ghostview is installed on your system, one of these commands
78 will produce a window with some music notation on your screen.
79 @example
80 kghostview test.ps
81 ggv test.ps
82 ghostview test.ps
83 gv test.ps
84 @end example
85 When you're satisfied with the result, you can print the PS file by
86 clicking File/Print inside ghostview.
87
88 The DVI file (@file{test.dvi}) contains the same sheet music in a
89 different format. DVI files are more easily processed by the computer,
90 so viewing them usually is quicker. Execute @code{xdvi test}
91 to view the DVI file.
92
93 If your DVI viewer does not have a "Print" button, you can print the
94 file by executing @code{lpr test.ps}.
95
96 @c volgende alinea schrappen?  
97
98 If you can't get the examples to print, then you should look into
99 installing and configuring ghostscript.  Refer to GhostScript's website
100 at @uref{http://www.ghostscript.com}.
101
102 @cindex GhostScript
103 @cindex @code{lpr}
104 @cindex Printing output
105 @cindex PostScript
106
107
108 Windows users start the terminal by clicking on the lilypond icon.
109 Notepad is sufficient for editing the lilypond file. Viewing the PS file
110 can be done with @code{gsview32 test.ps}. Viewing DVI files can be done
111 with @code{yap test}. The "print" button in Yap will print files.  You
112 can also print from the command line by executing @code{gsview32 /s
113 test.ps}
114
115
116 @c titel?
117
118 @node First steps
119 @section First steps
120
121 Let's try to explain this example:
122
123 The basics of any piece of music are notes.Notes are entered 
124 with letters @code{a} to @code{g} followed by a
125 number that represents the duration: a @code{2} is a half note, a
126 @code{4} is a quarter note. A period is used for augmentation dots, so
127 entering @code{2.} gives a dotted half note. 
128 @example
129      c2 e4 g2.
130 @end example
131 @lilypond[fragment]
132 \property Score.timing  = ##f
133 \property Staff.TimeSignature  = \turnOff
134 \property Staff.Clef  = \turnOff
135 \clef bass c2 e4 g2.
136 @end lilypond
137 If you don't specify a duration, then the duration last entered is used:
138 @c
139 @example
140   f4 e d c2.
141 @end example
142 @lilypond[fragment]
143 \property Score.timing  = ##f
144 \property Staff.TimeSignature  = \turnOff
145 \property Staff.Clef  = \turnOff
146 \clef bass  f4 e d c2.
147 @end lilypond
148 The time signature can be set with a command of the form @code{\time},
149 and the clef with @code{\clef} as follows:
150 @example
151      \time 3/4
152      \clef bass
153 @end example
154 @lilypond[fragment]
155         \time 3/4
156         \clef bass
157         s2._" "
158 @end lilypond
159
160 The commands together with the notes are combined to form a snippet of
161 music. They are combined by enclosing them with @code{\notes @{ @}}.
162 @example
163   \notes @{
164      \time 3/4
165      \clef bass
166      c2 e4 g2.
167      f4 e d c2.
168   @}
169 @end example
170
171 This snippet is ready to be printed. This is done by combining the music
172 with a printing command. The printing command is the so-called
173 @code{\paper} block.  The music and paper block are combined by
174 enclosing them in @code{\score}.
175
176 @lilypond[verbatim]
177 \score {
178   \notes {
179      \time 3/4
180      \clef bass
181      c2 e4  g2.
182      f4 e d c2.
183   }
184   \paper { }
185 }
186 @end lilypond
187
188 @ignore
189 The @code{\paper} block looks empty, which means that we get default. That is because we did not contains page layout settings, such as the linewidth and
190 the staff size. For now, we'll use standard settings, hence the paper
191 block is empty (its braces enclose a blank space).
192 @end ignore
193
194 Rests are entered just like notes with the name @code{r}
195 @lilypond[fragment,verbatim]
196 r4 r8 r16
197 @end lilypond
198
199 Octaves are entered by adding apostrophes or commas to note names. For
200 example, the central C is entered as @code{c'}.
201
202 Pitches can be octaviated by adding  apostrophes or commas. The central C is
203 @code{c'}. Going up octave by octave we get @code{c''},
204 @code{c'''}. Going down from central C, we get @code{c} @code{c,}
205 @code{c,,} etc.
206
207 @lilypond[verbatim,fragment]
208 c'4 c'' c''' c c,
209 @end lilypond
210
211 LilyPond uses Dutch note names: you can make a note sharp by appending
212 @code{is} to the name, and flat by appending @code{es} to the name.
213 @lilypond[verbatim,fragment]
214 fis'4 bes'4 aeses'4
215 @end lilypond
216
217 Ties are created by entering a tilde (@code{~}) between the notes to be
218 tied:
219 @lilypond[fragment,verbatim]
220   g'4 ~ g' a'2 ~ a'4
221 @end lilypond
222 Ties look almost the same as slurs, but they are different. Ties can
223 only indicate the extension of a note. Ties connect two note heads with
224 the same pitch.  Slurs on the other hand, can be drawn across many
225 notes, and indicate bound articulation.
226  
227 The key signature is set with the command @code{\key}:
228 @lilypond[fragment,verbatim]
229   \key d \major
230   g'1
231   \key c \minor
232   g'
233 @end lilypond
234
235 The next example shows octave marks, ties, and rests in action. 
236 @lilypond[verbatim]
237 \score {
238   \notes {
239     \time 4/4
240     \clef treble
241     \key d \minor
242     r4 r8 d''8 cis''4 e''
243     d''8 a'4. ~ a'  b'8
244     cis''4 cis''8 cis'' bis'4 d''8 cis'' ~
245     cis''2 r2
246   }
247   \paper { }
248 }
249 @end lilypond
250 There is one interesting point to note in this example: accidentals
251 don't have to be marked explicitly. You just enter the pitch, and
252 LilyPond determines wether or not to print an accidental.
253
254 Managing larger pieces. 
255
256 If you look at the last piece, it is already apparent that entering
257 octaves using quotes is not very convenient. A score written in high
258 register will be encoded using lots quotes. This makes the input file
259 unreadable, and it also is a source of many errors.
260
261 This problem is solved by relative octave mode. In this mode, the quotes
262 are used to mark large jumps in the melody. Without any quotes or
263 commas, the interval between a note and its predecessor is assumed to be
264 a fourth or less. Quotes and commas add octaves in up and down
265 direction.  Relative octaves are introduced by @code{\relative} followed
266 by a starting pitch
267 @lilypond[fragment,verbatim]
268 \relative c'' { c4 d4 b4 e4 a,4 f'4 g,4 a'4 }
269 @end lilypond
270
271 Slurs (not to be confused with ties) are entered with parentheses. You
272 mark the starting note and ending note with a @code{(} and a
273 @code{)} respectively.
274
275 @lilypond[fragment,relative 2, verbatim]
276 c8( cis d ) e 
277 @end lilypond
278
279 If you need two slurs at the same time (one for articulation, one for
280 phrasing), you can also make phrasing slurs with @code{\(} and
281 @code{\)}.
282
283 @c lousy example
284 @lilypond[fragment,relative 1, verbatim]
285 a8(\( ais b ) c cis2 b'2 a4 cis, \) c
286 @end lilypond
287
288 Beams are drawn automatically, but if you don't like the choices, you
289 can enter beams by hand. Surround the notes to be grouped with @code{[}
290 and @code{]}:
291 @lilypond[fragment,relative 1, verbatim]
292 [a8 ais] [d es r d]
293 @end lilypond
294
295 You can make more than one staff, by specifying @code{\context Staff} before 
296 snippets of music, and combining those snippets in @code{<} and
297 @code{>}, as is demonstrated here:
298
299 @lilypond[fragment,verbatim]
300 < \context Staff = staffA { \clef treble c'' }
301   \context Staff = staffB { \clef bass c }
302 >
303 @end lilypond
304 Here, @code{staffA} and @code{staffB} are names that you give to the
305 staff. For now, it doesn't matter what names you give, as long as they
306 are different.
307
308 We can typeset a melody with two staffs now:
309
310 @lilypond[verbatim]
311 \score {
312   \notes 
313   < \context Staff = staffA {
314       \time 3/4
315       \clef treble
316       \relative c'' { e2 ( d4 c2 b4 [a8 a] [b b] [g g] )a2. }  
317     }
318     \context Staff = staffB {
319        \clef bass
320        c2 e4  g2.
321        f4 e d c2.
322     }
323   >
324   \paper {} 
325 }
326 @end lilypond
327
328 Notice that the time signature is specified in one melody staff only
329 (the top staff), but is printed on both. LilyPond knows that the time
330 signature should be the same for all staffs.
331
332 [TODO add some more here
333
334
335 * \header
336
337 * dynamics , articulation
338
339 * <chords>
340
341 * identifiers?
342
343 ]
344
345 This is the end of the simple tutorial. What follows is also a manual in
346 tutorial-style, but it is much more in-depth, and alas more
347 intimidating.  You should read it if you want to know about the more
348 advanced features of lilypond, such as producing orchestral scores and
349 parts, fine tuning output, writing polyphonic music, etc.
350
351
352
353 @node The first tune
354 @section The first tune
355
356
357 This tutorial will demonstrate how to use Lilypond by presenting
358 examples of input along with resulting output.  We will use English
359 terms for notation.  In case you are not familiar with those, you may
360 consult the glossary that is distributed with LilyPond.
361
362 The examples discussed are included in the distribution, in the
363 subdirectory @file{input/tutorial/}@footnote{When we refer to filenames,
364 they are relative to the top directory of the source package. }
365
366
367 To demonstrate what LilyPond input looks like, we start off with a
368 full-fledged, yet simple example. It is a convoluted version
369 of the famous minuet in J. S. Bach's @emph{Klavierb@"uchlein}. The file
370 is included in the distribution as  @file{minuet.ly}.
371 @cindex Bach, Johann Sebastian 
372
373 @lilypond[verbatim]
374 % all text after a percent sign is a comment
375 % and is ignored by Lilypond
376 \include "paper16.ly"
377 \score {
378     \notes                        
379     \relative c'' \sequential {
380             \time 3/4                
381             \key g \major
382
383         \repeat "volta" 2 {
384             d4 g,8 a b c d4 g, g |
385             e'4 c8 d e fis g4 g, g |
386             c4 d8( )c b a( )b4 c8 b a g |
387             a4 [b8 a] [g fis] g2.  |
388         }
389
390         b'4 g8 a b g
391         a4 d,8 e fis d |
392         g4 e8 fis g d cis4 b8 cis a4 |
393         a8-. b-. cis-. d-. e-. fis-.
394         g4 fis e |
395         fis a,  r8 cis8
396         d2.-\fermata
397         \bar "|."
398     }
399     \paper {
400        % standard settings are too wide for a book
401        linewidth = 14.0 \cm
402    }
403 }
404 @end lilypond
405
406 We will analyse the input, line by line.
407 @separate
408 @example
409         % all text after a percent sign is a comment
410         % and is ignored by Lilypond
411 @end example 
412 The percent sign, @code{%}, introduces a line comment.  You can also
413 comment out a block of several lines, by enclosing them in
414 @code{%@{} and @code{%@}}.
415 @cindex comment
416 @cindex block comment
417 @cindex line comment
418 @separate
419 @example 
420
421         \include "paper16.ly"
422  
423 @end example
424 @cindex @code{\include}
425 @cindex point, printer's
426 @cindex staff size setting 
427 By default, LilyPond will typeset the music in a size such that each 
428 staff is 20 point@footnote{A point is the standard measure of length for
429 printing; one point is 1/72.27 inch.} high.  We want smaller
430 output (16 point staff height), so we must import the settings for that
431 size, which is done here.
432 @separate
433 @example 
434
435         \score @{
436  
437 @end example 
438 Music is printed by combining a piece of music with directions for
439 outputting it.  This combination is formed in the @code{\score} block.
440 @separate
441 @example 
442
443         \notes                
444  
445 @end example 
446 Prepare LilyPond for accepting notes.
447 @cindex octaves, choosing
448 @cindex pitch
449 @separate
450 @example 
451
452         \relative c''
453  
454 @end example
455 @cindex relative
456 As we will see, each note is described by its note name, duration,
457 octave and possibly a chromatic alteration.  In this setup, the octave
458 is indicated by using high quotes (@code{'}) and ``lowered quotes''
459 (commas: @code{,}).  The central C is denoted by @code{c'}.  The C one
460 octave higher is @code{c''}.  One and two octaves below the central C is
461 denoted by @code{c} and @code{c,} respectively.
462
463 Even though a piece of music often spans a range of several octaves, it
464 mostly moves in small intervals.  LilyPond has a special entry mode to
465 save typing in this situation.  In this ``relative'' octave mode,
466 octaves of notes without quotes are chosen such that a note is as close
467 as possible (graphically, on the staff) to the preceding note.  If you
468 add a high-quote an extra octave is added.  A lowered quote (a comma)
469 will subtract an extra octave.
470
471 Because the first note has no predecessor,
472 you have to give the (absolute) pitch of the note to start with.
473 @separate
474 @example 
475
476         \sequential @{
477  
478 @end example 
479 What follows is sequential music, i.e.,
480 @cindex sequential music
481 notes that are to be played and printed after each other.
482 @separate
483 @example 
484
485         \time 3/4
486  
487 @end example
488 @cindex time signature, setting
489 @cindex @code{\time}
490 Set (or change) the time signature of the current piece: a 3/4 sign is
491 printed.  The time signature setting is also used to generate bar lines
492 at the right spots.
493 @separate
494 @example 
495
496         \key g \major
497  
498 @end example
499 @cindex key signature, setting
500 @cindex @code{\key}
501 Set (or change) the current key signature to G-major.  Although in this
502 example, the @code{\key} command happened to be entered after the
503 @code{\time} command, in the output the time signature will be printed
504 after the key signature; LilyPond knows about music typesetting
505 conventions.
506 @separate
507 @example 
508
509         \repeat "volta" 2
510  
511 @end example 
512 The following piece of music is played twice.  The first argument
513 indicates the type of repeat.  In this case, @code{"volta"} means that
514 prima volta/secunda volta brackets are used for the alternative
515 endings---if there were any.
516 @separate
517 @example 
518
519         @{
520  
521 @end example 
522 The subject of the repeat is again sequential music.  Since
523 @code{\sequential} is such a common construct, a shorthand is provided:
524 just leave off @code{\sequential}, and the result is the same.
525 @separate
526 @example 
527
528         d4 g,8
529  
530 @end example 
531 Two notes.  The first note is a quarter note with relative pitch
532 @code{d}.  The relative music was started with a @code{c''}, so the real
533 pitch of this note is @code{d''}.  The duration of a note is designated
534 by a number; the @code{4} here represents a quarter note.
535
536 The second note is an eight note with relative pitch @code{g,}.  The
537 pitch is taken relative to the previous @code{d''}, making this
538 note have real pitch @code{g'}.  The @code{8} represents an eight note.
539 @separate
540 @example 
541
542         a b
543  
544 @end example 
545 Two more notes, with pitch @code{a} and @code{b}.  Because their
546 duration is the same as the @code{g,8}, there is no need to enter the
547 duration, but you may enter it anyway, i.e., @code{a4 b4}
548 @separate
549 @example 
550
551         d4 g, g |
552  
553 @end example
554 @cindex bar check
555 @cindex @code{|}
556 @cindex errors, finding 
557 Three more notes.  The @code{|} character is a ``bar check''.  LilyPond
558 will verify that bar checks are found at the start of a measure.  This can
559 help you track down typing errors.
560
561 @cindex alteration, chromatic
562 @cindex chromatic alteration
563 @separate
564 @example 
565
566         c8 d e fis
567
568 @end example 
569 So far, no notes were chromatically altered.  Here is the first one that
570 is: @code{fis}.  Lilypond by default uses Dutch@footnote{Note names are
571 available in several languages, but we find the Dutch names quite
572 convenient.} note names, and ``Fis'' is the Dutch note name for ``F
573 sharp''.  However, there is no sharp sign in the output. The program
574 keeps track of key signatures, and will only print accidentals if they
575 are needed.
576
577 For groups of eighth notes and shorter, LilyPond can determine how the
578 notes should form a beam.  In this case, the 4 eights are automatically
579 printed as a beam.
580 @separate
581 @example 
582
583         c4 d8( )c b a( )b4 c8 b a g |
584  
585 @end example 
586 The beginning and ending notes of a slur are marked with parentheses,
587 @code{(} and @code{)} for start and end respectively.  The line above
588 indicates two slurs.  These slur markers (parentheses) are entered
589 between the slurred notes.
590 @separate
591 @example 
592
593         a4 [b8 a] [g fis] 
594  
595 @end example 
596 Automatic beaming can be overridden by inserting beam marks, @code{[}
597 and @code{]}.  These beam markers (brackets) are put around the notes
598 you want beamed.
599 @separate
600 @example 
601
602         g2.  |
603  
604 @end example
605 @cindex augmentation dot
606 @cindex dot
607 A period adds an augmentation dot to the note.
608 @separate
609 @example 
610
611         @}
612  
613 @end example 
614 The end of the sequential music to be repeated.  LilyPond will typeset a
615 repeat bar.
616 @separate
617 @example 
618
619         cis'4 b8 cis a4 |
620  
621 @end example 
622 Accidentals are printed whenever necessary: the first C sharp of the bar
623 will be printed with an accidental, the second one without.
624 @separate
625 @example 
626
627         a8-. b-. cis-. d-. e-. fis-.
628  
629 @end example
630 @cindex articulation
631 You can enter articulation signs either in a verbose form or using a
632 shorthand.  Here we demonstrate the shorthand: it is formed by a dash
633 and the character for the articulation to use, e.g. @code{-.} for
634 staccato as shown above.
635 @separate
636 @example 
637
638         fis a, r8 cis8
639  
640 @end example 
641  
642 Rests are denoted by the special notename @code{r}.  
643 @separate
644 @example 
645
646         d2.-\fermata
647  
648 @end example 
649 All articulations have a verbose form, like @code{\fermata}.  The
650 command @code{\fermata} is not part of the core of the language, but it
651 is a shorthand for a more complicated description of a fermata symbol.
652 @code{\fermata} names that description and is therefore called an
653 identifier.
654 @cindex identifier
655 @cindex @code{\fermata}
656 @separate
657 @example
658         \bar "|."
659         @}
660 @end example 
661 Here the music ends.  LilyPond does not automatically typeset and end
662 bar, we must explicitely request one, using @code{"|."}.
663
664 @separate
665 @example 
666
667         \paper @{
668                 linewidth = 14.0\cm
669         @}
670  
671 @end example 
672 The @code{\paper} block specifies how entered music should be converted
673 to notation output.  Most of the details of the conversion (font sizes,
674 dimensions, etc.) have been taken care of, but to fit the output in this
675 document, it has to be narrower.  We do this by setting the line width
676 to 14 centimeters (approximately 5.5 inches).
677 @separate
678 @example 
679
680         @}
681  
682 @end example 
683 The last brace ends the @code{\score} block.
684
685
686
687
688 @node Lyrics and chords
689 @section Lyrics and chords
690
691 In this section we show how to typeset a song. This file is
692 included as @file{flowing.ly}.
693
694 @example 
695 \header @{
696         title = "The river is flowing"
697         composer = "Traditional"
698 @}
699 \include "paper16.ly"
700 melody = \notes \relative c' @{
701         \partial 8
702         \key c \minor
703         g8 |
704         c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
705         c4 c8 d [es () d] c4 | d4 es8 d c4.
706         \bar "|."
707 @}
708
709 text = \lyrics @{
710         The ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
711         ri -- ver is flo -- wing down to the sea.
712 @}
713
714 accompaniment =\chords @{
715         r8
716         c2:3- f:3-.7 d:min es4 c8:min r8
717         c2:min f:min7 g:7^3.5 c:min @}
718
719 \score @{
720         \simultaneous @{
721           %\accompaniment
722           \context ChordNames \accompaniment
723
724           \addlyrics
725             \context Staff = mel @{        
726               \property Staff.noAutoBeaming = ##t
727               \property Staff.automaticMelismata = ##t
728               \melody 
729             @}
730             \context Lyrics \text
731         @}
732         \midi  @{ \tempo 4=72 @}
733         \paper @{ linewidth = 10.0\cm @}
734 @} 
735 @end example 
736
737
738 The result would look this.@footnote{The titling and font size shown
739 may differ, since the titling in this document is not generated by
740 @code{ly2dvi}.}
741
742 @center @strong{The river is flowing}
743 @center Traditional 
744
745 @lilypond[center]
746 \header {
747         title = "The river is flowing"
748         composer = "Traditional"
749 }
750 \include "paper16.ly"
751 melody = \notes \relative c' {
752         \partial 8
753         \key c \minor
754         g8 |
755         c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
756         c4 c8 d [es () d] c4 | d4 es8 d c4.
757         \bar "|."
758 }
759
760 text = \lyrics {
761         The ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
762         ri -- ver is flo -- wing down to the sea.
763 }
764
765 accompaniment =\chords {
766         r8
767         c2:3- f:3-.7 d:min es4 c8:min r8
768         c2:min f:min7 g:7^3.5 c:min }
769
770 \score {
771         \simultaneous {
772           %\accompaniment
773           \context ChordNames \accompaniment
774
775           \addlyrics
776             \context Staff = mel {
777               \property Staff.noAutoBeaming = ##t
778               \property Staff.automaticMelismata = ##t
779               \melody 
780             }
781             \context Lyrics \text
782         }
783         \midi  { \tempo 4=72 }
784         \paper { linewidth = 10.0\cm }
785 }
786 @end lilypond
787
788 Again, we will dissect the file line by line.
789 @separate
790 @example 
791
792         \header @{
793  
794 @end example
795 @cindex @code{\header}
796 Information about the music you are about to typeset goes into a
797 @code{\header} block.  The information in this block is not used by
798 LilyPond, but it is passed into the output.  @file{ly2dvi} uses this
799 information to print titles above the music.
800 @separate
801 @example 
802
803         title = "The river is flowing"
804         composer = "Traditional (?)"
805 @end example
806 @cindex assignments
807 @cindex identifier assignment
808 the @code{\header} block contains assignments.  In each assignment, a
809 variable is set to a value. Lexically, both the variable name and the
810 assigned value are strings. The values have to be quoted here, because
811 they contain spaces, the variable names could also be put within quotes
812 but it is not necessary. 
813 @separate
814 @example 
815
816         \include "paper16.ly"
817  
818 @end example
819 Smaller size for inclusion in a book.
820 @separate
821 @example 
822
823         melody = \notes \relative c' @{
824  
825 @end example 
826 The structure of the file will be the same as the previous one, a
827 @code{\score} block with music in it.  To keep things readable, we will
828 give names to the different parts of music, and use the names to
829 construct the music within the score block.
830
831 @separate
832 @example 
833         \partial 8
834 @end example 
835
836 @cindex @code{\partial}
837 @cindex anacrusis
838 The piece starts with an anacrusis of one eighth.
839 @separate
840 @example
841         \key c \minor
842 @end example
843 The key is C minor: we have three flats.
844
845 @separate
846 @example 
847
848         c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
849         c4 c8 d [es () d] c4 | d4 es8 d c4.
850         \bar "|."
851  
852 @end example 
853
854 @cindex manual beaming
855 @cindex automatic beaming, turning off
856 We use explicit beaming.  Since this is a song,  we turn automatic
857 beams off, and use explicit beaming where needed.
858 @separate
859 @example 
860
861         @}
862  
863 @end example 
864 This ends the definition of @code{melody}.  
865
866 @separate
867 @example 
868
869         text = \lyrics @{
870  
871 @end example
872 @cindex lyrics
873 @cindex identifier assignment
874 @cindex syllables, entering
875 Another identifier assignment.  This one is for the lyrics. 
876 Lyrics are formed by syllables that have duration, and not by
877 notes. To make LilyPond parse words as syllables,  switch it  into
878 lyrics mode with @code{\lyrics}.  Again, the brace after @code{\lyrics}
879 is a shorthand for @code{\sequential @{}.
880 @separate
881 @example 
882
883   The4 ri -- ver is flo- __ wing,  flo -- wing and gro -- wing, the
884   ri- ver is flo- __ wing down to the sea.
885 @}
886  
887 @end example
888 @cindex extenders, lyric
889 @cindex hyphens, lyric 
890 The syllables  themselves are  separated by spaces.  You can get syllable
891 extenders by entering @code{__}, and centered hyphens with
892 @code{-}@code{-}.  We enter the syllables as if they are all quarter notes
893 in length (hence the @code{4}), and use a feature to align the
894 syllables to the music, which obviously isn't all quarter notes.
895 @separate
896 @example 
897
898         accompaniment =\chords @{
899  
900 @end example
901 @cindex chords
902 @cindex mode, chords
903 We'll put chords over the music. To enter them, there is a special mode
904 analogous to @code{\lyrics} and @code{\notes} mode, where you can give
905 the names of the chords you want, instead of listing the notes
906 comprising the chord.
907 @separate
908 @example 
909
910         r8
911  
912 @end example 
913 There is no accompaniment during the anacrusis.
914 @separate
915 @example 
916
917         c2:3- f:3-.7
918  
919 @end example
920
921 @cindex tonic
922 @cindex chord modifier
923 @cindex modifier, chord 
924 A chord is started by  the tonic of the chord. The
925 first one lasts a half note.  An unadorned note creates a major
926 triad. Since a minor triad is wanted, @code{3-} is added to modify the
927 third to be small. @code{7} modifies (adds) a seventh, which is small by
928 default to create the @code{f a c es} chord.  Multiple modifiers must be
929 separated by dots.
930 @separate
931 @example 
932
933         d:min es4 c8:min r8
934  
935 @end example
936
937 Some modifiers have predefined names, eg. @code{min} is  the same as
938 @code{3-}, so @code{d-min} is a minor @code{d} chord.
939 @separate
940 @example 
941
942         c2:min f:min7 g:7^3.5 c:min @}
943  
944 @end example
945 @cindex named modifier
946
947 A named modifier @code{min} and a normal modifier @code{7} do not have
948 to be separated by a dot.  Tones from a chord are removed with chord
949 subtractions.  Subtractions are started with a caret, and they are
950 also separated by dots.  In this example, @code{g:7^3.5} produces a
951 minor seventh.  The brace ends the sequential music.
952 @separate
953 @example 
954
955         \score @{
956                 \simultaneous @{
957  
958 @end example 
959 We assemble the music in the @code{\score} block.  Melody, lyrics and
960 accompaniment have to sound at the same time, so they should be
961 @code{\simultaneous}.
962 @cindex @code{\simultaneous}
963 @separate
964 @example 
965
966         %\accompaniment
967  
968 @end example 
969 Chord mode generates notes grouped in @code{\simultaneous} music.  If
970 you remove the comment sign, you can see the chords in normal
971 notation: they will be printed as note heads on a separate
972 staff. To print them as chords names, they have to be interpreted as
973 being chords, not notes. This is done with the following command:  
974 @separate
975 @example 
976
977         \context ChordNames \accompaniment
978  
979 @end example
980 @cindex context
981 @cindex interpretation context
982 @cindex notation context
983
984
985 Normally, the notes that you enter are transformed into note heads.
986 Note heads alone make no sense, they need surrounding information: a key
987 signature, a clef, staff lines, etc.  They need @emph{context}.  In
988 LilyPond, these symbols are created by objects called `interpretation
989 contexts'.  Interpretation contexts exist for generating notation
990 (`notation context') and for generating sound (`performance
991 context'). These objects only exist during a run of LilyPond.
992
993 By default, LilyPond will create a Staff context for you.  If you would
994 remove the @code{%} sign in the previous line, you would see that
995 mechanism in action.
996
997 We don't want that default here, because we want chord names.  The
998 command above explicitly creates an interpretation context of 
999 @code{ChordNames} type to interpret the music @code{\accompaniment}. 
1000 @separate
1001 @example 
1002
1003         \addlyrics
1004  
1005 @end example
1006 @cindex @code{\addlyrics}
1007 @cindex lyrics and melody, combining
1008 @cindex combining lyrics and melody
1009
1010 The lyrics should be aligned with the melody.  This is done by
1011 combining both with @code{\addlyrics}.  @code{\addlyrics} takes two
1012 pieces of music (usually a melody and lyrics, in that order) and
1013 aligns the syllables of the second piece under the notes of the
1014 first piece.  If you would reverse the order, the notes would be
1015 aligned on the lyrics, which is not very useful, and looks
1016 silly.
1017 @separate
1018 @example 
1019
1020         \context Staff = mel @{
1021  
1022 @end example
1023
1024 The second argument of @code{\addlyrics} is the melody.  We instantiate
1025 a @code{Staff} context explicitly: should you choose to remove the
1026 comment before the ``note heads'' version of the accompaniment, the
1027 accompaniment will be on a nameless staff.  The melody has to be on
1028 staff different from the accompaniment.  This is accomplished by giving
1029 the melody and accompaniment staffs different names.
1030 @separate
1031 @example 
1032
1033         \property Staff.noAutoBeaming = ##t
1034  
1035 @end example
1036 @cindex \property
1037 @cindex context variables
1038 @cindex setting context variables
1039 An interpretation context has variables, called properties, that tune
1040 its behaviour.  One of the variables is @code{noAutoBeaming}.  Setting
1041 this Staff's property to @code{##t}, which is the boolean value @var{true},
1042 turns the automatic beaming mechanism off for the current staff.
1043 @cindex GUILE
1044 @cindex Scheme
1045 @cindex accessing Scheme
1046 @cindex evaluating Scheme
1047 @cindex LISP
1048
1049 LilyPond internally uses GUILE, a Scheme-interpreter. Scheme is a
1050 language from the LISP family. You can learn more about Scheme at
1051 @uref{http://www.scheme.org}. It is used to represent data throughout
1052 the whole program. The hash-sign (@code{#}) accesses GUILE directly: the
1053 code following the hash-sign is evaluated as Scheme.  The boolean value
1054 @var{true} is @code{#t} in Scheme, so for LilyPond @var{true} looks like
1055 @code{##t}.
1056
1057 If Scheme scares you, don't worry. You don't need to know Scheme to
1058 create beautiful sheet music.
1059
1060
1061
1062 @separate
1063 @example 
1064
1065         \property Staff.automaticMelismata = ##t
1066  
1067 @end example
1068 @cindex automaticMelismata
1069 @cindex melismata
1070 @cindex @code{\addlyrics} and slurs
1071 Similarly, we  don't want to print a  syllable when there is
1072 a slur. This sets up @code{\addlyrics} to not put lyrics under each
1073 separate note while there is a slur.
1074 @separate
1075 @example 
1076
1077           \melody
1078         @}
1079  
1080 @end example 
1081 Finally, we put the melody on the current staff.  Note that the
1082 @code{\property} directives and @code{\melody} are grouped in sequential
1083 music,  so the property settings are done before the melody is
1084 processed.
1085 @separate
1086 @example 
1087
1088         \context Lyrics \text
1089  
1090 @end example 
1091 The second argument of @code{\addlyrics} is the text. The text also
1092 should not land on a Staff, but on a interpretation context for
1093 syllables, extenders, hyphens etc.  This context is called
1094 Lyrics.
1095 @separate
1096 @example 
1097
1098         \midi  @{ \tempo 4=72@}
1099  
1100 @end example 
1101 MIDI (Musical Instrument Digital Interface) is a standard for
1102 connecting and recording digital instruments. So a MIDI file is like a
1103 tape recording of an instrument. The @code{\midi} block causes makes the
1104 music go to a MIDI file, so you can listen to the music you entered.  It
1105 is great for checking the music.  Whenever you hear something weird, you
1106 probably hear a typing error.
1107
1108 Syntactically, @code{\midi} is similar to @code{\paper @{ @}}, since it
1109 also specifies an output method. You can specify the tempo using the
1110 @code{\tempo} command, in this case the tempo of quarter notes is set to
1111 72 beats per minute.
1112 @separate
1113 @example 
1114
1115         \paper @{ linewidth = 10.0\cm @}
1116  
1117 @end example 
1118 We also want notation output.  The linewidth is short so the piece
1119 will be set in two lines.
1120
1121 @node More movements 
1122 @section More movements
1123
1124 [FIXME: merge here with, or move this to: Other ways to run LilyPond]
1125
1126 You probably ran @file{ly2dvi} on the last example, and ended up with a
1127 viewable @file{.dvi} file.  However, between there are a few steps of
1128 which LilyPond is only one. To enhance your understanding of what's
1129 happening under the hood when you run @code{ly2dvi}, we explain what
1130 programs are run.
1131
1132 @code{ly2dvi} is a program that calls a number of programs  in sequence.
1133 The first thing it does, is running LilyPond on the input file. After
1134 some calculations, a @file{.tex} is produced. The contents
1135 of this file are very  low-level instructions.
1136
1137 For example,  the following file (@file{miniatures.ly}) 
1138
1139 @example
1140 \version "1.3.124"
1141 \header @{ title = "Two miniatures"  @}
1142
1143 #(set! point-and-click line-column-location)
1144
1145 \paper @{ linewidth = -1.0 @}
1146
1147 \score @{
1148     \notes @{ c'4 d'4 @}
1149     \header @{
1150         opus = "Opus 1."
1151         piece = "Up" @}
1152 @}
1153 \score @{
1154     \notes @{ d'4 c'4 @}
1155     \header @{
1156         opus = "Opus 2."
1157         piece = "Down" @}
1158 @}
1159 @end example
1160
1161 The titling in this manual was not generated by ly2dvi, so we can't
1162 exactly show it would look, but the result should resemble this:
1163
1164 @center @strong{Two miniatures}
1165 @flushright
1166 Opus 1.
1167 @end flushright
1168 @flushleft
1169 @var{Up}
1170 @end flushleft
1171 @lilypond
1172   \score {
1173     \notes { c'4 d'4 }
1174     \paper { linewidth = -1.0 }
1175   }
1176 @end lilypond
1177 @flushright
1178 Opus 2.
1179 @end flushright
1180 @flushleft
1181 @var{Down}
1182 @end flushleft
1183 @lilypond
1184   \score {
1185     \notes { d'4 c'4 }
1186     \paper { linewidth = -1.0 }
1187   }
1188 @end lilypond
1189
1190 This file is produced by ly2dvi in a few stages, with the help of text
1191 formatting tools. LilyPond produces two output files, @file{miniatures.tex}
1192 and @file{miniatures-1.tex}.  They both look like this:
1193
1194 @example
1195         ...
1196   \placebox@{-5  \outputscale @}%
1197   @{  8.7229  \outputscale @}%
1198   @{\magfontWXGEomMMBo\char90 @}%
1199   
1200   \placebox@{-4  \outputscale @}%
1201   @{ 81.0647  \outputscale @}%
1202         ...
1203 @end example
1204
1205 @file{ly2dvi} looks at what output LilyPond produces, and generates a
1206 file called @file{ly2dvi.out.tex}. This file contains formatting
1207 instructions for the title and page layout.  A fragment might look like
1208
1209 @example
1210
1211         \def\lilypondopus@{Opus 1.@}
1212         \def\lilypondpiece@{Up@}
1213         \def\mustmakelilypondtitle@{@}
1214         \input miniatures.tex
1215         \def\lilypondtitle@{Two miniatures@}
1216
1217 @end example
1218
1219 @file{ly2dvi} runs it through LaTeX. LaTeX is a text-formatting system
1220 built on top of @TeX{}. It's very popular in the academic world. If LaTeX
1221 is successful, this will produce a @file{.dvi} file, containing both the
1222 titling and the actual music.  @code{ly2dvi} completes its task by
1223 deleting the two temporary files, leaving only @file{miniatures.dvi}.
1224
1225 Next, now we'll look at the example line by line to explain new things.
1226
1227 @separate
1228 @example 
1229 \version "1.3.124"
1230 @end example 
1231 Lilypond and its language are still under development, and occasionally,
1232 details of the syntax are changed. This fragment indicates for which
1233 version the input file was written. When you compile this file, the
1234 version number will be checked, and you will get a warning when the file
1235 is too old.
1236
1237 This version number is also used by the @code{convert-ly} program (See
1238 @ref{convert-ly}), which uses it to update the file to the latest lily
1239 version.
1240
1241 @separate
1242 @example
1243   \header @{ title = "Two miniatures"  @}
1244 @end example
1245 This sets the titling information for the entire file.
1246
1247 @separate
1248 @example
1249         #(set! point-and-click line-column-location)
1250 @end example
1251
1252 This piece of Scheme code sets the Scheme variable
1253 @code{point-and-click} to the value @var{line-column-location} (which
1254 itself is a Scheme procedure).
1255
1256 Editing input files can be quite complicated if you're working with
1257 large files: if you're digitizing existing music, you have to
1258 synchronize the .ly file, the sheet music on your lap and the sheet
1259 music on the screen.  The point-and-click mechanism makes it easy to
1260 find the origin of an error in the .ly file: when you view the file with
1261 Xdvi and click on a note, your editor will jump to the spot where that
1262 note was entered.  For more information, see @ref{Point and click}.
1263
1264 @separate
1265 @example
1266   \paper @{ 
1267 @end example
1268
1269 The @code{\score} blocks that follow in the file don't have
1270 @code{\paper} sections, so the settings of this block are substituted: A
1271 paper block, at top-level, i.e. not in a @code{\score} block sets the
1272 default page layout.
1273
1274 @separate
1275 @example
1276   linewidth = -1.0 @}
1277 @end example
1278
1279
1280
1281 The variable @code{linewidth} normally sets the length of the systems on
1282 the page. However, a negative value has a special meaning. If
1283 @code{linewidth} is less than 0, no line breaks are inserted into the
1284 score, and the spacing is set to natural length: a short phrase takes up
1285 little space, a longer phrase more space.
1286
1287 @separate
1288 @example
1289   \score @{
1290     \notes @{ c'4 d'4 @}
1291 @end example
1292
1293 In previous examples, notes were specified in relative octaves,
1294 i.e. each note was put in the octave that would put it closest to its
1295 predecessor. Besides relative, there is also absolute octave
1296 specification, which you get when you don't specify @code{\relative}. In
1297 this input mode, the central C is denoted by @code{c'}. Going down, you
1298 get @code{c} @code{c,} @code{c,,} etc.  Going up, you get @code{c''}
1299 @code{c'''} etc.
1300
1301 When you're copying music from existing sheet music, relative octaves
1302 are probably the easiest to use: it's less typing work and errors are
1303 easily spotted. However, if you write LilyPond input, either by hand
1304 (ie. composing) or by computer, absolute octaves are probably less work.
1305
1306
1307 @separate
1308 @example
1309     \header @{
1310 @end example
1311
1312 The @code{\header} is normally at the top of the file, where it sets
1313 values for the rest of the file. If you want to typeset different pieces
1314 from one file (for example, if there are multiple movements, or if
1315 you're making an exercise book), you can put different @code{\score}
1316 blocks into the input file. ly2dvi will assemble all LilyPond output
1317 files into a big document. The contents of \header blocks specified
1318 within each score, are used for the titling of each movement.
1319 @separate
1320 @example
1321         opus = "Opus 1."
1322         piece = "Up" @}
1323 @end example
1324 For example, the Opus number is put at the right, and the piece string
1325 will be at the left.
1326
1327
1328
1329 @node A piano excerpt
1330 @section A piano excerpt
1331
1332 Our fourth subject is a piece of piano music.  The fragment in the input
1333 file is a piano reduction of the G major Sinfonia by Giovanni Battista
1334 Sammartini.  It was composed around 1740.  It's in the source package
1335 under  the name @file{sammartini.ly}.
1336
1337 @lilypond[verbatim]
1338 \include "paper16.ly"
1339
1340 stemDown = \property Voice.Stem \override #'direction = #-1
1341 stemUp = \property Voice.Stem \override #'direction = #1
1342 stemBoth = \property Voice.Stem \revert #'direction  
1343
1344 viola = \notes \relative c' \context Voice = viola {
1345     <c4-\f-\arpeggio g' c>
1346     \stemDown g'8. b,16
1347     s1 s2. r4
1348     g
1349 }
1350
1351 oboes = \notes \relative c'' \context Voice = oboe {
1352     \stemUp s4  g8. b,16 c8 r <e'8.^\p g> <f16 a>
1353     \grace <e8( g> <d4 )f> <c2 e>
1354     \times 2/3 { <d8 \< f> <e g> <f a> }
1355     <
1356         { \times 2/3 { a8 g c } \! c2 }
1357         \context Voice = oboeTwo {
1358             \stemDown
1359             \grace {
1360                 \property Grace.Stem \override #'direction = #-1
1361                 [f,16 g] }
1362             f8 e e2
1363         }
1364     >
1365     \stemBoth
1366     \grace <c,8( e> <)b8. d8.-\trill> <c16 e> | 
1367     [<d ( f> < )f8. a>] <)b,8 d> r [<d16( f> <f8. )a>] <b,8 d> r  |
1368     [<c16( e>  < )e8. g>] <c8 e,>
1369 }
1370
1371 hoomPah = \repeat unfold 8 \notes
1372     \transpose c' { \stemUp c8 \stemBoth \stemDown c'8 \stemBoth }
1373
1374 bassvoices = \notes \relative c' {
1375     c4 g8. b,16
1376     \autochange Staff \hoomPah
1377     \translator Staff = down
1378     \stemDown [c8 c'8] r4
1379     <g d'> r4
1380     < {\stemUp r2 <e4 c'> <c8 g'> }
1381         \context Voice = reallyLow  {\stemDown g2 ~ | g4 c8 } >
1382 }
1383
1384 \score {
1385     \context PianoStaff \notes <
1386         \context Staff = up < \time 2/2
1387             \viola
1388             \oboes
1389         >
1390         \context Staff = down < \time 2/2 \clef bass
1391             \bassvoices
1392         >
1393     >
1394     \midi { }
1395     \paper {
1396         indent = 0.0
1397         linewidth = 15.0 \cm }
1398 }
1399 @end lilypond
1400
1401 If this looks like incomprehensible gibberish to you, you are right.
1402 This example has been doctored to have as many quirks as possible.
1403
1404 As you can see, this example features multiple voices on one staff.  To
1405 make room for those voices, their notes have to be stemmed in opposite
1406 directions.
1407
1408 Printed symbols are internally represented by so-called Graphical
1409 Objects (more colloquially: Grobs).  These statements concern the
1410 grob called `Stem'. Each grob is described by a bunch of settings. These
1411 setting determine the fonts, offsets, sub-routines to be called on the
1412 grob, etc.  The initial values of these settings are set in the Scheme
1413 file @file{scm/grob-description.scm}.
1414
1415 @separate
1416 @example
1417   stemDown = \property Voice.Stem \override #'direction = #-1
1418 @end example
1419
1420 Set a proprerty for all Stem grobs in the current Voice:
1421 @code{direction} is set to @code{-1}, which encodes down.  The setting
1422 remains in effect until it is reverted.
1423
1424 @separate
1425 @example
1426  \property Voice.Stem \revert #'direction  
1427 @end example
1428
1429 Revert the to the previous setting.  The effect of precisely one
1430 @code{\stemDown} or @code{\stemUp} is neutralised.
1431
1432
1433 LilyPond includes the identifiers @code{\stemUp}, @code{\stemDown} along
1434 with some other commonly used formatting instructions, but to explain how
1435 it works, we wrote our own here.  Of course, you should use predefined
1436 identifiers like these if possible: then you will be affected less by
1437 the implementation changes we occasionally make.
1438
1439 @separate
1440 @example 
1441 viola = \notes \relative c'  \context Voice = viola @{ 
1442 @end example 
1443 In this example, you can see multiple parts on a staff.  Each part is
1444 associated with one notation context.  This notation context handles
1445 stems and dynamics (among others).  The name of this context is
1446 @code{Voice}.  For each part we have to make sure that there is
1447 precisely one @code{Voice} context, so we give it an unique name
1448 (`@code{viola}').
1449
1450 @separate
1451 @example 
1452 <c4-\f-\arpeggio g' c>
1453 @end example 
1454 The delimiters @code{<} and @code{>} are shorthands for
1455 @code{\simultaneous @{} and @code{@}}. The expression enclosed in
1456 @code{<} and @code{>} is a chord.
1457
1458 @cindex dynamics
1459 @cindex loudness
1460 @cindex forte
1461 @cindex arpeggio
1462
1463 @code{\f} places a forte symbol under the chord. The forte applies to
1464 the whole chord, but the syntax requires that commands like forte and
1465 arpeggio are attached to a note, so here we attach them to the first
1466 note.
1467
1468 @code{\arpeggio} typesets an arpeggio sign (a wavy vertical line) before
1469 the chord.
1470
1471 @separate
1472 @example 
1473    \stemDown
1474 @end example 
1475
1476
1477 @separate
1478 @example 
1479         g'8. b,16 
1480 @end example 
1481 Relative octaves work a little differently with chords.  The starting
1482 point for the note following a chord is the first note of the chord.  So
1483 the @code{g} gets an octave up quote: it is a fifth above the starting
1484 note of the previous chord (the central C).
1485
1486 @separate
1487 @example 
1488 s1 s2. r4 
1489 @end example 
1490 @code{s} is a spacer rest.  It does not print anything, but it does have
1491 the duration of a rest. It is useful for filling up voices that
1492 temporarily don't play. In this case, the viola doesn't come until one
1493 and a half measure later.
1494
1495 @separate
1496 @example 
1497 oboes = \notes \relative c'' \context Voice = oboe @{ 
1498 @end example 
1499 Now comes a part for two oboes.  They play homophonically, so we
1500 print the notes as one voice that makes chords. Again, we insure that
1501 these notes are indeed processed by precisely one context with
1502 @code{\context}.
1503 @separate
1504 @example 
1505 \stemUp s4  g8. b,16 c8 r <e'8.-\p g> <f16 a> 
1506 @end example 
1507 @code{\stemUp} is a reference to the @code{\property \override} command
1508 defined above. 
1509 @separate
1510 @example 
1511 \grace <e8 g> < d4 f> <c2 e> 
1512 @end example
1513 @cindex @code{\grace}
1514 @cindex ornaments
1515 @cindex grace notes
1516
1517 @code{\grace} introduces grace notes.  It takes one argument, in this
1518 case a chord.
1519
1520 @ignore
1521 The slur started on the @code{e} of the chord
1522 will be attached to the next note.@footnote{LilyPond will squirm
1523 about unended Slurs.  In this case, you can ignore the warning}.
1524 @end ignore
1525 @separate
1526 @example 
1527 \times 2/3 
1528 @end example
1529 @cindex tuplet
1530 @cindex triplets
1531 Tuplets are made with the @code{\times} keyword.  It takes two
1532 arguments: a fraction and a piece of music.  The duration of the piece
1533 of music is multiplied by the fraction.  Triplets make notes occupy 2/3
1534 of their notated duration, so in this case the fraction is 2/3.
1535 @separate
1536 @example 
1537 @{ <d8 \< f> <e g> <f a> @} 
1538 @end example 
1539 The piece of music to be `tripletted' is sequential music containing
1540 three notes.  On the first chord, a crescendo is started with
1541 @code{\<}. To be precise, the crescendo start is syntactically attached
1542 to the preceding note, the @code{d}.
1543
1544 @cindex dynamics
1545 @cindex crescendo
1546 @cindex @code{\<}
1547
1548 @separate
1549 @example 
1550
1551 @end example 
1552 At this point, the homophonic music splits into two rhythmically
1553 different parts.  We can't use a sequence of chords to enter this, so
1554 we make a `chord' of sequences to do it.  We start with the upper
1555 voice, which continues with upward stems:
1556 @separate
1557 @example 
1558  @{ \times 2/3 @{ a8 g c @} \! c2 @} 
1559 @end example
1560
1561 @cindex @code{\!}
1562
1563 The crescendo is ended at the half note by the escaped exclamation
1564 mark @code{\!}.
1565 @separate
1566 @example 
1567 \context Voice = oboeTwo @{
1568 \stemDown 
1569 @end example 
1570 We can't share stems with the other voice, so we have to create a new
1571 @code{Voice} context.  We give it the name @code{oboeTwo} to distinguish
1572 it from the other context.  Stems go down in this voice.
1573 @separate
1574 @example 
1575 \grace @{  
1576 @end example
1577 @cindex Grace context
1578 When a grace section is processed, a @code{Grace} context is
1579 created. This context acts like a miniature score of its own.  It has
1580 its own time bookkeeping, and you can make notes, beams, slurs
1581 etc. Here we fiddle with a property and make a beam.  The argument of
1582 @code{\grace} is sequential music.
1583
1584 @separate
1585 @example 
1586 \property Grace.Stem \override #'direction = #-1
1587 [f,16 g] @}
1588 @end example 
1589
1590 Normally, grace notes are always stem up, but in this case, the upper
1591 voice interferes. We set the stems down here.
1592
1593 As far as relative mode is concerned, the previous note is the
1594 @code{c'''2} of the upper voice, so we have to go an octave down for
1595 the @code{f}.
1596 @separate
1597 @example 
1598
1599   f8 e e2
1600 @} > 
1601 @end example 
1602 This ends the two-part section.
1603 @separate
1604 @example 
1605 \stemBoth
1606 \grace <c,8( e> <)b8. d8.-\trill> <c16 e> |  
1607 @end example
1608 @cindex trill
1609 @cindex stemBoth
1610
1611 @code{\stemBoth} ends the forced stem directions. From here, stems are
1612 positioned as if it were single part music.
1613
1614 The bass has a little hoom-pah melody to demonstrate parts switching
1615 between staffs.  Since it is repetitive, we use repeats:
1616 @separate
1617 @example 
1618 hoomPah  =  \repeat unfold 8
1619 @end example
1620 @cindex unfolded @code{\repeat}
1621 The unfolded repeat prints the notes in its argument as if they were
1622 written out in full eight times.
1623 @separate
1624 @example
1625 \notes \transpose c' @{
1626 @end example
1627 @cindex transposing
1628 @cindex relative mode and transposing
1629
1630 Transposing can be done with @code{\transpose}.  It takes two arguments
1631 the first specifies what central C should be transposed to.  The second
1632 is the to-be-transposed music.  As you can see, in this case, the
1633 transposition has no effect, as central C stays at central C.
1634
1635 The purpose of this no-op is circumventing relative mode.  Relative mode
1636 can not be used together with transposition, so @code{\relative} will
1637 leave the contents of @code{\hoomPah} alone.  We can use it without
1638 having to worry about getting the motive in a wrong octave.
1639 @separate
1640 @example 
1641 bassvoices = \notes \relative c' @{
1642 c4 g8. b,16
1643 \autochange Staff \hoomPah 
1644 @end example
1645 @cindex staff switch, automatic
1646 @cindex cross staff voice, automatic
1647 @cindex @code{\autochange}
1648
1649 Voices can switch between staffs. The easiest way to get this, is to use
1650 @code{\autochange}. This command looks at the pitch of each note, and if
1651 necessary, will cross to the other staff. For this to work, the two
1652 staffs must be called @code{"up"} and @code{"down"}.
1653 @separate
1654 @example
1655         \translator Staff = down
1656 @end example
1657 @cindex staff switch
1658 @cindex cross staff voice
1659 We want the remaining part of this melody on the lower staff, so we do a
1660 manual staff switch here.
1661
1662
1663 @separate
1664 @example 
1665 \context Voice = reallyLow  @{\stemDown g2 ~ | g4 c8 @} > 
1666 @end example
1667 @cindex tie
1668 @cindex @code{~}
1669 After skipping some lines, we see @code{~}.  This mark makes ties.  Note
1670 that ties and slurs are different things.  A tie can only connect two
1671 note heads of the same pitch, whereas a slur can connect many chords
1672 with one curve.
1673
1674 @separate
1675 @example 
1676 \context PianoStaff 
1677 @end example 
1678  A special context is needed to get cross staff beaming right.  This
1679 context is called @code{PianoStaff}.
1680 @separate
1681 @example 
1682 \context Staff = bottom < \time 2/2 \clef bass 
1683 @end example 
1684 The bottom staff must have a different clef.
1685 @separate
1686 @example 
1687 indent = 0.0 
1688 @end example 
1689 To make some more room on the line, the first (in this case the only)
1690 line is not indented.  The line still looks very cramped, but that is due
1691 to the page layout of this document.
1692
1693
1694 @ignore
1695 [TODO:
1696
1697 * font-size, multi-stanza.
1698
1699 * Simple part combining in a Hymn
1700 @end ignore
1701
1702
1703 @node An orchestral score
1704 @section An orchestral score
1705
1706 @menu
1707 * The full score::              
1708 * Extracting an individual part::  
1709 @end menu
1710
1711
1712 Our last two examples show a way to setup the music for an orchestral
1713 score.  When typesetting a piece for several instruments, you'll want to
1714 create a conductor's full score, alongside several individual parts.
1715
1716 LilyPond is well suited for this task.  We will declare the music for
1717 each instrument individually, giving the music of each instrument its
1718 own name.  These pieces of music are then combined in different
1719 @code{\score} blocks to produce different combinations of the score.
1720
1721 This orchestral score example consists of three input files.  In the
1722 first file, @file{os-music.ly}, we define the music for all instruments.
1723 This file will be used both for producing the score and the separate
1724 parts.
1725
1726 If you were to run lilypond on this file, no printable output would be
1727 produced.
1728
1729 @example
1730 % os-music.ly
1731 \header @{
1732   title = "Zo, goed lieverd?"
1733   subtitle = "How's, this babe?"
1734   composer = "JCN"
1735   opus = "1"
1736   piece = "Laid back"
1737 @}
1738 global = @{
1739   \time 2/4
1740   \skip 2*4 \bar "|."
1741 @}
1742 Key = \notes \key as \major
1743 flautoI = \notes\relative c'' @{
1744   f8 g f g f g f g
1745   bes as bes as bes as bes as
1746 @}
1747 flautoII = \notes\relative c'' @{
1748   as8 bes as bes R1 d4 ~ d
1749 @}
1750 tromboI = \notes\relative c'' @{
1751   c4. c8 c8 c4. es4 r as, r
1752 @}
1753 tromboII = \notes\relative c'' @{
1754   as4. as8 as8 as4. R1*1/2 as4 es'
1755 @}
1756 timpani = \notes\relative c, @{
1757   \times 2/3 @{ f4 f f @}
1758   \times 4/5 @{ as8 as as as as @}
1759   R1
1760 @}
1761 corno = \notes\relative c' @{
1762    bes4 d f, bes d f, bes d
1763 @}
1764 @end example
1765
1766 We will not go through the input line by line, but only indicate and
1767 explain the new elements.
1768
1769
1770 @separate
1771 @example
1772 global = @{
1773   \time 2/4
1774   \skip 2*4 \bar "|.";
1775 @}
1776 @end example
1777
1778 Declare setting to be used globally.  The @code{\skip} command produces
1779 no output, but moves forward in time: in this case, the duration of a
1780 half note (@code{2}), and that four times (@code{*4}).  This brings us
1781 to the end of the piece, and we can set the end bar.
1782
1783 @separate
1784 @example
1785 Key = \notes \key as \major
1786 @end example
1787 Declare the key signature of the piece and assign it to the identifier
1788 @var{Key}.  Lateron, we'll use @code{\Key} for all staffs except those
1789 for transposing instruments.
1790
1791 @node The full score
1792 @subsection The full score
1793
1794
1795 The second file, @file{os-score.ly} reads the definitions of the first
1796 (@file{os-music.ly}), and defines the @code{\score} block for the full
1797 conductor's score.
1798
1799
1800 @example
1801 % os-score.ly
1802 \include "os-music.ly"
1803 \include "paper13.ly"
1804
1805 #(set! point-and-click line-column-location)
1806 #(define text-flat '((font-relative-size . -2)
1807          (music "accidentals--1")))
1808
1809 \score @{
1810   <
1811     \global
1812     \property Score.BarNumber \override #'padding = #3
1813     \context StaffGroup = woodwind <
1814       \context Staff = flauti <
1815         \property Staff.midiInstrument = #"flute"
1816         \property Staff.instrument = "2 Flauti"
1817         \property Staff.instr = "Fl."
1818         \Key
1819         \context Voice=one @{ \voiceOne \flautoI @}
1820         \context Voice=two @{ \voiceTwo \flautoII @}
1821       >
1822     >
1823     \context StaffGroup = timpani <
1824       \context Staff = timpani <
1825         \property Staff.midiInstrument = #"timpani"
1826         \property Staff.instrument = #'(lines "Timpani" "(C-G)")
1827         \property Staff.instr = #"Timp."
1828         \clef bass
1829         \Key
1830         \timpani
1831       >
1832     >
1833     \context StaffGroup = brass <
1834       \context Staff = trombe <
1835         \property Staff.midiInstrument = #"trumpet"
1836         \property Staff.instrument = #`(lines "2 Trombe" "(C)")
1837         \property Staff.instr = #`(lines "Tbe." "(C)")
1838         \Key
1839         \context Voice=one \partcombine Voice
1840           \context Thread=one \tromboI
1841           \context Thread=two \tromboII
1842       >
1843       \context Staff = corni <
1844         \property Staff.midiInstrument = #"french horn"
1845         \property Staff.instrument = #`(lines "Corno"
1846           (columns "(E" ,text-flat ")"))
1847         \property Staff.instr = #`(lines "Cor."
1848           (columns "(E" ,text-flat ")"))
1849         \property Staff.transposing = #3
1850         \notes \key bes \major
1851         \context Voice=one \corno
1852       >
1853     >
1854   >
1855   \paper @{
1856     indent = 15 * \staffspace
1857     linewidth = 60 * \staffspace
1858     textheight = 90 * \staffspace
1859     \translator@{
1860       \VoiceContext
1861       \consists "Multi_measure_rest_engraver"
1862     @}
1863     \translator@{
1864       \HaraKiriStaffContext
1865       \remove "Multi_measure_rest_engraver"
1866     @}
1867   @}
1868   \midi @{
1869     \tempo 4 = 75
1870   @}
1871 @}
1872 @end example
1873
1874 @center @strong{Zo, goed lieverd?}
1875 @sp 1
1876 @center How's, this babe?
1877 @flushright
1878 Opus 1.
1879 @end flushright
1880 @flushleft
1881 @sc{Laid back}
1882 @end flushleft
1883
1884 @lilypondfile{os-score.ly}
1885
1886 @separate
1887 @example
1888 \include "os-music.ly"
1889 @end example
1890 First, we need to include the music definitions we made in
1891 @file{os-music.ly}.
1892
1893 @separate
1894 @example
1895 #(set! point-and-click line-column-location)
1896 @end example
1897 In a large orchestral score like this you're bound to make some small
1898 mistakes, so we enable point and click (See @ref{Point and click})
1899 editing.
1900
1901 @separate
1902 @example
1903 #(define text-flat '((font-relative-size . -2)
1904          (music "accidentals--1")))
1905 @end example
1906
1907 When naming the tuning of the french horn, we'll need a piece of text
1908 with a flat sign.  LilyPond has a mechanism for font selection and
1909 kerning called Scheme markup text (See @ref{Text markup}).  The flat
1910 sign is taken from the music font, and its name is @code{accidentals--1}
1911 (The sharp sign is called @code{accidentals-+1}).  The default font is
1912 too big for text, so we select a relative size of @code{-2}.
1913
1914 @separate
1915 @example
1916   <
1917     \global
1918 @end example
1919 Of course, all staffs are simultaneous and use the same global settings.
1920
1921 @separate
1922 @example
1923     \property Score.BarNumber \override #'padding = #3
1924 @end example
1925 LilyPond prints bar numbers at the start of each line, but
1926 unfortunately, they end up a bit too close to the staff in this example.
1927 A bar number internally is a Grob called @var{BarNumber}.  BarNumber
1928 Grobs can be manipulated through their @var{side-position-interface}.  One
1929 of the properties of a @var{side-position-interface} that can be tweaked
1930 is the @var{padding}: the amount of extra space that is put between this
1931 Grob and other Grobs.  We set the padding to three staff spaces.
1932
1933 You can find all this kind of information in LilyPond's automatically
1934 generated documentation in
1935 @ifnottex
1936 @ref{ (lilypond-internals)lilypond-internals, LilyPond Internals}.
1937 @end ifnottex
1938 @iftex
1939 the online documentation.
1940 @end iftex
1941
1942 @separate
1943 @example
1944     \context StaffGroup = woodwind <
1945       \context Staff = flauti <
1946 @end example
1947 A new notation context: the StaffGroup.  StaffGroup can hold one or more
1948 Staffs, and will print a big bracket at the left of the score.  Start a
1949 new staff group for the woodwind section (just the flutes in this case).
1950 Immediately after that, we start the staff for the two flutes, that also
1951 play simultaneously.
1952
1953 @separate
1954 @example
1955         \property Staff.midiInstrument = #"flute"
1956 @end example
1957 Specify the instrument for MIDI output (see @ref{MIDI instrument
1958 names}).
1959
1960 @separate
1961 @example
1962         \property Staff.instrument = "2 Flauti"
1963         \property Staff.instr = "Fl."
1964 @end example
1965 And define the instrument names to be printed in the margin,
1966 @code{instrument} for the first line of the score, @code{instr} for the
1967 rest of the score.
1968
1969 @separate
1970 @example
1971         \Key
1972 @end example
1973 The flutes play in the default key.
1974
1975 @separate
1976 @example
1977         \context Voice=one @{ \voiceOne \flautoI @}
1978         \context Voice=two @{ \voiceTwo \flautoII @}
1979 @end example
1980 Last come the actual flute parts.  Remember that we're still in
1981 simultaneous mode.  We name both voices differently, so that LilyPond
1982 will actually create two Voice contexts.  The flute parts are simple, so
1983 we specify manually which voice is which: @code{\voiceOne} forces the
1984 direction of stems, beams, slurs and ties up, @code{\voiceTwo} sets
1985 directions down.
1986
1987 @separate
1988 @example
1989       >
1990     >
1991 @end example
1992 Close the flutes staff and woodwind staff group.
1993
1994 @separate
1995 @example
1996         \property Staff.instrument = #'(lines "Timpani" "(C-G)")
1997 @end example
1998 The timpani staff only shows a new piece of scheme markup, it sets two
1999 lines of text.
2000
2001 @separate
2002 @example
2003         \context Voice=one \partcombine Voice
2004           \context Thread=one \tromboI
2005           \context Thread=two \tromboII
2006 @end example
2007 You have seen the notation contexts Staff and Voice, but here's a new
2008 one: Thread.  One or more Threads can be part of a Voice.  The Thread
2009 takes care of note heads and rests, the Voice combine note heads onto a
2010 stem.
2011
2012 For the trumpets we use the automatic part combiner (see @ref{Automatic
2013 part combining}) to combine the two simultaneous trumpet parts onto the
2014 trumpet staff.  Each trumpet gets its own Thread context, which must be
2015 named @code{one} and @code{two}).  The part combiner makes these two
2016 threads share a Voice when they're similar, and splits the threads up
2017 when they're different.
2018
2019 @separate
2020 @example
2021         \property Staff.instrument = #`(lines "Corno"
2022           (columns "(E" ,text-flat ")"))
2023 @end example
2024 The french horn has the most complex scheme markup name, made up of two
2025 lines of text.  The second line has two elements (columns), the @code{E}
2026 and the flat sign @code{text-flat} that we defined before.
2027
2028 @separate
2029 @example
2030         \property Staff.transposing = #3
2031 @end example
2032 The french horn is to be tuned in E-flat, so we tell the MIDI backend to
2033 transpose this staff by three steps.
2034
2035 Note how we can choose different tuning for entering, printing and
2036 playing, using @code{\transpose} and the MIDI Staff proprerty
2037 @var{transposing}.
2038
2039 @separate
2040 @example
2041         \notes \key bes \major
2042 @end example
2043 Therefore, it has a different key.
2044
2045 @separate
2046 @example
2047     indent = 15 * \staffspace
2048     linewidth = 60 * \staffspace
2049 @end example
2050 We specify a big indent for the first line and a small linewidth for this
2051 tutorial.
2052
2053 @separate
2054
2055 Usually, LilyPond's predefined setup of notation contexts (Thread,
2056 Voice, Staff, Staffgroup, Score) is just fine.  But in this case, we
2057 want a different type of Staff context.
2058
2059 In orchestral scores, it often happens that one instrument has only
2060 rests during one line of the score.  The @code{HaraKiriStaffContext} can
2061 be used as a regular @code{StaffContext} drop-in and will take care of
2062 the automatic removing of empty staffs.
2063
2064 @node Extracting an individual part
2065 @subsection Extracting an individual part
2066
2067 The third file, @file{os-flute-2.ly} also reads the definitions of the
2068 first (@file{os-music.ly}), and defines the @code{\score} block for the
2069 second flute part.
2070
2071 @example
2072 \include "os-music.ly"
2073 \include "paper16.ly"
2074
2075 \score @{
2076   \context Staff <
2077     \property Score.skipBars = ##t
2078     \property Staff.midiInstrument = #"flute"
2079     \global
2080     \Key
2081     \flautoII
2082   >
2083   \header @{
2084     instrument = "Flauto II"
2085   @}
2086   \paper @{
2087     linewidth = 80 * \staffspace
2088     textheight = 200 * \staffspace
2089   @}
2090   \midi @{
2091     \tempo 4 = 75
2092   @}
2093 @}
2094 @end example
2095
2096 @center @strong{Zo, goed lieverd?}
2097 @sp 1
2098 @center How's, this babe?
2099 @center @emph{Flauto II}
2100 @flushright
2101 Opus 1.
2102 @end flushright
2103 @flushleft
2104 @sc{Laid back}
2105 @end flushleft
2106 @lilypondfile{os-flute-2.ly}
2107
2108
2109 Because we separated the music definitions from the @code{\score}
2110 instantiations, we can easily define a second score from the music of
2111 the second flute.  This then is the part for the second flute player.
2112 Of course, we make separate parts for all individual instruments.
2113
2114 @separate
2115 @example
2116     \flautoII
2117 @end example
2118 In this individual part the second flute has a whole staff for itself,
2119 so we don't want to force stem or tie directions.
2120
2121 @separate
2122 @example
2123   \header @{
2124     instrument = "Flauto II"
2125   @}
2126 @end example
2127 The @code{\header} definitions were also read from @file{os-music.ly},
2128 but we need to set the instrument for this particular score.
2129
2130 @separate
2131 @example
2132     \property Score.skipBars = ##t
2133 @end example
2134 In the conductor's full score, all bars with rests are printed, but for
2135 the individual parts, we want to contract pieces of consecutive empty
2136 bars.  LilyPond will do this if Score's @var{skipBars} property to
2137 true. 
2138
2139
2140 @node Other ways to run LilyPond
2141 @section Other ways to run LilyPond
2142
2143 Until now, you have been using @file{ly2dvi} to invoke LilyPond.
2144 There are three other routes.  Firstly, there is a script called
2145 @code{lilypond-book}, that allows you to freely mix LilyPond input with
2146 Texinfo or LaTeX input. For example, this manual was written using
2147 @code{lilypond-book}. It is discussed in @ref{lilypond-book}.
2148
2149
2150 Secondly, you can generate PostScript directly. This is useful if you
2151 can not or do not want to run @TeX{} on your system.  To obtain direct
2152 PostScript output, invoke LilyPond as follows:
2153 @cindex PostScript output
2154 @example
2155 lilypond -f ps test.ly
2156 @end example
2157 You have to set some environment variables to view or print this
2158 output. More information can be found in @ref{Invoking
2159 LilyPond}.
2160
2161
2162 Thirdly, if you want to do special things with your output, you can run
2163 invoke lilypond directly:
2164 @example
2165 lilypond test.ly
2166 @end example
2167 to produce plain @TeX{} output.  Note that La@TeX{} will not work on the
2168 resulting @file{test.tex}.  You must run plain @TeX{} on it.
2169
2170 @cindex @TeX{}
2171
2172
2173
2174
2175
2176 @node Integrating text and music
2177 @section Integrating text and music
2178
2179 Sometimes, you might want to use music examples in a text that you are
2180 writing. For example, if you are writing a musicological treatise, a
2181 songbook, or (like us) the LilyPond manual.  You can make such texts by
2182 hand, simply by importing a PostScript figure into your wordprocessor.
2183 However, there is a also an automated procedure:
2184
2185 If you use La@TeX{} or texinfo, you can mix text and lilypond code. A
2186 script called @code{lilypond-book} will extract the music fragments, run
2187 lilypond on them, and put back the resulting notation.  lilypond-book is
2188 described fully in @ref{lilypond-book}, but here we show a small
2189 example. Since the example also contains explanatory text, we won't
2190 comment on the contents.
2191
2192 @example
2193 \documentclass[a4paper]@{article@}
2194 \begin@{document@}
2195
2196 In a lilypond-book document, you can freely mix music and text. For
2197 example:
2198 \begin@{lilypond@}
2199   \score @{ \notes \relative c' @{
2200      c2 g'2 \times 2/3 @{ f8 e d @} c'2 g4
2201   @} @}
2202 \end@{lilypond@}
2203 Notice that the music line length matches the margin settings of the
2204 document.
2205
2206 If you have no \verb+\score+ block in the fragment,
2207 \texttt@{lilypond-book@} will supply one:
2208
2209 \begin@{lilypond@}
2210   c'4
2211 \end@{lilypond@}
2212
2213 In the example you see here, a number of things happened: a
2214 \verb+\score+ block was added, and the line width was set to natural
2215 length. You can specify many more options using  \LaTeX style options
2216 in brackets:
2217
2218 \begin[verbatim,11pt,singleline,
2219   fragment,relative,intertext="hi there!"]@{lilypond@}
2220   c'4 f bes es
2221 \end@{lilypond@}
2222
2223 \texttt@{verbatim@} also shows the lilypond code, \texttt@{11pt@} selects
2224 the default music size, \texttt@{fragment@} adds a score block,
2225 \texttt@{relative@} uses relative mode for the fragment, and
2226 \texttt@{intertext@} specifies what to print between the
2227 \texttt@{verbatim@} code and the music.
2228
2229 If you include large examples into the text, it may be more convenient
2230 to put the example in a separate file:
2231
2232 \lilypondfile[printfilename]@{sammartini.ly@}
2233
2234 The \texttt@{printfilename@} option adds the file name to the output.
2235
2236 \end@{document@}
2237 @end example
2238
2239 Under Unix, you can view the results as follows.
2240 @example
2241 $ cd input/tutorial
2242 $ lilypond-book --outdir=out/ lilbook.tex
2243 lilypond-book (GNU LilyPond) 1.3.146
2244 Reading `/home/hanwen/usr/src/lilypond-1.3.146/input/tutorial/lilbook.tex'
2245 Reading
2246 `/home/hanwen/usr/src/lilypond-1.3.146/input/tutorial/sammartini.ly'
2247 @var{lots of stuff deleted}
2248 Writing `out/lilbook.latex'
2249 $ cd out
2250 $ latex lilbook.latex
2251 @var{lots of stuff deleted}
2252 $ xdvi lilbook 
2253 @end example
2254
2255 Notice the @code{outdir} option to lilypond-book. Running lilypond-book
2256 and running latex creates a lot of temporary files, and you wouldn't
2257 those to clutter up your working directory. Hence, we have them created
2258 in a separate subdirectory.
2259
2260 The result more or less looks like this: 
2261
2262 @separate
2263
2264 In a lilypond-book document, you can freely mix music and text. For
2265 example:
2266 @lilypond
2267   \score { \notes \relative c' {
2268      c2 g'2 \times 2/3 { f8 e d } c'2 g4
2269   } }
2270 @end lilypond
2271 Notice that the music line length matches the margin settings of the
2272 document.
2273
2274 If you have no @code{\score} block in the fragment,
2275 @code{lilypond-book} will supply one:
2276
2277 @lilypond
2278   c'4
2279 @end lilypond
2280
2281 In the example you see here, a number of things happened: a
2282 @code{\score} block was added, and the line width was set to natural
2283 length. You can specify many more options using  La@TeX{} style options
2284 in brackets:
2285
2286 @lilypond[verbatim,11pt,singleline,
2287   fragment,relative,intertext="hi there!"]
2288   c'4 f bes es
2289 @end lilypond
2290
2291 @code{verbatim} also shows the lilypond code, @code{11pt} selects
2292 the default music size, @code{fragment} adds a score block,
2293 @code{relative} uses relative mode for the fragment, and
2294 @code{intertext} specifies what to print between the
2295 @code{verbatim} code and the music.
2296
2297 If you include large examples into the text, it may be more convenient
2298 to put the example in a separate file:
2299
2300 @lilypondfile[printfilename]{sammartini.ly}
2301
2302 The @code{printfilename} option adds the file name to the output.
2303 @node  end of tutorial
2304 @section The end        
2305          
2306 That's all folks.  From here, you can either try fiddling with input
2307 files, or you can read the reference manual.  You can find more example
2308 files in @file{input} and @file{input/test}.  You can also look at some
2309 real music.  Have a look at the @uref{Mutopia project,
2310 http://www.mutopiaproject.org}.
2311
2312
2313
2314 @ignore
2315
2316 [TODO
2317
2318 this should be on mutopia website.
2319
2320 ]
2321
2322
2323 @c waar deze info?  is uiteindelijk wel handig, schat ik.
2324 [TODO: cut blabla]
2325
2326 If you have a big music project, or just a lot of LilyPond input files,
2327 all generated output from LilyPond, @TeX{} and metafont will clutter
2328 your working directory.  LilyPond comes with a one-size-fits-all
2329 pre-cooked makefile that helps you manage producing output.  It will
2330 produce all output in the directory @file{out} , generate and track
2331 dependencies. Also, it helps in preparing your submission to @ref{Mutopia
2332 project}.
2333
2334 @file{make/ly.make}
2335 @example
2336 mkdir my-project
2337 cd my-project
2338 cp /usr/share/lilypond/make/ly.make GNUmakefile
2339 cp /usr/share/doc/lilypond/examples/input/tutorial/minuet.ly .
2340 make minuet
2341 [..]
2342 Generated out/minuet.ps for target minuet.
2343 @end example
2344
2345 Type @samp{make help} to see possible targets.
2346
2347 [TODO]
2348 @file{/usr/share/lilypond/doc/lilypond/examples/input/mutopia-header.ly}
2349
2350
2351
2352
2353
2354 [TODO: rewrite completely.]
2355
2356 @menu
2357 * Songs with additional verses::  
2358 @end menu
2359
2360 @end ignore
2361