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