]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/tutorial.itely
release: 1.3.8
[lilypond.git] / Documentation / user / tutorial.itely
1 @chapter Tutorial
2
3
4 @node Tutorial, , , Top
5 @menu
6 * Introduction::                  Introduction
7 * The first tune::                The first tune
8 * Lyrics and chords::             Lyrics and chords
9 * Piano music::                   Piano music
10 * end of tutorial::                       The end
11 @end menu
12
13 @node Introduction,  , , Tutorial
14 @section Introduction
15
16   
17 LilyPond prints music from a specification that you, the user, supply.
18 You have to give that specification using a @emph{language}.  This
19 document is a gentle introduction to that language, which is called
20 Mudela, an acronym of Music Definition Language.
21
22 This tutorial will demonstrate how to use Mudela by presenting
23 examples of input along with resulting output.  We will use English
24 terms for notation.  In case you are not familiar with those, you may
25 consult the glossary that is distributed with LilyPond.
26
27 The examples discussed are included in the distribution, in the
28 subdirectory @file{input/tutorial/}.  It is recommended that you
29 experiment with writing Mudela input yourself, to get a feel for
30 how LilyPond behaves.
31
32 @node The first tune,  , , Tutorial
33 @section The first tune
34
35
36 To demonstrate what LilyPond input looks like, we start off with a
37 full fledged, yet simple example. It is a convoluted version
38 of the famous menuet in J. S. Bach's @emph{Klavierbuechlein}.
39
40 @mudela[verbatim]
41 % lines preceded by a percent are comments.
42 \include "paper16.ly"
43 \score {
44     \notes                        
45     \relative c'' \sequential{                
46             \time 3/4;                
47             \key g;
48
49         \repeat "volta" 2 {
50             d4 g,8 a b c d4 g, g |
51             e'4 c8 d e fis g4 g, g |
52             c4 d8()c b a( )b4 c8 b a g |
53             a4 [b8 a] [g fis] g2.  |
54         }
55
56         b'4 g8 a b g
57         a4 d,8 e fis d |
58         g4 e8 fis g d cis4 b8 cis a4 |
59         a8-. b-. cis-. d-. e-. fis-.
60         g4 fis e |
61         fis a,  r8 cis8
62         d2.-\fermata
63         \bar "|.";
64     }
65     \paper {
66        % standard settings are too wide for a book
67        linewidth = 14.0 \cm;
68    }
69 }
70 @end mudela
71
72 Enter it (or copy it, the filename is @file{menuet.ly}), compile it
73 with LilyPond and view the output.  Details of this procedure may vary
74 from system to system.  To create the output, one would issue the
75 command `@code{ly2dvi menuet}'.  @file{ly2dvi} is a program that does
76 the job of running LilyPond and TeX, handling of titles and
77 adjusting of page margins.
78
79 If all goes well, the file @file{menuet.dvi} will be created.
80 To view this output, issue the command `@code{xdvi menuet}'.
81
82 Now that we are familiar with the procedure of producing output, we
83 will analyse the input, line by line.
84 @ignore
85 Let's try to redo this
86 @example
87
88         % lines preceded by a percent are comments.
89  
90 @end example 
91 The percent sign, `@code{%}', introduces a line comment.  If you want to
92 make larger comments, you can use block comments. These are delimited
93 by `@code{%@{}' and `@code{%@}}'
94 @end ignore
95 @multitable @columnfractions .60 .39
96 @item
97 @noindent
98 @c @example  urg: no tt font
99 @c @exdent % lines preceded by a percent are comments.
100 @exdent @code{% lines preceded by a percent are comments.}
101 @c @end example
102 @tab
103 The percent sign, `@code{%}', introduces a line comment.  If you
104 want to make larger comments, you can use block comments. These
105 are delimited by `@code{%@{}' and `@code{%@}}'
106 @end multitable
107 @example 
108
109         \input "paper16.ly"
110  
111 @end example 
112 By default, LilyPond will use definitions for a 20
113 point@footnote{A point is the standard measure of length for
114 printing.  One point is 1/72.27 inch.} high staff.  We want smaller
115 output (16 point staff height), so we must import the settings for
116 that size, which is done.@example 
117
118         \score @{
119  
120 @end example 
121   A mudela file combines music with directions for outputting that
122 music.  The music is combined with the output directions by putting
123 them into a @code{\score} block.
124 @example 
125
126         \notes                
127  
128 @end example 
129  This makes LilyPond ready for accepting notes.
130 @example 
131
132         \relative c''
133  
134 @end example 
135  As we will see, pitches are combinations of octave, note name and
136 chromatic alteration.  In this scheme, the octave is indicated by
137 using raised quotes (`@code{'}') and ``lowered'' quotes (commas:
138 `@code{,}').  The central C is denoted by @code{c'}.  The C one octave
139 higher is @code{c''}.  One and two octaves below the central C is
140 denoted by @code{c} and @code{c,} respectively.
141
142 For pitches in a long piece you might have to type many quotes.  To
143 remedy this, LilyPond has a ``relative'' octave entry mode.  In this
144 mode, octaves of notes without quotes are chosen such that a note is
145 as close as possible (graphically, on the staff) to the the preceding
146 note.  If you add a high-quote an extra octave is added.  The lowered
147 quote (a comma) will subtract an extra octave.  Because the first note
148 has no predecessor, you have to give the (absolute) pitch of the note
149 to start with.@example 
150
151         \sequential @{
152  
153 @end example 
154   What follows is sequential music, i.e.,
155 notes that are to be played and printed after each other.@example 
156
157         \time 3/4;
158  
159 @end example 
160   This command changes the time signature of the current piece: a 3/4
161 sign is printed.  This command is also used to generate bar lines in
162 the right spots.@example 
163
164         \key g;
165  
166 @end example 
167  This command changes the current key to G-major.  Although this
168 command comes after the @code{\time} command, in the output, the key
169 signature comes before the time signature: LilyPond knows about music
170 typesetting conventions. @example 
171
172         \repeat "volta" 2
173  
174 @end example 
175   This command tells LilyPond that the following piece of music must
176 be played twice; @code{"volta"} volta brackets should be used for
177 alternatives---if there were any.
178 @example 
179
180         @{
181  
182 @end example 
183 The subject of the repeat is again sequential music.  Since
184 @code{\sequential} is such a common construct, a shorthand is provided:
185 just leave off @code{\sequential}, and the result is the same. @example 
186
187         d4
188  
189 @end example 
190  This is a note with pitch @code{d} (determined up to octaves).  The
191 relative music was started with a @code{c''}, so the real pitch of this
192 note is @code{d''}.  The @code{4} designates the duration of the note
193 (it is a quarter note). @example 
194
195         a b
196  
197 @end example 
198 These are notes with pitch @code{a} and @code{b}.  Because their
199 duration is the same as the @code{g}, there is no need to enter the
200 duration (You may enter it anyway, eg. @code{a4 b4}) @example 
201
202         d4 g, g |
203  
204 @end example 
205  Three more notes.  The `@code{|}' character is a `barcheck'.  When
206 processing the music, LilyPond will verify that barchecks are found at
207 the start of a measure.  This can help you track down errors.
208
209  So far, no notes were chromatically altered.  Here is the first one
210 that is: @code{fis}. Mudela by default uses Dutch note names, and
211 ``Fis'' is the Dutch note name for ``F sharp''.  However, there is no
212 sharp sign in the output. The program keeps track of key signatures,
213 and will only print accidentals if they are needed.
214 @example 
215
216         c8 d e fis
217  
218 @end example 
219 LilyPond guesses were beams can be added to eighth and shorter notes.
220 In this case, a beam over 4 eighths is added.
221 @example 
222
223         c4 d8( )c b a( )b4 c8 b a g |
224  
225 @end example 
226   The next line shows how to make a slur:
227 the beginning and ending note of the slur is marked with an opening and
228 closing parenthesis respectively.  In the line shown above this is
229 done for two slurs.  Slur markers (parentheses) are between
230 the notes.@example 
231
232         a4 [b8 a] [g fis] 
233  
234 @end example 
235 Automatic beaming can be overridden by inserting beam marks
236 (brackets).  Brackets are put around notes you want beamed.@example 
237
238         g2.  |
239  
240 @end example 
241 A duration with augmentation dot  is notated
242 with the duration number followed by a period.@example 
243
244         @}
245  
246 @end example 
247   This ends the sequential music to be repeated.  LilyPond will typeset
248 a repeat bar.  @example 
249
250         cis'4 b8 cis a4 |
251  
252 @end example 
253  This line shows that Lily will print an accidental if that is
254 needed: the first C sharp will be printed with an accidental, the
255 second one without.  @example 
256
257         a8-. b-. cis-. d-. e-. fis-.
258  
259 @end example 
260 You can enter articulation signs either in a verbose form using a
261 shorthand.  Here we demonstrate the shorthand: it is formed by a dash
262 and the the character for the articulation to use, e.g. `@code{-.}' for
263 staccato as shown above.  @example 
264
265         fis a, r8 cis8
266  
267 @end example 
268  
269 Rests are denoted by the special notename `@code{r}'.  You can also enter
270 an invisible rest by using the special notename `@code{s}'.
271 @example 
272
273         d2.-\fermata
274  
275 @end example 
276  All articulations have a verbose form, like @code{\fermata}.  The
277 command `@code{\fermata}' is not part of the core of the language (most
278 of the other discussed elements are), but it is a shorthand for a more
279 complicated description of a fermata.  @code{\fermata} names that
280 description and is therefore called an @emph{identifier}. @example 
281
282         @}
283  
284 @end example 
285  
286 Here the music ends.
287 @example 
288
289         \paper @{
290                 linewidth = 14.0\cm;
291         @}
292  
293 @end example 
294 This specifies a conversion from music to notation output.  Most of
295 the details of this conversions (font sizes, dimensions, etc.) have
296 been taken care of, but  to fit the output  in this document, it has
297 to be smaller.  We do this by setting the line width to 14 centimeters
298 (approximately 6 inches).
299 @example 
300
301         @}
302  
303 @end example 
304 The last brace ends the @code{\score} block.
305
306 There are two things to note here. The format contains musical
307 concepts like pitches and durations, instead of symbols and positions:
308 the input format tries to capture the meaning of @emph{music}, and not
309 notation.  Therefore Second, the format tries to be @emph{context-free}:
310 a note will sound the same regardless of the current time signature,
311 the key, etc.
312
313 The purpose of LilyPond is explained informally by the term `music
314 typesetter'.  This is not a fully correct name: not only does the
315 program print musical symbols, it also makes esthetic decisions.  All
316 symbols and their placement is @emph{generated} from a high-level musical
317 description.  In other words,  LilyPond would be best
318 described by `music compiler' or `music to notation compiler'.
319
320 @node Lyrics and chords, , , Tutorial
321 @section Lyrics and chords
322
323 In this section we show how to typeset a song of unknown
324 origin.@footnote{The author would welcome information about the origin
325 of this song.}.
326
327 @example 
328 \header @{
329         title = "The river is flowing";
330         composer = "Traditional (?)";
331 @}
332 \include "paper16.ly"
333 melody = \notes \relative c' @{
334         \partial 8;
335         g8 |
336         c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
337         c4 c8 d [es () d] c4 | d4 es8 d c4.
338         \bar "|.";
339 @}
340
341 text = \lyrics @{
342         The ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
343         ri -- ver is flo -- wing down to the sea.
344 @}
345
346 accompaniment =\chords @{
347         r8
348         c2:3- f:3-.7 d:min es4 c8:min r8
349         c2:min f:min7 g:7^3.5 c:min @}
350
351 \score @{
352         \simultaneous @{
353 %         \accompaniment
354           \context ChordNames \accompaniment
355
356           \addlyrics
357             \context Staff = mel @{        
358               \property Staff.noAutoBeaming = "1"
359               \property Staff.automaticMelismata = "1"
360               \melody 
361             @}
362             \context Lyrics \text
363         @}
364         \midi  @{ @}
365         \paper @{ linewidth = 10.0\cm; @}
366 @} 
367 @end example 
368
369
370 The result would look this@footnote{The titling and font size shown
371 may differ, since the titling in this document is not generated by
372 @file{ly2dvi}.}.
373
374 @center @strong{The river is flowing}
375 @center Traditional 
376
377 @mudela[center]
378 \header {
379         title = "The river is flowing";
380         composer = "Traditional (?)";
381 }
382 \include "paper16.ly"
383 melody = \notes \relative c' {
384         \partial 8;
385         \key c \minor;
386         g8 |
387         c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
388         c4 c8 d [es () d] c4 | d4 es8 d c4.
389         \bar "|.";
390 }
391
392 text = \lyrics {
393         The ri -- ver is flo- __ wing, flo -- wing and gro -- wing, the
394         ri -- ver is flo -- wing down to the sea.
395 }
396
397 accompaniment =\chords {
398         r8
399         c2:3- f:3-.7 d:min es4 c8:min r8
400         c2:min f:min7 g:7^3.5 c:min }
401
402 \score {
403         \simultaneous {
404 %         \accompaniment
405           \context ChordNames \accompaniment
406
407           \addlyrics
408             \context Staff = mel {
409               \property Staff.noAutoBeaming = "1"
410               \property Staff.automaticMelismata = "1"
411               \melody 
412             }
413             \context Lyrics \text
414         }
415         \midi  { }
416         \paper { linewidth = 10.0\cm; }
417 }
418 @end mudela
419
420 Again, we will dissect the file line by line.@example 
421
422         \header @{
423  
424 @end example 
425 Information about the music you are about to typeset goes into a
426 @code{\header} block.  The information in this block is not used by
427 LilyPond, but it is included in the output.  @file{ly2dvi} uses this
428 information to print titles above the music.
429 @example 
430
431         title = "The river is flowing";
432         composer = "Traditional (?)"; 
433 @end example 
434 the @code{\header} block contains assignments.  An assignment starts
435 with a string.  (which is unquoted, in this case). Then comes the
436 equal sign `@code{=}'.  After the equal sign comes the expression you
437 want to store.  In this case, you want to put in strings.  The
438 information has to be quoted here, because it contains spaces. The
439 assignment is finished with a semicolon.@example 
440
441         \include "paper16.ly"
442  
443 @end example 
444 Smaller size for inclusion in a book.@example 
445
446         melody = \notes \relative c' @{
447  
448 @end example 
449 The structure of the file will be the same as the previous one, a
450 @code{\score} block with music in it.  To keep things readable, we will
451 give names to the different parts of music, and use the names to
452 construct the music within the score block.
453
454 @example 
455         \partial 8;
456 @end example 
457
458 The piece starts with an anacrusis of one eighth.
459 @example
460         \key c \minor
461 @end example
462 The key is C minor: we have three flats.
463
464
465 @example 
466
467         c4 c8 d [es () d] c4 | f4 f8 g [es() d] c g |
468         c4 c8 d [es () d] c4 | d4 es8 d c4.
469         \bar "|.";
470  
471 @end example 
472 We use explicit beaming.  Since this is a song,  we will turn automatic
473 beams off, and use explicit beaming where needed.@example 
474
475         @}
476  
477 @end example 
478 This ends the definition of @code{melody}.  Note that there are no
479 semicolons after assignments at top level.@example 
480
481         text = \lyrics @{
482  
483 @end example 
484 Another identifier assignment.  This one is for the lyrics. 
485 Lyrics are formed by syllables that have duration, and not by
486 notes. To make LilyPond parse words as syllables,  switch it  into
487 lyrics mode with @code{\lyrics}.  Again, the brace after @code{\lyrics}
488 is a shorthand for @code{\sequential @{}. @example 
489
490         The4 ri -- ver is flo- __ wing,  flo -- wing and gro -- wing, the
491         ri- ver is flo- __ wing down to the sea.
492         @}
493  
494 @end example 
495 The syllables  themselves are  separated by spaces.  You can get syllable
496 extenders by entering `@code{__}', and centered hyphens with
497 `@code{-}@code{-}'.  We enter the syllables as if they are all quarter notes
498 in length (hence the @code{4}), and use a feature to align the
499 syllables to the music (which obviously isn't all quarter notes.)
500 @example 
501
502         accompaniment =\chords @{
503  
504 @end example 
505 We'll put chords over the music.  There is a special mode (analogous
506 to @code{\lyrics} and @code{\notes} mode) where you can give the names
507 of the chords you want, instead of the notes comprising the chord.
508 @example 
509
510         r8
511  
512 @end example 
513 There is no accompaniment during the anacrusis.@example 
514
515         c2:3- f:3-.7
516  
517 @end example 
518 A chord is started by  the tonic of the chord. The
519 first one lasts a half note.  An unadorned note creates a major
520 triad, while a minor triad is wanted.  @code{3-} modifies the third to
521 be small. @code{7} modifies (adds) a seventh, which is small by default
522 to create the @code{f a c es} chord.  Multiple modifiers must be
523 separated by a dot.@example 
524
525         d:min es4 c8:min r8
526  
527 @end example 
528 Some modifiers have predefined names, eg. @code{min} is  the same as
529 @code{3-}, so @code{d-min} is a minor @code{d} chord.@example 
530
531         c2:min f:min7 g:7^3.5 c:min @}
532  
533 @end example 
534 A named modifier @code{min} and a normal modifier @code{7} do not have
535 to be separated by a dot.  Tones from a chord are removed with chord
536 subtractions.  Subtractions are started with a caret, and they are
537 also separated by dots.  In this example, @code{g:7^3.5} produces a
538 minor seventh.  The brace ends the sequential music. @example 
539
540         \score @{
541                 \simultaneous @{
542  
543 @end example 
544 We assemble the music in the @code{\score} block.  Melody, lyrics and
545 accompaniment have to sound at the same time, so they should be
546 @code{\simultaneous}.@example 
547
548         %\accompaniment
549  
550 @end example 
551 Chord mode generates notes grouped in @code{\simultaneous} music.  If
552 you remove the comment sign, you can see the chords in normal
553 notation: they will be printed as note heads on a separate
554 staff. @example 
555
556         \context ChordNames \accompaniment
557  
558 @end example 
559 Normally, the notes that you enter are transformed into note heads.
560 The note heads alone make no sense, they need surrounding information:
561 a key signature, a clef, staff lines, etc.  They need @emph{context}.  In
562 LilyPond, these symbols are created by objects called `interpretation
563 context'.  Interpretation contexts only exist during a run of
564 LilyPond.  Interpretation contexts that are for printing music (as
565 opposed to playing music) are called `notation context'.
566
567 By default, LilyPond will create a Staff contexts for you.  If you
568 would remove the @code{%} sign in the previous line, you can see that
569 mechanism in action.
570
571 We don't want default contexts here, because we want names, not note
572 heads.  An interpretation context can also created upon explicit
573 request. The keyword for such a request is @code{\context}.  It takes
574 two arguments.  The first is the name of a interpretation context.
575 The name is a string, it can be quoted with double quotes).  The
576 second argument is the music that should be interpreted in this
577 context.  For the previous line, we could have written @code{\context
578 Staff \accompaniment}, and get the same effect.@example 
579
580         \addlyrics
581  
582 @end example 
583 The lyrics need to be aligned with the melody.  This is done by
584 combining both with @code{\addlyrics}.  @code{\addlyrics} takes two
585 pieces of music (usually a melody and lyrics, in that order) and
586 aligns the syllables of the second piece under the notes of the
587 first piece.  If you would reverse the order, the notes would be
588 aligned on the lyrics, which is not very useful. (Besides, it looks
589 silly.)@example 
590
591         \context Staff = mel @{
592  
593 @end example 
594 This is the argument of @code{\addlyrics}.  We instantiate a
595 @code{Staff} context explicitly: should you chose to remove comment
596 before the ``note heads'' version of the accompaniment, the
597 accompaniment will be on a nameless staff.  The melody has to be on a
598 different staff as the accompaniment.  This is accomplished by giving
599 the melody staff a different name.@example 
600
601         \property Staff.noAutoBeaming = "1"
602  
603 @end example 
604 An interpretation context has variables that tune its behaviour.  One
605 of the variables is @code{noAutoBeaming}.  If set and non-zero (i.e.,
606 true) LilyPond will not try to put automatic beaming on the current
607 staff.@example 
608
609         \property Staff.automaticMelismata = "1"
610  
611 @end example 
612 Similarly, we  don't want to print a  syllable when there is
613 a slur. This sets up the Staff context to signal slurs while
614 @code{\addlyrics} is processed. @example 
615
616           \melody
617         @}
618  
619 @end example 
620 Finally, we put the melody on the current staff.  Note that the
621 @code{\property} directives and @code{\melody} are grouped in sequential
622 music,  so the property settings are done before the melody is
623 processed.  @example 
624
625         \context Lyrics \text
626  
627 @end example 
628 The second argument of @code{\addlyrics} is the text. The text also
629 should not land on a Staff, but on a interpretation context for
630 syllables, extenders, hyphens etc.  This context is called
631 Lyrics.@example 
632
633         @}
634  
635 @end example 
636 This ends @code{\simultaneous}.@example 
637
638         \midi  @{ @}
639  
640 @end example 
641 This makes the music go to a MIDI file.  MIDI is great for
642 checking music you enter.  You listen to the MIDI file: if you hear
643 something unexpected, it's probably a typing error.  @code{\midi} is an
644 `output definition', a declaration that specifies how to output music
645 analogous to @code{\paper @{ @}}.@example 
646
647         \paper @{ linewidth = 10.0\cm; @}
648  
649 @end example 
650 We also want notation output.  The linewidth is short so the piece
651 will be set in two lines. @example 
652
653         @}
654  
655 @end example 
656 End the score block.
657
658 @node Piano music, , , Tutorial
659 @section Piano music
660
661 Our third subject is a piece piano music.  The fragment in the input
662 file is a piano reduction of the G major Sinfonia by Giovanni Battista
663 Sammartini.  It was composed around 1740. 
664
665 @mudela[verbatim]
666
667 \include "paper16.ly";
668
669 viola = \notes \relative c' \context Voice = viola {
670         <c4-\f g' c>
671         \property Voice.verticalDirection = \down g'8. b,16
672         s1 s2. r4
673         g
674 }
675
676 oboes = \notes \relative c'' \context Voice = oboe {
677         \stemup s4  g8. b,16 c8 r <e'8.-\p g> <f16 a>
678         \grace <e8( g> <d4 f> <c2 e> \times 2/3 { <d8 \< f> <e g> <f a> }
679         <
680           { \times 2/3 { a8 g c } \! c2 }
681           \context Voice = oboeTwo {
682                 \stemdown
683                 \grace {
684                     \property Grace.verticalDirection = \down
685                     [f,16 g] }
686                 f8 e e2
687         } >
688         \stemboth
689         \grace <c,8( e> <)b8. d8.-\trill> <c16 e> | 
690         [<d ( f> < )f8. a>] <)b,8 d> r [<d16( f> <f8. )a>] <b,8 d> r  |
691         [<c16( e>  < )e8. g>] <c8 e,>
692 }
693
694 hoomPah  = \notes \transpose c' {
695     c8 \translator Staff = top \stemdown 
696     c'8 \translator Staff = bottom \stemup }
697
698 hoomPahHoomPah = { [\hoomPah \hoomPah] }
699
700 bassvoices = \notes \relative c' {
701         c4 g8. b,16
702         \hoomPahHoomPah \hoomPahHoomPah \hoomPahHoomPah \hoomPahHoomPah
703         \stemdown [c8 c'8] r4
704         <g d'> r4
705         < {\stemup r2 <e4 c'> <c8 g'> }
706           \context Voice = reallyLow  {\stemdown g2 ~ | g4 c8 } >
707 }
708
709 \score {
710         \context PianoStaff \notes <
711                 \context Staff = top < \time 2/2;
712                         \context Voice = viola \viola
713                         \oboes
714                 >
715                 \context Staff = bottom < \time 2/2; \clef bass;
716                         \bassvoices
717                 >
718         >
719         \midi { }
720         \paper {
721           indent = 0.0;
722           linewidth = 15.0 \cm; }
723 }
724 @end mudela
725
726 If it looks like incomprehensible gibberish to you@dots{} Then you are
727 right.  The author has doctored this example to have as many quirks in
728 one system as possible.@example 
729 viola = \notes \relative c'  \context Voice = viola @{ 
730 @end example 
731 In this example, you can see multiple parts on a staff.  Each part is
732 associated with one notation context.  This notation context handles
733 stems and dynamics (among others).  The name of this context is
734 @code{Voice}.  For each part we have to make sure that there is
735 precisely one Voice context@footnote{If @code{\context} would not
736 have been specified explicitly, three @code{Voice} contexts would be
737 created: one for each note  in the first chord.}.@example 
738 <c4-\f g' c> 
739 @end example 
740 @code{<} and @code{>} are short hands for @code{\simultaneous @{} and
741 @code{@}}. So the expression enclosed in @code{<} and @code{>} is a
742 chord.  @code{\f} places a forte symbol  under the chord.@example 
743 \property Voice.verticalDirection = \down 
744 @end example 
745 @code{verticalDirection} is a property of the voice context. It
746 controls the directions of stems, articulations marks and other
747 symbols.
748   If @code{verticalDirection} is set to @code{\down}
749 (identifier for the integer -1) the stems go down,
750 @code{\up} (identifier for the integer 1) makes the stems go up.@example 
751         g'8. b,16 
752 @end example 
753 Relative octaves work a little differently with chords.  The starting
754 point for the note following a chord is the first note of the chord.  So
755 the @code{g} gets an octave up quote: it is a fifth above the starting
756 note of the previous chord (the central C).
757
758 @example 
759 s1 s2. r4 
760 @end example 
761 @code{s} is a `spacer' rest.  It does not print anything,  but it does
762 have the duration of a rest.   @example 
763 oboes = \notes \relative c'' \context Voice = oboe @{ 
764 @end example 
765 Now comes a part for two oboes.  They play homophonically, so we
766 print the notes as one voice that makes chords. Again, we insure that
767 these notes are indeed processed by precisely one context with
768 @code{\context}.@example 
769 \stemup s4  g8. b,16 c8 r <e'8.-\p g> <f16 a> 
770 @end example 
771 @code{\stemup} is an identifier reference.  It is shorthand for
772 @code{\property Voice.verticalDirection = \up}.  If possible, you
773 should use predefined identifiers like these for setting properties.
774 Your input will be less dependent upon the implementation of LilyPond.
775 @example 
776 \grace <e8( g> < )d4 f> <c2 e> 
777 @end example 
778 @code{\grace} introduces grace notes.  It takes one argument, in this
779 case a chord.  The slur started on the @code{e} of the chord
780 will be attached to the next note.@footnote{LilyPond will squirm
781 about unended Slurs.  In this case, you can ignore the warning}.
782 @example 
783 \times 2/3 
784 @end example 
785 Tuplets are made with the @code{\times} keyword.  It takes two
786 arguments: a fraction and a piece of music.  The duration of the
787 second argument is multiplied by the first argument.  Triplets make
788 notes occupy 2/3 of their notated duration, so in this case the
789 fraction is 2/3. @example 
790 @{ <d8 \< f> <e g> <f a> @} 
791 @end example 
792 The piece of music to be `tripletted' is sequential music containing
793 three notes.  On the first chord (the @code{d}), a crescendo is started
794 with @code{\<}.@example 
795
796 @end example 
797 At this point, the homophonic music splits into two rhythmically
798 different parts.  We can't use a sequence of chords to enter this, so
799 we make a `chord' of sequences to do it.  We start with the upper
800 voice, which continues with upward stems: @example 
801  @{ \times 2/3 @{ a8 g c @} \! c2 @} 
802 @end example 
803 The crescendo is ended at the half note by the escaped exclamation
804 mark `@code{\!}'.  @example 
805 \context Voice = oboeTwo @{
806 \stemdown 
807 @end example 
808 We can't share stems with the other voice, so we have to create a new
809 @code{Voice} context.  We give it the name @code{oboeTwo} to distinguish
810 it from the other context.  Stems go down in this voice. @example 
811 \grace @{  
812 @end example 
813 When a grace section is processed, a @code{Grace} context is
814 created. This context acts like a miniature score of its own.  It has
815 its own time bookkeeping, and you can make notes, beams, slurs
816 etc. Here fiddle with a property and make a beam.  The argument of
817 @code{\grace} is sequential music.@example 
818 \property Grace.verticalDirection = \down
819 [f,16 g] @} 
820 @end example 
821 Normally, grace notes are always stem up, but in this case, the upper
822 voice interferes. We set the stems down here.
823
824 As far as relative mode is concerned, the previous note is the
825 @code{c'''2} of the upper voice, so we have to go an octave down for
826 the @code{f}.
827 @example 
828
829   f8 e e2
830 @} > 
831 @end example 
832 This ends the two-part section. @example 
833 \stemboth
834 \grace <c,8( e> <)b8. d8.-\trill> <c16 e> |  
835 @end example 
836 @code{\stemboth} ends the forced stem directions. From here, stems are
837 positioned as if it were single part music.
838
839 The bass has a little hoom-pah melody to demonstrate parts switching
840 between staffs.  Since it is repetitive, we use identifiers:@example 
841 hoomPah  = \notes \transpose c' @{ 
842 @end example 
843 Transposing can be done with @code{\transpose}.  It takes two
844 arguments; the first specifies what central C should be transposed to.
845 The second is the to-be-transposed music.  As you can see, in this
846 case, the transposition is a no-op.  Central C is transposed to
847 central C.
848
849 The purpose of this no-op is circumventing relative mode.  Relative
850 mode can not be used in conjunction with transposition, so relative
851 mode will leave the contents of @code{\hoomPah} alone.  We can use it
852 without having to worry about getting the motive in a wrong
853 octave@footnote{@code{hoomPah = \relative @dots{}} would be more
854 intuitive to use, but that would not let me plug @code{\transpose}
855 :-).}.@example 
856 c8 \translator Staff = top \stemdown  
857 @end example 
858 We assume that the first note will be put in the lower staff.  After
859 that note we switch to the upper staff with @code{\translator}.  To be
860 precise, this @code{\translator} entry switches the current voice to a
861 @code{Staff} named @code{top}. So we have to name the upper staff
862 `@code{top}'.  Stem directions are set to avoid interfering with the
863 oboe voices.  @example 
864 c'8 \translator Staff = bottom \stemup @} 
865 @end example 
866 Then a note is put on the upper staff, and we switch again.  We have
867 to name the lower staff `@code{bottom}'. @example 
868 hoomPahHoomPah = @{ [\hoomPah \hoomPah] @} 
869 @end example 
870 Put two of these fragments in sequence, and beam them.@example 
871 bassvoices = \notes \relative c' @{
872 c4 g8. b,16
873 \hoomPahHoomPah \hoomPahHoomPah \hoomPahHoomPah
874 \hoomPahHoomPah 
875 @end example 
876 Entering the bass part is easy: the hoomPahHoomPah variable is
877 referenced four times.@example 
878 \context Voice = reallyLow  @{\stemdown g2 ~ | g4 c8 @} > 
879 @end example 
880 After skipping some lines, we see @code{~}.  This mark makes ties.@example 
881 \context PianoStaff 
882 @end example 
883 For piano music, a special context is needed to get cross staff
884 beaming right.  It is called @code{PianoStaff}.@example 
885 \context Staff = bottom < \time 2/2; \clef bass; 
886 @end example 
887 The bottom staff must have a different clef.@example 
888 indent = 0.0; 
889 @end example 
890 To make some more room on the line, the first (in this case the only)
891 line is not indented.  The line still looks is very cramped, but that is due
892 to the format of this tutorial.
893
894 This example shows a lot of features, but the organisation isn't
895 perfect.  For example, it would be less confusing to use a chord
896 containing sequential music than a sequence of chords for the oboe
897 parts.
898
899 [TODO: demonstrate Hara-Kiri with scores and  part extraction.]
900
901 @node  end of tutorial, , , Tutorial
902 @section The end        
903          
904 That's all folks.  From here, you can either try fiddling with input
905 files, or you can read the reference manual.