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