]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/tex/mudela.doc
9ffc13a0badcbfc74edbb3526a90183a773c40c7
[lilypond.git] / Documentation / tex / mudela.doc
1 % -*-tex-*-
2
3 % this document should be run through the mudela-book script after lilypond
4 % has been installed.  The rules have been precooked into the
5 % Documentation/Rules.make file; do 
6 %
7 %   make out/introduction.dvi
8 %
9 % or
10 %
11 %   mudela-book --outdir=out/ --outname=introduction.mudtex introduction.doc
12 %   latex '\nonstopmode \input out/introduction.mudtex'
13
14 % Hoi Tim, hier staan wat 'enge' commando's (die dingen met een '\'
15 % zoals \documentclass en \def\mudela...).
16 % Daar moet je je niets van aantrekken, ga gewoon naar Introduction
17 % en begin te tiepen.
18
19 \documentclass{report}
20 \usepackage{a4wide}
21 \title{Mudela}
22 \author{Jan Nieuwenhuizen \& Han-Wen Nienhuys}
23
24 \def\file#1{\verb+#1+}
25
26 % ugh: trick to get examples not generate par
27 % these are for 16pt
28 \def\mudelapaperlinewidth{-28.452756}%
29 \def\mudelapaperindent{28.452756}%
30 \def\mudelapaperrulethickness{0.400000}%
31 \def\mudelapaperbarsize{16.000000}%
32 \def\mudelapaperinterline{4.000000}%
33 \def\mudelapapernotewidth{5.930000}%
34 \def\mudelapaperwholewidth{8.640000}%
35 \def\mudelapaperunitspace{22.000000}%
36 \def\mudelapaperbasicspace{4.000000}%
37 \def\mudelapapergeometric{0.000000}%
38 \def\mudelapaperarithmetic_basicspace{2.000000}%
39 \def\mudelapaperarithmetic_multiplier{4.800000}%
40 \def\mudelapaperinterbeam{3.140000}%
41 \def\mudelapapergourlay_energybound{100000.000000}%
42 \def\mudelapapergourlay_maxmeasures{14.000000}%
43 % huh?
44 % \def\exampleheight{2\mudelapaperbarsize pt}
45 \def\exampleheight{2cm}
46
47 % ful of pars, needs the above
48 \input lilyponddefs
49 % generates par
50 \musixsixteendefs
51 \def\musixsixteendefs{}
52 % generates par
53 \turnOnPostScript%
54 \def\turnOnPostScript{}
55 % generates par
56 \def\interscoreline{}
57
58
59 \begin{document}
60 \maketitle
61
62 %\def\interexample{\hskip15mm$\Longrightarrow$\hskip15mm}
63 %\def\interexample{\hbox to10mm{\hfill\hbox to0pt{\hss\vbox to\exampleheight{\vss$\Longrightarrow$\vss}\hss}\hfill}}
64 \def\interexample{}
65 \def\preexample{\par}
66 \def\postexample{\par\medskip}
67
68 \def\file#1{{\texttt{#1}}}
69 \setcounter{secnumdepth}{-1}
70
71 \chapter{A tutorial}
72
73 \emph{\Large ***Under construction: april 98***}
74
75 \section{Introduction}
76
77 This chapter is a gentle introduction to using LilyPond to typeset
78 simple music.
79
80 LilyPond is a so called ``batch'' program.  This means, that you use a
81 text editor (such as \texttt{emacs} or \texttt{vi}) to create an input
82 file.  When you are done editing your input file, you save it, and you
83 run LilyPond on the file.  If Lily finds any errors in your input file
84 then she\footnote{ We're sure that if computer programs could have
85 gender, LilyPond would be a female computer program.  So we will refer
86 to the program as a she. This gender-bending is not to tease you, dear
87 reader.  We do it in real life as well. In the past two years LilyPond
88 has become sort of a baby daughter to us, keeping us awake at night,
89 but also providing us lots of joy.  We hope you do not mind our little
90 aberration from computer-manual tradition.
91
92 % The name LilyPond is actually sort of a girl's name.  Can you guess which
93 % one ?
94 %
95 } will complain.  If everything is well, than she'll generate a file, that
96 you can process further to view or print.
97
98 Using LilyPond to print or view some music is a procedure with four
99 steps.  To get you started we'll run down the full procedure for you
100 once.
101
102 \begin{enumerate}
103 \item
104 Fire up your favourite editor (if you know none, try \texttt{joe silly.ly}),
105 and key in the following text:
106 \begin{verbatim}
107 \score {
108         <
109         \type Staff = aStaff \melodic { g'2 e'4 }
110         \type Lyrics = yell \lyric { Air2 ball!4 }
111         >
112         \paper {}
113 }
114 \end{verbatim}
115
116 Save your file as \file{silly.ly}.
117
118 %The input files for LilyPond have the default extension \file{.ly}.
119
120 \item
121 Run LilyPond on your newly created file: enter \verb+lilypond silly+.
122 LilyPond will then print all kinds of mumbo jumbo that can safely be
123 ignored.  You might see something like this:
124 \begin{verbatim}
125 GNU LilyPond 0.1.55/FlowerLib 1.1.39
126 Parsing ... [/home/hanwen/musix/spacer/init/lily-init.ly[/home/hanwen/
127
128         ... stuff left out here ...
129
130                                 Documentation/silly.ly]
131 Interpreting music ...[1] (time: 0.04 seconds)
132 Preprocessing elements... 
133 Calculating column positions ... [2]
134 Approximated: 1 lines, (with an average of 4.0 columns)
135 Time: 0.01 seconds
136 warning: Can not solve this casting problem exactly; revert to Word_wrap
137 [2]Time: 0.00 seconds
138
139 Postprocessing elements...
140 TeX output to silly.tex ...
141 \end{verbatim}
142 All has gone well; there were some warning but no errors.  The output
143 is a TeX file, and it is called \file{silly.tex}.  \file{TeX} is
144 usually spelled as \TeX.  It is batch program for typesetting text,
145 developed by the great programmer and scientist Donald Knuth to
146 typeset his famous The Art of Computer Programming bookseries.  As you
147 can see \TeX\ can be adapted to do a lot more.  In fact, the document
148 that you are reading now was also done with \TeX.
149 \item
150   To do something useful with the output you have to run \TeX\ on it
151   first.  Run the command \verb+tex silly+.  The output should resemble this:
152 \begin{verbatim}
153 This is TeX, Version 3.14159 (C version 6.1)
154 (silly.tex
155 Babel <v3.6h> and hyphenation patterns for american, dutch, loaded.
156 (/home/hanwen/lib/texmf/tex/lilypond/lilyponddefs.tex
157 (/home/hanwen/lib/texmf/tex/lilypond/dyndefs.tex)
158 (/home/hanwen/lib/texmf/tex/lilypond/fetdefs.tex
159 (/home/hanwen/lib/texmf/tex/lilypond/feta20.tex)
160 (/home/hanwen/lib/texmf/tex/lilypond/lily-ps-defs.tex))) [1] )
161 Output written on silly.dvi (1 page, 3084 bytes).
162 Transcript written on silly.log.
163 \end{verbatim}
164   The human translation is ``everything went OK, the result is one
165   page long, and I put it in \file{silly.dvi}.''
166
167 \item The \file{silly.dvi} file is a description of how a piece of
168 text looks when it is printed.  You can view it, or print it.  If you
169 are using a Unix system equipped with X-Windows, then you can issue
170 the command \file{xdvi silly} to view the result.  If this is not the
171 case, consult your local \TeX\ guru on printing and viewing DVI files.
172 What is in your window should look like this:
173 \begin{mudela}
174 \score {
175         <
176         \type Staff = aStaff \melodic { g'2 e'4 }
177         \type Lyrics = yell \lyric { Air2 ball!4 }
178         >
179 }
180 \end{mudela}
181 \end{enumerate}
182
183 The remainder of this document is not about \TeX, and mostly not even
184 about LilyPond.  What you entered into your text editor in step~1. and
185 fed to LilyPond is a special kind of file composed of notenames,
186 special words and punctation.  The remainder of this document explains
187 how to combine these elements to express a piece of music in the
188 language that LilyPond understands.  In other words, we try to explain
189 how to use LilyPond, and not how LilyPond works.  For want of a better
190 name we call the language Mudela (short for Music Description
191 Language).
192
193 This document does not cover all of Mudela.  Due to technical details,
194 the precise working of Mudela is coupled to the innards of LilyPond.
195 If you really want to know all the details, your best bet would be to
196 get the sources to LilyPond and read the parser and scanner source.
197 They are in \file{lilypond-x.y.z/lily/parser.y},
198 \file{lilypond-x.y.z/lily/lexer.l}\footnote{Of course, it would be even
199 better if you would improve LilyPond and send the resulting diffs to
200 us.  But that would a really different ballpark (And we haven't
201 started with the programming guide yet.)}
202
203 In the following sections the basic elements of Mudela are presented.
204 We don't want to bore you too much with details, so we will leave-out
205 some red tape that's needed for a valid piece of Mudela: to be
206 precise, we will write \verb+X Y Z+, when we really mean
207 \begin{verbatim}
208 \score {
209         \melodic { X Y Z }
210         \paper {}
211 }
212 \end{verbatim}
213 Usually, we will also print the resulting fragment of music on the
214 right just as it was produced by LilyPond.  
215
216 For the remainder we will assume that you can carry out steps 1 to 4
217 from the above instruction.  We will also assume that you know how
218 music notation works.  If you are not familiar with the English terms
219 for music notation, then you should consult XXXX [FIXME], it contains
220 a glossary of musical terms.
221
222 \section{Music copying versus music definition}
223
224 If you have done music copying before, then using LilyPond may seem
225 awkward to you in the beginning.  The purpose of LilyPond is informally
226 explained by the term ``music typesetter.''
227
228 This may give the impression that the program is like a drawing tool
229 that lets you control precisely how the music is formatted.  This is
230 not the case: not only does the program print musical symbols,
231 LilyPond also tries to make esthetic decisions---to be precise, we
232 programmed her to do what we find pretty.  You do not have complete
233 control over what is happening.  On the other hand, good engraving is
234 a very complex trade, so it is a Good Thing that you do not have to
235 worry about what is happening.
236
237 Secondly, LilyPond operates on musical definitions.  This really is
238 something different from graphical definitions.  If you copy music by
239 hand from a printed score, you don't have to know what the score
240 means; you just copy the symbols.  With LilyPond such a thing is not
241 possible: we expect you to enter the meaning of the score, not the
242 score itself.  If put more concretely: you do not enter ``black
243 notehead without flag, fourth staff line'', but ``a quarter note,
244 pitch d$^2$''.  LilyPond will figure out from the musical info what
245 kind of graphic presentation is needed.
246
247 This has some drawbacks: most notably, it is difficult to enter sheet
248 music that you cannot read.  On the other hand, any piece of music
249 once entered can be played and transposed automatically.
250
251
252 \section{When you know the notes to print\ldots}
253
254 The basic building block of music is the note.  You can have LilyPond
255 print a note by specifying its pitch and the duration.  The pitch of
256 the central C, also known as c$^1$, is written as \verb+c'+.  A quarter
257 note duration is written as \verb+4+.  So, to print quarter note with
258 central C pitch, you enter the following
259 \begin{mudela}[fragment,verbatim,center]
260 c'4
261 \end{mudela}
262 The pitch \verb+c'+ actually consists of two parts: one for the note
263 name, and one part for the octave.  The number of apostrophes
264 specifies the octave to use, and the letter which note name to use.
265 The note names simply are the letters \verb+a+ to \verb+g+.
266
267 For example,
268 \begin{mudela}[fragment,verbatim]
269   c'4 d'4 e'4 c'4 c''4 d''4 e''4 f''4 g''4 a''4 b''4 c'''4
270 \end{mudela}
271
272 The duration of a note is specified as a number: a whole note is
273 denoted by 1, the half note by 2, the quarter by 4, and so on.  Here
274 are some random notes to show how it works
275 \begin{mudela}[fragment,verbatim]
276 'c8 c8 c'16 c''32 d''64 b'64 c'''2 c1 c'4 d'4 e'4 f'4 g'4 a'4
277 \end{mudela}
278
279 This gives us already enough material to make simple songs:
280 \begin{mudela}[fragment,verbatim]
281         c''4 d''4 e''4 c''4
282         e''4 f''4 g''2
283         g''8 a''8 g''8 f''8 e''4 c''4
284         c''4 g'4 c''2
285 \end{mudela}
286
287 There is only one part about pitches that we haven't told you:
288 chromatically altered pitches.  The names ``a'' to ``g'' for typing
289 pitches are convenient: they are short, pronounceable and they
290 resemble the normal vocabulary for pitches.
291
292 Enter flats and sharps.  In English there is no standard terse word
293 for C sharp or C flat.  For this reason, we implemented a different,
294 non-english convention for entering altered pitches, see
295 table~\ref{notename-tab}: one makes a note sharp by adding the suffix
296 ``--is'' to the name, one makes the a note flat by adding the suffix
297 ``--es.''  For a double sharp you simply add another ``--is'' suffix,
298 flats ditto.
299
300
301 \begin{table}[h]
302   \begin{center}
303     \caption{Defaults note names}\label{notename-tab}
304     \begin{tabular}{ll}
305       english         &LilyPond\\
306       \hline\\
307       c double flat   &ceses\\
308       c flat          &ces\\
309       c natural       &c\\
310       c sharp         &cis\\
311       c double sharp  &cisis\\
312     \end{tabular}
313     
314   \end{center}
315 \end{table}
316
317 Variations on this convention are used in a number of germanic
318 languages, notably Dutch, German, Swedish, and Norwegian.  To be
319 precise, LilyPond actually defaults to dutch notenames, with aes,
320 aeses, ees and eeses added for consistency.
321
322 If you are not comfortable with these names, you can make your own
323 names.  Included with the example initialisation files are note names
324 for different languages, among others English (C sharp is abbreviated
325 to cs), Italian, Swedish, Norwegian
326
327 \section{Hairy rhythms}
328
329 \section{Handy input}
330
331
332 \chapter{Features}
333
334 Durations are entered as their reciproce values
335 % a1 a2 a4 a a8 a a16 a a32 a a64 a a a a
336 \begin{mudela}[fragment,verbatim,center]
337 a1 a2 a4 a a8 a a16 a32 a64
338 \end{mudela}
339 note that you only have to specify
340 the duration when it changes:
341 Lily assumes a note has the same duration as the previous one.
342
343 Now we can already write a little tune
344 \begin{mudela}[fragment,verbatim,center]
345 c d e c | c d e c | e f g2
346 \end{mudela}
347 As you'll probably have guessed,
348 the vertical bar (pipe) \verb+|+ may be used to mark
349 measures.
350
351 In the scale shown above
352 we left-out the last c note of the next octave.
353 Postfixing the pitch with a quote \verb+'+
354 produces a note by one octave higher
355 \begin{mudela}[fragment,verbatim,center]
356 c c' c''
357 \end{mudela}
358
359 Prefixing the pitch with a quote \verb+'+
360 produces a note by one octave lower
361 \begin{mudela}[fragment,verbatim,center]
362 a 'a ''a
363 \end{mudela}
364
365 \section{Slurs and Ties}
366
367 A tie connects two adjacent noteheads
368
369 \begin{mudela}[fragment,verbatim,center]
370 e' ~ e
371 \end{mudela}
372
373 Whereas a slur rather connects `chords', 
374 and tries to avoid crossing stems
375
376 \begin{mudela}[fragment,verbatim,center]
377 e'( )e
378 \end{mudela}
379
380 And of course, such a (legato) slur can span several notes
381 \begin{mudela}[fragment,verbatim,center]
382 c( d e )f
383 \end{mudela}
384
385 \section{Beams and Plets}
386
387 A beam is 
388 \begin{mudela}[fragment,verbatim,center]
389 [a8 a] [a16 a a a]
390 \end{mudela}
391
392 Here's a beamed triplet
393 \begin{mudela}[fragment,verbatim,center]
394 [/3 a8 a a]/1
395 \end{mudela}
396
397 a triplet without a beam
398 \begin{mudela}[fragment,verbatim,center]
399 \[/3 a4 a8\]
400 \end{mudela}
401
402 and a combination
403 \begin{mudela}[fragment,verbatim,center]
404 [/3 a8 a16 a] a8 \]
405 \end{mudela}
406
407 Abbreviations
408 \begin{mudela}[fragment,verbatim,center]
409 c1:16 [:16 e1 g]
410 \end{mudela}
411
412 \begin{mudela}[fragment,verbatim,center]
413 c4:32 [:16 c8 d8]
414 \end{mudela}
415
416 \section{Notenames}
417
418 Lily has predefined sets of notenames
419 for various languages%
420 \footnote{These are Dutch, English, German, Italian and Swedish.
421 Simply include the language specific init file \file{<language.ly>}.}.
422 The default set are the ones we like best are the Dutch notenames.
423
424 A sharp is formed by adding \verb+is+
425 \begin{mudela}[fragment,verbatim,center]
426 cis dis eis fis gis ais bis
427 \end{mudela}
428
429 and a flat is formed by adding \verb+es+%
430 %\footnote{Exceptions: \verb+es+ and \verb+as+.}
431 \footnote{Exceptions: {\tt es} and {\tt as}.}
432 \begin{mudela}[fragment,verbatim,center]
433 ces des es fes ges as bes
434 \end{mudela}
435
436 With the obvious names for double sharps
437 \begin{mudela}[fragment,verbatim,center]
438 cisis disis eisis fisis gisis aisis bisis
439 \end{mudela}
440
441 and double flats
442 \begin{mudela}[fragment,verbatim,center]
443 ceses deses eses feses geses ases beses
444 \end{mudela}
445 See why we like-em?
446
447 There are two special `notenames', the rest
448 \begin{mudela}[fragment,verbatim,center]
449 r16 [a a a]
450 \end{mudela}
451
452 and the space
453 \begin{mudela}[fragment,verbatim,center]
454 a2 s-"diminuendo" | a
455 \end{mudela}
456
457
458 \section{Commands}
459
460 \begin{mudela}[fragment,verbatim,center]
461 \clef "bass"; 'c
462 \end{mudela}
463
464 and a clef-change
465 \begin{mudela}[fragment,verbatim,center]
466 \clef "violin"; f' e' \clef "alto"; d' c'
467 \end{mudela}
468
469 \begin{mudela}[fragment,verbatim,center]
470 \meter 3/4; c g g |
471 \end{mudela}
472
473 \begin{mudela}[fragment,verbatim,center]
474 \key fis cis;
475 'g 'a 'b cis d e fis g'
476 \end{mudela}
477 Note how Mudela allows you to 
478 convey a musical message
479 rather than forces you to produce a list of typesetting commands.
480 If the music a \verb+cis+, you type a \verb+cis+.
481 Depending on the key and context of the note
482 Lily will determine what accidentals to typeset.
483
484 A reminder accidental can be forced by
485 using an exclamation mark \verb+!+
486 on a pitch a reminder accidental
487 \begin{mudela}[fragment,verbatim,center]
488 cis d e cis | c! d e c |
489 \end{mudela}
490
491 \begin{mudela}[fragment,verbatim,center]
492 \meter 2/4;
493 \bar "|:"; c c \bar ":|:"; c c \bar ":|"; c c \bar "|."; 
494 \end{mudela}
495
496 \section{Chords and Voices}
497
498 Here's a simple chord
499 \begin{mudela}[fragment,verbatim,center]
500 <c e g>
501 \end{mudela}
502
503 here are a few
504 \begin{mudela}[fragment,verbatim,center]
505 <
506         { c()d()c }
507         { e()f()e }
508         { g()a()g }
509 >
510 \end{mudela}
511
512 and similarly voices
513 \begin{mudela}[fragment,verbatim,center]
514 <
515         { \voiceone c g c g }
516         { \voicetwo 'c2 'g2 }
517 >
518 \end{mudela}
519
520
521 \section{A complete example}
522 %\label{se:complete}
523
524 A Mudela file needs some red tape
525
526 \begin{mudela}[verbatim,center]
527 \score{
528         \melodic {
529                 \octave c';
530                 c d e c |
531                 c d e c |
532                 e f g2 |
533         }
534 }
535 \end{mudela}
536
537 \section{Lyrics}
538
539 \begin{mudela}[verbatim,center]
540 \score{
541         < 
542                 \melodic{ 
543                         \octave c'; 
544                         c d e c | c d e c |
545                         e f g2 | e4 f g2
546                         \bar "|.";
547                 }
548                 \type Lyrics \lyric{ 
549                         Fr\`e-4 re Ja- que
550                         Fr\`e- re Ja- que
551                         Dor- mez vous?2
552                         Dor-4 mez vous?2
553                 }
554         >
555 }
556 \end{mudela}
557
558 \section{Variables}
559
560
561 \section{Ly2dvi}
562 Check-out this handy little script 
563 that not only may save you quite some keystrokes,
564 but produces titles and takes care of
565 margins and (hopefully) papersizes.
566 See \file{ly2dvi (1)}.
567
568 \chapter{Input format reference}
569
570 October 8, 1997
571
572 This document describes the the GNU LilyPond input format, which is an
573 effective language for defining music.  We call this language (rather
574 arrogantly) The Musical Definition Language or Mudela, for
575 short.\footnote{If anybody comes up with a better name, we'd gladly
576   take this. Gourlay already uses Musical Description Language,
577   G-Sharp Score Definition Language.  ISO standard 10743 defines a
578   Standard Music Description Language.  We're not being original here}
579
580 The first aim of Mudela is to define a piece of music, being complete
581 from both from a musical typesetting, as from a musical performing
582 point of view.
583
584 The Musical Definition Language (Mudela), has a logical structure,
585 making use of identifiers, that allows for flexible input, and
586 definition reuse. See \file{MANIFESTO} for reasons and design considerations.
587
588 The below included for explanatory purposes only (i.e., for a complete
589 and up-to-date definition, see \file{lily/parser.y} and
590 \file{lily/lexer.l}):
591
592 As a related note, you should take a look at the examples and the init
593 files, as this document does not cover every aspect of mudela yet, and
594 may be out of date.\footnote{Ok, I am being pessimistic here.  This
595   just is a disclaimer.  Docs usually are written after the program
596   itself.}  This document intends to give an idea of how it works, it
597 is not a guide on how to use it.  
598
599
600 \section{Basic elements}
601
602 \subsection{Files}
603
604 The de-facto extension of Mudela is \file{.ly}. Files may be included by
605 entering \verb+\include+ at the start of a line:
606
607 \begin{verbatim}
608 \include "a_file.ly"
609 \end{verbatim}
610
611
612 \subsection{Comments}
613
614 Line comments are introduced by a
615 \verb+%+. 
616 Block comments are delimited
617 by 
618 \verb+%{+ 
619 and
620 \verb+%}+. 
621 They do not nest.
622
623 \subsection{Versions}
624
625 Occasionally, small changes in syntax across different versions of
626 Mudela might give syntax errors. To warn you about possible
627 incompatibilities, you can specify the Mudela version for which the
628 inputfile was written,
629 \begin{verbatim}
630 \version "0.0.50";
631 \end{verbatim}
632
633 A perl-script which tries to convert to newer versions
634 (\file{convert-mudela}) is included in the LilyPond distribution.
635
636 \subsection{Words}
637
638 Keywords are preceded by a backslash: \verb+\+. They contain
639 alphabetic characters only.
640
641 Identifiers in their normal form consist start with a backslash, a
642 alpha character, followed by alpha-numerics. Identifiers can contain
643 any characters (except whitespace, 
644  and \verb+%+), if you use this construct:
645
646 \begin{verbatim}
647 \$i'm_a_weird!!!identifier
648 \end{verbatim}
649
650 (which is the identifier with the name
651 \verb+i'm_a_weird!!!identifier+).  \verb+$+ Takes any sequence of
652 characters which are not whitespace, \verb+$+ and \verb+%+.
653 \verb+$i'm_a_weird!!!string+
654 \def\foobar{$} % silly fontlock mode 
655
656 \subsection{Nesting characters}
657
658 Mudela uses the brace (\verb+{+ and \verb+}+) for most hierarchical
659 structures.  For chords the \verb+<+ and the \verb+>+ are used as
660 nesting braces.
661
662 \subsection{Constants}
663
664 Please note that -.5 is not a Real.
665
666 \begin{verbatim}
667 "I am a string"
668 -1.2e3          % a real
669 12              % an int
670 \end{verbatim}
671
672         
673 \subsection{Identifiers}
674
675 When assigning identifiers you use
676
677 \begin{verbatim}
678 string = ...
679 \end{verbatim}
680
681 If you reuse identifiers, then the previous contents will be thrown
682 away after the right hand is evaluated, eg
683 \begin{verbatim}
684 bla = \melodic { \bla }
685 \end{verbatim}
686 is legal
687
688 When using identifiers they have to be escaped:
689
690 \begin{verbatim}
691 oboe = \melodic { ... }
692 \score{ \melodic { \oboe }}
693 \end{verbatim}
694
695 The left-hand part of the assignment is really a string, so 
696 \begin{verbatim}
697 "Foo bar 4 2 " = \melodic { .. }
698 \end{verbatim}
699
700 is also a valid assignment (but you would have trouble referencing to it)
701
702
703 \subsection{Hierarchical structures}
704
705 The general structure consists of declarations:
706 \begin{verbatim}
707 IDENTIFIER = \TYPE{
708         <type specific data>
709 }
710 \end{verbatim}
711 and instantiations:
712
713 \begin{verbatim}
714 \TYPE{ <type specific data> }
715 \end{verbatim}
716
717 (Currently, \verb+\score+ is the only type that can be instantiated
718 at top level. Currently declarations can only be done at top level)
719
720 Most instantiations that use an IDENTIFIER are specified as follows:
721
722 \begin{verbatim}
723 \TYPE{ IDENTIFIER [...] }
724 \end{verbatim}
725
726 Some exceptions on this rule have been made to prevent inputting
727 Mudela becoming tedious
728
729
730 \subsection{Modes:}
731
732 To simplify different aspects of music definition (entering the notes
733 and manipulating them) Mudela has a number of different input "modes":
734
735 \begin{description}
736
737
738 \item[Normal mode]
739
740 At the start of parsing, Mudela assumes normal mode.
741 In Normal mode, a word is looked up in the following order:
742 \begin{description}
743 \item{\verb+word+}    string
744 \item{\verb|"string"|} string
745 \item{\verb|\word|} keyword, identifier
746 \end{description}
747 In normal mode, a word is assumed to start with an alphabetic
748 character, followed by alpha-numeric characters.
749
750 \item[Note mode] Note mode is introduced by the keyword
751   \verb+\melodic+.  In Note mode, a word is looked up in the following
752   order:
753 \begin{description}
754 \item{\verb+word+} notename, string
755 \item{\verb|"string"|} string
756 \item{\verb|\word|} keyword, identifier
757 \end{description}
758
759 In Note mode a word is considered to have alphabetic characters only,
760 so the underscore (\_) is illegal.  If you accidently mistype a
761 notename, the parser will assume that you are entering a string (and
762 it will most likely complain that you should be in \verb|\lyrics| mode to
763 do lyrics)
764
765
766 \item[Lyric mode] Lyrics mode (and thus Simple mudela) is introduced
767   by the keyword \verb+\lyrics+.  Because of the various control
768   characters that can appear in lyrics, eg, ``foreign language''
769   accents, the inputting a string containing these has been made very
770   easy.
771
772 In Lyrics mode, a word is looked up in the following order:
773 \begin{description}
774 \item{\verb+word+}    string (thus a lyric)
775 \item{\verb|"string"|} string
776 \item{\verb|\word|} keyword, identifier
777 \end{description}
778
779 In Lyric mode every sequence of non-digit and non-white characters
780 starting with an alphabetic character or the \_ is considered a word.
781
782 \begin{verbatim}
783 a&@&@&TSI|{[    % a word
784 1THtrhortho     % not a "word"
785 Leise Fl\"u\ss{}teren meine Sapfe       % 4 words
786 _ _ _ _         % 4 words: 4 spaces
787 \end{verbatim}
788 \end{description}
789
790 These modes are of a lexical nature. Normal and Note mode largely
791 resemble each other, save the possibility of entering Reals, 
792 meaning of \verb+_+ and the resolution of words
793
794 \subsection{Notes}
795
796 You enter a note by giving the name and the reciprocal of the duration:
797
798 \begin{mudela}[fragment,verbatim]
799 a'4     % Dutch names
800 \end{mudela}
801
802 is a A-1 pitched crotchet. The ' signifies an octave change.  A-1 is 440
803 Hz concert-pitch. \verb+c'+ is also known as the central c. More examples:
804
805 \begin{mudela}[fragment,verbatim]
806         'a      % 110
807         a       % 220
808         A       % 110, uppercase octavates down
809         a'      % 440
810         a''     % 880
811         'as4.*2/3
812 \end{mudela}
813
814 The last one  is an A flat, (just below 110 Hz concert-pitch). The \verb+*2/3+
815 signifies that this note is part of a triplet (3 in stead of 2). The
816 duration is one and a half quarter note (\verb+4.+) times 2/3.
817
818 Notenames are just a special kind of identifiers, and can be declared
819 for any language appropriate (see \file{init/dutch.ly}).  The default language
820 for notenames is defined to be Dutch. In Dutch, the notenames are
821 a,b,c,d,e,f and g. Sharps are formed by adding the extension "is",
822 flats by adding ``es''
823
824 \begin{verbatim}
825 % double sharp
826 cisis disis eisis fisis gisis aisis bisis
827 % sharps
828 cis dis eis fis gis ais bis
829 % naturals
830 c d e f g a b 
831 % flats
832 ces des es fes ges as bes
833 % double flats
834 ceses deses eses feses geses ases beses
835 \end{verbatim}
836
837 Rests are named r or s
838 \begin{verbatim}
839 r       % print a rest
840 s       % a "space" rest, nothing is printed.
841 \end{verbatim}
842
843 These notenames along with duration are enough material to construct
844 simple melodies:
845
846 \begin{mudela}[verbatim,fragment]
847 \octave c';
848 c4 c4 g4 g4 a4 a4 g2
849 f4 f4 e4 e4 d4 d4 c2
850 \end{mudela}
851
852 Music is able to express more. generally speaking, the other
853 'features' are either connected between notes (slurs, beams: spanning
854 requests) or attached to notes (eg. accents). The former are
855 implemented as START and STOP stop features and then attached to the note.
856
857 \begin{description}
858 \item{[ and ]}      start and stop a beam
859 \item{( and )}      start and stop a slur
860 \end{description}
861
862 example: 
863 \begin{mudela}[verbatim,fragment]
864   \octave c';
865   [c8 () d8 () e8  
866   e8(] [)g8 <c'8] e'8>              % NO nesting!
867   [2/3 c8 c8 c8]1/1       % a triplet
868 \end{mudela}
869
870 Please note that these two characters do \emph{not} necessarrily nest,
871 they should be attached to the note.  For this reason, the construct
872 \verb+[ <c4 c4>]+ will generate a parse error.
873   
874 \subsection{Slurs and Ties}
875
876 Ties connect the noteheads of adjacent notes. They are entered as follows:
877
878 \begin{mudela}[verbatim,fragment]
879 a'4 ~ a''4
880 \end{mudela}
881
882 Slurs connect whole chords, and try to avoid crossing stems. They are
883 entered as follows:
884
885 \begin{mudela}[verbatim,fragment]
886 a'4(  )a''4
887 \end{mudela}
888
889 \subsection{Scripts}
890
891 Symbols which can be put at either side (above or below) of a staff
892 are entered as follows:
893 \begin{mudela}[verbatim,fragment]
894         a-^     % marcato, direction: default
895         %a^-     % portato, direction: above note
896         a_.     % staccato, direction: below note
897         a^\fermata      % predefined identifier
898         c_"marcato"     % add a text
899         c^"marcato"
900         c-"marcato"
901 \end{mudela}
902
903 If you want to define your own scripts refer to \file{init/script.ly} for
904 details.
905
906
907 Dynamics can be put after the notename:
908 \begin{verbatim}
909 a4 \dynamic { 0 } % 0 = fff, 7 = ppp
910 \end{verbatim}
911
912 Mudela defines the following dynamic identifiers:
913
914 \begin{verbatim}
915 ppp pp p mp mf f ff fff sfz fz fp
916 \end{verbatim}
917 and the following abbreviations:
918 \begin{verbatim}
919 \<      %start crescendo
920 \>      % start decrescendo
921 \!      % end crescendo/decrescendo
922 \end{verbatim}
923
924 \subsection{Defaults}
925
926 If omit the duration of a note, a default value is substituted. For
927 this default value mudela uses the last duration explicitly entered.
928
929 Thus the following inputs are  equivalent
930 \begin{verbatim}
931 c4 c4 c16 c16 c16 s16 c4 c16
932 c4 c c16 c c c c4 c16
933 \end{verbatim}
934
935 If you are typing music which does not lie in the "small" and "large"
936 octave, you can prevent having to type \verb+'+ all the time by using the
937 \verb+\octave+ command: These two lines have the same pitch.
938 \begin{verbatim}
939 c'' d'' e'' c d e c d e
940 \octave c''; c d e ''c ''d ''e \octave c; c d e
941 \end{verbatim}
942
943 By default the setting of \verb+\octave+ is 0.
944
945 \subsection{Lyrics}
946
947 Lyrics in Mudela resemble Simple mudela a lot, with notes substituted
948 by text. 
949
950 All syllables are entered separately, separated by whitespace 
951 \begin{verbatim}
952 Twin-4 kle4 twin-4 kle4 ... 
953 \end{verbatim}
954
955 Two syllables or words that compose a single
956 duration entry are bound together using an underscore 
957 \begin{verbatim}
958 He_could4 not4
959 \end{verbatim}
960
961 \section{Composition: forming bigger structures}
962
963 The previous examples tacitly assumed that a sequence of notes is
964 printed in a left to right manner. This is not entirely correct, you
965 will get the bigger picture in this section. 
966
967 In mathematics you can form expressions by combining expressions,
968 which are ultimately some kind of atom or terminal symbol.  The same
969 goes for mudela: there are some basic building blocks, and by
970 combining those you create complex music.
971
972 You can combine music in three ways:
973 \begin{itemize}
974 \item If you enclose a sequence of music-elements in braces ( \verb+{+
975     and \verb+}+ ), then you form another kind of music called (Voice) with those pieces.
976   The duration of the Voice is the sum of the durations of its elements
977 \begin{verbatim}
978 { c c g g a a g2 }      % twinkle twinkle
979 { { c c g g} { a a g2 } }
980 \end{verbatim}
981 \item You can stack music by enclosing a sequence of music elements
982   with \verb+<+ and \verb+>+. This is called a Chord.  The duration of a Chord is
983   the union of the durations of its elements Example:
984 \begin{verbatim}
985 <a4 {cis8 cis8} e'4>      % a-major chord
986 \end{verbatim}
987 \item 
988   You can form music by transposing music:
989 \begin{verbatim}
990 \transpose  
991                 d       % from c to the d that's one octave down
992                 { e4 f4 }       % the horizontal music
993 \end{verbatim}
994 \end{itemize}
995
996 Of course you can also combine these three mechanisms.
997 \begin{verbatim}
998 { c <c e> <c e g> <c e g \transpose d' dis > }  % 4 increasing chords
999 \end{verbatim}
1000
1001 The basic building block in Mudela is called Request. Examples of
1002 Requests are: Timing (such as Meter), Rhythmic, Melodic, Note (which is a combination of
1003 Rhythmic and Melodic), Musicscript (put an accent over a note or
1004 rest), etc.  For the actual up to date listing, you should consult the
1005 LilyPond source code: the Request types form a big class hierarchy.
1006
1007 Normally you don't enter Requests directly, since that would be
1008 tedious.  Mudela has standard abbreviations for the most common
1009 combination of Requests. If you enter \verb+c4+, this is an
1010 abbreviation for:
1011 \begin{verbatim}
1012 Request_chord{
1013   Note_req{
1014     notename: 0 acc: 0 oct: -1
1015     duration { 4}
1016   }
1017   Stem_req{
1018     duration { 4}
1019   }  
1020 }
1021 \end{verbatim}
1022
1023 The \verb+Request_chord+ is a special kind of chord which only allows
1024 Requests as its elements.  The examples of the previous section were
1025 processed with \verb+{+ and \verb+}+ enclosing the input.
1026
1027 \subsection{Durations}
1028
1029 A duration always starts with the duration type (1,2,4 etc), and then
1030 any optional multipliers/dots.  Old fashioned durations can be entered
1031 as follows
1032 \begin{verbatim}
1033 'c\breve
1034 gis'\longa
1035 \end{verbatim}
1036
1037
1038         
1039 \subsection{Meters/groupings}
1040
1041 A meter has this form:
1042 \begin{verbatim}
1043 \meter 3/4 ;
1044 \end{verbatim}
1045
1046 Rhythmic grouping is  a concept closely associated with this. For
1047 example, in a 5/8 meter, the counts are grouped 2+3. In mudela this is
1048 entered as
1049 \begin{verbatim}
1050 \grouping  8*2 8*3 ;
1051 \end{verbatim}
1052 You can start the piece with a partial measure, the command takes the
1053 same syntax as grouping: 
1054 \begin{verbatim}
1055 \partial 16*3 4;
1056 \end{verbatim}
1057
1058 Make the piece start with a upstep [english translation?]
1059 lasting 1 3/4 quarter notes.
1060
1061 These commands are also "voice elements", and constitute ``Music''
1062 (consisting of stuff with duration 0).
1063
1064
1065 \subsection{Voicegroups}
1066
1067
1068 [OUTDATED]
1069
1070 If more than one "voice" is in a staff, then you have the option of
1071 putting the different voices into so called voicegroups: members of
1072 the same voicegroup share certain characteristics, among others:
1073
1074         - dynamics
1075         - text
1076         - beams and stems
1077         - scripts
1078
1079 For the actual list, see the init file \file{init/register.ly}
1080
1081 Putting different musical lines in to the same voicegroup effectively
1082 makes LilyPond try to form chords of all those lines. Putting
1083 different musical lines in to different voicegroups effectively makes
1084 LilyPond try to set those lines as independently as possible. 
1085
1086 [adsolete. Has to be fixed in lily]
1087
1088 You can set the voicegroup of a voice with the command \verb+\group+, e.g.,
1089
1090 \begin{verbatim}        
1091         oboeI = \melodic { 
1092                 \group "oboes"; 
1093                 [e8 f8
1094                 \group "+solo";
1095                 [g16 a16 g16 fis16]
1096                 \group "-";
1097                 g8 f8
1098         }
1099         oboeII = \melodic { \group "oboes";
1100                 c8 d8]
1101                 e4
1102                 e8 d8
1103         }
1104         ///     ...
1105
1106         \staff { 
1107                 melodicregs \melodic{ oboeI }
1108                 \melodic { oboeII}
1109 }
1110 \end{verbatim}
1111
1112 In this example, the two oboe voices share one staff and are initially
1113 in the voicegroup called "oboes". They will share beams, dynamics etc.
1114 After two quarter notes, oboeI "pushes" its group: a new voicegroup is
1115 created, called "oboes+solo". The \verb+\group "-"+ command makes the
1116 voice enter "oboes" again.
1117
1118 Please do note that [] are voicegroup wide; the previous input is
1119 valid: the beam, started in oboeI, voicegroup "oboes" is also ended in
1120 voicegroup "oboes", albeit not in oboeI but oboeII
1121
1122 This concept may seem contorted, but it allows you to set the separate
1123 oboe parts without changing the \verb+oboeI+ and \verb+oboeII+ (assuming that
1124 you edit the [] in the example.)
1125
1126 The construct
1127 \begin{verbatim}
1128 < { .... } {......} >
1129 \end{verbatim}
1130 makes a chord (all horizontal parts are in the same voicegroup). The construct
1131 \begin{verbatim}
1132 \multi 2 < { ....} { .... } >
1133 \end{verbatim}
1134 creates horizontal parts which behave independently. You will have to
1135 set voicegroup features by hand (\verb+\stem+ and \verb+\hshift+. See examples)
1136
1137 The construct
1138 \begin{verbatim}
1139 \multi 3 < { ....} { .... } >
1140 \end{verbatim}
1141 creates  a chord with each part in a different staff
1142
1143
1144 \subsection{Examples}
1145
1146 Examples are included with the GNU LilyPond distribution. For the sake of
1147 maintenance no long examples are included in this document.
1148
1149
1150 \section{History}
1151
1152 This language has a number of roots. First and foremost, GNU
1153 LilyPond's predecessor mpp was the inspiration of the Note-mode input.
1154 Secondly, the hierarchical structure looks a lot like Rayce's (Rayce
1155 is a raytracer that I've written as a hobby project. ), which in turn
1156 owes a lot to POVRay.
1157
1158 Now, we know, musictypesetting and raytracing do not necessarily
1159 require the same input format, and we know that a lot more ways exist
1160 to convert music to ASCII, but we did give this language some
1161 thoughts. As always suggestions are appreciated.
1162
1163 \end{document}
1164
1165