]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/tex/mudela.yo
patch::: 1.0.1.jcn2: vix
[lilypond.git] / Documentation / tex / mudela.yo
1 COMMENT(-*-text-*-)
2
3 DEFINEMACRO(var)(1)(whenlatex(latexcommand({\normalfont\scshape )ARG1+latexcommand(}))\
4     whenhtml(sc(ARG1)))
5
6
7
8 COMMENT( This document contains Mudela fragments.  You need at least
9 Yodl-1.30.18 to convert this to tex or html.
10
11 TODO
12
13 in stead <-> instead
14 )
15
16 htmlbodyopt(bgcolor)(white)
17 htmlcommand(<font color=black>)
18
19 latexpackage()(a4wide)
20 latexlayoutcmds(
21 %\usepackage[latin1]{inputenc}
22 \input mudela-book
23 )
24
25 whenlatex(notableofcontents())
26 whentexinfo(notableofcontents())
27
28 report(Mudela, the Music-Definition Language)
29       (Han-Wen Nienhuys and Jan Nieuwenhuizen)
30       (nop()PIPETHROUGH(date "+%B %d, %Y")()()nop())
31
32 COMMENT(
33
34 * The [ ] look weird
35
36 * paragraphs have too much space.
37
38 )
39
40
41 latexcommand(\def\interexample{})
42 latexcommand(\def\preexample{\par})
43 latexcommand(\def\postexample{\par\medskip})
44 latexcommand(\def\file#1{{code(#1)}})
45 COMMENT(
46 latexcommand(\def\texttt#1{\tt #1})
47 latexcommand(\def\textbf#1{\bf #1})
48 )
49
50 chapter(Tutorial)
51
52 whenhtml(
53 nsubsect(Disclaimer)
54 This document is written in url(Yodl)(ftp://pcnov095.win.tue.nl/pub/yodl)
55 and should foremost produce nice LaTeX() output.
56 In other formats, such as html, some things will look a bit different,
57 while other things will be simply left out.
58 Therefore, the authoritive version of this document is the PostScript version, 
59 produced via LaTeX().
60 )
61
62 sect(Introduction)
63 label(tutorial:introduction)
64 latexcommand(\parindent2pc)
65   
66 If you are reading this, you probably are interested in printing
67 music.  LilyPond is a program that can print music from a
68 specification that you, the user, supply.  Using LilyPond may be a bit
69 quaint in the beginning, because you have to give that specification
70 using a em(language).  That might not be what you expect if you are
71 familiar with graphical interfaces.  But there are some big
72 advantages: first, once you master the language, entering music can be
73 done quite efficiently.  Secondly, it is possible to explain exactly
74 what the meaning of a language is, i.e., the semantics are much
75 clearer.  Thirdly, since the program is not interactive, no tradeoffs
76 have to be made between processing speed and beauty of the output.
77
78 This chapter is a gentle introduction to Mudela, the language that
79 instructs LilyPond to typeset music.  We will explain Mudela by
80 presenting a series of examples of Mudela input.  The corresponding
81 output will be shown on the right or below, just as it was produced by
82 LilyPond.
83
84 We will assume that you more or less understand the basics of music notation.  
85 If you are not familiar with the English terms for music notation, you 
86 should consult bind(Appendix)ref(glossary): it contains a glossary 
87 of musical terms along with translations in some other languages.
88
89 If you want to try the examples given here, you should have look a 
90 look at bind(Section)ref(sec:running-lilypond) first.
91
92 sect(Music copying, music definition and music entry)
93 label(tutorial:copying-vs-def-vs-entry)
94
95 If you have copied music before, using LilyPond may seem awkward
96 to you in the beginning.  The purpose of LilyPond informally is
97 explained by the term `music typesetter'.
98
99 This may give the impression that the program is like a drawing tool
100 and that it lets you control precisely how the music is formatted.
101 This is not the case: not only does the program print musical symbols,
102 LilyPond also tries to make esthetic decisions---to be precise, we
103 programmed her to do what we find nop(pretty.)footnote(We formed our
104 taste by looking at, and reading all about fine music engraving.  Of
105 course, our taste is also bound by all the accepted rules of common
106 music notation.)  You do not have complete control over what is
107 happening.  Usually that is not a big loss, since good engraving is a
108 very complex trade. In other words, you don't have control, so you do
109 not have to worry about what is happening precisely.
110
111 Secondly, we expect you to enter the meaning of the music, not the
112 sheet music itself.  The input to LilyPond is a music definition,
113 which is something different than notation: notation is a graphical
114 system.  Put more concretely: your input to LilyPond should contain
115 information like ``a dotted quarter note, pitch nop(d)sups(2).''
116 LilyPond will figure out from the musical information that a black
117 note head with a stem but without flag, fourth staff line, with dot
118 should be printed.
119
120 When you are copying music by hand from a printed score, you don't have 
121 to know what the score means; you just copy the symbols.  With LilyPond 
122 such a thing is not possible.  You have to enter the meaning of the 
123 symbols, and this might not always be as easy.  On the other hand, once 
124 entered, any piece of music can be played and transposed automatically.
125
126 Finally, in some spots we will cheat a bit when it comes to musical
127 definition.  Mudela has some entry modes that help to make typing
128 Mudela pleasant.  For example, the phrase ``a dotted quarter note,
129 pitch nop(d)sups(2)'' translates to the following longhand:
130 verb(
131 \musicalpitch { 1 2 0 } \duration { 2 1 })
132
133 This data is what we consider the musical em(definition).  Mudela
134 has a special entry mode where you can conveniently abbreviate this to
135 `code(d''4.)'.  There are some features that also make the quotes and
136 numbers in `code(d''4.)'  superfluous in some cases.
137
138 For those who are curious, the numbers in `code(\musicalpitch { 1 2 0
139 })' example mean octave, notename, and accidental respectively.  The
140 numbers in `code(\duration { 2 1 })' are the (negative) logarithm of the
141 duration (2 is a quarter note, 3 is an eighth note, etc.) and the number
142 of augmention dots respectively.
143
144 sect(When you know the notes to nop(print)ellipsis())
145
146 The basic building block of music is the note.  You can have LilyPond
147 print a note by specifying its pitch and duration.  The pitch of the
148 central C is written as code(c').  This is in line with musicological
149 notation; there this pitch is transcribed as nop(c)sups(1) or c'.  A
150 quarter-note duration is written as code(4).  So, to print a quarter
151 note whose pitch is central C, you enter the following:
152 mudela(fragment,verbatim,center)( c'4 )
153
154
155 subsect(Duration)
156
157 The duration of a note is specified as a number: a whole note is
158 denoted by 1, a half note by 2, a quarter by 4, and so on.  If you
159 want to augment a duration with a dot, simply affix a period to the
160 number.  Here are some random notes to show how it works.
161
162 mudela(fragment,verbatim)(
163   c'1 c'2 c'4 c'8 c'16 c'32 c'64 c'64 c'2. c'8. c'16
164 )
165
166 subsect(Basic pitches)
167
168 The pitch code(c') actually consists of two parts: one part for the
169 note name, and one for the octave.  The letter specifies which note
170 name to use: note names simply are the letters code(a) to code(g).
171 The number of apostrophes specifies the octave to use: the central C
172 is denoted by code(c').footnote(By convention, the A above central C
173 at concert pitch is the tone that is used to tune instruments.  Its
174 frequency is about 440 Hz.)  The C which is an eighth higher (the C in
175 the ``two-line octave'') is denoted by code(c''): every octave adds a
176 quote.  A note name without quotes designates the pitch below code(c')
177 (the C in the ``small octave''). If you want to go down even further,
178 commas should be added, e.g., the C in the ``contra octave'' is
179 expressed as code(c,,).footnote(The comma is meant to represent a
180 sunken apostrophe.)
181
182
183 This example demonstrates octaves:
184 mudela(fragment,verbatim,center)(
185    c,,4 c,4 c4 c'4 c''4 c'''4
186 )
187
188 And this example demonstrates notenames:
189 mudela(center,fragment,verbatim)(
190   c'4 d'4 e'4 f'4 g'4 a'4 b'4 c''4
191 )
192
193 A rest can be entered as a note with the special name code(r), e.g.,
194 mudela(fragment,verbatim,center)(r4)
195
196 This already gives us enough material to make simple songs. In
197 bind(Figure)ref(fig:twinkle1) a portion of the traditional song
198 ``Twinkle Twinkle Little Star'' is shown.
199
200 latexcommand(\begin{figure}[h])
201   center(
202 mudela(fragment,verbatim)(
203         c''4 c''4 g''4 g''4
204         a''4 a''4 g''2
205 )
206     latexcommand(\caption{Twinkle twinkle little star (version 1)})
207     label(fig:twinkle1)
208   )
209 latexcommand(\end{figure})
210
211
212 subsect(Alterations)
213
214 We have so far ignored chromatically altered pitches.  The names `a'
215 to `g' for entering pitches are convenient: they are short,
216 pronounceable and they resemble the words for pitches in normal
217 musical vocabulary.
218
219 Enter flats and sharps.  In English there is no standard terse word
220 for C sharp or C flat.  For this reason, we implemented a different,
221 non-English convention for entering altered pitches: a note is made
222 sharp by adding the suffix `--is' to its name, and flat by adding the
223 suffix `--es'.  For a double sharp another `--is' suffix is added, for
224 flats another `--es' suffix. The names for the alterations of C are
225 given in bind(Table)ref(notename-tab).
226
227 latexcommand(\begin{table}[h])
228   center(
229     table(2)(ll)(
230       row(cell(english)cell(LilyPond))
231       rowline()
232       row(cell(c double flat)cell(ceses))
233       row(cell(c flat)cell(ces))
234       row(cell(c natural)cell(c))
235       row(cell(c sharp)cell(cis))
236       row(cell(c double sharp)cell(cisis))
237     )
238   )
239   latexcommand(\caption{Default note names})
240   label(notename-tab)
241 latexcommand(\end{table})
242
243 Variations on this convention are used in a number of germanic
244 languages, notably Dutch, German, Swedish, and Norwegian.  To be
245 precise, LilyPond actually defaults to Dutch notenames, with
246 code(aes), code(aeses), code(ees) and code(eeses) added for
247 consistency.
248
249 Throughout this document we will continue to use the Dutch names.  To make
250 (Dutch) pronunciation easier, the a-flat and e-flat are contracted to
251 code(as) and code(es).  Similarly, the a double flat and e double flat are
252 contracted to code(ases) and code(eses).
253
254 If you are not comfortable with these names, you can make your own.
255 Note names for different languages are included with the example
256 initialisation files, amongst others English (C sharp is abbreviated
257 to code(cs)), Italian, Swedish and Norwegian.  If you want to use
258 these names, you should look at bind(Section)ref(subsect:include) for
259 information on how to use include files.
260
261 sect(Running LilyPond)
262 label(sec:running-lilypond)
263
264 In the previous section some basic elements of Mudela were presented.
265 We didn't want to bore you too much with repetitive details, so we
266 left out some red tape that's needed for a  of Mudela in a form that is accepted
267 by LilyPond.  To
268 be precise, we wrote code(X Y Z), when we really meant
269 verb(\score {
270    \melodic { X Y Z }
271    \paper {}
272 })
273 We will continue to leave out the red tape this, until the time is fit to explain what the
274 above it means.
275
276
277 Because LilyPond uses a language, it  is a so called em(batch)
278 program.
279 This means, that you use a
280 text editor (such as code(emacs) or code(vi)) to create an input
281 file.  When you are done editing your input file, you save it, and you
282 run LilyPond on the file.  If Lily finds any errors in your input file
283 then nop(she)footnote(We're sure that if computer programs could have
284   gender, LilyPond would be a female computer program.  So we will
285   refer to the program as a she. This gender-bending is not to tease
286   you, dear reader.  We do it in real life as well. In the past two
287   years LilyPond has become sort of a baby daughter to us, keeping us
288   awake at night, but also providing us with lots of joy.  We hope you do
289   not mind our little aberration from the traditions of computer-manual
290   writing.) COMMENT( 
291  The name LilyPond is actually sort of a girl's name.  Can you guess which
292  one ?)
293 will complain.  If everything went well, then she'll generate a file, that
294 you can process further to view or print.
295
296 Using LilyPond to print or view some music is a four-step procedure.
297 To get you started we'll run down the full procedure for you once.
298
299 enumerate(
300 it()
301 Fire up your favourite editor (if you don't
302 know any editors, try code(joe silly.ly)),
303 and key in the example from bind(Figure)ref(fig:twinkle1), with red tape:
304 verb(
305 \score {
306         \melodic {
307           c''4 c''4 g''4 g''4
308           a''4 a''4 g''2
309         }
310         \paper {}
311 }
312 )
313
314 Save your file as file(twinkle.ly).footnote(The default extension for Mudela
315 files is file(.ly).)
316
317 it()
318 Run LilyPond on your newly created file: enter code(lilypond twinkle).
319 LilyPond will then print all kinds of mumbo jumbo that can safely be
320 ignored.  You might see something like this:
321 verb(
322 GNU LilyPond 0.1.55/FlowerLib 1.1.39
323 Parsing ... [/home/hanwen/musix/spacer/init/lily-init.ly[/home/hanwen/
324
325         ... stuff left out here ...
326
327                               ]  Documentation/twinkle.ly]
328 Interpreting music ...[1] (time: 0.04 seconds)
329 Preprocessing elements... 
330 Calculating column positions ... [2]
331 Approximated: 1 lines, (with an average of 4.0 columns)
332 Time: 0.01 seconds
333 warning: Can not solve this casting problem exactly; revert to Word_wrap
334 [2]Time: 0.00 seconds
335
336 Postprocessing elements...
337 TeX output to twinkle.tex ...
338 )
339
340 All has gone well; there were some warnings but no errors.  The run
341 resulted in output, a TeX file called file(twinkle.tex).
342
343 file(TeX) is usually spelled TeX().  It is a batch program for
344 typesetting text. It was developed by the great programmer and
345 scientist Donald Knuth to typeset his famous bookseries em(The Art of
346 Computer Programming).  As you can see, TeX() can be adapted to do a
347 lot more.  whenlatex(In fact, the document that you are reading now was also
348 produced with TeX().) COMMENT(ugh.)
349
350
351 it()
352   To do something useful with the output you have to run TeX() on it
353   first.  Run the command code(tex twinkle).  The output should resemble this:
354 verb(
355 This is TeX, Version 3.14159 (C version 6.1)
356 (twinkle.tex
357 Babel <v3.6h> and hyphenation patterns for american, dutch, loaded.
358 (/home/hanwen/lib/texmf/tex/lilypond/lilyponddefs.tex
359 (/home/hanwen/lib/texmf/tex/lilypond/dyndefs.tex)
360 (/home/hanwen/lib/texmf/tex/lilypond/fetdefs.tex
361 (/home/hanwen/lib/texmf/tex/lilypond/feta20.tex)
362 (/home/hanwen/lib/texmf/tex/lilypond/lily-ps-defs.tex))) [1] )
363 Output written on twinkle.dvi (1 page, 3084 bytes).
364 Transcript written on twinkle.log.
365 )
366   The human translation is ``everything went OK, the result is one
367   page long, and I put it in file(twinkle.dvi).''
368
369 it()The file(twinkle.dvi) file is a description of how a piece of
370 text looks when it is printed.  You can view it, or print it.  If you
371 are using a Unix system equipped with X-Windows, then you can issue
372 the command file(xdvi twinkle) to view the result.  If this is not the
373 case, consult your local TeX() guru on printing and viewing DVI files.
374 What is in your window should approximately look like this:
375 mudela()(
376 \score {
377         \melodic {
378           c''4 c''4 g''4 g''4
379           a''4 a''4 g''2
380         }
381         \paper { linewidth = 13.\cm; }
382 }
383 )
384
385 it()
386 If you want to print file(twinkle.dvi), you should invoke the command
387 code(dvips twinkle).  Running this command should generate a
388 PostScript file called file(twinkle.ps).  This file can be printed on
389 any PostScript compatible printer.  You should not use any other
390 tools: the output from LilyPond contains fragments of PostScript which
391 will not print correctly if you don't use PostScript.  If your printer
392 doesn't understand PostScript, you should check out GhostScript, a
393 PostScript emulator.
394 )
395
396
397
398 The four-pass procedure sketched above is a bit clumsy.  Moreover, the
399 result is pretty crude: the page does not include prettily printed
400 titles and if you are unlucky, the margins don't come out well.  Jan
401 Arne Fagertun wrote a tool to take the above steps out of your hands,
402 make neat margins and print titling.  The tool is called file(ly2dvi),
403 and it should be on your system if you use Lily on a Unix platform.
404 If you use file(ly2dvi), then you can do verb(ly2dvi twinkle.ly ) in
405 stead of steps 2 and 3.  You will feel the real advantage of using
406 file(ly2dvi) when you add titling to the music.  This is something
407 that we will discuss in bind(Section)ref(tutorial:titling).
408
409
410 COMMENT(This document does not cover all of Mudela.  Due to technical details,
411 the precise working of Mudela is coupled to the innards of LilyPond.
412 If you really want to know all the details, your best bet would be to
413 get the sources to LilyPond and read the parser and scanner source.
414 They are in file(lilypond-x.y.z/lily/parser.yy) and
415 file(lilypond-x.y.z/lily/lexer.ll).)
416
417
418
419 sect(Chords)
420
421 Up till now we have only considered music that was rather simple.  All
422 the music had notes going in one direction, from left to right, one
423 note following the other.  You might be wondering if this is all Lily
424 can do, or whether it is possible to stack notes as well (creating
425 em(chords)).  Rest assured: we designed LilyPond while keeping in mind
426 that she must be able to handle any notation construct that can be
427 expressed conveniently.  Of course we did not leave out chords.
428
429 In Mudela you can form a chord of several notes by enclosing them in
430 pointed parentheses, bind(i.e.)bind(langle())bind(and)rangle().  ASCII
431 doesn't really have these delimiters, so Mudela uses the larger-than
432 (code(>)) and smaller-than (code(<)) signs instead.  For example, a
433 D-major nop(chord)footnote(Recall what was said in the previous
434 section about flats and sharps: the word code(fis) means an f sharp.)
435 can be described by the following fragment:
436 mudela(fragment,verbatim,center)(
437   <d'8  fis'8 a'8 d''8>
438 )
439
440   Chords can be entered in the music in the same places that notes
441 can.  As an example we give a snippet of ``Twinkle Twinkle Little
442 Star'' in chords.  The chords may seem, slightly unconventional, but they
443 only serve to show how chords work.  We've aligned the chords
444 in the input on their starting beat just to help you reading it.
445 This layout does not influence the typesetting result in any way.
446
447 mudela(verbatim, fragment)(
448   c''4             c''4              <c''4 g''4>       <c''4 e''4 g''4>
449   <c''4 e''4 a''4> <b'4 d''4 a''4>   <b'2 d''2 g''2>
450   <a'4 d''4 f''4>  <bes'4 d''4 f''4> <bes'4 c''4 e''4> <g'4 c''4 e''4>
451   <e'4 a'4 d''4>   <a4 g'4 cis''4>   <d'2 f'2 d''2>
452 )
453
454
455
456 sect(Shortcuts for duration)
457
458 If you typed the last example into a Mudela file, you will have
459 noticed that the input has lots of repetitions.  You will probably
460 have made some errors with the right durations and number of
461 octavation quotes.
462 To save keystrokes and prevent errors Mudela
463 has some handy shortcuts.  The simplest is the shortcut for
464 durations.  You don't have to type the duration if it
465 is the same as the last duration entered.  This saves a considerable
466 number of keystrokes, and thus reduces the potential for errors.  The
467 previous example can be reduced to verb(
468   c''4          c''            <c'' g''>        <c'' e'' g''>
469   <c'' e'' a''> <b' d'' a''>   <b'2 d'' g''>
470   <a'4 d'' f''> <bes' d'' f''> <bes' c'' e''> <g' c'' e''>
471   <e' a' d''>   <a g' cis''>   <d'2 f' d''>
472 )
473
474
475 If you entered this, you probably made some little errors with the
476 right amount of quotes as well.  To remedy this, mudela has another
477 feature called `relative octaves', which reduces the amount of quotes
478 needed.  If you want to enter large pieces of music em(now) we
479 recommend you make an excursion to
480 bind(Section)ref(sec:relativeoctaves) and learn about relative
481 octaves.
482
483
484
485 sect(Comments)
486
487 If you want to make some private notes about the Mudela code that you
488 entered, you can do so by inserting comments into your file.  The
489 contents of these comments are ignored by LilyPond.  Mudela has two  comment
490 styles: line comments and block comments.  The line comment
491 is introduced by the percent sign:
492 verb(
493   c''4
494   c''4   % shouldn't this be a different pitch?
495 )
496
497 Block comments are enclosed in code(%{) and code(%}).
498
499 verb(
500   c''4
501         %{
502         Ludwig van Bavaria's  original manuscript has an fffff dynamic sign.  
503         Clearly one can see the onset of paranoid schizophrenia in the
504         composer from these subtle nuances in his writings.
505         %}
506   c''4 
507 )
508
509
510 sect(Adding nuances: articulation and dynamics)
511
512 Having just chords and notes does not give you real music.  Real music
513 has more liveliness to it: music can have articulation, dynamics
514 (louder and softer), etc.  This liveliness has notation, so LilyPond
515 can print it.  We'll start out by explaining how to obtain the
516 smallest grains of nuance: the articulation of a single note.  Articulation
517 is entered by writing a dash and the name of the desired articulation
518 mark.  You have to add a backslash in front of the name to distinguish
519 it from the name of a note.  mudela(fragment,verbatim)(
520   c''4-\staccato
521   c''4-\tenuto )
522
523 Typing a lot of staccato notes in this syntax will get tedious very
524 quickly.  Therefore, Mudela has some handy abbreviations for
525 articulation marks such as staccato and tenuto.  They are shown in the
526 following example:
527
528 mudela()(
529 \score{ \melodic {
530         \property Voice.textstyle = typewriter
531         c''4-._"c''4-." s4
532         c''4--_"c''4--"  s4
533         c''4-+_"c''4-+" s4
534         c''4-|_"c''4-|" s4
535         c''4->_"c''4->"  s4
536         c''4-^_"c''4-\\^{ }"  s4 }
537         \paper { linewidth = 12.\cm; }})
538
539
540 COMMENT(For a full list of supported articulation instructions, refer to the
541 chapter on features, bind(Chapter)ref(features).)
542
543 Text and digits for fingering can be entered in the same manner: add a
544 dash and the text or digit to be printed:
545 mudela(fragment,verbatim)(
546   c''4-1 g''4-5 c''-"Sul tasto" )
547 Currently, the meaning of the
548 syntax `note-dash-digit/articulation/text' is just ``add a superscript to this
549 note.''  This is not in line with our goal to em(define) music with
550 Mudela.  We hope that this will be fixed in a future version of the
551 language.  In the meantime you can abuse this: the super- and
552 subscripts can be forced into up or down position respectively by entering an
553 a caret (code(^)) or an underscore, code(_) instead of the dash:
554 mudela(fragment,verbatim,center)(
555   c'4-^ c'4^^ c'''4-^ c'''4_^
556 )
557
558 Dynamic markings are another way to add a nuance to a note.  They are
559 entered by adding the name for the dynamic sign after the note.  You
560 should not enter a dash between the name and the note.footnote(This
561   is inconsistent.  We hope that this will be fixed in a later
562   version of the language.)
563 mudela(verbatim,fragment)(
564   c4 \ff c4 \fp c4 c4 \ppp c4 c4 \sfz
565 )
566 COMMENT(UGH)
567
568 sect(Bridging the notes: beams, slurs and ties)
569
570 Up till now most of the typesetting concerned simple fixed symbols
571 only.  Now we turn to variable symbols: symbols that run from one note
572 to another. In LilyPond terminology, such a symbol is called a
573 em(spanner).  To print a spanner, you have to attach a marker to the
574 note that begins it and to the one that ends it.
575
576
577 The first example of such a symbol is the slur.  For the slur, the
578 start marker is the opening parenthesis. It won't be a surprise that
579 the stopping marker is the closing parenthesis.
580 For example:
581 mudela(fragment,center,verbatim)( c'4( )c'4 )
582
583 otice that the parentheses should be between the notes.footnote(The
584 location of the parentheses might be changed in a future version of
585 the language.)
586
587 It is your job to make sure that each slur that you start also ends.
588 If it doesn't end, then Bad Things are likely to happen.  The slur is
589 quite flexible: you can nest nop(slurs,)footnote(This is inconsistent when
590 compared to the syntax for articulation hints.  This will probably be
591 fixed soon.) and you can connect a note with a slur on both the left and the
592 right side:
593
594 mudela(fragment,verbatim,center)(
595   c'4((   )c''4 )c'4( )g'4 
596 )
597
598 Another spanner is the beam (see bind(Figure)ref(mud:beam)).  It
599 indicates the duration of the connected notes, and thus it acts like an
600 extended version of the flag.  Secondly, the pattern of
601 left/right-pointing beams hints at the metric structure of the
602 measure.
603
604
605 latexcommand(\begin{figure}[h])
606   center(
607     mudela(fragment)([c'8 c'8] [c'16 c'16 c'16 c'16] [c'16. c'32 c'32 c'16.] )
608     latexcommand(\caption{Some beams})
609     label(mud:beam)
610   )
611 latexcommand(\end{figure})
612
613
614 Strictly speaking, a beam is not a musical concept.  The pattern of a
615 beam can be derived from the structure of the time signature and the durations
616 of the notes. It is merely a device that helps you understand the
617 rhythms notated. Unfortunately, LilyPond is not smart enough to insert
618 beams into your music on her own. You will have to instruct her by
619 marking the starting and stopping point of the beam with `code([)' and
620 `code(])' respectively, e.g.
621
622 mudela(fragment,verbatim,center)(
623   [g'8 g'8]
624 )
625
626 LilyPond has code that guesses what the pattern should look like, so
627 that you don't have to specify the beaming for complicated
628 patterns.footnote(Unfortunately the algorithm used is not foolproof yet:
629   code([c8. c32 c32]) will produce incorrect results.)
630
631 Again, it is your responsibility to make sure that you end every beam
632 that you start.
633
634 A third spanner is similar to the slur: the tie.  The tie looks like a
635 slur, but a slur connects whole chords, whereas the tie connects
636 note heads.  Tied notes should be played as one long note.
637 In analogy with TeX()'s tie (which  ties together words with a
638 space), LilyPond's tie is entered as a tilde, ~.  
639 mudela(verbatim,center,fragment)(c''1 ~ c''4)
640
641 The input convention for the tilde is somewhat peculiar when used in
642 conjunction with chords.  Internally, the extra information that is
643 represented by the tilde has to be attached to a note (or to a rest,
644 for that matter).  For this reason, you can't put the tilde between
645 two chords (as in code( <c' g'> ~ <c' g'>)).  The tilde sign must be
646 directly after a note of the chords.  It does not matter which
647 one. The following example demonstrates this:
648 mudela(fragment,verbatim,center)(
649   <c'1 ~  g' es''> <c'4 g' es''> 
650 )
651
652 sect(Commands)
653 label(sec:commands)
654
655 Up till now, we only printed notes, and correspondingly only entered
656 notes. But notation contains many other constructs, constructs that
657 help you with reading those notes.  Examples of such constructs are
658 clefs, time signatures, keys etc.
659
660 If you look carefully at the example in
661 bind(Figure)ref(fig:twinkle1), you will notice that the output
662 includes some bar lines and clefs, and that there are no references to
663 those in the input.  They were generated automatically.
664
665 Not all such hints can be inserted automatically, and you can also
666 override some of the settings.  This can be done by inserting various
667 commands between the music.  The general form of these commands is
668 center(
669   em(keyword) sc(arguments)
670 )
671
672 em(keyword)s are words that have a special meaning to the parser of
673 Mudela.  Because the parser must be able to distinguish the keywords
674 from note names, they have to be preceded by a so-called escape
675 character, the backslash, `code(\)'.  To separate the arguments from
676 any notes that might follow the arguments, you have to end your
677 command with a semicolon.  An added benefit of this construction is
678 that the commands stand out between your notes, because of the
679 backslashes.
680
681 So the general form actually is `code(\keyword argument argument ... ;)'
682 Let us review these commands:
683
684 description(
685 dit(code(\clef) var(clefname)) This command sets the current clef for notation,
686   i.e., a clef symbol is printed and the notes following this command
687   are shifted vertically.  The argument is a string, the name of the
688   new clef. The default clef is the treble clef.
689   mudela(fragment,verbatim)(
690     \clef "bass"; c'4
691     \clef "treble"; c'4
692     \clef "alto"; c'4    
693   )
694 dit(code(\key) var(pitch)) This command changes the current key signature.  The
695   key signature is printed at the start of every line.  The argument
696   is the name of the corresponding major key.  The key of C-minor can 
697   thus be specified as `code(\key es)'.
698   
699 dit(code(\accidentals) var(pitchlist))
700
701 This command changes the current key signature.  The signature is
702 given in the form of a list of accidentals, which can be useful for
703 unconventional keys.  The key of C-minor can be specified as
704 `code(\accidentals bes es as)'.   The command `code(\accidentals fis es
705 bis)' provides a more exotic example.
706
707
708 dit(code(\time) var(numerator)code(/)var(denominator))
709   This command chages the current time signature.  LilyPond uses the
710   time signature to
711   calculate where to place the bars that start a measure.  These bars
712   in turn are the places where a system can be broken into lines.
713
714   The default value for this time signature is common time (4/4).  You
715   can also tell this from the  Twinkle ``Twinkle Little
716 Star'' example in bind(Figure)ref(fig:twinkle1).  This
717 song actually has a 2/4 time signature, so a metrically more correct
718   version  would start with as follows:
719   mudela(fragment,center,verbatim)(
720     \time 2/4;  c'4 c'  g' g' 
721   )
722
723
724 dit(code(\cadenza) var(togglevalue)) When typesetting music without a
725 regular meter (such as an ad libitum cadenza), no bar lines should be
726 printed.  In LilyPond you can achieve this by issuing the command
727 `code(\cadenza 1)': it turns off the automatically
728 generated bar lines.
729
730 You switch them on again with `code(\cadenza 0)', and then a bar line
731 is printed.  LilyPond will act as if you are again at the start of a
732 measure.
733
734 dit(code(\bar) var(bartype))
735   This command lets you print special bar lines, such as repeats.  You
736   can also use it to allow line breaks when entering cadenzas.  The
737   argument var(bartype) is a string that describes what kind of bar line to print.
738
739 mudela(fragment,verbatim)(
740     \bar "|:"; c'4 \bar ":|:";    c'4  \bar ":|";  c'4 \bar "||";
741     c'4 \bar "empty"; c'4 \bar "|.";
742 )
743   The command `code(\bar "empty")' does not create any visible bar
744     line, but it does  tells LilyPond to allow a linebreak
745   at that position.
746   
747 dit(code(\partial) var(duration)) some music starts with a measure that
748 isn't fully filled, a so-called upstep.  The code(\partial) command
749 allows you to make
750 upsteps. The argument is a duration similar to the duration of a note.
751 Example:
752   mudela(fragment,verbatim)(
753     \time 4/4;
754     \partial 4;
755     [d'8 dis'] e' c''4 e'8 c''4 
756   )
757
758   dit(code(\grouping) var(durationslist)) sets the metric structure of the measure.
759     Its effect can best be shown by an example:
760     mudela(fragment,verbatim)(
761         \time 5/16;
762         \grouping 16*3 16*2;
763         [c'8 c'16 c'8]
764         \grouping 16*2 16*3;
765         [c'8 c'16 c'8]
766         \grouping 16*5 ;
767         [c'8 c'16 c'8]
768     )
769
770 In practice, you won't be needing this command very often: the
771 grouping is switched automatically when you issue a code(\time)
772 command.  It is set to a combination of groups
773 of 2 and 3 beats, with as many groups of
774 3 as possible (in other words: 4/4 is divided in two times two beats
775 (2+2), 8/8 in 3+3+2)
776 )
777
778 The commands that are described above aren't really music, but they
779 can be used in the same places as notes.  This makes the grammar of the
780 language simpler.  It is possible to put a command into a chord.
781 For example, the following two snippets of Mudela produce identical output.
782 verb(
783   <c4 e g \time 2/4;>
784   \time 2/4; <c4 e g>
785 )
786
787
788
789 sect(Complex music: more than one staff)
790 label(tutorial:more-staffs)
791
792
793 Now we explain how to typeset music that runs in multiple staffs.
794 Consider the following---somewhat unrealistic---example:
795
796 mudela(fragment)(
797  \type GrandStaff <e'4 {\clef bass; g4^""} >
798 )
799
800   The music consists of two notes.  Perhaps this is sheet music for a
801 piano player, and one note is meant to be played with the left hand,
802 and the other with the right hand.  That music would sound the same if
803 it were written as a single chord on a single staff, i.e.,
804 mudela(fragment)(
805   <g4 e'4>
806 )
807
808
809 This is another example where we can see that there can be a difference
810 between a musical idea, and the way it is expressed in notation.
811
812 The Mudela construct for multiple staffs reflects the similarity
813 between the two examples: to get multiple staffs in Mudela you enter a
814 chord, with an additional instruction to tell LilyPond that the chord
815 does not represent notes stacked together, but staffs stacked
816 together.
817
818 If a piece of music is to be interpreted as a staff, then this can be
819 expressed with the code(\type) construct.  The following input says
820 ``the quarter note with pitch e should be put on a staff.''
821
822 verb(
823   \type Staff e'4 
824 )
825
826 The same can be done for the other note, i.e.,
827
828 verb(
829   \type Staff g4 
830 )
831
832 If you want to stack these staffs, you must create a chord of both:
833
834 verb(
835   < \type Staff e'4
836     \type Staff g4 
837   >
838 )
839
840 This looks reasonable, but the effect of this input is not what you
841 might expect (try it!).  When interpreting this chord LilyPond will
842 start with the first entry.  She'll look for a (nameless) staff.  Such a
843 staff is not found, so it is created.  On this staff the code(e) note
844 is put.  When the second code(\type) entry is read, LilyPond will
845 start looking for a nameless staff.   The  staff that contains  the
846 code(e) is found, and the code(g) is put there as well.
847
848 The correct solution is to label both code(\type) constructs with
849 different names, for example code(trebleStaff) and code(bassStaff).
850 This makes LilyPond distinguish between them, and create two staffs:
851
852 mudela(verbatim,fragment)(
853   < \type Staff = trebleStaff e'4
854     \type Staff = bassStaff  g4 
855   >
856 )
857
858 The names that you choose do not matter just as long as they are
859 different.  This is almost right, except for the brace at the left and
860 the clef of the second staff.  The bass clef will be taken care of in
861 the next chapter. If you want a brace, then you have to tell LilyPond
862 that the chord you just formed is to be interpreted as a so-called
863 grand staff.  This is also done with the code(\type) command.
864 mudela(verbatim,fragment)(
865   \type GrandStaff <
866      \type Staff = treblestaff  e'4 
867      \type Staff = bassstaff  g4 
868   >
869 )
870
871 sect(Appending instead of stacking: sequential music)
872 label(tutorial:voice)
873
874 The previous section dealt with a pretty hypothetical situation: sheet
875 music with two staffs and each staff containing only one single note.
876 In real-life situations staffs contain more than one note.  They
877 contain music that has to be played in sequence.  A staff can contain
878 a em(voice).  We haven't learned  how to make a voice yet: we need a
879 new construct to express this notion of `voice'.
880
881 The construct is called em(sequential) music.  A list of musical
882 objects (e.g., notes, chords or commands) can be made into sequential
883 music by enclosing the list in braces; for example:
884
885 mudela(fragment,verbatim,center)(
886   { c'4 c'4 }
887 )
888 mudela(fragment,verbatim,center)(
889   { <c'4 e'> <e' g'> }
890 )
891
892
893 We could have called this construct more colloquially `voice', but
894 this would cause confusion later on, when a second kind of voice
895 enters the scene.  Similar confusion might arise from the word
896 `chord', therefore from now on, we will talk about `simultaneous
897 music', when we refer to items enclosed in < and >.
898
899
900 The notion of a em(new) construct needs some explanation: we have been
901 using sequential music all the time, except that it was hidden in the
902 red tape in bind(Section)ref(tutorial:introduction).
903
904
905
906 If we want to put whole voices onto a staff, then we have to
907 substitute sequential music for the single notes in the example from
908 the previous section.  A code(\clef) command in the second piece of
909 sequential
910 music  will also set the clef in
911 the bass staff.
912 mudela(fragment,verbatim)(
913     \type GrandStaff <
914      \type Staff = treblestaff  { e'4 f'}
915      \type Staff = bassstaff  {\clef "bass"; g a }
916   >
917 )
918
919 COMMENT(You can nest simultaneous music and chords in any way you want.  If
920 you are interested in the entire story, you should consult
921 bind(Chapter)ref(chap:features), which has a grammar in
922 bind(Section)ref(sec:grammar).)
923
924 sect(Notation context)
925
926 This section is about translation contexts, a topic of LilyPond that
927 is somewhat advanced.  You don't have to understand this to use
928 LilyPond to print simple music.  If you don't want to typeset fancy
929 polyphonic music or tweak the LilyPond notation engine, you can skip
930 the next two sections.
931
932 In bind(Section)ref(tutorial:more-staffs) it was explained, that there
933 are more ways to notate a simple chord: as a single voice on a single
934 staff or in multiple staffs (and we'll soon see, that you can typeset
935 it as multiple voices on a  staff).  Obviously the concept of staff is not
936 really something musical.  But what is it then?
937
938
939 The most simplistic explanation is: a staff is a peculiarity of the
940 notation system.  In other words, a staff is a graphic device, a
941 special picture of five lines on which one can print note heads.  To
942 avoid confusion, we will call this view on the concept of staff
943 `staff symbol' from now on.
944
945
946 There is more to it than meets the eye and mind.  A staff
947 contains---besides a staff symbol--- some more components:
948 itemize(
949 it()A staff can a have a key signature (printed at the left)
950 it()A staff has bar lines
951 it()A staff has a clef (printed at the left)
952 )
953 To explain what a staff really is,   we'll try to print music without
954 these components.  If these components aren't printed, it is still
955 possible to print music:
956 mudela()(\score{
957 \melodic \relative c' {  \time 2/4; g'4 c,4 a'4 f4 e c d2 }
958 \paper { 
959   linewidth = -1.;
960   Staff = \translator {
961     \type "Line_group_engraver_group";
962
963     defaultclef = violin;
964
965     \consists "Timing_engraver";
966     \consists "Separating_line_group_engraver";
967
968     \accepts "Voice";
969   }
970  }
971 })
972
973 As you can see, one can still make out the general form of the melody
974 and the rhythm that is to be played, but the notation is difficult to
975 read and the musical information is not complete.  The stress pattern
976 in the notes can't be deduced from this output.  For this, we need a
977 time signature:
978
979 mudela()(
980 \score {
981   \melodic \relative c' {  \time 2/4; g'4 c,4 a'4 f4 e c d2 }
982   \paper{
983   linewidth = -1.;
984     Staff = \translator {
985     \type "Line_group_engraver_group";
986     defaultclef = violin;
987     \consists "Time_signature_engraver";
988     \consists "Separating_line_group_engraver";
989     \accepts "Voice";
990   }
991  }
992 })
993
994 Technically speaking you know where the strong and weak beats are, but
995 it is difficult to find them quickly.   Bar lines  help you in finding
996 the location within the measure of the notes:
997 mudela()(
998 \score {
999   \melodic \relative c' {  \time 2/4; g'4 c,4 a'4 f4 e c d2 }
1000   \paper{
1001   linewidth = -1.;
1002     Staff = \translator {
1003     \type "Line_group_engraver_group";
1004     defaultclef = violin;
1005     \consists "Bar_engraver";
1006     \consists "Time_signature_engraver";
1007     \consists "Separating_line_group_engraver";
1008     \accepts "Voice";
1009   }
1010  }
1011 })
1012
1013 We can remedy part of the difficulties with reading pitches by adding a staff
1014 symbol:
1015
1016 mudela()(\score{
1017   \melodic\relative c' { \time 2/4; g'4 c,4
1018 a'4 f4 e c d2 } \paper {
1019   linewidth = -1.;
1020   Staff = \translator {
1021     \type "Line_group_engraver_group";
1022
1023     defaultclef = violin;
1024     \consists "Bar_engraver";
1025     \consists "Time_signature_engraver";
1026     \consists "Staff_sym_engraver";
1027     \consists "Separating_line_group_engraver";
1028
1029     \accepts "Voice";
1030   }
1031  }
1032 })
1033
1034 This makes the output decidedly easier to read, but you still don't
1035 know what the pitches of the notes above are.  So this is still not
1036 enough.  But suppose you see the following notation:
1037 mudela()(\score {
1038   \melodic \relative c' {\clef alto;  \time 2/4; g'4 c,4 a'4 f4 e c d2 }
1039 \paper {
1040   linewidth = -1.;
1041   Staff = \translator {
1042     \type "Line_group_engraver_group";
1043
1044      defaultclef = violin;
1045     \consists "Bar_engraver";
1046     \consists "Time_signature_engraver";
1047      \consists "Clef_engraver";
1048      \consists "Staff_sym_engraver";
1049      \consists "Timing_engraver";
1050      \consists "Separating_line_group_engraver";
1051
1052     \accepts "Voice";
1053   }
1054  }
1055 })
1056
1057 Now you know the pitch of the notes: you look at the start of the line
1058 and see a clef, with this clef, you can determine the notated pitches.
1059 You have found the em(context) in which the notation is to be
1060 interpreted!
1061
1062 So the context determines the relationship between a piece of music
1063 and its notation: you, the reader, use context to deduce music from
1064 notation.  Because LilyPond is a notation ``writer'' instead of a
1065 reader, context works the other way around for Lily: with context a
1066 piece of music can be converted to notation.
1067 The components of a staff form context, and context is needed to read
1068 and write notation.  This motivates the following definition.
1069
1070 quote(
1071 A bf(notation context) is  a conversion from music to notation.
1072 )
1073
1074 The example focused mainly on on staffs, but a staff is not the only
1075 type of notation context.  Notation contexts may be nested: you can
1076 print polyphonic music by putting multiple `Voice' contexts in one
1077 `Staff' context.  The arguments of the code(\type) command (Staff,
1078 GrandStaff) were in fact all names of different contexts.
1079 The notions of ``current clef'' and ``current position within the
1080 measure'' are all properties of notation contexts.  Commands like
1081 code(\clef) and code(\cadenza) change these properties.  
1082
1083
1084 The following is a list of the contexts that are supported by
1085 LilyPond:
1086 description(
1087
1088 dit(Voice) The code(Voice) context is a context that corresponds to a
1089   voice on a staff.  This context handles the conversion of noteheads,
1090   dynamic signs, stems, beams, super- and subscripts, slurs, ties and rests
1091
1092 dit(Staff) The code(Staff) context handles clefs, bar lines, keys,
1093   accidentals.  A code(Staff) context can contain multiple code(Voice)
1094   contexts.
1095
1096 dit(RhythmicStaff) The code(RhythmicStaff) context is like the staff,
1097   but much simpler: the notes are printed on one line, and pitches are
1098   ignored.  code(RhythmicStaff) can contain code(Voice) contexts.
1099
1100 dit(GrandStaff) A code(GrandStaff) context contains code(Staff)
1101   contexts, and it adds a brace to the output at the
1102   nop(left.)footnote(This is a major deficiency in the current
1103   implementation.    Currently stems,
1104   slurs and beams cannot be printed across two staffs.
1105 In reality, a grand staff is  a hybrid of one big staff and two stacked staffs.)
1106   
1107   A code(GrandStaff) context can contain multiple
1108   code(Staff)s. Typically, it will contain two code(Staff)s, one
1109   treble staff, and one bass staff. The bar lines of the contained
1110   staffs are connected vertically.
1111
1112 dit(StaffGroup) A code(StaffGroup) context contains code(Staff) or
1113   code(Lyrics) contexts, and prints a bracket at the left.  The bar
1114   lines in the participating staffs are connected.
1115
1116 dit(Lyrics) As its name suggests, The code(Lyrics) context deals with
1117   typesetting lyrics.  This topic will be covered in
1118   bind(Section)ref(tutorial:lyrics).
1119   
1120 dit(Score) The code(Score) context is the toplevel context: no context can
1121   contain a code(Score) context.  The code(Score) context handles the
1122   administration of time signatures.  It also makes sure that items
1123   such as clefs, time signatures, and key-signatures are aligned across staffs.
1124   
1125   The code(Score) can contain code(Staff), code(StaffGroup), code(Lyrics), code(GrandStaff) and
1126   code(RhythmicStaff) contexts.
1127
1128 COMMENT(do ChoireStaff)
1129 )
1130
1131
1132   Later on, in bind(Section)ref(tutorial:engravers) we will
1133 explain how you can create your own contexts.
1134
1135 If you are familiar with structured documents (like HTML, SGML or
1136 LaTeX()), you might see the analogy of a context with a stylesheet: a
1137 stylesheet is neither presentation nor information, but rather a
1138 recipe em(how) a specific piece of information should be presented.
1139 Analogously, a notation context is neither music nor notation, but the
1140 conversion between the two.  The big difference with text is that in
1141 music notation the elements provided by context are essential to
1142 understanding what is notated.
1143
1144
1145
1146 sect(Polyphonic music (or: Notation context properties))
1147
1148 In the last section we explained that a notation context can have
1149 properties that influence the conversion from music to notation.  A
1150 simple example of such a property is the clef: the type of clef partially
1151 determines the vertical position of note heads in a staff.  Some of
1152 these properties can be modified by commands such as code(\clef) and
1153 code(\time).   But there is more:  notation contexts  also have
1154 properties are settable in a generic fashion.  We will demonstrate
1155 this feature by printing multiple voices on a staff.
1156
1157 In polyphonic (keyboard) music and orchestral scores often more than
1158 one voice is printed on one staff.  We'll explain how to achieve this
1159 effect with LilyPond.  The effect is not unlike the two stacked staffs
1160 from bind(Section)ref(tutorial:more-staffs), except that we don't want
1161 to stack staffs but voices.  Thus,  the general template is the following:
1162 verb(
1163   \type Staff <
1164     \type Voice = one  ...
1165     \type Voice = two  ...
1166   >
1167 )
1168
1169 On the ellipsis there should be music going from left to right, in
1170 otherr words, there should be sequential music, notes enclosed in
1171 braces.  Let us try the following simple melodies:
1172
1173 mudela(fragment,verbatim)(
1174 \type "Staff" <
1175   \type "Voice" = "one" { r4 as'4 () as'4 g'4 }
1176   \type "Voice" = "two" { g'2 f'4 e'4 }
1177 >)
1178
1179 As you can see the result is not quite perfect.  The notes on the last
1180 two beats look like plain chords and not like separate voices.  What
1181 really happened was that the stems of the upper and lower voices were
1182 printed on top of each other.  If you have tried running this example, you will probably
1183 have noticed a complaint  about ``too many
1184 clashing notecolumns''  during the LilyPond run.
1185 This complaint refers to the overlapping stems.
1186
1187 To remedy this, engravers traditionally make the stems of the upper
1188 and lower voice point in different directions: the stems of the lower
1189 voice point down, and the stems of the upper up, as shown in
1190 bind(Figure)ref(tutorial:multi-voice-fig).
1191
1192 Surely the direction of a single stem is a property of the stem as a
1193 graphical object.  But the fact that all of the stems in a voice point
1194 in the same direction is not directly graphical.  Since this is a
1195 property shared by all the stems in the voice, it is logical to
1196 consider this property to be a property of the context code(Voice).
1197 And this is how it's done in LilyPond: the context code(Voice) has an
1198 attribute whose value is the direction to use
1199 for stems.  You can change it to `up'
1200 by issuing the following phrase:footnote(The name code(ydirection) is
1201 no mistake.  The property also controls the up/down directions of
1202 super-/subscripts, slurs, ties, etc.)
1203
1204 verb(
1205   \property "Voice"."ydirection" = "1"
1206 )
1207
1208 This command should be read as ``change the property called
1209 code(ydirection) within the current code(Voice) context to the value
1210 code(-1).''  For the property code(ydirection) the value code(1) means
1211 `up', and code(-1) means `down'.   The proper way to code the
1212 polyphonic example is given in bind(Figure)ref(tutorial:multi-voice-fig).
1213
1214 latexcommand(\begin{figure}[h])
1215 mudela(fragment,verbatim,center)(
1216   \type "Staff" <
1217     \type "Voice" =  "one"  {
1218       \property Voice.ydirection = "1"
1219       r4 as'4 () as'4 g'4 }
1220     \type "Voice" =  "two"  {
1221       \property Voice.ydirection = "-1"
1222       g'2 f'4 e'4 }
1223   >
1224 )
1225     latexcommand(\caption{multiple voices})
1226     label(tutorial:multi-voice-fig)
1227 latexcommand(\end{figure})
1228
1229 Other properties can also be set, and they can be within different
1230 contexts.  In general, you can set a property by specifying
1231 code(\property) var(contexttype)code(.)var(propertyname) code(=)
1232 var(value).  Both var(ContextType), var(PropertyName) and var(Value)
1233 should be strings.
1234
1235 The effect of a property is pretty much hardwired into the
1236 implementation (and thus subject to change), so we will not deal with
1237 all the possible properties in detail. Among other characteristics that
1238 can be set are the layout of slurs and beams.  The initialisation file
1239 file(property.ly) explains most properties.
1240
1241 We conclude this section with another example of a context property.
1242 Polyphonic music that has three or four voices can't be printed by
1243 simply changing the directions of the stems for each voice, obviously.
1244 Traditionally, some chords are shifted horizontally to print if this many
1245 voices have to be printed.
1246 LilyPond can also do this, and the property that controls the
1247 horizontal shifting is called code(hshift).  The notes in a
1248 code(Voice) context that has code(hshift) set to a true value (i.e.,
1249 non-zero or non-empty), will be shifted horizontally in the case of a
1250 collision.  The following example demonstrates the effect.
1251
1252 mudela(fragment,verbatim)(
1253   \type "Staff" <
1254     \type "Voice" =  "one"  {
1255       \property Voice.ydirection = "1"
1256       r4 as'4 () as'4 g'4 }
1257     \type "Voice" =  "two"  {
1258       \property Voice.ydirection = "1"
1259       \property Voice.hshift = 1
1260       g'2 f'4 e'4 }
1261     \type "Voice" = "three" {
1262       \property Voice.ydirection = "-1"
1263       [d'8 dis'] [d' cis'] [c' b] c'4
1264     }
1265   >
1266 )
1267
1268 sect(Lyrics)
1269 label(tutorial:lyrics)
1270
1271 Now for something completely different: Lyrics.  Lyrics are also
1272 considered to be music, although a lyric by itself does not have any
1273 pitch.  Producing lyrics has two aspects. First, you have to enter the
1274 text, i.e., the syllables along with their durations.  
1275 After this, you have to specify how to convert these to graphics.
1276
1277 Lyrics consist of syllables, which are strings together with
1278 durations.  Previously we only entered note names, so for entering
1279 lyrics we have to instruct LilyPond that what we enter are not note
1280 names but words---or rather: strings.  This instruction is the keyword
1281 code(\lyric).  After entering this keyword you can enter a musical
1282 construct---sequential music, simultaneous music, code(\type)
1283 entries, etc.--- but with syllables in stead of pitches.  For example:
1284 verb( \lyric { 'got8 me on my knees4, Le-8 lie! })
1285
1286 The effect of code(\lyric) can be compared with the effect of the
1287 doublequote character, code("), for it also changes the lexical
1288 meaning of spaces and characters.  This mode is another example of a
1289 handy input feature of the language.
1290
1291 Next comes the conversion to notation.  LilyPond can't (yet) figure
1292 out that lyrics need different treatment than notes.  As a result, the
1293 default conversion will try to put the text you entered as note heads
1294 onto a staff, and this will fail.  This default must be overriden with
1295 a code(\type) keyword.  Printing syllables of text in a line is done
1296 by a context called code(Lyrics).  You can select this context with
1297 the code(\type) keyword.  Here is a simple example:
1298
1299 mudela(fragment,verbatim)(
1300         \type Lyrics \lyric { 'got8 me on my knees,4 Le-8 lie! })
1301
1302 The result is technically more or less correct, but without a melody it
1303 just doesn't work, so let's add a blob of cream:
1304 mudela(fragment,verbatim)(
1305   <
1306     \type Staff  { c''8. c''16 bes'8. a'16 g'4 f'8 g'4. }
1307     \type Lyrics \lyric { 'got8. me16 on8. my16 knees,4 Le-8 lie!4. }
1308   >
1309 )
1310
1311 The strings that makes up each syllable in the lyrics block are passed
1312 along to TeX() verbatim, so if you are proficient with TeX() you can
1313 do various nifty things.  Just keep in mind that a syllable either
1314 starts with a letter (a character in the range `code(a)' to `code(z)'
1315 or `code(A)' to `code(Z)'), or it is a string enclosed quotes. It ends
1316 with either a number for the duration, or a space.  A last feature
1317 that should be mentioned is the space-lyric: if you want to enter
1318 a single ``syllable'' that consists of multiple words, i.e., words
1319 separated by  spaces, you should use an
1320 underscore instead of a space.  All these tricks are demonstrated in
1321 the following example:
1322
1323 COMMENT( urg
1324 \type Lyrics \lyric { 'got_m\textbf{e}4 on8. m$\cal_Y$16 knees,4 Le-8 lie!4.}
1325 \type Lyrics \lyric { 'got_m{\bf e}4 on8. m$\cal_Y$16 knees,4 Le-8 lie!4.}
1326 )
1327
1328 mudela(fragment,verbatim)(<
1329   \type Staff  { c''8. c''16 bes'8. a'16 g'4 f'8 g'4. }
1330   \type Lyrics \lyric { 'got_me4 on8. m$\cal_Y$16 "3s,"4 Le-8 lie!4.}
1331 >
1332 )
1333
1334 The spacing in the above example is a bit skewed because Lily can't
1335 tell that the long syllables you entered are not ordinary characters,
1336 but expand to really small symbols.
1337
1338
1339
1340
1341 COMMENT(Rood is de kleur van geluk.)
1342 COMMENT(Dat geldt ook voor haar.)
1343
1344
1345 sect(Toplevel Mudela)
1346
1347 Now the time has come to unravel the red tape that we have hidden from
1348 you in the introduction.  Mudela has a hierarchical structure for we
1349 have seen that sequential and simultaneous music can be nested.
1350 Mudela also has other `blocks' that can be nested.  The general syntax
1351 for a block is code(\keyword { ... }).
1352
1353 When you run LilyPond, what happens is that you define music, and
1354 specify one (or more) conversions to apply to that music, for example
1355 a conversion to notation.  This is done by putting the definition of
1356 the music and the definition of the conversion together in a
1357 code(\score) block, e.g.,
1358 verb(
1359 \score {
1360         % ... music ...
1361         \paper {}
1362 })
1363
1364 This is almost  the context that should be around all
1365 of the previous examples.  The precise context reads thus:
1366 verb(
1367 \score {
1368         \melodic { ... }
1369         \paper {}
1370 })
1371 On the ellipsis, you entered what shown as the example input.
1372 You can see that in the
1373 above example, the code(\melodic { ... }) forms the music, the
1374 code(\paper {}) is a conversion to paper (notation, that is).  The
1375 code(\paper) definition is copied from a default definition
1376 (which is in the initialisation file file(paper16.ly)).
1377 The paper part also contains
1378 the definition of the contexts.
1379
1380 The keyword code(\melodic) is analogous to the code(\lyric) keyword.  It
1381 will switch the tokenizer into a mode that interprets plain words as
1382 note names.  If it can't recognize the words as a note name, it will
1383 assume that they are strings.  That is the reason why you can write
1384 code(\clef bass) in stead of code(\clef "bass"); most of the strings
1385 in code(\melodic) mode can be written without quotes.
1386
1387 The braces that you see after the code(\melodic) keyword are the
1388 braces that are around sequential music.  Because of these braces, the
1389 sequences of notes in our simple examples were sequential (and not
1390 simultaneous).  As a result the notes were printed from left to right,
1391 and not stacked.
1392
1393 sect(Identifiers)
1394
1395
1396 Now that we are comfortable with the toplevel entries in a mudela
1397 file, we can investigate some more of the recreations on toplevel, in
1398 particular em(identifiers).  Generally you can define an identifier by
1399 entering code(identifierName = ... )
1400 where there can be a variety of things on the ellipsis.
1401
1402 Here is a (partial) list of what you can abbreviate with identifiers
1403 at top-level.
1404 itemize(
1405 it()The code(\score) block
1406 it()The code(\paper) block
1407 it()The code(\midi) block (to be explained in
1408   bind(Section)ref(tutorial:sound))
1409 it()Music (sequential music, simultaneous music etc.)
1410 it()Durations
1411 it()Strings
1412 it()Translators (to be explained in bind(Section)ref(tutorial:engravers))
1413 it()Integers
1414 it()Reals  
1415 )
1416
1417 When you refer
1418 to the abbreviated entity, you must precede code(identifierName)
1419 with a backslash, i.e., code(\identifierName).  For example:
1420 mudela(verbatim)(
1421   czerny = \melodic { [c16 g e g] }
1422   \score {
1423     \melodic \type GrandStaff <
1424       { c''2 g''2 }
1425       { \clef bass; \czerny \czerny \czerny \czerny}
1426     >
1427     \paper {
1428       linewidth = -1.0;
1429       stem_length = 12.0*\internote;
1430     }
1431   }
1432 )
1433
1434
1435
1436 Another interesting feature of this example are the assignments within
1437 the paper block.  Some blocks, such as code(\paper), have a scope of
1438 their own.  In the case of the code(\paper) block, these variables
1439 influence the characteristics of the output.  As is shown, you can
1440 tune quantities like the stemlength, and enter simple expressions.
1441 The purpose of the negative linewidth is to prevent the music from
1442 being justified.  The identifiers that are meaningful are for the
1443 paper block is strongly implementation dependent, so they will not be
1444 listed here.  Moreover, since most of the values are predefined to
1445 sensible defaults, there usually is no need to tune these values.
1446
1447 Recall the properties of a context, that could be set with
1448 code(\property).  It is a very general mechanism to tune the output of
1449 the music, that is neatly separated from the real music.
1450 Unfortunately, it is not convenient to type or read, and the precise
1451 effect of a setting property isn't always apparent from its
1452 definition.  To remedy this, we can use an identifier to capture the
1453 meaning of a code(\property).
1454
1455 mudela(verbatim)(
1456 stemup = \property Voice.ydirection = "1"
1457 stemdown = \property Voice.ydirection = "-1"
1458 shift = \property Voice.hshift = "1"
1459 \score {
1460   \type "Staff" \melodic <
1461     \type "Voice" =  "one"  {
1462       \stemup
1463       r4 as'4 () as'4 g'4 }
1464     \type "Voice" =  "two"  {
1465       \stemup
1466       \shift
1467       g'2 f'4 e'4 }
1468     \type "Voice" = "three" {
1469       \stemdown
1470       [d'8 dis'] [d' cis'] [c' b] c'4
1471     }
1472   >
1473   \paper{  linewidth = -1.0\pt; }
1474 }
1475 )
1476
1477 Several abbreviations like code(\stemup) are defined in the
1478 standard initialisation file file(property.ly).  Setting or changing
1479 context properties can have a similar effect as the commands that were
1480 discussed in bind(Section)ref(sec:commands).  Don't be fooled by the
1481 similarity in appearance between a declared property-setting entry
1482 and a real command.  Real commands are hardcoded into the language
1483 and they have to be terminated by semicolons.
1484
1485 You can also use identifiers to break up the heavy nesting that can occur
1486 in the code(\score) block.  Another useful application is
1487 parametrisation of the music: if you use identifiers in the
1488 code(\score) block, you can make variations of the music by simply
1489 redefining those identifiers.  One particular application of this is
1490 part extraction: by using identifiers and redefining them, one can
1491 print extracted parts and a full orchestral score from the same
1492 music definition.
1493
1494
1495
1496 sect(Sound output)
1497 label(tutorial:sound)
1498
1499 You get output by combining music with definition a conversion to
1500 output.  Up till now we have only focused on the graphic output of
1501 traditional engraving.  But there is no reason why that should be the
1502 only form of output for music.  LilyPond currently supports one other
1503 conversion: the conversion from abstract music to sound. You can have
1504 LilyPond play the music that you entered.  The format that is used
1505 for this output is MIDI.  
1506
1507 The only information that you need to enter is the
1508  nop(tempo)footnote(Unfortunately,
1509 this the only thing that can be tuned at this
1510 time.  This is a limitation: the tempo of music can vary throughout
1511 the music.) for the performance.  The syntax for the tempo is
1512 code(\tempo )var(duration) = var(beatsperminute);), for example:
1513 verb(
1514 \score {
1515    ...music...
1516    \midi { \tempo 4 = 76; }
1517 }
1518 )
1519
1520 The most useful purpose of this sound output is to prooflisten your
1521 files: typing errors (especially if they involve accidentals)  stand
1522 out when you listen.
1523 The output was implemented in a very rudimentary manner, so it is
1524 probably not worth listening to for any other reason.
1525
1526
1527 sect(Contexts revisited: engravers)
1528 label(tutorial:engravers)
1529
1530 As was promised, we will now take a dive into the more wizardrous parts
1531 of LilyPond: redefining (notation) contexts.  We previously explained
1532 that a context 
1533 itemize(
1534 it()is a conversion from music to notation,
1535 it()can contain other contexts
1536 it()handles specific notation constructs
1537 )
1538
1539 This characterization almost automatically explains what the definition of a
1540 context should look like:
1541 itemize(
1542 it()It should be part of the ``notation output definition,'' i.e., the
1543   code(\paper) block
1544 it()
1545   It should contain a specification of what other contexts may be contained
1546   in the context we're defining.
1547 it()
1548   It should contain a list of the notation constructs  to be
1549   handled.
1550 )
1551
1552 In practice, the context definition
1553 looks like this:
1554 verb(
1555 \translator
1556 {
1557         \type "Engraver_group_engraver";
1558         \accepts "...";
1559         \accepts "...";
1560         \accepts "...";
1561
1562         \consists " ... ";
1563         \consists " ... ";
1564         \consists " ... ";
1565
1566         propertyname = "value";
1567         propertyname = "value";
1568
1569 } )
1570
1571   This is encoded by the 
1572
1573 The code(\translator) keyword opens the block for translation (or
1574 context) definition.  The code(\type) keyword explains to Lily that
1575 the context should be formed by taking an (empty) instance of
1576 code(Engraver_group_engraver).  The code(Engraver_group_engraver) is a
1577 C++ class from the source code to Lily.  The code(\accepts) entries
1578 explain what kind of contexts this context could contain.  If we were
1579 to define a context for a staff, the definition would typically
1580 contain code(\accepts "Voice";).
1581
1582 The code(\consists) entries specify which notation constructs should
1583 be handled. This needs a little explanation: LilyPond contains the
1584 code for quite a large number of basic building blocks for notation
1585 generation, and each building block handles only one notation
1586 construct.  The name of such a building block is `engraver'.  You can
1587 specify which notation construct a context should handle by specifying
1588 which engravers should be part of the context.  The code(\consists
1589 "Foobar") entry really means ``add an instance of code(Foobar) to the
1590 translation group.''
1591
1592
1593 For example if this context should print time signatures, the definition
1594 should include `code(\consists "Time_signature_engraver";)'.  Again
1595 code(Time_signature_engraver) is a class from the source code of LilyPond.
1596
1597
1598
1599 Finally, one can pre-set some properties in a context definition.
1600
1601 As a practical example, we will show you how to typeset polymetric
1602 music, i.e., music where the meter can differ for each staff.  The
1603 solution is not very complicated: normally all timing information
1604 (time signature, rhythmic grouping) is synchronised across each staff.  In
1605 LilyPond this is expressed by having only one registration for timing
1606 information for all staffs.  To be precise, there is only one
1607 code(Timing_engraver), and it is located in the top level context, the
1608 code(Score) context.
1609
1610 All staffs use the information in the global code(Timing_engraver)
1611 for generating bar lines and time signatures.  In polymetric music, this timing
1612 information can be different for every staff, so we should redefine
1613 the code(Staff) context to include and the code(Score) context to exclude the
1614 code(Timing_engraver).  
1615
1616 mudela(verbatim)(
1617 polymetricpaper = \paper {
1618   Score = \translator {
1619     \type Score_engraver;
1620     \consists "Score_priority_engraver";
1621     \consists "Priority_horizontal_align_engraver";
1622     \consists "Vertical_align_engraver";
1623     % \consists "Timing_engraver"; % removed Timing_engraver
1624     \accepts "Staff";
1625   }
1626
1627   Staff = \translator {
1628     \type "Line_group_engraver_group";
1629
1630     defaultclef = violin;
1631
1632     \consists "Bar_engraver";
1633     \consists "Clef_engraver";
1634     \consists "Key_engraver";
1635     \consists "Local_key_engraver";
1636     \consists "Time_signature_engraver";
1637     \consists "Timing_engraver";  % added Timing_engraver
1638     \consists "Staff_sym_engraver";
1639     \consists "Separating_line_group_engraver";
1640
1641     \accepts "Voice";
1642   }
1643 }
1644 \score {
1645   \melodic <
1646     \type Staff = one { \time 2/4; c'4 c'4 c'4 c'4 c'4 c'4 }
1647     \type Staff = two { \time 3/4; c'4 c'4 c'4 c'4 c'4 c'4 }
1648   >
1649   \paper { \polymetricpaper
1650     linewidth = -1.;
1651   }
1652 }
1653 )
1654
1655 As you can see, we used the identifier code(polymetricpaper) to break
1656 up the large score block.  More of these context definitions appear in
1657 the standard initialisation file file(engraver.ly).
1658
1659 sect(Urtexts and context selection)
1660 label(tutorial:urtext)
1661
1662 In bind(Section)ref(tutorial:more-staffs), we have shown you how to make
1663 multiple staffs, and explained that you have to label every staff (or
1664 more precisely: different contexts), to make sure that new ones are
1665 created when you need them.  In this section, the real power of this
1666 mechanism will unveiled.
1667
1668 By naming other contexts that you create, you can reference other contexts
1669 than the current context from within the music.  For example, from within the music that you
1670 enter for staff code(One), one could enter a small piece of music,
1671 and send it to staff code(Two), e.g.,
1672 mudela(fragment,verbatim)(
1673   <
1674     \type Staff = one { c''4 \type Staff = two { c4 c4 } c''4 }
1675     \type Staff = two { \clef bass; g,4 g,4 g,4 g,4  }    
1676   >
1677 )
1678
1679
1680 Another useful application of this feature is making Urtexts.
1681 em(Urtext) is the German word for `original text'.  The Urtext
1682 edition of a piece of music, is an edition that reflects the original
1683 writing of the composer.  Such editions are useful for musicologists,
1684 and performers that want  to perform authentic interpretations.  However,
1685 for mere mortals, the Urtext can be quite hard to read.  It might not
1686 contain fingering and beaming, and typically it is full of footnotes.
1687 Moreover, common interpretations may have emerged---after the composer
1688 died.  For this reason, the music that can be had as Urtext usually is also
1689 available in enhanced and edited editions.
1690
1691 The mechanism of context selection can be used to fabricate an Urtext
1692 and an edited edition from em(one source).  We will use the first few
1693 bars of bind(J.)bind(S.)Bach's lovely Cello suite bind(no.)I to
1694 demonstrate this.  The example makes heavy use of space rests: a space
1695 rest is a like a rest that doesn't print anything.  It can be used as
1696 a placeholder, to attach articulation marks to.  It is entered as a
1697 note with the name code(s).
1698
1699 mudela(verbatim)(
1700   bach =  \melodic { [c16 g e' d'] [e' g e' g] }
1701   
1702   staffStuff = \melodic { \clef bass; \time 4/4; s1 \bar "|."; }
1703   
1704   slursOne = \melodic { s16( s s s s16 s s )s }
1705   slursTwo = \melodic { s16-. s s() s s16() s  s ()s }
1706
1707   \score{
1708     { < \type Voice = celloVoice { \bach \bach }
1709         \type Voice = celloVoice { \slursOne \slursOne }
1710         \staffStuff
1711       >
1712       <
1713         \type Voice = celloVoice { \bach \bach }
1714         \type Voice = celloVoice { \slursTwo \slursTwo }
1715         \staffStuff
1716       >
1717     }
1718     \paper {}
1719   }
1720 )
1721
1722  The slurs that you define should be put on the music that is defined
1723 by the code(\bach) identifier.  By labeling a code(Voice) context, and
1724 directing both the articulation and the notes to that same code(Voice)
1725 context, the articulation is put over the right notes.
1726
1727
1728 sect(Transposing)
1729 label(tutorial:more-grammar)
1730
1731 COMMENT(In this section, we will complete the grammar for Music that was
1732 sketched earlier. )
1733 One of the things that you can do with music is
1734 em(transposing) it.  If you want to transpose a piece of music, then
1735 you should prefix the keyword code(\transpose) along with the pitch
1736 (relative to the central C) for the transposition.footnote(the
1737 code(\type Staff) is to make sure that no separate staffs are created
1738 for the code(\scale) and code(\transpose cis' \scale) part.)
1739
1740
1741 mudela(verbatim)(
1742 scale = \melodic \relative c' { [c8 d e f] }
1743 \score {
1744   \melodic {
1745     \type Staff { \scale \transpose cis'  \scale }
1746     }
1747   \paper { linewidth = -1.0; }
1748 })
1749
1750
1751 sect(Staff switching)
1752
1753 We have seen that contexts can be nested.  This means that they form a
1754 tree.  It is possible to edit this tree: for example, a code(Voice)
1755 context can be taken out of a code(Staff) context, and put into
1756 another.  This has the effect of the voice switching staffs (something
1757 that often happens in keyboard music).  The syntax for this operation
1758 with these particular contexts is code(\translator Staff = newStaffName).
1759
1760 The effect is analogous to the first example in section
1761 ref(tutorial:urtext), but with the code(\translator) construction it
1762 is possible to split the real music and the commands that determine in
1763 which staff the music is printed.  For example:
1764
1765 mudela(verbatim)(
1766
1767 % real music
1768 aVoice = \type Voice = voiceA \melodic { c''4 c4 c4 c''4 }
1769 bVoice = \type Voice = voiceB \melodic { g,4 g,4 g,4 g,4  }    
1770
1771 % staff switching stuff
1772 switch = \type Voice = voiceA \melodic { s4 \translator Staff = staffB s4
1773                    s4 \translator Staff = staffA s4 }
1774
1775 \score {
1776   <
1777     \type Staff = staffA < \aVoice \switch >
1778     \type Staff = staffB < \bVoice \clef bass; >
1779   >
1780   \paper { linewidth = -1.; }
1781 }
1782 )
1783
1784 Don't try to switch staffs when you are in the middle of a slur or
1785 beam, though.  It doesn't work yet.
1786
1787 sect(Hairy durations: triplets)
1788
1789 In the previous section we explained an operation that changes the
1790 pitches of music, transposition.  In this section we will explain an
1791 operation that modifies the duration of the notes that you enter.
1792 When notes are part of a triplet, then the real of duration of the
1793 notes are 2/3 part of what their shape indicates:
1794 mudela(fragment)(
1795 \[/3  c'4 c'4 c'4 \]/1
1796 )
1797
1798 To support this notion, Mudela allows you to modify the duration of a
1799 note by multiplication or division.  A code(c'4) note that would be in  a
1800 triplet is written as code(c'4*2/3).  If you sequence a few of these
1801 notes, you get a triplet.footnote(We added a normal staff in the example to
1802 show the difference.)
1803 mudela(fragment,verbatim)(
1804 <  \type Staff = staffA { c'8*2/3 c'8*2/3 c'8*2/3 c'4}
1805    \type Staff = staffB { c''8 c''8 c''4 } >)
1806
1807 LilyPond knows that these notes are no normal eighth notes, but the
1808 reader doesn't yet.  To help the reader a beam or a bracket with a `3'
1809 should be printed.  The special beam command `code([2/3)' and the
1810 matching close beam `code(]1/1)' will take care of that, and
1811 they also abbreviate the code(*2/3) part.  If you want brackets in
1812 stead of beams, you can use `code(\[2/3])' and `code(\]1/1)'.
1813 mudela(fragment,verbatim)(
1814 < \type Staff = staffA {
1815     [2/3 c'8 c'8 c'8 ]1/1
1816     \[2/3 c'8 c'8 c'8 \]1/1
1817   }
1818   \type Staff = staffB { [c''8 c''8 c''8 c''8] }
1819 >)
1820
1821 Other tuplets  can be entered in the same way.
1822 mudela(fragment,verbatim)(
1823 < \type Staff = staffA {
1824     \time 7/8;
1825     [7/6 c'8 c'8 c'8 c'8 c'8 c'8 ]1/1
1826   }
1827   \type Staff = staffB {
1828     \time 7/8;
1829     [c''8 c''8 c''8 c''8 c''8 c''8 c''8] } >
1830 )
1831
1832 For your convenience, code([2/3) can be further abbreviated to code([/3), and
1833 you can abbreviate code(]1/1) on the closing beam marker to code(]/1).
1834
1835 mudela(fragment,verbatim)(
1836 < \type Staff = staffA {
1837     [/3 c'8 c'8 c'8 ]/1 c'4
1838   }
1839   \type Staff = staffB { [c''8 c''8] c''4 } >
1840 )
1841
1842
1843 bf(Important) the construct with code([/3) and
1844 code([/1) is a hack that sets a mode in the parser.  This means that
1845 verb(id = \melodic { c8 c8 c8 }
1846 notATriplet =\melodic { [2/3 \id ]1/1 })
1847 does not produce a triplet.  It will hopefully
1848 soon be replaced by a construction that mixes more elegantly with the
1849 grammar for Music.
1850
1851
1852 sect(Shortcuts for octaves)
1853 label(sec:relativeoctaves)
1854
1855 Plain Mudela contains a lot of quotes to get the octaves right.  This
1856 need for quotes can be reduced: most of the pitch intervals in
1857 conventional music are small.  Therefore, it makes sense to leave out
1858 the quotes when the interval is small.  We have built a mode that does
1859 exactly this.  It is called the relative mode for octaves.  You can
1860 switch it on by entering code(\relative).  Then LilyPond will
1861 interpret every note as if they mean the note with the same name
1862 closest to the previous.  You have to specify the first pitch because
1863 the first note of a list obviously has no predecessor.  So, you can
1864 enter a scale without using octavation quotes, e.g.,
1865
1866 mudela(fragment,verbatim)(
1867     \relative c' { c d e f g a b c }
1868 )
1869
1870 For chords, the relative mode works slightly differently.  In a
1871 sequence of chords, the first note of a chord gives the starting point
1872 for the next chord.  We can demonstrate this with our twinkle twinkle example
1873 verb(
1874   \relative c' {
1875   c4       c            <c g'>    <c e g>
1876   <c e a>  <b d a'>     <b2 d g>
1877   <a4 d f> <bes d f>    <bes c e> <g c e>
1878   <e a d>  <a, g' cis'> <d2 f d'>
1879   }
1880 )
1881
1882 LilyPond converts any music with code(\relative) prepended to absolute
1883 music immediately when it is read. Internally it is stored it in
1884 absolute pitches.  Since the tutorial mainly deals with how to specify
1885 musical information, and not how to enter it conveniently, the
1886 tutorial doesn't use it.
1887
1888
1889 sect(Large pieces)
1890 label(tutorial:large-pieces)
1891
1892 In our quest for a clean and powerfull music language, we took the effort
1893 of entering some larger pieces of music as well.  From this we learned
1894 certain things that lead to direct improvements of Mudela, such as the 
1895 relative mode.  We also gained some practial experience, that resulted in a 
1896 compilation of tips that may be of use to you.
1897
1898 Entering a large piece of music will often imply the need to produce a
1899 conductor's score, as well as individual parts for all instruments.  This
1900 can most easily be achieved making use of identifiers and including mudela
1901 files.
1902
1903 subsect(Identifiers)
1904
1905 Briefly introduced before, identifiers are your biggest help in structurising
1906 a large piece of music.  As an example, we'll consider a string quartet.  
1907 In short, it will look like this: verb(
1908     global = \melodic{ }
1909     violinoOne = \melodic \relative c { .. }
1910     violinoTwo = \melodic \relative c { .. }
1911     viola = \melodic \relative c { .. }
1912     violoncello = \melodic \relative c { .. }
1913 )
1914
1915 The code(\global) part contains everything that is global, i.e., the
1916 same, for each instrument.  This may include time signature, key, repeat
1917 signs, different bar types, time signature- and key changes, rehearsal
1918 marks, etc.
1919
1920 For each instrument, you'll have something vaguely resembling verb(
1921     violinoOneStaff = \type Staff = violinoOne <
1922         \property Staff.midi_instrument = "violin"
1923         \property Staff.instrument = "Violino I"
1924         \property Staff.instr = "Vl. I"
1925         \global
1926         \violinoOne
1927     >
1928 )
1929
1930
1931 [Versions, relative mode,
1932  barchecks, splitting of files]
1933
1934 subsect(Including Mudela files)
1935 ref(subsect:include)
1936
1937 You can include other Mudela files  with the command code(\include):
1938 verb(
1939 \include "paper13.ly"
1940 \score {
1941        ...
1942        \paper { \paper_thirteen }
1943 })
1944
1945 The file is looked for in the  standard search path.
1946
1947
1948 subsect(Grouping of staffs)
1949
1950 subsect(Versioning)
1951
1952 sect(Titling)
1953 label(tutorial:titling)
1954
1955 A piece of sheet music isn't complete without proper opening and
1956 closing titles.  LilyPond does not have any real support for setting
1957 text: that is a job best left to TeX().  But you can pass messages to
1958 TeX() from the input file.   You can  write TeX() macros to handle
1959 these messages.
1960 To do this, you add a code(\header) block
1961 to your input file.  The format is quite simple,
1962
1963 verb(
1964 \header{
1965     "key" =  "value";
1966     "key" =  "value";
1967     "key" =  "value";
1968     % etc.
1969 })
1970
1971 When  the results of the music typesetting are output, the contents of
1972 code(\header) are also up into the TeX() file.  Tools like
1973 code(ly2dvi) can use this information to generate pretty titling for
1974 your input file. Consult the manual page of code(ly2dvi) for more
1975 details.
1976
1977
1978 The code(\header) block should be at toplevel in mudela, and
1979 preferably at the top of the file.  If you have an input file  with
1980 multiple code(\score) blocks, you should add a header to every score,
1981 describing the different sub parts of the music piece, eg.
1982
1983
1984 verb(\header {
1985         "composer" = "Ludwig Van Bavaria";
1986         "title" = "Symphonie Megalomane";
1987     }
1988     \score{
1989        ... % some music
1990        \header { movement = "Mit roher Kraft wild herausfahrend!"; }
1991       \paper { }
1992     }
1993     \score{
1994        ... % some more music
1995        \header { movement = "Saut\'e comme un oeuf."; }
1996       \paper { }
1997     }
1998 )
1999
2000 If you want you can also put the code(\header) block at the top of the
2001 input file; it will then be put into every output file automatically.
2002 This will make it clear what the file contains as soon as you open it.
2003
2004
2005
2006 chapter(Features)
2007 label(features)
2008
2009 bf(This document is not up to date).  All rendered examples of course
2010 are current, but the rest probably isn't.  Adjusting the tutorial was
2011 considered more important than writing the reference manual.  We
2012 apologize for the inconvenience.
2013
2014
2015 This document describes the the GNU LilyPond input format, which is an
2016 effective language for defining music.  We call this language (rather
2017 arrogantly) The Musical Definition Language or Mudela, for
2018 short.footnote(If anybody comes up with a better name, we'd gladly
2019   take this. Gourlay already uses Musical Description Language,
2020   G-Sharp Score Definition Language.  ISO standard 10743 defines a
2021   Standard Music Description Language.  We're not being original here.)
2022
2023 The first aim of Mudela is to define a piece of music, being complete
2024 from both from a musical typesetting, as from a musical performing
2025 point of view.
2026
2027 The Musical Definition Language (Mudela), has a logical structure,
2028 making use of identifiers, that allows for flexible input, and
2029 definition reuse. See the documentation file file(MANIFESTO), included
2030 with the LilyPond sources for reasons and design considerations.
2031
2032 The below is included for explanatory purposes only (i.e., for a
2033 complete and up-to-date definition, see file(lily/parser.yy) and
2034 file(lily/lexer.ll)).
2035
2036 As a related note, you should take a look at the examples and the init
2037 files, as this document does not cover every aspect of Mudela yet, and
2038 may be out of date.footnote(Ok, I am being pessimistic here.  This
2039 just is a disclaimer.  Docs usually are written after the program
2040 itself.)  This document intends to give an idea of how it works. It is
2041 not a guide on how to use it.
2042
2043 sect(Files)
2044
2045 The de-facto extension of Mudela is file(.ly). Files may be included by
2046 entering code(\include) at the start of a line:
2047
2048 verb(
2049 \include "a_file.ly"
2050 )
2051
2052
2053 sect(Comments)
2054
2055 Line comments are introduced by a
2056 code(%).
2057 Block comments are delimited
2058 by 
2059 code(%{)
2060 and
2061 code(%}).
2062 They do not nest.
2063
2064
2065 sect(Versions)
2066
2067 Occasionally, small changes in syntax across different versions of
2068 Mudela might give syntax errors. To warn you about possible
2069 incompatibilities, you can specify the Mudela version for which the
2070 inputfile was written,
2071 verb(
2072 \version "0.0.50";
2073 )
2074
2075 A Python-script which tries to convert to newer versions
2076 (file(convert-mudela)) is included in the LilyPond distribution.
2077
2078 sect(Keywords)
2079
2080 Keywords are preceded by a backslash: code(\). They contain
2081 alphabetic characters only.
2082
2083
2084 sect(Nesting characters)
2085
2086 Mudela uses the brace, `code({)' and `code(})' for most hierarchical
2087 structures.  For chords the code(<) and the code(>) are used as
2088 nesting braces.
2089
2090 sect(Constants)
2091
2092 verb(
2093 "I am a string"
2094 -1.2e3          % a real
2095 12              % an int
2096 )
2097
2098         
2099 sect(Identifiers)
2100
2101 When assigning identifiers you use
2102
2103 verb(
2104 string = ...
2105 )
2106
2107 If you reuse identifiers, then the previous contents will be thrown
2108 away after the right hand is evaluated, e.g.
2109 verb(
2110 bla = \melodic { \bla }
2111 )
2112 is legal
2113
2114 When using identifiers they have to be escaped:
2115
2116 verb(
2117 oboe = \melodic { ... }
2118 \score{ \melodic { \oboe }}
2119 )
2120
2121 The left-hand part of the assignment is really a string, so 
2122 verb(
2123 "Foo bar 4 2 " = \melodic { .. }
2124 )
2125
2126 is also a valid assignment (but you would have trouble referencing to it)
2127
2128
2129 sect(Hierarchical structures)
2130
2131 The general structure consists of declarations:
2132 verb(
2133 IDENTIFIER = \TYPE{
2134         <type specific data>
2135 }
2136 )
2137 and instantiations:
2138
2139 verb(
2140 \TYPE{ <type specific data> }
2141 )
2142
2143 (Currently, code(\score) is the only type that can be instantiated
2144 at top level.)
2145
2146 Most instantiations that use an IDENTIFIER are specified as follows:
2147
2148 verb(
2149 \TYPE{ \IDENTIFIER [...] }
2150 )
2151
2152 Some exceptions on this rule have been made to prevent inputting
2153 Mudela becoming tedious
2154
2155 sect(Modes:)
2156
2157 To simplify different aspects of music definition (entering the notes
2158 and manipulating them) Mudela has a number of different input "modes":
2159
2160 description(
2161
2162
2163 dit(Normal mode)
2164
2165 At the start of parsing, Mudela assumes normal mode.
2166 In Normal mode, a word is looked up in the following order:
2167 description(
2168 dit(code(word))    string
2169 dit(code("string")) string
2170 dit(code(\word)) keyword, identifier
2171 )
2172 In normal mode, a word is assumed to start with an alphabetic
2173 character, followed by alpha-numeric characters.
2174
2175 dit(Note mode) Note mode is introduced by the keyword
2176   code(\melodic).  In Note mode, a word is looked up in the following
2177   order:
2178 description(
2179 dit(code(word)) notename, string
2180 dit(code("string")) string
2181 dit(code(\word)) keyword, identifier
2182 )
2183
2184 In Note mode a word is considered to have alphabetic characters only,
2185 so the underscore (_) is invalid.  If you accidently mistype a
2186 notename, the parser will assume that you are entering a string (and
2187 it will most likely complain that you should be in code(\lyric) mode to
2188 do lyrics)
2189
2190
2191 dit(Lyric mode) Lyrics mode is introduced by the keyword
2192   code(\lyric).  Because of the various control characters that can
2193   appear in lyrics, e.g., foreign language accents, the inputting a
2194   string containing these has been made very easy.
2195
2196 In Lyrics mode, a word is looked up in the following order:
2197 description(
2198 dit(code(word))    string (thus a lyric)
2199 dit(code("string")) string
2200 dit(code(\word)) keyword, identifier
2201 )
2202
2203 In Lyric mode every sequence of non-digit and non-white characters
2204 starting with an alphabetic character or the _ is considered a word.
2205
2206 verb(
2207 a&@&@&TSI|{[    % a word
2208 1THtrhortho     % not a "word"
2209 Leise DOEXPAND(Fl\)DOEXPAND("u\)ss{}teren meine Sapfe       % 4 words
2210 _ _ _ _         % 4 words: 4 spaces
2211 )
2212 )
2213
2214 These modes are of a lexical nature. Normal and Note mode largely
2215 resemble each other, save the possibility of entering Reals, 
2216 meaning of code(_) and the resolution of words
2217
2218
2219
2220
2221
2222 Durations are entered as their reciprocal values
2223 mudela(fragment,verbatim,center)(
2224 a'1 a'2 a'4 a a'8 a a'16 a'32 a'64
2225 )
2226 Notice that you only have to specify the duration when it changes: Lily
2227 assumes a note has the same duration as the previous one.
2228
2229 Now we can already write a little tune
2230 mudela(fragment,verbatim,center)(
2231 c' d' e' c' | c' d' e' c' | e' f' g'2
2232 )
2233 As you'll probably have guessed,
2234 the vertical bar  code(|) may be used to mark
2235 measures.
2236
2237 In the scale shown above
2238 we left-out the last c note of the next octave.
2239 Postfixing the pitch with a quote code(')
2240 produces a note by one octave higher
2241 mudela(fragment,verbatim,center)(
2242 c c' c''
2243 )
2244
2245 Postfixing the pitch with a comma, code(,)
2246 produces a note by one octave lower
2247 mudela(fragment,verbatim,center)(
2248 a a, a,,
2249 )
2250
2251 sect(Slurs and Ties)
2252
2253 A tie connects two adjacent note heads
2254
2255 mudela(fragment,verbatim,center)(
2256 e' ~ e'
2257 )
2258
2259 Whereas a slur rather connects `chords', 
2260 and tries to avoid crossing stems
2261
2262 mudela(fragment,verbatim,center)(
2263 e'( )e'
2264 )
2265
2266 And of course, such a (legato) slur can span several notes
2267 mudela(fragment,verbatim,center)(
2268 c'( d' e' )f'
2269 )
2270
2271 sect(Beams and Tuplets)
2272
2273 A beam is 
2274 mudela(fragment,verbatim,center)(
2275 [a'8 a'] [a'16 a' a' a']
2276 )
2277
2278 Here's a beamed triplet
2279 mudela(fragment,verbatim,center)(
2280 [/3 a'8 a' a']/1
2281 )
2282
2283 a triplet without a beam
2284 mudela(fragment,verbatim,center)(
2285 \[/3 a'4 a'8\]
2286 )
2287
2288 and a combination
2289 mudela(fragment,verbatim,center)(
2290 [/3 a'8 a'16 a'] a'8 \]
2291 )
2292
2293 Abbreviations
2294 mudela(fragment,verbatim,center)(
2295 c'1:16 [:16 e'1 g']
2296 )
2297
2298 mudela(fragment,verbatim,center)(
2299 c'4:32 [:16 c'8 d'8]
2300 )
2301
2302 sect(Notenames)
2303
2304 Lily has predefined sets of notenames
2305 for various nop(languages)footnote(These 
2306 are Dutch, English, German, Italian and Swedish.
2307 Simply include the language specific init file file(language.ly).).
2308 The default set are the ones we like best are the Dutch notenames.
2309
2310 A sharp is formed by adding code(is)
2311 mudela(fragment,verbatim,center)(
2312 cis' dis' eis' fis' gis' ais' bis'
2313 )
2314
2315 and a flat is formed by adding code(es)
2316 mudela(fragment,verbatim,center)(
2317 ces' des' es' fes' ges' as' bes'
2318 )
2319
2320 With the obvious names for double sharps
2321 mudela(fragment,verbatim)(
2322 cisis' disis' eisis' fisis' gisis' aisis' bisis'
2323 )
2324
2325 and double flats
2326 mudela(fragment,verbatim)(
2327 ceses' deses' eses' feses' geses' ases' beses'
2328 )
2329
2330
2331 There are two special `notenames', the rest
2332 mudela(fragment,verbatim,center)(
2333 r16 [a' a' a']
2334 )
2335
2336 and the space
2337 mudela(fragment,verbatim,center)(
2338 a'2 s-"diminuendo" | a'
2339 )
2340
2341
2342 sect(Commands)
2343
2344 mudela(fragment,verbatim,center)(
2345 \clef "bass"; c
2346 )
2347
2348 and a clef-change
2349 mudela(fragment,verbatim,center)(
2350 \clef "treble"; f' e' \clef "alto"; d' c'
2351 )
2352
2353 mudela(fragment,verbatim,center)(
2354 \time 3/4; c' g' g' |
2355 )
2356
2357 mudela(fragment,verbatim,center)(
2358 \key d;
2359 g a b cis' d' e' fis' g'
2360 )
2361 Note how Mudela allows you to 
2362 convey a musical message and doesn't force  you to produce a list of typesetting commands.
2363 If the music has a code(cis), you type a code(cis).
2364 Depending on the key and context of the note
2365 Lily will determine what accidentals to typeset.
2366
2367 A reminder accidental can be forced by
2368 using an exclamation mark code(!)
2369 on a pitch a reminder accidental
2370 mudela(fragment,verbatim,center)(
2371 cis' d' e' cis' | c'! d' e' c' |
2372 )
2373
2374 mudela(fragment,verbatim)(
2375 \time 2/4;
2376 \bar "|:"; c' c' \bar ":|:"; c' c' \bar ":|"; c' c' \bar "|."; 
2377 )
2378
2379 sect(Chords and Voices)
2380
2381 Here's a simple chord
2382 mudela(fragment,verbatim,center)(
2383 <c e g>
2384 )
2385
2386 here are a few
2387 mudela(fragment,verbatim,center)(
2388 <
2389         { c'()d'()c' }
2390         { e'()f'()e' }
2391         { g'()a'()g' }
2392 >
2393 )
2394
2395 and similarly voices
2396 mudela(fragment,verbatim)(
2397 <
2398         { \voiceone c'4 g' c' g' }
2399         { \voicetwo c2 g2 }
2400 >
2401 )
2402
2403
2404 sect(A complete example)
2405 COMMENT(%label(se:complete))
2406
2407 A Mudela file needs some red tape
2408
2409 mudela(verbatim)(
2410 \score{
2411         \melodic {
2412                 c' d' e' c' |
2413                 c' d' e' c' |
2414                 e' f' g'2 |
2415         }
2416 }
2417 )
2418
2419 sect(Lyrics)
2420
2421 Lyrics are entered like notes, with pitches substituted
2422 by text. 
2423
2424 All syllables are entered separately, separated by whitespace 
2425 verb(
2426 Twin-4 kle4 twin-4 kle4 ... 
2427 )
2428
2429 Two syllables or words that compose a single
2430 duration entry are bound together using an underscore 
2431 verb(
2432 He_could4 not4
2433 )
2434
2435
2436 COMMENT(
2437 URG
2438                         Fr\`e-4 re Ja- que
2439                         Fr\`e- re Ja- que
2440 )
2441
2442 mudela(verbatim,center)(
2443 \score{
2444         < 
2445                 \melodic  \transpose c''  {
2446                         c d e c | c d e c |
2447                         e f g'2 | e'4 f g'2
2448                         \bar "|.";
2449                 }
2450                 \type Lyrics \lyric{ 
2451                         DOEXPAND(Fr\)`e-4 re Ja- que
2452                         DOEXPAND(Fr\)`e- re Ja- que
2453                         Dor- mez vous?2
2454                         Dor-4 mez vous?2
2455                 }
2456         >
2457 }
2458 )
2459
2460 sect(Composition: forming bigger structures)
2461 label(sec:grammar)
2462
2463 The computer savy user may be interested in a more formal
2464 specification.  We can capture what have learned about forming
2465 sentences in Mudela in a context-free grammar.
2466
2467 latexcommand(\smallskip)
2468
2469 table(2)(lll)(
2470         row(cell(em(Music))cell(: em(Note)))
2471         row(cell()cell(code(|) em(Rest)))
2472         row(cell()cell(code(|) code({) em(MusicList) code(})))
2473         row(cell()cell(code(|) code(<) em(MusicList) code(>)))
2474         row(cell()cell(code(|) em(Command)))
2475         row(cell()cell(code(|) code(\type) em(string) code(=) em(string)  em(Music)))
2476         row(cell()cell(;))
2477         row(cell(em(MusicList))cell(: em(empty)))
2478         row(cell()cell(code(|)  em(MusicList)  em(Music)))
2479         row(cell()cell(;))
2480 )
2481
2482 latexcommand(\smallskip)
2483
2484
2485
2486
2487
2488 In mathematics you can form expressions by combining expressions,
2489 which are ultimately some kind of atom or terminal symbol.  The same
2490 goes for Mudela: there are some basic building blocks, and by
2491 combining those you create complex music.
2492
2493 You can combine music in three ways:
2494 itemize(
2495 it()If you enclose a sequence of music-elements in braces ( code({)
2496     and code(}) ), then you form another kind of music called
2497 sequential music
2498     with those pieces.
2499   The duration of sequential composition is the sum of the durations of its elements
2500   verb(
2501       { c c g g a a g2 }      % twinkle twinkle
2502       { { c c g g} { a a g2 } }
2503   )
2504 it()You can stack music by enclosing a sequence of music elements
2505     with code(<) and code(>). This is called simultaneous music.  
2506     The duration of a simultaneous composition is the union of the durations 
2507     of its elements Example:
2508     verb(
2509         <a4 {cis8 cis8} e'4>      % a-major chord
2510     )
2511 it()You can form music by transposing music:
2512     verb(
2513     \transpose  
2514         d       % from c to the d that's almost one octave down
2515                 { e4 f4 }       % the horizontal music
2516 )
2517 it()verb(\type)
2518 it()verb(\property)
2519 it()verb(\translator)
2520 it()verb(\relative)
2521 )
2522
2523 Of course you can also combine these three mechanisms.
2524 verb(
2525 { c <c e> <c e g> <c e g \transpose d' dis > }  % 4 increasing chords
2526 )
2527
2528
2529 sect(Durations)
2530
2531 A duration always starts with the duration type (1,2,4 etc), and then
2532 any optional multipliers/dots.  `Gregrorian' durations can be entered
2533 as follows
2534 verb(
2535 c'\breve
2536 gis'\longa
2537 )
2538
2539
2540         
2541 sect(Time signatures/groupings)
2542
2543 A time signature specification has this form:
2544 verb(
2545 \time 3/4 ;
2546 )
2547
2548 Rhythmic grouping is  a concept closely associated with this. For
2549 example, in a 5/8 time signature, the counts are grouped 2+3. In Mudela this is
2550 entered as
2551 verb(
2552 \grouping  8*2 8*3 ;
2553 )
2554
2555 You can start the piece with a partial measure, the command takes a
2556 duration as an argument
2557 verb(
2558 \partial 16*3;
2559 )
2560
2561 Make the piece start with a upstep 
2562 lasting 1 3/4 quarter notes.
2563
2564 These commands  constitute `Music', and have a duration of 0.
2565
2566
2567 sect(Properties)
2568
2569 By default the same accidentals are valid for all octaves, but
2570   this can be changed with the property code(specialaccidentals).
2571
2572
2573 The identifier code(\specialkey) sets the property for the Staff.  A
2574 key with two flats in one octave and three
2575   sharps in the next can be declared with verb(\specialkey
2576 \accidentals bes es fis' cis' gis';)
2577
2578 sect(Music fragments)
2579 label(tutorial:music-fragments)
2580
2581 Sometimes you only need to print a small fragment of music, perhaps 
2582 something much like one of the examples in this document.  Back in
2583 section ref(sec:running-lilypond) we told you that the music you
2584 enter should be encapsulated in something like:
2585 verb(
2586 \score<
2587         \melodic\relative c{
2588                 d
2589         }
2590         \paper{ }
2591         \midi{ }
2592 >
2593 )
2594 where the only interesting information is this particular example is verb(
2595         d
2596 )
2597 The rest of the above example was already nicknamed `red tape'.
2598 You may easily get bored if you have to provide this same red tape 
2599 for every fragmenty you nop(try)footnote(Of course, in most cases your
2600 favourite text editor (TM)
2601 will help you out.).
2602
2603 Luckily there's a trick around this, and it's called file(.fly) files.
2604 If you use the extension file(.fly) for Mudela file file(foo),
2605 LilyPond will embed your file(foo.fly) nop(in)footnote(Or something very 
2606 similar.  If you want to know exactly, see file(init/init.fly)):
2607 verb(
2608 \score<
2609         \melodic\relative c{
2610                 <<foo.ly>>
2611         }
2612         \paper{ }
2613         \midi{ }
2614 )
2615
2616 Here's how it works.  If you run LilyPond on your file file(bar.ly), you
2617 may notice that she starts-off by reading quite a number of files before
2618 she actually reaches your file(bar.ly).  There's no magic going on, Lily
2619 by default reads an initialisation file (file(init/init.ly)).  In the
2620 initialisation process a lot of things are defined that you'll need for 
2621 normal operation, such as notenames and various other mudela shortcuts,
2622 engraver and perforer definitions, font sizes, musical dimensions and 
2623 paper sizes.  When you use the extension file(.fly), Lily just starts
2624 reading another initialisation file (file(init/init.fly)), that includes the 
2625 red tape for you too.
2626
2627
2628 appendix()
2629
2630 chapter(Glossary)
2631 label(glossary)
2632
2633 This glossary is far from complete.  Additions are welcome.
2634
2635 whenlatex(latexcommand(
2636     {\parindent -1pc
2637     \parskip 0pc\parsep 0pc
2638     %  COMMENT( from the texbook)
2639     \def\length#1{\count0=0 \getlength#1\end}
2640     \def\getlength#1{\ifx#1\end \let\next=\relax
2641       \else\advance\count0 by1 \let\next=\getlength\fi \next}
2642       \def\inlanguage#1#2{{\length{#2}%
2643         \ifnum\count0=0
2644         \else
2645         \emph{#1}: #2.
2646         \fi}}
2647     \small
2648
2649     % COMMENT(\def\tableentry#1#2#3#4#5#6#7{\par\textbf{#1}: #7)
2650     \def\tableentry#1#2#3#4#5#6#7{\par{\bf #1}: #7
2651       \inlanguage{Fran\c cais}{#2}
2652        \inlanguage{British}{#4}  \inlanguage{Deutsch}{#3}
2653        \inlanguage{Nederlands}{#5}\inlanguage{Italiano}{#6}}
2654       \input{vocabulary}
2655     }
2656 ))
2657
2658 whenhtml(
2659     includeverbatim(DOEXPAND(outdir)/vocabulary.html)
2660 )
2661
2662 whenlatex(latexcommand(
2663     \bibliographystyle{plain}
2664     \bibliography{engraving}
2665 ))
2666
2667
2668 COMMENT(The bib stuff is somewhere else on the WWW site)
2669 COMMENT(
2670 setchapterstring{}
2671
2672 whenhtml{
2673     nchapter{Bibliography}
2674     includeverbatim{out-www/engraving.html}
2675 })
2676