]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/tutorial.itely
* Documentation/user/tutorial.itely: Revised (continued).
[lilypond.git] / Documentation / user / tutorial.itely
1 @c -*-texinfo-*-
2 @c This file is part of lilypond.tely
3
4 @c TODO:
5 @c   * more details about running lilypond; error messages,
6 @c     compiling/viewing (emacs?)
7 @c   * where to go from First steps+More basics?
8
9 @c Your first LilyPond score in 10 minutes?
10
11 @node Tutorial
12 @chapter Tutorial
13
14 This tutorial starts with a short introduction to the LilyPond music
15 language.  After this first contact we will show you how to produce
16 printed output.  Then you will be able to create and print your own
17 sheets of music.
18
19 @ifhtml
20 Many people learn programs by trying and fiddling around with the
21 program.  This is also possible with LilyPond.  If you click on a
22 picture in the HTML version of this manual, you will see the exact
23 LilyPond input that was used to generate that image.
24 Try it on this image
25
26 @lilypond[quote,raggedright,relative=2]
27 c-\markup { \bold \huge { Click here.  } }
28 @end lilypond
29 @end ifhtml
30
31 By cutting and pasting the full input into a test file, you have a
32 starting template for experiments.  If you like learning in this way,
33 you will probably want to print out or bookmark
34 @ifhtml
35 the
36 @end ifhtml
37 @ref{Cheat sheet}, which is a table listing all commands for quick
38 reference.
39
40 @menu
41 * First steps::                 
42 * Running LilyPond::            
43 * More about pitches::          
44 * Entering ties::               
45 * Automatic and manual beams::  
46 * Octave entry::                
47 * Music expressions explained::  
48 * More staves::                 
49 * Adding articulation marks to notes::  
50 * Combining notes into chords::  
51 * Basic rhythmical commands::   
52 * Commenting input files::      
53 * Printing lyrics::             
54 * A lead sheet::                
55 * Listening to output::         
56 * Titling::                     
57 * Single staff polyphony::      
58 * Piano staves::                
59 * Organizing larger pieces::    
60 * An orchestral part::          
61 * Integrating text and music::  
62 @end menu
63
64
65 @node First steps
66 @section First steps
67
68 The first example demonstrates how to enter the most elementary piece
69 of music, a scale.  A note can be entered by typing its name, from
70 @samp{a} through @samp{g}.  So, if you enter
71
72 @example
73 c d e f g a b
74 @end example
75
76 @noindent
77 the result looks like this
78
79 @lilypond[quote,notime,relative=1]
80 c d e f g a b
81 @end lilypond
82
83 The duration of a note is specified by a number after the note name.
84 @samp{1} for a @rglos{whole note}, @samp{2} for a @rglos{half note},
85 @samp{4} for a @rglos{quarter note} and so on
86
87 @example
88 a1 a2 a4 a16 a32
89 @end example
90
91 @lilypond[quote,notime]
92 \set Score.timing = ##f
93 \set Staff.autoBeaming = ##f
94 \transpose c c' { a1 a2 a4 a16 a32 s16_" " }
95 @end lilypond
96
97 If you do not specify a @rglos{duration}, the duration last entered is
98 used for the next notes.  The duration of the first note in input
99 defaults to a quarter
100
101 @example
102 a a8 a a2 a
103 @end example
104
105 @lilypond[quote,notime]
106 \set Score.timing = ##f
107 \transpose c c' { a a8 a a2 a s16_" " }
108 @end lilypond
109
110
111 Rests are entered just like notes, but with the name @samp{r}
112
113 @cindex rests
114 @example
115 r2 r4 r8 r16
116 @end example
117
118 @lilypond[quote,notime]
119 \set Score.timing = ##f
120 r2 r4 r8 r16 s16_" "
121 @end lilypond
122 @separate
123
124 Add a dot @samp{.} after the duration to get a @rglos{dotted note}
125
126 @example
127 a2. a4 a8. a16
128 @end example
129
130 @lilypond[quote,notime]
131 \set Score.timing = ##f
132 \transpose c c' { a2. a4 a8. a16 s16_" " }
133 @end lilypond
134
135 The @rglos{meter} (or @rglos{time signature}) can be set with the
136 @code{\time} command
137
138 @example
139 \time 3/4
140 \time 6/8
141 \time 4/4
142 @end example
143
144 @c A clef here may lead to confusion, remove it.
145 @lilypond[quote]
146 \override Staff.Clef #'transparent = ##t 
147 \time 3/4
148 s4_" "
149 \time 6/8
150 s4_" "
151 \time 4/4
152 s16_" "
153 @end lilypond
154
155 The @rglos{clef} can be set using the @code{\clef} command
156
157 @c what is more common name treble or violin?
158 @c in Dutch, it is violin.
159 @c in English it is definitely treble.
160 @example
161 \clef treble
162 \clef bass
163 \clef alto
164 \clef tenor
165 @end example
166
167 @lilypond[quote,notime]
168 \set Score.timing = ##f
169 \clef violin
170 s4_" "
171 \clef bass
172 s4_" "
173 \clef alto
174 s4_" "
175 \clef tenor
176 s16_" "
177 @end lilypond
178
179 To recognize names like @samp{c} and @samp{d} as pitches, they have to
180 be entered inside a so-called @code{\notes} block.  This block is
181 formed by enclosing notes and commands are enclosed in curly braces
182 @code{@{@tie{}@dots{}@tie{}@}} and adding the keyword @code{\notes} before
183 the opening brace
184
185 @example
186 \notes @{
187   \time 3/4
188   \clef bass
189   c2 e4 g2.
190   f4 e d c2 r4
191 @}
192 @end example
193
194 Now the piece of music is almost ready to be printed.  Enclose
195 the @code{\notes} block in a @code{\score} block
196
197 @example
198 \score @{
199   \notes @{
200     \time 3/4
201     \clef bass
202     c2 e4 g2.
203     f4 e d c2 r4
204   @}
205 @}
206 @end example
207
208 @noindent
209 and the music will be converted to printable output.
210
211 @lilypond[quote,noindent]
212 \score {
213   \notes {
214      \time 3/4
215      \clef bass
216      c2 e4 g2.
217      f4 e d c2 r4
218   }
219   \paper {
220     linewidth = 55 * \staffspace
221   }
222 }
223 @end lilypond
224
225 In many examples in this manual, both @code{\score} and @code{\notes}
226 and accompanying braces are left out for brevity.  However, they must
227 be present when feeding the file to LilyPond.
228
229 For more elaborate information on
230
231 @quotation
232 @table @asis
233 @item Entering pitches and durations
234 see 
235 @ref{Pitches}, and @ref{Durations}.
236 @item Clefs
237 see @ref{Clef}.
238 @item Rests
239 see @ref{Rests}.  
240 @item Time signatures and other timing commands
241 see @ref{Time signature}.
242 @end table
243 @end quotation
244
245
246 @node Running LilyPond
247 @section Running LilyPond
248
249 @c FIXME: let's not be so casual about Emacs and VIM, but rather
250 @c instruct (how) to use them; let advanced user figure-out what
251 @c commands to type?
252
253 @c
254 @c We don't have enough space to explain either VIM
255 @c or Emacs non-advanced users, and I fear that both editors will only
256 @c confuse newbies. I vote for keeping the material in footnotes.
257 @c 
258 @c --hwn 
259
260 In the last section we explained what kind of things you could enter
261 in a LilyPond file.  In this section we will explain what commands to
262 run and how to view or print the output.  If you have not used
263 LilyPond before, want to test your setup, or want to run an example
264 file yourself, read this section.  The instructions that follow are
265 for Unix-like systems.  Some additional instructions for Microsoft
266 Windows are given at the end of this section.
267
268 Begin by opening a terminal window and starting a text editor.  For
269 example, you could open an xterm and execute
270 @code{joe}.@footnote{There are macro files for VIM addicts, and there
271 is a @code{LilyPond-mode} for Emacs addicts.  If it has not been
272 installed already, refer to
273 @c FIXME lousy reference.
274 the file @file{INSTALL.txt}.}  In your text editor, enter the following
275 input and save the file as @file{test.ly}
276
277 @example
278 \score @{
279   \notes @{ c'4 e' g' @}
280 @} 
281 @end example
282
283 @noindent
284 To process @file{test.ly}, proceed as follows
285
286 @example
287 lilypond test.ly
288 @end example
289
290 @noindent
291 You will see something resembling
292
293 @example
294 lilypond (GNU LilyPond) 2.2.0
295 Running lilypond-bin...
296 Now processing `/home/fred/ly/test.ly'
297 Parsing...
298 Interpreting music...[1]
299 @emph{... more interesting stuff ... }
300 DVI output to `test.dvi'...
301 PDF output to `test.pdf'...
302 PS output to `test.ps'...
303 @end example
304
305 @cindex DVI file
306 @cindex Viewing music
307 @cindex xdvi
308 @noindent
309 The result is the file @file{test.pdf}@footnote{For @TeX{}
310 aficionados: there is also a @file{test.dvi} file.  It can be viewed
311 with @code{xdvi}.  The DVI uses a lot of PostScript specials, which do
312 not show up in the magnifying glass.  The specials also mean that the
313 DVI file cannot be processed with @code{dvilj}.  Use @code{dvips} for
314 printing.
315 @cindex dvips
316 @cindex dvilj
317 @cindex DVI driver
318 } which you can print or with the standard facilities of your
319 operating system.@footnote{If your system does not have any tools
320 installed, you can try @uref{Ghostscript,
321 http://www.cs.wisc.edu/~ghost/}, a freely available package for
322 viewing and printing PDF and PostScript files.}
323
324 On Windows, start up a text-editor@footnote{Any simple or
325 programmer-oriented editor will do, for example Notepad.  Do not use a
326 word processor, its formatting codes will confuse LilyPond.} and enter
327
328 @example
329 \score @{
330   \notes @{ c'4 e' g' @}
331 @} 
332 @end example
333
334 Save it on the desktop as @file{test.ly} and make sure that it is not
335 called @file{test.ly.TXT}.  Double clicking @file{test.ly} will process
336 the file and show the resulting PDF file.
337
338
339 @node More about pitches
340 @section More about pitches 
341
342 A @rglos{sharp} (@texisharp{}) pitch is made by adding @samp{is} to
343 the name, a @rglos{flat} (@texiflat{}) pitch by adding @samp{es}.  As
344 you might expect, a @rglos{double sharp} or @rglos{double flat} is
345 made by adding @samp{isis} or @samp{eses}@footnote{This syntax
346 derived from note naming conventions in Nordic and Germanic languages,
347 like German and Dutch.}
348
349 @example
350 cis1 ees fisis aeses
351 @end example
352
353 @lilypond[quote,notime]
354 \set Score.timing = ##f
355 \transpose c c' { cis1 ees fisis aeses s16_" " }
356 @end lilypond
357
358 @cindex key signature, setting
359 The key signature is set with the command @code{\key}, followed by
360 a pitch and @code{\major} or @code{\minor}
361
362 @example
363 \key d \major
364 g1
365 \key c \minor
366 g
367 @end example
368
369 @lilypond[quote,notime,fragment]
370 \key d \major
371 g'1
372 \key c \minor
373 g'
374 @end lilypond
375
376 @noindent
377 Key signatures together with the pitches (including alterations) are
378 used to determine when to print accidentals.  This is a
379 feature that often causes confusion to newcomers, so let us explain it
380 in more detail.
381
382
383 LilyPond makes a sharp distinction between musical content and
384 layout.  The alteration (flat, natural or sharp) of a note is part of
385 the pitch, and is therefore musical content.  Whether an accidental (a
386 flat, natural or sharp @emph{sign}) is printed in front of the
387 corresponding note is a question of layout.  Layout is something that
388 follows rules, so accidentals are printed automatically according to
389 those rules.  The pitches in your music are works of art, so they will
390 not be added automatically, and you must enter what you want to hear.
391
392 In this example
393
394 @lilypond[quote,notime,fragment]
395 \key d \major
396 d' cis' fis'
397 @end lilypond
398
399 @noindent
400 no note gets an explicit accidental, but you still must enter
401
402 @example
403 \key d \major
404 d cis fis
405 @end example
406
407 @noindent
408 The code @samp{d} does not mean `print a black dot just below the
409 staff.'  Rather, it means: `a note with pitch D-natural.'  In the key
410 of A-flat, it does get an accidental
411
412 @lilypond[quote,notime,fragment]
413 \key as \major
414 d'
415 @end lilypond
416
417 @example
418 \key as \major
419 d
420 @end example
421
422 Adding all alterations explicitly might require a little more effort
423 when typing, but the advantage is that transposing is easier, and
424 music can be printed according to different conventions.  See
425 @ref{Accidentals}, for some examples how accidentals can be printed
426 according to different rules.
427
428
429 For more information on
430
431 @quotation
432 @table @asis
433 @item Accidentals
434 see @ref{Accidentals}.
435
436 @item Key signature
437 see @ref{Key signature}.
438 @end table
439 @end quotation
440
441 @node Entering ties
442 @section Entering ties
443
444 @cindex tie
445 A tie is created by appending a tilde @samp{~} to the first note
446 being tied
447
448 @lilypond[quote,notime,fragment,verbatim,relative=3]
449 g4~ g a2~ a4
450 @end lilypond
451 @separate
452
453 For more information on Ties see @ref{Ties}.
454
455
456
457 @node Automatic and manual beams
458 @section Automatic and manual beams
459
460 @cindex beams, by hand 
461 Beams are drawn automatically
462
463 @lilypond[quote,fragment,relative=2,verbatim]
464 a8 ais d es r d
465 @end lilypond
466 @separate
467
468 @noindent
469 If you do not like where beams are put, they can be entered by
470 hand.  Mark the first note to be beamed with @samp{[} and the last one
471 with @samp{]}.
472
473 @lilypond[quote,fragment,relative=2,verbatim]
474 a8[ ais] d[ es r d]
475 @end lilypond
476 @separate
477
478 For more information on beams, see @ref{Beaming}.
479
480
481 Here are key signatures, accidentals and ties in action
482
483 @example
484 \score @{
485   \notes @{
486     \time 4/4
487     \key g \minor
488     \clef violin
489     r4 r8 a8 gis4 b
490     a8 d4.~ d e8
491     fis4 fis8 fis8 eis4 a8 gis~
492     gis2 r2
493   @}
494 @}
495 @end example
496
497 @lilypond[quote, noindent]
498 \score {
499   \notes \transpose c c' { 
500     \time 4/4
501     \key g \minor
502     \clef violin
503     r4 r8 a8 gis4 b
504     a8 d4.~ d e8
505     fis4 fis8 fis8 eis4 a8 gis~
506     gis2 r2
507   }
508   \paper { linewidth = 50 * \staffspace }
509 }
510 @end lilypond
511 @cindex accidentals
512
513 @noindent
514 There are some interesting points to note in this example.  Bar lines
515 and beams are drawn automatically.  Line breaks are calculated
516 automatically; it does not matter where the line breaks are in the
517 source file.  Finally, the order in which time, key and clef changes
518 are entered is not relevant: in the printout, these are ordered
519 according to standard notation conventions.
520
521
522
523 @node Octave entry
524 @section Octave entry
525
526
527 @c Tim wants to move this quotes example just before the: quotes-do not-work
528 @c score, but we'd need to remove quotes from the other two (key and
529 @c tie) examples...
530
531 @c better to have this just before the `octaves are bad' snipped
532 @c but we'd need to remove the ', from \key and tie 
533 To raise a note by an octave, add a high quote @code{'} (apostrophe) to
534 the note name, to lower a note one octave, add a `low quote' @code{,}
535 (a comma).  Middle C is @code{c'}
536
537 @example
538 c'4 c'' c''' \clef bass c c,
539 @end example
540
541 @lilypond[quote,notime,fragment]
542 c'4 c'' c''' \clef bass c c,
543 @end lilypond
544 @separate
545
546 An example of the use of quotes is in the following Mozart fragment
547
548 @lilypond[quote,raggedright,fragment,verbatim]
549 \key a \major
550 \time 6/8
551 cis''8. d''16 cis''8 e''4 e''8
552 b'8. cis''16 b'8 d''4 d''8 
553 @end lilypond
554
555 @noindent
556 The last example shows that music in a high register needs lots of quotes.
557 This makes the input less readable, and it is a source of errors.  The
558 solution is to use `relative octave' mode.  In practice, this is the
559 most convenient way to copy existing music.  To use relative mode, add
560 @code{\relative} before the piece of music.  You must also give a note
561 from which relative mode starts, in this case @code{c''}.  If you do not
562 use octavation quotes (i.e., do not add @code{'} or @code{,} after a
563 note), relative mode chooses the note that is closest to the previous
564 one.  For example, @samp{c f} goes up while @samp{c g} goes down
565
566 @lilypond[quote,notime,fragment,verbatim]
567 \relative c'' {
568   c f c g c
569 }
570 @end lilypond
571 @separate
572
573
574 Since most music has small intervals, pieces can be written almost
575 without octavation quotes in relative mode.  The previous example is
576 entered as
577
578 @lilypond[quote,raggedright,fragment,verbatim]
579 \relative c'' {
580   \key a \major
581   \time 6/8
582   cis8. d16 cis8 e4 e8
583   b8. cis16 b8 d4 d8
584 }
585 @end lilypond
586
587 @c needed better, maybe even redundant explanation
588 @c   added another example below.
589 @c grappig: Pa vond het heel logies, en slim toen-i eenmaal begreep.
590 @c in eerste instantie drong het `relative' niet door zonder extra uitleg.
591 Larger intervals are made by adding octavation quotes.
592
593 @lilypond[quote,notime,verbatim,fragment]
594 \relative c'' {
595   c f, f c' c g' c,
596 }
597 @end lilypond
598 @separate
599
600 In summary, quotes or commas no longer determine the absolute height
601 of a note in @code{\relative} mode.  Rather, the height of a note is
602 relative to the previous one, and changing the octave of a single note
603 shifts all following notes an octave up or down.
604
605 For more information on Relative octaves see @ref{Relative octaves},
606 and @ref{Octave check}.
607
608
609 @node Music expressions explained
610 @section Music expressions explained
611
612
613 In input files, music is represent by so-called @emph{music
614 expression}.  We have already seen in the previous examples; 
615 a single note is a music expression
616
617 @lilypond[quote,verbatim,relative=3]
618 a4
619 @end lilypond
620
621 Enclosing group of notes in braces creates a new music
622 expression
623
624 @lilypond[quote,verbatim,relative=3]
625 { a4 g4 }
626 @end lilypond
627
628 Putting a bunch of music expressions (notes) in braces, means that
629 they should be played in sequence.  The result again is a music
630 expression, which can be grouped with other expressions sequentially.
631 Here, the expression from the previous example is combined with two
632 notes
633
634 @lilypond[quote,verbatim,relative=3]
635 { { a4 g } f g } 
636 @end lilypond
637
638 This technique is useful for non-monophonic music.  To enter music
639 with more voices or more staves, we also combine expressions in
640 parallel.  Two voices that should play at the same time, are entered
641 as a simultaneous combination of two sequences.  A `simultaneous'
642 music expression is formed by enclosing expressions in @code{<<} and
643 @code{>>}.  In the following example, three sequences (all containing
644 two notes) are combined simultaneously
645
646 @lilypond[quote,verbatim,relative=3]
647 <<
648    { a4 g }
649    { f e }
650    { d b }
651 >>
652 @end lilypond
653
654 This mechanism is similar to mathematical
655 formulas: a big formula is created by composing small formulas.  Such
656 formulas are called expressions, and their definition is recursive, so
657 you can make arbitrarily complex and large expressions.  For example,
658
659 @example
660 1
661
662 1 + 2
663
664 (1 + 2) * 3
665
666 ((1 + 2) * 3) / (4 * 5)
667 @end example
668
669 @cindex expression
670 @cindex music expression
671 This example shows a sequence of expressions, where each expression is
672 contained in the next one.  The simplest expressions are numbers and
673 operators (like @samp{+}, @samp{*} and @samp{/}).  Parentheses are used
674 to group expressions.
675
676 Like mathematical expressions, music expressions can be nested
677 arbitrarily deep@footnote{The reason for getting three staves in the
678 previous example but just a single staff in current one will be explained
679 later.}
680
681 @lilypond[quote,verbatim,relative=2] 
682 {
683   c <<c e>>
684   << { e f } { c <<b d>> } >>
685 }
686 @end lilypond
687
688
689 @cindex indent
690 When spreading expressions over multiple lines, it is customary to use
691 an indent that indicates the nesting level.  Formatting music like this
692 eases reading, and helps you insert the right number of closing
693 braces at the end of an expression.  For example,
694
695 @example
696 \score @{
697   \notes <<
698     @{
699       @dots{}
700     @}
701     @{
702       @dots{}
703     @}
704   >>
705 @}
706 @end example
707
708 Some editors have special support for entering LilyPond, and can help
709 indenting source files.  See @ref{Editor support}, for more information.
710
711
712
713 @node More staves
714 @section More staves
715
716 To print more than one staff, each piece of music that makes up a
717 staff is marked by adding @code{\new Staff} before it.  These
718 @code{Staff} elements are then combined parallel with @code{<<} and
719 @code{>>}, as demonstrated here
720
721 @lilypond[quote,fragment,verbatim]
722 <<
723   \new Staff { \clef violin c'' }
724   \new Staff { \clef bass c }
725 >>
726 @end lilypond
727
728
729 The command @code{\new} introduces a `notation context.'  A notation
730 context is an environment in which musical events (like notes or
731 @code{\clef} commands) are interpreted.  For simple pieces, such
732 notation contexts are created implicitly.  For more complex pieces, it
733 is best to mark contexts explicitly.  This ensures that each fragment
734 gets its own stave.
735
736 There are several types of contexts: @code{Staff}, @code{Voice} and
737 @code{Score} handle normal music notation.  Other contexts are also
738 @code{Lyrics} (for setting lyric texts) and @code{ChordNames} (for
739 printing chord names).
740
741
742 In terms of syntax, prepending @code{\new} to a music expression
743 creates a bigger music expression.  In this way it resembles the minus
744 sign in mathematics.  The formula @math{(4+5)} is an expression, so
745 @math{-(4+5)} is a bigger expression.
746
747 We can now typeset a melody with two staves
748
749 @c TODO: (c) status of this Paul McCartney (?) song (let's all stand together)
750
751 @lilypond[quote,verbatim,raggedright]
752 \score {
753   \notes <<
754     \new Staff {
755       \time 3/4
756       \clef violin
757       \relative c'' {
758         e2 d4 c2 b4 a8[ a]
759         b[ b] g[ g] a2. }  
760     }
761     \new Staff {
762        \clef bass
763        c2 e4 g2.
764        f4 e d c2.
765     }
766   >>
767 }
768 @end lilypond
769
770 For more information on context see the description in
771 @ref{Interpretation contexts}.
772
773
774
775 @node Adding articulation marks to notes
776 @section Adding articulation marks to notes
777
778 @cindex articulation
779 @cindex accents
780 @cindex staccato
781
782 Common accents can be added to a note using a dash (@samp{-}) and a
783 single character
784
785 @lilypond[quote,verbatim,relative=2]
786 c-.  c-- c-> c-^ c-+ c-_
787 @end lilypond
788 @separate
789
790 @cindex fingering
791 Similarly, fingering indications can be added to a note using a dash
792 (@samp{-}) and the digit to be printed
793
794 @lilypond[quote,verbatim,relative=2]
795 c-3 e-5 b-2 a-1
796 @end lilypond
797
798
799 Dynamic signs are made by adding the markings (with a backslash) to
800 the note
801
802 @lilypond[quote,verbatim,relative=2]
803 c\ff c\mf
804 @end lilypond
805 @separate
806
807 @cindex dynamics
808 @cindex decrescendo
809 @cindex crescendo
810
811 Crescendi and decrescendi are started with the commands @code{\<} and
812 @code{\>}.  An ending dynamic, for example @code{\f}, will finish the
813 crescendo, or the command @code{\!} can be used
814
815 @lilypond[quote,verbatim,relative=2]
816 c2\< c2\ff\> c2 c2\!
817 @end lilypond
818 @separate
819
820
821
822 @cindex slur
823
824 A slur is a curve drawn across many notes, and indicates legato
825 articulation.  The starting note and ending note are marked with
826 @samp{(} and @samp{)}, respectively
827
828 @lilypond[quote,fragment,relative=2,verbatim]
829 d4( c16)( cis d e c cis d e)( d4)
830 @end lilypond
831 @separate
832
833 @cindex slurs versus ties
834 A slur looks like a tie, but it has a different meaning.  A tie simply
835 makes the first note sound longer, and can only be used on pairs of
836 notes with the same pitch.  Slurs indicate the articulations of notes,
837 and can be used on larger groups of notes.  Slurs and ties are also
838 nested in practice
839
840 @lilypond[quote,fragment,relative=2]
841 c2~( c8 fis fis4 ~ fis2 g2)
842 @end lilypond
843
844 @cindex phrasing slurs
845 Slurs to indicate phrasing can be entered with @code{\(} and
846 @code{\)}, so you can have both legato slurs and phrasing slurs at the
847 same time.
848
849 @lilypond[quote,fragment,relative=2,verbatim]
850 a8(\( ais b c) cis2 b'2 a4 cis, c\)
851 @end lilypond
852
853
854 For more information on
855
856 @quotation
857 @table @asis
858 @item Fingering
859 see @ref{Fingering instructions}.
860 @item Articulations
861 see @ref{Articulations}.
862 @item Slurs
863 see @ref{Slurs}.
864 @item Phrasing slurs
865 see @ref{Phrasing slurs}.
866 @item Dynamics
867 see @ref{Dynamics}.
868 @end table
869 @end quotation
870
871
872 @node Combining notes into chords
873 @section Combining notes into chords
874
875 @cindex chords
876 Chords can be made by surrounding pitches with angled brackets.
877 Angled brackets are the symbols @code{<} and @code{>}.
878
879 @lilypond[quote,relative=1,fragment,verbatim]
880 r4 <c e g>4 <c f a>8
881 @end lilypond
882 @separate
883
884
885 You can combine markings like beams and ties with chords.  They must
886 be placed outside the angled brackets
887
888 @lilypond[quote,relative=1,fragment,verbatim]
889 r4 <c e g>8[ <c f a>]~ <c f a>
890 @end lilypond
891
892 @example
893 r4 <c e g>8\>( <c e g> <c e g> <c f a>8\!)
894 @end example
895
896 @lilypond[quote,relative=1,fragment]
897 \slurUp
898 r4 <c e g>8\>( <c e g> <c e g> <c f a>8\!)
899 @end lilypond
900 @separate
901
902
903
904
905 @node Basic rhythmical commands
906 @section Basic rhythmical commands
907
908 @cindex pickup
909 @cindex anacruse
910 @cindex partial measure
911 A pickup is entered with the keyword @code{\partial}.  It
912 is followed by a duration: @code{\partial 4} is a quarter note upstep
913 and @code{\partial 8} an eighth note
914
915 @lilypond[quote,relative=2,verbatim,fragment]
916 \partial 8
917 f8 c2 d e
918 @end lilypond
919
920 @cindex tuplets
921 @cindex triplets
922 Tuplets are made with the @code{\times} keyword.  It takes two
923 arguments: a fraction and a piece of music.  The duration of the piece
924 of music is multiplied by the fraction.  Triplets make notes occupy
925 2/3 of their notated duration, so a triplet has 2/3 as its fraction
926
927 @lilypond[quote,relative=1,verbatim,fragment]
928 \times 2/3 { f8 g a }
929 \times 2/3 { c r c }
930 @end lilypond
931
932 @cindex grace notes
933 @cindex accacciatura
934 Grace notes are also made by prefixing a music expression with the
935 keyword @code{\appoggiatura} or @code{\acciaccatura}
936 @cindex appoggiatura
937 @cindex acciaccatura
938
939 @lilypond[quote,relative=2,verbatim,fragment]
940 c4 \appoggiatura b16 c4
941 c4 \acciaccatura b16 c4
942 @end lilypond
943
944 @noindent
945
946 For more information on
947
948 @table @asis
949 @item Grace notes
950 see @ref{Grace notes},
951 @item Tuplets
952 see @ref{Tuplets},
953 @item Pickups
954 see @ref{Partial measures}.
955 @end table
956
957
958
959 @node Commenting input files
960 @section Commenting input files
961
962 @cindex comments
963 @cindex line comment
964 @cindex block comment
965 A comment is a remark for the human reader of the music input, it is
966 ignored and has no effect on the printed output.  There are two types
967 of comments.  The percent symbol @code{%} introduces a line comment;
968 the rest of the line is ignored.  A block comments marks a whole
969 section of music input, anything that is enclosed in @code{%@{} and
970 @code{%@}} is ignored.  The following fragment shows possible uses for
971 comments
972
973 @example
974 % notes for twinkle twinkle follow
975 c4 c g' g a a
976
977 %@{
978     This line, and the notes below
979     are ignored, since they are in a
980     block comment.
981
982     g g f f e e d d c2 
983 %@}
984 @end example
985
986 There is a special statement that really is a kind of comment. The
987 version statement marks for which version of LilyPond the file was
988 written. To mark a file for version 2.1.17, use
989
990 @example
991 \version "2.1.17"
992 @end example
993
994 These annotations make future upgrades of LilyPond go more
995 smoothly. Changes in the syntax are handled with a special program,
996 @file{convert-ly} (see @ref{Invoking convert-ly}), and it uses
997 @code{\version} to determine what rules to apply.
998
999
1000 @node Printing lyrics
1001 @section Printing lyrics
1002 @cindex lyrics
1003
1004 @c TODO: (c) status of the Queen fragment.
1005
1006 @cindex Lyrics
1007 @cindex Songs
1008 Lyrics are entered by separating each syllable with a space,
1009
1010 @example
1011 I want to break free
1012 @end example
1013
1014 To prevent certain words (for example `as') as being read as a
1015 pitch, the input-mode must be switched.  This is done with
1016 @code{\lyrics}.  In @code{\lyrics} mode, all words are read as lyric
1017 syllables.
1018
1019 @example
1020 \lyrics @{ I want to break free @}
1021 @end example
1022
1023 @noindent
1024 Again, the braces @code{@{@}} signify that the syllables are sung in
1025 sequence.
1026
1027 By default, music expressions are interpreted in @code{Staff} context.  For
1028 lyrics, this is obviously not desirable, so it is necessary
1029 to explicitly specify a @code{Lyrics} context,
1030
1031 @example
1032 \new Lyrics \lyrics @{ I want to break free @}
1033 @end example
1034
1035 The melody for this song is as follows
1036
1037 @lilypond[quote,fragment,relative=2]
1038 c4
1039 \times 2/3 { f4 g g } \times 2/3 { g4( a2) }
1040 @end lilypond
1041
1042 The lyrics can be set to these notes, combining both with the
1043 @code{\lyricsto} keyword
1044
1045 @example
1046 \lyricsto "@var{name}" \new Lyrics @dots{}
1047 @end example
1048
1049 @noindent
1050 where @var{name} identifies to which melody the lyrics should be
1051 aligned.  In this case, there is only one melody, so we can leave it
1052 empty.
1053
1054 The final result is 
1055
1056 @lilypond[quote,verbatim,fragment,raggedright]
1057 \score {
1058  \notes <<
1059    \partial 4
1060    \relative c' {
1061       c4
1062       \times 2/3 { f g g } \times 2/3 { g4( a2) }
1063    }
1064    \lyricsto "" \new Lyrics \lyrics { I want to break free }
1065  >>
1066 }
1067 @end lilypond
1068
1069 @cindex melisma
1070 @cindex extender line
1071 @c synonyms?
1072 This melody ends on a @rglos{melisma}, a single syllable (`free')
1073 sung to more than one note.  This is indicated with an @emph{extender
1074 line}.  It is entered as two underscores, i.e.,
1075
1076 @example
1077 \lyrics @{ I want to break free __ @}
1078 @end example 
1079
1080 @lilypond[quote,raggedright]
1081 \score {
1082   <<
1083     \notes \relative c' \new Voice {
1084       \partial 8
1085       c8
1086       \times 2/3 { f g g } \times 2/3 { g4( a2) }
1087     }
1088     \lyricsto "" \new Lyrics \lyrics { I want to break free __ }
1089    >>
1090 }
1091 @end lilypond
1092
1093 Similarly, hyphens between words can be entered as two dashes,
1094 resulting in a centered hyphen between two syllables
1095
1096 @example
1097 Twin -- kle twin -- kle
1098 @end example
1099
1100 @lilypond[quote,raggedright]
1101 \score {
1102   <<
1103     \notes \relative f' \context Voice = bla {
1104       \time 2/4
1105       f4 f c' c'
1106     }
1107     \new Lyrics \lyrics \lyricsto "bla" { Twin -- kle twin -- kle }
1108   >>
1109 }
1110 @end lilypond
1111
1112 More options, like putting multiple lines of lyrics below a melody are
1113 discussed in @ref{Vocal music}.
1114
1115
1116
1117 @node A lead sheet
1118 @section A lead sheet
1119
1120 @cindex Lead sheets
1121 @cindex chords
1122 @cindex chord names
1123
1124 In popular music, it is common to denote accompaniment as chord-names.
1125 Such chords can be entered like notes,
1126
1127 @example
1128 c2 f4. g8
1129 @end example
1130
1131 @noindent
1132 but now, each pitch is read as the root of a chord instead of a note.
1133 This mode is switched on with @code{\chords}
1134
1135 @lilypond[quote,verbatim,raggedright]
1136 \score {
1137   \chords { c2 f4. g8 }
1138 }
1139 @end lilypond
1140
1141 Other chords can be created by adding modifiers after a colon.  The
1142 following example shows a few common modifiers
1143
1144 @lilypond[quote,verbatim]
1145 \chords { c2 f4:m g4:maj7 gis1:dim7 }
1146 @end lilypond
1147
1148 For lead sheets, chords are not printed on staves, but as names on a
1149 line of themselves.  Hence, we have to override the context with
1150 @code{\new}, rendering the music expression in a @code{ChordNames}
1151 context
1152
1153 @lilypond[quote,verbatim]
1154 \new ChordNames \chords { c2 f4.:m g4.:maj7 gis8:dim7 }
1155 @end lilypond
1156
1157 @cindex lead sheet
1158 @separate
1159 When put together, chord names, lyrics and a melody form
1160 a lead sheet, for example,
1161
1162 @example
1163 \score @{
1164   <<
1165     \new ChordNames \chords @{ @emph{chords} @}
1166     \notes @emph{the melody}
1167     \lyricsto "" \new Lyrics \lyrics @{ @emph{the text} @}
1168   >>
1169 @}
1170 @end example
1171
1172 @lilypond[quote,raggedright]
1173 \score {
1174   <<
1175     \partial 4
1176     \new ChordNames \chords { r8 c2:sus4 f } 
1177     \notes \relative c' {
1178       c4
1179       \times 2/3 { f g g } \times 2/3 { g4( a2) }
1180     }
1181    \new Lyrics \lyricsto "" \lyrics { I want to break free __ }
1182   >>
1183 }
1184 @end lilypond
1185
1186
1187 A complete list of modifiers and other options for layout can be found
1188 in @ref{Chords}.
1189
1190 @node Listening to output
1191 @section Listening to output
1192
1193 @cindex sound
1194 @cindex MIDI
1195
1196 MIDI (Musical Instrument Digital Interface) is a standard for
1197 connecting and controlling digital instruments.  A MIDI file is like a
1198 tape recording of a MIDI instrument.
1199
1200 To create a MIDI from a music piece of music, add a 
1201 @code{\midi} block causes LilyPond to create a MIDI file, so you
1202 can listen to the music you entered.  It is great for checking the
1203 music: octaves that are off or accidentals that were mistyped stand
1204 out very much when listening to the musical transcription.
1205
1206 The @code{\midi} block is added to @code{\score}, for example,
1207
1208 @example 
1209 \score @{
1210     @var{..music..}
1211     \midi @{ \tempo 4=72 @}
1212 @}
1213 @end example 
1214
1215 Here, the tempo is specified using the @code{\tempo} command.  In this
1216 case the tempo of quarter notes is set to 72 beats per minute.  More
1217 information on auditory output in the notation manual, @ref{Sound}.
1218
1219 If there is a @code{\midi} command in a @code{\score}, only MIDI will
1220 be produced.  If notation is needed too, a @code{\paper} block must be
1221 added too
1222
1223 @example 
1224 \score @{
1225     @var{..music..}
1226     \midi @{ \tempo 4=72 @}
1227     \paper @{ @}
1228 @}
1229 @end example 
1230
1231 @cindex paper block
1232
1233 @node Titling
1234 @section Titling
1235
1236 Bibliographic information is entered in a separate block, the
1237 @code{\header} block.  The name of the piece, its composer, etc., are
1238 entered as an assignment, within @code{\header @{ @dots{} @}}.  For
1239 example,
1240
1241 @example 
1242 \header @{
1243   title = "Eight miniatures" 
1244   composer = "Igor Stravinsky"
1245   tagline = "small is beautiful"
1246 @}
1247
1248 \score @{ @dots{} @}
1249 @end example
1250
1251 @cindex bibliographic information
1252 @cindex titles
1253 @cindex composer
1254 @cindex Engraved by LilyPond
1255
1256 When the file is processed the title and composer are printed above
1257 the music.  The `tagline' is a short line printed at bottom of the last
1258 page which normally says `Engraved by LilyPond, version @dots{}'.  In
1259 the example above it is replaced by the line `small is
1260 beautiful.'@footnote{Nicely printed parts are good PR for us, so
1261 please leave the tagline if you can.}
1262
1263 Normally, the @code{\header} is put at the top of the file.  However,
1264 for a document that contains multiple pieces (e.g.  an etude book, or
1265 an orchestral part with multiple movements), the header can be
1266 put in the @code{\score} block as follows; in this case, the name of
1267 each piece will be printed before each movement
1268
1269
1270 @cindex Engraved by LilyPond
1271 @cindex signature line
1272 @cindex tag line
1273
1274 @example 
1275 \header @{
1276   title = "Eight miniatures" 
1277   composer = "Igor Stravinsky"
1278   tagline = "small is beautiful"
1279 @}
1280
1281 \score @{ @dots{}
1282   \header @{ piece = "Adagio" @}
1283 @}
1284 \score @{ @dots{}
1285   \header @{ piece = "Menuetto" @}
1286 @}
1287 @end example
1288
1289 More information on titling can be found in @ref{Invoking lilypond}.
1290
1291
1292 @node Single staff polyphony
1293 @section Single staff polyphony
1294
1295 @cindex polyphony
1296 @cindex multiple voices
1297 @cindex voices, more -- on a staff
1298
1299 When different melodic lines are combined on a single staff they are
1300 printed as polyphonic voices: each voice has its own stems, slurs and
1301 beams, and the top voice has the stems up, while the bottom voice has
1302 them down.
1303
1304 Entering such parts is done by entering each voice as a sequence (with
1305 @code{@{ ..  @}}), and combining those simultaneously, separating the
1306 voices with @code{\\}
1307
1308 @lilypond[quote,verbatim,relative=3]
1309 << { a4 g2 f4~ f4 } \\
1310    { r4 g4 f2 f4 } >>
1311 @end lilypond
1312
1313 For polyphonic music typesetting, spacer rests can also be convenient: these
1314 are rests that do not print.  It is useful for filling up voices that
1315 temporarily do not play.  Here is the same example with a spacer rest
1316 instead of a normal rest
1317
1318 @lilypond[quote,relative=3]
1319 << { a4 g2 f4~ f4 } \\
1320    { s4 g4 f2 f4 } >>
1321 @end lilypond
1322
1323 Again, these expressions can be nested arbitrarily
1324
1325 @lilypond[quote,fragment,relative=3]
1326 <<
1327   \new Staff <<
1328     { a4 g2 f4~ f4 } \\
1329     { s4 g4 f2 f4 }
1330   >>
1331   \new Staff <<
1332     \clef bass
1333     { <c, g>1 ~ <c g>4 } \\
1334     { f4 d e2 ~ e4}
1335   >>
1336 >>
1337 @end lilypond
1338
1339 More features of polyphonic typesetting in the notation manual
1340 in @ref{Polyphony}.
1341
1342 @node Piano staves
1343 @section Piano staves
1344
1345 @cindex staff switch, manual
1346 @cindex cross staff voice, manual
1347 @cindex @code{\context}
1348
1349 Piano music is typeset in two staves connected by a brace.  Printing
1350 such a staff is similar to the polyphonic example in @ref{More staves},
1351
1352 @example
1353 << \new Staff @{ @dots{} @}
1354    \new Staff @{ @dots{} @} >>
1355 @end example
1356
1357 @noindent
1358 but now this entire expression must be interpreted as a
1359 @code{PianoStaff}
1360
1361 @example
1362 \new PianoStaff << \new Staff @dots{} >>
1363 @end example
1364
1365 Here is a full-fledged example
1366
1367 @lilypond[quote,relative=1,fragment]
1368 \new PianoStaff <<
1369   \new Staff { \time 2/4 c4 c g' g }
1370   \new Staff { \clef bass c,, c' e c }
1371 >>
1372 @end lilypond
1373
1374 More information on formatting piano music is in @ref{Piano music}.  
1375
1376 @node Organizing larger pieces
1377 @section Organizing larger pieces
1378
1379 When all of the elements discussed earlier are combined to produce
1380 larger files, the @code{\score} blocks get a lot bigger, because the
1381 music expressions are longer, and, in the case of polyphonic pieces,
1382 more deeply nested.  Such large expressions can become unwieldy.
1383
1384 By using variables, also known as identifiers, it is possible to break
1385 up complex music expressions.  An identifier is assigned as follows
1386
1387 @example
1388 namedMusic = \notes @{ @dots{}
1389 @end example
1390
1391 The contents of the music expression @code{namedMusic}, can be used
1392 later by preceding the name with a backslash, i.e., @code{\namedMusic}.
1393 In the next example, a two note motive is repeated two times by using
1394 variable substitution
1395
1396 @lilypond[quote,raggedright,verbatim]
1397 seufzer = \notes {
1398   e'4( dis'4)
1399 }
1400 \score {
1401   \new Staff { \seufzer \seufzer }
1402 }
1403 @end lilypond
1404
1405 The name of an identifier should have alphabetic characters only;
1406 no numbers, underscores or dashes.  The assignment should be outside of
1407 the @code{\score} block.
1408
1409 It is possible to use variables for many other types of objects in the
1410 input.  For example,
1411
1412 @example
1413 width = 4.5\cm
1414 name = "Wendy"
1415 aFivePaper = \paper @{ paperheight = 21.0 \cm @}
1416 @end example
1417
1418 Depending on its contents, the identifier can be used in different
1419 places.  The following example uses the above variables
1420
1421 @example
1422 \score @{
1423   \notes @{ c4^\name @}
1424   \paper @{
1425     \aFivePaper
1426     linewidth = \width
1427   @}
1428 @}
1429 @end example
1430
1431 More information on the possible uses of identifiers is in the
1432 technical manual, in TODO.
1433
1434
1435 @node An orchestral part
1436 @section An orchestral part
1437
1438 In orchestral music, all notes are printed twice: both in a part for
1439 the musicians, and in a full score for the conductor.  Identifiers can
1440 be used to avoid double work: the music is entered once, and stored in
1441 a variable.  The contents of that variable is then used to generate
1442 both the part and the score.
1443
1444 It is convenient to define the notes in a special file, for example,
1445 suppose that the @file{horn-music.ly} contains the following part of a
1446 horn/bassoon duo,
1447
1448 @example
1449 hornNotes = \notes \relative c @{
1450   \time 2/4
1451   r4 f8 a cis4 f e d
1452 @}
1453 @end example
1454
1455 Then, an individual part is made by putting the following in a file
1456
1457 @example
1458 \include "horn-music.ly"
1459 \header @{
1460   instrument = "Horn in F"
1461 @}
1462 \score @{
1463   \notes \transpose f c' \hornNotes
1464 @}
1465 @end example
1466
1467 The line
1468
1469 @example
1470 \include "horn-music.ly"
1471 @end example
1472
1473 @noindent
1474 substitutes the contents of @file{horn-music.ly} at this position in
1475 the file, so @code{hornNotes} is defined afterwards.  The command
1476 @code{\transpose f c'} indicates that the argument, being
1477 @code{\hornNotes}, should be transposed by a fifth downwards: sounding
1478 @code{f} is denoted by notated @code{c'}, which corresponds with
1479 tuning of a normal French Horn in F.  The transposition can be seen in
1480 the following output
1481
1482 @lilypond[quote,raggedright]
1483 \score {
1484   \notes \transpose f c' \notes \relative c {
1485     \time 2/4
1486     r4 f8 a cis4 f e d
1487   }
1488 }
1489 @end lilypond
1490
1491 In ensemble pieces, one of the voices often does not play for many
1492 measures.  This is denoted by a special rest, the multi-measure
1493 rest.  It is entered with a capital @code{R} followed by a duration (1
1494 for a whole note, 2 for a half note, etc.).  By multiplying the
1495 duration, longer rests can be constructed.  For example, this rest
1496 takes 3 measures in 2/4 time
1497
1498 @example
1499 R2*3
1500 @end example
1501
1502 When printing the part, multi-rests
1503 must be condensed.  This is done by setting a run-time variable
1504
1505 @example
1506 \set Score.skipBars = ##t
1507 @end example
1508
1509
1510 This commands sets the property @code{skipBars} property in the
1511 @code{Score} context to true (@code{##t}).  Prepending the rest and
1512 this option to the music above, leads to the following result
1513
1514 @lilypond[quote,raggedright]
1515 \score {
1516   \notes \transpose f c' \relative c {
1517     \time 2/4
1518     \set Score.skipBars = ##t 
1519     R2*3
1520     r4 f8 a cis4 f e d
1521   }
1522 }
1523 @end lilypond
1524
1525
1526 The score is made by combining all of the music in a @code{\score}
1527 block.  Assuming that the other voice is in @code{bassoonNotes} in the
1528 file @file{bassoon-music.ly}, a score is made with
1529
1530 @example
1531 \include "bassoon-music.ly"
1532 \include "horn-music.ly"
1533
1534 \score @{
1535   \simultaneous @{
1536     \new Staff \hornNotes
1537     \new Staff \bassoonNotes
1538   @}
1539 @}
1540 @end example
1541
1542 @noindent
1543 leading to 
1544
1545 @lilypond[quote,raggedright]
1546 \score {
1547   \notes \relative c \simultaneous {
1548     \new Staff {
1549       \time 2/4 R2*3
1550       r4 f8 a cis4 f e d
1551     }
1552     \new Staff {
1553       \clef bass
1554       r4 d,8 f | gis4 c | b bes |
1555       a8 e f4 | g d | gis f
1556     }
1557   }
1558 }
1559 @end lilypond
1560
1561 More in-depth information on preparing parts and scores in the
1562 notation manual, in @ref{Orchestral music}.
1563
1564 Setting run-time variables (`properties') is discussed in ref-TODO.
1565
1566 @node Integrating text and music
1567 @section Integrating text and music
1568
1569 @cindex La@TeX{}, music in
1570 @cindex HTML, music in
1571 @cindex Texinfo, music in
1572
1573 Some texts include music examples.  Examples are musicological
1574 treatises, songbooks or manuals like this.  Such texts can be made by
1575 hand, simply by importing a PostScript figure into the word processor.
1576 However, there is an automated procedure to reduce the amount of work
1577 involved HTML, La@TeX{}, and Texinfo documents.
1578
1579 A script called @code{lilypond-book} will extract the music fragments,
1580 run format them, and put back the resulting notation.  This program is
1581 fully described in @ref{lilypond-book manual}.  Here we show a small
1582 example.  The example also contains explanatory text, so we will not
1583 comment on it further
1584
1585 @example
1586 \documentclass[a4paper]@{article@}
1587 \begin@{document@}
1588
1589 Documents for lilypond-book may freely mix music and text.  For
1590 example,
1591
1592 \begin@{lilypond@}
1593   \score @{ \notes \relative c' @{
1594      c2 g'2 \times 2/3 @{ f8 e d @} c'2 g4
1595   @} @}
1596 \end@{lilypond@}
1597
1598 If there is no \verb+\score+ block in the fragment,
1599 \texttt@{lilypond-book@} will supply one
1600
1601 \begin@{lilypond@}
1602   c'4
1603 \end@{lilypond@}
1604
1605 In this example two things happened: a
1606 \verb+\score+ block was added, and the line width was set to natural
1607 length.
1608
1609 Options are put in brackets.
1610
1611 \begin[staffsize=26,verbatim]@{lilypond@}
1612   c'4 f16
1613 \end@{lilypond@}
1614
1615
1616 Larger examples can be put in a separate file, and introduced with
1617 \verb+\lilypondfile+.
1618
1619 \lilypondfile@{screech-boink.ly@}
1620
1621 \end@{document@}
1622 @end example
1623
1624 Under Unix, you can view the results as follows
1625
1626 @example
1627 $ cd input/tutorial
1628 $ mkdir -p out/
1629 $ lilypond-book --output=out/ lilybook.tex
1630 lilypond-book (GNU LilyPond) 2.1.19
1631 Reading `input/tutorial/lilybook.tex'
1632 Reading `input/screech-boink.ly'
1633 @var{lots of stuff deleted}
1634 Writing `out/lilybook.tex'
1635 $ cd out
1636 $ latex lilybook
1637 @var{lots of stuff deleted}
1638 $ xdvi lilybook 
1639 @end example
1640
1641 To convert the file into a nice PDF document, run the following
1642 commands
1643
1644 @example
1645 $ dvips -Ppdf -u +lilypond lilybook
1646 $ ps2pdf lilybook.ps
1647 @end example
1648
1649
1650 Running lilypond-book and running latex creates a lot of temporary
1651 files, which would clutter up the working directory.  To remedy this,
1652 use the @code{output} option.  It will create the files in a separate
1653 subdirectory @file{out}.
1654
1655 The result looks more or less like 
1656
1657 @separate
1658
1659 Documents for lilypond-book may freely mix music and text.  For
1660 example
1661
1662 @lilypond[quote,raggedright]
1663 \score {
1664   \notes \relative c' {
1665     c2 g'2 \times 2/3 { f8 e d } c'2 g4
1666   }
1667 }
1668 @end lilypond
1669
1670 If you have no @code{\score} block in the fragment,
1671 @code{lilypond-book} will supply one
1672
1673 @lilypond[quote]
1674 c'4
1675 @end lilypond
1676
1677 In this example two things happened: a
1678 @code{score} block was added, and the line width was set to natural
1679 length.
1680
1681 Options are put in brackets.
1682
1683 @lilypond[quote,staffsize=26,verbatim]
1684 c'4 f16
1685 @end lilypond
1686
1687 Larger examples can be put in a separate file, and introduced with
1688 @code{\lilypondfile}.
1689
1690 @lilypondfile[quote,noindent]{screech-boink.ly}