2 \documentclass{article}
4 \title{GNU LilyPond input format 0.1}
5 \author{Han-Wen Nienhuys}
9 \def\interexample{\par Produces the following:\par}
10 \def\preexample{\par\medskip}
11 \def\postexample{\par\medskip}
12 \def\file#1{{\texttt{#1}}}
14 \section{Introduction}
16 This document describes the the GNU LilyPond input format, which is an
17 effective language for defining music. We call this language
18 (rather arrogantly) The Musical Definition Language (Mudela 0.1).
20 [If anybody comes up with a better name, we'd gladly take
21 this. Gourlay already uses Musical Description Language, GSharp Score
22 Definition Language. We're not being original here]
24 The first aim of Mudela is to define a piece of music,
25 being complete from both from a musical typesetting,
26 as from a musical performing point of view.
29 The Musical Definition Language (Mudela) version 2, has a logical
30 structure, making use of typing and naming (using identifiers), that
31 allows for flexible input, and definition reuse. See MANIFESTO for
32 reasons and design considerations.
34 The below included for explanatory purposes only (i.e., for a complete
35 and up-to-date definition, see \file{lily/parser.y} and
38 As a related note, you should take a look at the examples and the init
39 files, as this document does not cover every aspect of mudela yet, and
45 The de-facto extension of Mudela is \file{.ly}. Files may be included by
46 entering \verb+include+ at the start of a line:
55 Line comments are introduced by a \verb+%+. Block comments are delimited
56 by \verb+%{+ and \verb+%}+. They do not nest.
60 Occasionally, small changes in syntax across different versions of
61 Mudela might give syntax errors. To warn you about possible
62 incompatibilities, you can specify the Mudela version for which the
63 inputfile was written,
68 A perl-script which tries to convert to newer versions
69 (\file{convert-mudela}) is included in the LilyPond distribution.
73 Keywords are preceded by a backslash: \verb+\+. They contain
74 alphabetic characters only.
76 Identifiers in their normal form consist start with a backslash, a
77 alpha character, followed by alpha-numerics. Identifiers can contain
78 any characters (except whitespace, \verb+$+ and \verb+%+), if you use this
82 \$i'm_a_weird!!!identifier
85 (which is the identifier with the name
86 \verb+i'm_a_weird!!!identifier+). \verb+$+ Takes any sequence of
87 characters which are not whitespace, \verb+$+ and \verb+%+.
88 \verb+$i'm_a_weird!!!string+
90 \subsection{Nesting characters}
92 Mudela uses the brace (\verb+{+ and \verb+}+) for most hierarchical
93 structures. For chords the \verb+<+ and the \verb+>+ are used as
96 \subsection{Constants}
98 Please note that -.5 is not a Real.
107 \subsection{Identifiers}
109 When assigning identifiers you use
116 When using identifiers they have to be escaped:
119 oboe = \melodic { ... }
120 \score{ \melodic { \oboe }}
122 \subsection{Hierarchical structures}
124 The general structure consists of declarations:
133 \TYPE{ <type specific data> }
136 (Currently, \verb+\score+ is the only type that can be instantiated
137 at top level. Currently declarations can only be done at top level)
139 Most instantiations that use an IDENTIFIER are specified as follows:
142 \TYPE{ IDENTIFIER [...] }
145 Some exceptions on this rule have been made to prevent inputting
146 Mudela becoming tedious
151 To simplify different aspects of music definition (entering the notes
152 and manipulating them) Mudela has a number of different input "modes":
159 At the start of parsing, Mudela assumes normal mode.
160 In Normal mode, a word is looked up in the following order:
163 \word keyword, identifier
165 In normalmode, a word is assumed to start with an alphabetic
166 character, followed by alpha-numeric characters.
169 Note mode (and thus Simple mudela) is introduced by
170 the keyword \verb+\melodic+. In Note mode, a word is looked up in
174 word notename, string
175 \word keyword, identifier
177 In Note mode a word is considered to have alphabetic characters only.
180 Lyrics mode (and thus Simple mudela) is introduced by the keyword \verb+\lyrics+.
182 In Lyrics mode, a word is looked up in the following order:
186 \word keyword, identifier
189 In Lyric mode every sequence of non-digit and non-white characters
190 starting with an alphabetic character or the \_ is considered a word.
193 a&@&@&TSI|{[ % a word
194 1THtrhortho % not a "word"
195 Leise Fl\"u\ss{}teren meine Sapfe % 4 words
196 _ _ _ _ % 4 words: 4 spaces
200 These modes are of a lexical nature. Normal and Note mode largely
201 resemble each other, save the possibility of entering Reals,
202 meaning of \verb+_+ and the resolution of words
206 You enter a note by giving the name and the reciprocal of the duration:
208 \begin[fragment,verbatim]{mudela}
212 is a A-1 pitched quaver. The ' signifies an octave change. A-1 is 440
213 Hz concert-pitch. \verb+c'+ is also known as the central c. More examples:
215 \begin[fragment,verbatim]{mudela}
218 A % 110, uppercase octavates down
224 The last one is an A flat, (just below 110 Hz concert-pitch). The \verb+*2/3+
225 signifies that this note is part of a triplet (3 in stead of 2). The
226 duration is one and a half quaver (\verb+4.+) times 2/3.
228 Notenames are just a special kind of identifiers, and can be declared
229 for any language appropriate (see \file{dutch.ini}). The default language
230 for notenames is defined to be dutch. In dutch, the notenames are
231 a,b,c,d,e,f and g. Sharps are formed by adding the extension "is",
232 flats by adding ``es''
236 cisis disis eisis fisis gisis aisis bisis
238 cis dis eis fis gis ais bis
242 ces des es fes ges as bes
244 ceses deses eses feses geses ases beses
247 Rests are named r or s
250 s % a "space" rest, nothing is printed.
253 These notenames along with duration are enough material to construct
256 \begin[verbatim,fragment]{mudela}
262 Music is able to express more. generally speaking, the other
263 'features' are either connected between notes (slurs, beams: spanning
264 requests) or attached to notes (eg. accents). The former are
265 implemented as START and STOP stop features and then attached to the note.
273 \begin[verbatim,fragment]{mudela}
276 e8(] [)g8 <c'8] e'8> % NO nesting!
277 [2/3 c8 c8 c8]1/1 % a triplet
280 Please note that these two characters do \emph{not} necessarrily nest,
281 they should attached to the note \verb+[ <c4 c4>]+ will generate a parse
282 error for this reason.
284 \subsection{Slurs and Ties}
286 Ties connect the noteheads of adjecent notes. They are entered as follows:
288 \begin[fragment]{mudela}
292 Slurs connect whole chords, and try to avoid crossing stems. They are
296 \begin[fragment]{mudela}
302 Symbols which can be put at either side (above or below) of a staff
303 are entered as follows:
304 \begin[fragment]{mudela}
305 a-^ % marcato, direction: default
306 a^- % portato, direction: above note
307 a_. % staccato, direction: below note
308 a^\fermata % predefined identifier
309 c_"marcato" % add a text
314 If you want to define your own scripts refer to \file{script.ini} for
318 Dynamics can be put after the notename:
320 a4 \dynamic { 0 } % 0 = fff, 7 = ppp
323 Mudela defines the following dynamic identifiers:
326 ppp pp p mp mf df ff fff % df iso f, f is a notename.
328 and the following abbreviations:
331 \> % start decrescendo
332 \! % end crescendo/decrescendo
335 \subsection{Defaults}
337 If omit the duration of a note, a default value is substituted. For
338 this default value mudela uses the last duration explicitly entered.
340 Thus the following inputs are equivalent
342 c4 c4 c16 c16 c16 s16 c4 c16
343 c4 c c16 c c c c4 c16
346 If you are typing music which does not lie in the "small" and "large"
347 octave, you can prevent having to type \verb+'+ all the time by using the
348 \verb+\octave+ command: These two lines have the same pitch.
350 c'' d'' e'' c d e c d e
352 \octave c''; c d e ''c ''d ''e \octave c; c d e
355 By default the setting of \verb+\octave+ is 0.
359 Lyrics in Mudela resemble Simple mudela a lot, with notes substituted
362 All syllables are entered separately, separated by whitespace
364 Twin-4 kle4 twin-4 kle4 ...
367 Two syllables or words that compose a single
368 duration entry are bound together using an underscore
373 \subsection{ Music direction}
375 Mudela reads left to right, but you can still stack voices and
376 Voice\_elements which are produced in two directions: horizontal
377 (voice like) and vertical (chord like)
379 A note is a prime example of a Music-element is the note:
384 If you enclose a sequence of Music-elements in braces ( { } ), then you form
385 another kind of Music-element (Voice) with those pieces
387 { c c g g a a g2 } % twinkle twinkle
388 { { c c g g} { a a g2 } }
390 horOne = \melodic { c c g g }
391 horTwo = \melodic { a a g2 }
392 twinkle = \melodic { \horOne \horTwo }
395 You can stack Music-elements by enclosing a sequence Music-elements of
396 notes with < and >. Example:
398 <a cis e'> % a-major chord
400 You can also put vertical music inside horizontal music:
402 { c <c e> <c e g> <c e g c'> } % 4 increasing chords
408 {r2 r2 c c g g a a g2} > % a canon
411 The duration of a chord equals the union of the durations of each of
412 its elements. The \verb+\multi 2+ is a construct which is explained
415 You can also create a Music-element by transposing a Music-element:
418 d % from c to the d that's one octave down
419 { e4 f4 } % the horizontal music
423 \subsection{Voicegroups}
425 If more than one "voice" is in a staff, then you have the option of
426 putting the different voices into so called voicegroups: members of
427 the same voicegroup share certain characteristics, among others:
434 For the actual list, see the init file \file{register.ini}
436 Putting different musical lines in to the same voicegroup effectively
437 makes LilyPond try to form chords of all those lines. Putting
438 different musical lines in to different voicegroups effectively makes
439 LilyPond try to set those lines as independently as possible.
441 You can set the voicegroup of a voice with the command \verb+\group+, e.g.,
451 oboeII = \melodic { \group "oboes";
459 melodicregs \melodic{ oboeI }
463 In this example, the two oboe voices share one staff and are initially
464 in the voicegroup called "oboes". They will share beams, dynamics etc.
465 After two quavers, oboeI "pushes" its group: a new voicegroup is
466 created, called "oboes+solo". The \verb+\group "-"+ command makes the
467 voice enter "oboes" again.
469 Please do note that [] are voicegroup wide; the previous input is
470 valid: the beam, started in oboeI, voicegroup "oboes" is also ended in
471 voicegroup "oboes", albeit not in oboeI but oboeII
473 This concept may seem contorted, but it allows you to set the separate
474 oboe parts without changing the \verb+oboeI+ and \verb+oboeII+ (assuming that
475 you edit the [] in the example.)
479 < { .... } {......} >
481 makes a chord (all horizontal parts are in the same voicegroup). The construct
483 < \multi 2; { ....} { .... } >
485 creates horizontal parts which behave independently. You will have to
486 set voicegroup features by hand (\verb+\stem+ and \verb+\hshift+. See examples)
490 < \multi 3; { ....} { .... } >
492 creates a chord with each part in a different staff
495 \subsection{Durations}
497 A duration always starts with the duration type (1,2,4 etc), and then
498 any optional multipliers/dots
500 \subsection{Meters/groupings}
502 A meter has this form:
507 Rhythmic grouping is a concept closely associated with this. For
508 example, in a 5/8 meter, the counts are grouped 2+3. In mudela this is
513 You can start the piece with a partial measure, the command takes the
514 same syntax as grouping:
519 Make the piece start with a partial measure [transl?] lasting 1 3/4
522 These commands are also "voice elements", and constitute simple mudela
523 (consisting of stuff with duration 0).
527 In concrete, a piece of Mudela has the following structure:
529 % declare pieces of music:
530 melody = \music{ <simple mudela> }
531 accompany = \music{ <simple mudela> }
533 % instantiate (=create tex, midi output) the score:
540 \midi{ <midi definitions> }
541 \paper{ <paper and layout definitions> }
545 \subsection{Examples}
547 Examples are included with the GNU LilyPond distribution. For the sake of
548 maintenance no long examples are included in this document.
553 This language has a number of roots. First and foremost, GNU LilyPond's
554 predecessor mpp was the inspiration of simple Mudela. Secondly, the
555 hierarchical structure looks a lot like Rayce's (Rayce is a raytracer
556 that I've written as a hobby project. ), which in turn owes a lot to
559 Now, we know, musictypesetting and raytracing do not necessarily
560 require the same input format, and we know that a lot more ways exist
561 to convert music to ASCII, but we did give this language some
562 thoughts. As always suggestions are appreciated.