3 % this document should be run through the mudela-book script after lilypond
6 \documentclass{article}
8 \title{GNU LilyPond input format 0.1}
9 \author{Han-Wen Nienhuys}
13 \def\interexample{\par Produces the following:\par}
14 \def\preexample{\par\medskip}
15 \def\postexample{\par\medskip}
16 \def\file#1{{\texttt{#1}}}
18 \emph{This document is not complete yet}
20 \section{Introduction}
22 This document describes the the GNU LilyPond input format, which is an
23 effective language for defining music. We call this language (rather
24 arrogantly) The Musical Definition Language or Mudela, for
25 short.\footnote{If anybody comes up with a better name, we'd gladly
26 take this. Gourlay already uses Musical Description Language,
27 G-Sharp Score Definition Language. ISO standard 10743 defines a
28 Standard Music Description Language. We're not being original here}
30 The first aim of Mudela is to define a piece of music, being complete
31 from both from a musical typesetting, as from a musical performing
34 The Musical Definition Language (Mudela), has a logical structure,
35 making use of identifiers, that allows for flexible input, and
36 definition reuse. See \file{MANIFESTO} for reasons and design considerations.
38 The below included for explanatory purposes only (i.e., for a complete
39 and up-to-date definition, see \file{lily/parser.y} and
42 As a related note, you should take a look at the examples and the init
43 files, as this document does not cover every aspect of mudela yet, and
44 may be out of date.\footnote{Ok, I am being pessimistic here. This
45 just is a disclaimer. Docs usually are written after the program
46 itself.} This document intends to give an idea of how it works, it
47 is not a guide on how to use it.
50 \section{Basic elements}
54 The de-facto extension of Mudela is \file{.ly}. Files may be included by
55 entering \verb+\include+ at the start of a line:
64 Line comments are introduced by a
66 Block comments are delimited
75 Occasionally, small changes in syntax across different versions of
76 Mudela might give syntax errors. To warn you about possible
77 incompatibilities, you can specify the Mudela version for which the
78 inputfile was written,
83 A perl-script which tries to convert to newer versions
84 (\file{convert-mudela}) is included in the LilyPond distribution.
88 Keywords are preceded by a backslash: \verb+\+. They contain
89 alphabetic characters only.
91 Identifiers in their normal form consist start with a backslash, a
92 alpha character, followed by alpha-numerics. Identifiers can contain
93 any characters (except whitespace,
94 and \verb+%+), if you use this construct:
97 \$i'm_a_weird!!!identifier
100 (which is the identifier with the name
101 \verb+i'm_a_weird!!!identifier+). \verb+$+ Takes any sequence of
102 characters which are not whitespace, \verb+$+ and \verb+%+.
103 \verb+$i'm_a_weird!!!string+
104 \def\foobar{$} % silly fontlock mode
106 \subsection{Nesting characters}
108 Mudela uses the brace (\verb+{+ and \verb+}+) for most hierarchical
109 structures. For chords the \verb+<+ and the \verb+>+ are used as
112 \subsection{Constants}
114 Please note that -.5 is not a Real.
123 \subsection{Identifiers}
125 When assigning identifiers you use
131 If you reuse identifiers, then the previous contents will be thrown
132 away after the right hand is evaluated, eg
134 bla = \melodic { \bla }
138 When using identifiers they have to be escaped:
141 oboe = \melodic { ... }
142 \score{ \melodic { \oboe }}
145 The left-hand part of the assignment is really a string, so
147 "Foo bar 4 2 " = \melodic { .. }
150 is also a valid assignment (but you would have trouble referencing to it)
153 \subsection{Hierarchical structures}
155 The general structure consists of declarations:
164 \TYPE{ <type specific data> }
167 (Currently, \verb+\score+ is the only type that can be instantiated
168 at top level. Currently declarations can only be done at top level)
170 Most instantiations that use an IDENTIFIER are specified as follows:
173 \TYPE{ IDENTIFIER [...] }
176 Some exceptions on this rule have been made to prevent inputting
177 Mudela becoming tedious
182 To simplify different aspects of music definition (entering the notes
183 and manipulating them) Mudela has a number of different input "modes":
190 At the start of parsing, Mudela assumes normal mode.
191 In Normal mode, a word is looked up in the following order:
193 \item{\verb+word+} string
194 \item{\verb|"string"|} string
195 \item{\verb|\word|} keyword, identifier
197 In normal mode, a word is assumed to start with an alphabetic
198 character, followed by alpha-numeric characters.
200 \item[Note mode] Note mode is introduced by the keyword
201 \verb+\melodic+. In Note mode, a word is looked up in the following
204 \item{\verb+word+} notename, string
205 \item{\verb|"string"|} string
206 \item{\verb|\word|} keyword, identifier
209 In Note mode a word is considered to have alphabetic characters only,
210 so the underscore (\_) is illegal. If you accidently mistype a
211 notename, the parser will assume that you are entering a string (and
212 it will most likely complain that you should be in \verb|\lyrics| mode to
216 \item[Lyric mode] Lyrics mode (and thus Simple mudela) is introduced
217 by the keyword \verb+\lyrics+. Because of the various control
218 characters that can appear in lyrics, eg, ``foreign language''
219 accents, the inputting a string containing these has been made very
222 In Lyrics mode, a word is looked up in the following order:
224 \item{\verb+word+} string (thus a lyric)
225 \item{\verb|"string"|} string
226 \item{\verb|\word|} keyword, identifier
229 In Lyric mode every sequence of non-digit and non-white characters
230 starting with an alphabetic character or the \_ is considered a word.
233 a&@&@&TSI|{[ % a word
234 1THtrhortho % not a "word"
235 Leise Fl\"u\ss{}teren meine Sapfe % 4 words
236 _ _ _ _ % 4 words: 4 spaces
240 These modes are of a lexical nature. Normal and Note mode largely
241 resemble each other, save the possibility of entering Reals,
242 meaning of \verb+_+ and the resolution of words
246 You enter a note by giving the name and the reciprocal of the duration:
248 \begin[fragment,verbatim]{mudela}
252 is a A-1 pitched crotchet. The ' signifies an octave change. A-1 is 440
253 Hz concert-pitch. \verb+c'+ is also known as the central c. More examples:
255 \begin[fragment,verbatim]{mudela}
258 A % 110, uppercase octavates down
264 The last one is an A flat, (just below 110 Hz concert-pitch). The \verb+*2/3+
265 signifies that this note is part of a triplet (3 in stead of 2). The
266 duration is one and a half quarter note (\verb+4.+) times 2/3.
268 Notenames are just a special kind of identifiers, and can be declared
269 for any language appropriate (see \file{init/dutch.ly}). The default language
270 for notenames is defined to be Dutch. In Dutch, the notenames are
271 a,b,c,d,e,f and g. Sharps are formed by adding the extension "is",
272 flats by adding ``es''
276 cisis disis eisis fisis gisis aisis bisis
278 cis dis eis fis gis ais bis
282 ces des es fes ges as bes
284 ceses deses eses feses geses ases beses
287 Rests are named r or s
290 s % a "space" rest, nothing is printed.
293 These notenames along with duration are enough material to construct
296 \begin[verbatim,fragment]{mudela}
302 Music is able to express more. generally speaking, the other
303 'features' are either connected between notes (slurs, beams: spanning
304 requests) or attached to notes (eg. accents). The former are
305 implemented as START and STOP stop features and then attached to the note.
308 \item{[ and ]} start and stop a beam
309 \item{( and )} start and stop a slur
313 \begin[verbatim,fragment]{mudela}
316 e8(] [)g8 <c'8] e'8> % NO nesting!
317 [2/3 c8 c8 c8]1/1 % a triplet
320 Please note that these two characters do \emph{not} necessarrily nest,
321 they should be attached to the note. For this reason, the construct
322 \verb+[ <c4 c4>]+ will generate a parse error.
324 \subsection{Slurs and Ties}
326 Ties connect the noteheads of adjacent notes. They are entered as follows:
328 \begin[verbatim,fragment]{mudela}
332 Slurs connect whole chords, and try to avoid crossing stems. They are
335 \begin[verbatim,fragment]{mudela}
341 Symbols which can be put at either side (above or below) of a staff
342 are entered as follows:
343 \begin[verbatim,fragment]{mudela}
344 a-^ % marcato, direction: default
345 %a^- % portato, direction: above note
346 a_. % staccato, direction: below note
347 a^\fermata % predefined identifier
348 c_"marcato" % add a text
353 If you want to define your own scripts refer to \file{init/script.ly} for
357 Dynamics can be put after the notename:
359 a4 \dynamic { 0 } % 0 = fff, 7 = ppp
362 Mudela defines the following dynamic identifiers:
365 ppp pp p mp mf f ff fff sfz fz fp
367 and the following abbreviations:
370 \> % start decrescendo
371 \! % end crescendo/decrescendo
374 \subsection{Defaults}
376 If omit the duration of a note, a default value is substituted. For
377 this default value mudela uses the last duration explicitly entered.
379 Thus the following inputs are equivalent
381 c4 c4 c16 c16 c16 s16 c4 c16
382 c4 c c16 c c c c4 c16
385 If you are typing music which does not lie in the "small" and "large"
386 octave, you can prevent having to type \verb+'+ all the time by using the
387 \verb+\octave+ command: These two lines have the same pitch.
389 c'' d'' e'' c d e c d e
390 \octave c''; c d e ''c ''d ''e \octave c; c d e
393 By default the setting of \verb+\octave+ is 0.
397 Lyrics in Mudela resemble Simple mudela a lot, with notes substituted
400 All syllables are entered separately, separated by whitespace
402 Twin-4 kle4 twin-4 kle4 ...
405 Two syllables or words that compose a single
406 duration entry are bound together using an underscore
411 \section{Composition: forming bigger structures}
413 The previous examples tacitly assumed that a sequence of notes is
414 printed in a left to right manner. This is not entirely correct, you
415 will get the bigger picture in this section.
417 In mathematics you can form expressions by combining expressions,
418 which are ultimately some kind of atom or terminal symbol. The same
419 goes for mudela: there are some basic building blocks, and by
420 combining those you create complex music.
422 You can combine music in three ways:
424 \item If you enclose a sequence of music-elements in braces ( \verb+{+
425 and \verb+}+ ), then you form another kind of music called (Voice) with those pieces.
426 The duration of the Voice is the sum of the durations of its elements
428 { c c g g a a g2 } % twinkle twinkle
429 { { c c g g} { a a g2 } }
431 \item You can stack music by enclosing a sequence of music elements
432 with \verb+<+ and \verb+>+. This is called a Chord. The duration of a Chord is
433 the union of the durations of its elements Example:
435 <a4 {cis8 cis8} e'4> % a-major chord
438 You can form music by transposing music:
441 d % from c to the d that's one octave down
442 { e4 f4 } % the horizontal music
446 Of course you can also combine these three mechanisms.
448 { c <c e> <c e g> <c e g \transpose d' dis > } % 4 increasing chords
451 The basic building block in Mudela is called Request. Examples of
452 Requests are: Timing (such as Meter), Rhythmic, Melodic, Note (which is a combination of
453 Rhythmic and Melodic), Musicscript (put an accent over a note or
454 rest), etc. For the actual up to date listing, you should consult the
455 LilyPond source code: the Request types form a big class hierarchy.
457 Normally you don't enter Requests directly, since that would be
458 tedious. Mudela has standard abbreviations for the most common
459 combination of Requests. If you enter \verb+c4+, this is an
464 notename: 0 acc: 0 oct: -1
473 The \verb+Request_chord+ is a special kind of chord which only allows
474 Requests as its elements. The examples of the previous section were
475 processed with \verb+{+ and \verb+}+ enclosing the input.
477 \subsection{Durations}
479 A duration always starts with the duration type (1,2,4 etc), and then
480 any optional multipliers/dots
482 \subsection{Meters/groupings}
484 A meter has this form:
489 Rhythmic grouping is a concept closely associated with this. For
490 example, in a 5/8 meter, the counts are grouped 2+3. In mudela this is
495 You can start the piece with a partial measure, the command takes the
496 same syntax as grouping:
501 Make the piece start with a upstep [english translation?]
502 lasting 1 3/4 quarter notes.
504 These commands are also "voice elements", and constitute ``Music''
505 (consisting of stuff with duration 0).
508 \subsection{Voicegroups}
513 If more than one "voice" is in a staff, then you have the option of
514 putting the different voices into so called voicegroups: members of
515 the same voicegroup share certain characteristics, among others:
522 For the actual list, see the init file \file{init/register.ly}
524 Putting different musical lines in to the same voicegroup effectively
525 makes LilyPond try to form chords of all those lines. Putting
526 different musical lines in to different voicegroups effectively makes
527 LilyPond try to set those lines as independently as possible.
529 [adsolete. Has to be fixed in lily]
531 You can set the voicegroup of a voice with the command \verb+\group+, e.g.,
542 oboeII = \melodic { \group "oboes";
550 melodicregs \melodic{ oboeI }
555 In this example, the two oboe voices share one staff and are initially
556 in the voicegroup called "oboes". They will share beams, dynamics etc.
557 After two quarter notes, oboeI "pushes" its group: a new voicegroup is
558 created, called "oboes+solo". The \verb+\group "-"+ command makes the
559 voice enter "oboes" again.
561 Please do note that [] are voicegroup wide; the previous input is
562 valid: the beam, started in oboeI, voicegroup "oboes" is also ended in
563 voicegroup "oboes", albeit not in oboeI but oboeII
565 This concept may seem contorted, but it allows you to set the separate
566 oboe parts without changing the \verb+oboeI+ and \verb+oboeII+ (assuming that
567 you edit the [] in the example.)
571 < { .... } {......} >
573 makes a chord (all horizontal parts are in the same voicegroup). The construct
575 \multi 2 < { ....} { .... } >
577 creates horizontal parts which behave independently. You will have to
578 set voicegroup features by hand (\verb+\stem+ and \verb+\hshift+. See examples)
582 \multi 3 < { ....} { .... } >
584 creates a chord with each part in a different staff
587 \subsection{Examples}
589 Examples are included with the GNU LilyPond distribution. For the sake of
590 maintenance no long examples are included in this document.
595 This language has a number of roots. First and foremost, GNU
596 LilyPond's predecessor mpp was the inspiration of the Note-mode input.
597 Secondly, the hierarchical structure looks a lot like Rayce's (Rayce
598 is a raytracer that I've written as a hobby project. ), which in turn
599 owes a lot to POVRay.
601 Now, we know, musictypesetting and raytracing do not necessarily
602 require the same input format, and we know that a lot more ways exist
603 to convert music to ASCII, but we did give this language some
604 thoughts. As always suggestions are appreciated.