]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/mudela.pod
release: 0.0.44
[lilypond.git] / Documentation / mudela.pod
1 =head1 NAME
2
3 Mudela -  LilyPond input format 0.1
4
5 =head1 DESCRIPTION
6
7 This document describes the the LilyPond input format, which is an
8 effective language for definining music.  We call this language
9 (rather arrogantly) The Musical Definition Language (S<Mudela 2>).
10
11 The first aim of Mudela is to define a piece of music, 
12 being complete from both from a musical typesetting, 
13 as from a musical performing point of view.
14
15 The design of Mudela has been (perfect past tense, hopefully)
16 an ongoing process, 
17 the most important criteria being:
18
19 =over 4
20
21 =item *
22
23 define the (musical) message of the composer as unambiguously as possible,
24
25 =item *
26
27 be intuitive, and easily readable 
28 (compared to, say, Musi*TeX input, or MIDI :-),
29
30 =item *
31
32 be writable in ASCII with a simple texteditor, yfte(TM).
33
34 =back
35
36 Other considerations were (and will be):
37
38 =over 4
39
40 =item *
41
42 be able to edit the layout 
43 without danger of changing the original music (Urtext),
44
45 =item *
46
47 allow for adding different interpretations, again, 
48 without danger of changing the original,
49
50 =item *
51
52 easy to create a conductor's score, 
53 as well as the scores for all individual instruments,
54
55 =item *
56
57 provide simple musical manipulations, such as 
58 S<(i) extracting> a slice of music from a previously defined piece, 
59 S<(ii) extracting> only the rhythm from a piece of music, 
60 S<(iii) transposing>, etc.,
61
62 =item *
63
64 easy to comprehend to both programmers and others.
65
66 =back
67
68 Musical pieces could be
69
70 =over 5
71
72 =item *
73
74 Mahlerian orchestral scores,
75
76 =item *
77
78 piano pieces (Schubertian, Rachmaninovian),
79
80 =item *
81
82 pop songs (lyrics and chords),
83
84 =item *
85
86 gregorian chants,
87
88 =item *
89
90 Bach multivoice organ pieces,
91
92 =item *
93
94 short excerpts to be used in musicological publications.
95
96 =back
97
98
99 =head1 Overview
100
101 The Musical Definition Language (Mudela) S<version 2>,
102 has a logical structure, 
103 making use of typing and naming (using identifiers),
104 that allows for flexible input, and definition reuse.
105
106 The below included for explanatory
107 purposes only (i.e., for a complete and up-to-date definition, see
108 F<lily/parser.y> and F<lily/lexer.l>):
109
110 =head2 Files
111
112 The de-facto extension of Mudela is F<.ly>. Files may be included by
113 entering C<include> at the start of a line:
114
115         include "a_file.ly"
116
117 =head2 Comments
118
119 Line comments are introduced by a C<%>
120
121 =head2 Words
122
123 Keywords are preceded by a backslash "\". They contain alphabetic
124 characters only. 
125
126 Identifiers in their normal form consist start with a alpha character,
127 followed by alpha-numerics. Identifiers can contain any characters
128 (except whitespace, C<$> and C<%>), if you use this construct:
129
130         $Id_with###@weird92chars = 
131
132 =head2 Nesting characters
133
134 Mudela uses the brace (C<{> and C<}>) for hierarchical structures. To
135 aid the eye in reading, for chords the C<<> and the C<>> are used as
136 nesting braces.
137
138 =head2 Identifiers
139
140 =head2 Hierarchical structures
141
142 The general structure consists of declarations:
143
144         IDENTIFIER = \TYPE{
145                 <type specific data>
146         }
147
148 and instantiations:
149
150         \TYPE{ <type specific data> }
151
152 (Currently, C<\score> is the only type that can be instantiated
153 at top level. Currently declarations can only be done at top level)
154
155 Most instantiations that use an IDENTIFIER are specified as follows:
156
157         \TYPE { IDENTIFIER [...] }
158
159 Some exceptions on this rule have been made to prevent inputting
160 Mudela becoming tedious
161
162
163 =head2 Simple mudela
164
165 The actual musical part of Mudela that defines a melody, is known as 
166 I<simple mudela>. 
167
168 Simple mudela is the most common type of music.  It consists of a list
169 of notes or lyrics, chords, and commands.
170
171 =head2 Modes:
172
173 To simplify different aspects of music definition (entering the notes
174 and manipulating them) Mudela has a number of different input "modes":
175
176 =over 4
177
178 =item Normal mode
179
180 At the start of parsing, Mudela assumes normal mode.
181 In Normal mode, a word is looked up in the following order:
182
183         word    identifier, string
184         \word   keyword, string
185
186 In normalmode, a word is assumed to start with an alphabetic
187 character, followed by alpha-numeric characters.
188
189 =item Note mode
190
191 Note mode (and thus Simple mudela) is introduced by the keyword C<\music>.
192 In Note mode, a word is looked up in the following order:
193
194         word    identifier, string
195         \word   keyword, string
196
197 In Note mode a word is considered to have alphabetic characters only.
198
199 =item Lyric mode
200
201 Lyrics mode (and thus Simple mudela)  is introduced by the keyword C<\lyrics>.
202
203 In Lyrics mode, a word is looked up in the following order:
204
205         word    string
206         \word   keyword, string
207
208 In Lyric mode every sequence of non-digit and non-white characters
209 starting with an alphabetic character is considered a word.
210
211         a&@&@&TSI|{[    % a word
212         1THtrhortho     % not a "word"
213         Leise Fl\"u\ss{}teren meine Sapfe       % 4 words
214
215
216 =back
217
218 These modes are of a lexical nature. Normal and Note mode largely
219 resemble each other, save the possibility of entering Reals, and
220 meaning of C<_>
221
222 =head2 Notes
223
224 Simple mudela basically is a sequence of the notes you want to
225 enter. 
226
227         a'4     % dutch names
228
229 is a A-1 pitched quaver. The ' as well as the ' signify an octave change.
230 A-1 is 440 Hz concert-pitch. C<c'> is also known as the central
231 c. More examples:
232
233         'a      % 110
234         a       % 220
235         a'      % 440
236         a''     % 880
237
238 another example:
239
240         'as4.*2/3
241
242 This is an A flat, (just below 110 Hz concert-pitch). The C<*2/3>
243 signifies that this note is part of a triplet (3 in stead of 2). The
244 duration is one and a half quaver (C<4.>) times 2/3. 
245
246 The default language for notenames is defined to be dutch,
247
248         % double sharp
249         cisis disis eisis fisis gisis aisis bisis
250         % sharps
251         cis dis eis fis gis ais bis
252         % naturals
253         c d e f g a b 
254         % flats
255         ces des es fes ges as bes
256         % double flats
257         ceses deses eses feses geses ases beses
258
259 The standard notenames also have uppercase versions, which octavate
260 down:
261
262         a       % 220 concert-pitch
263         A       % 110
264         'A      % 55
265         A'      % 220
266         Cisis
267
268 The rest is named 
269
270         r
271
272 These notenames along with duration are enough material to construct
273 simple melodies:
274
275         c4 c4 g4 g4 a4 a4 g2
276         f4 f4 e4 e4 d4 d4 c2
277
278 Music is able to express more. generally speaking, the other
279 'features' are either connected between notes (slurs, beams: spanning
280 requests) or attached to notes (eg. accents). The former are
281 implemented as START and STOP stop features and then attached to the note.
282
283         []      START/STOP a beam
284         ()      START/STOP a slur
285
286
287 example: 
288
289         [c8 () d8 () e8 ]
290
291 Please note that these two characters do I<not> necessarrily nest, eg:
292
293         [c8 e8(] [)g8 c'8]
294
295
296 Symbols which can be put at either side of a staff are entered as follows:
297
298         a-^     % marcato, direction: default
299         a^-     % portato, direction: above note
300         a_.     % staccato, direction: below note
301         a^\script { "symbolindex"  . . . } % see script.ini for details.
302
303 Dynamics can be put after the notename:
304
305         a4 \dynamic { 0 } % 0 = fff, 7 = ppp
306
307 Mudela defines the following dynamic identifiers:
308
309         ppp pp p mp mf df ff fff        % df iso f, f is a notename.
310
311 The general form of a note is:
312
313         post-requests de-octavate notename octavate duration pre-requests 
314
315 Notenames are just identifiers, and can be declared for any
316 language appropriate (see F<dutch.ini>). 
317
318 =head2 Defaults
319
320 If omit the duration of a, a default value is substituted. For this
321 default value, there are two modes:
322
323 =over 4
324
325 =item 1
326
327 Use the last duration explicitly entered
328
329 =item 2
330
331 Use the explicitly set "default duration"
332
333 =back
334
335 Thus the following inputs are  equivalent
336
337         c4 c4 c16 c16 c16 s16 c4 c16
338
339         \duration { "last" }
340         c4 c c16 c c c c4 c16
341
342         \duration { 4 }
343         c c c16 c16 c16 c16 c c16
344
345         \duration { 16 }
346         c4 c4 c c c c c4 
347
348 If you are typing music which does not lie in the "small" and "large"
349 octave, you can prevent having to type C<'> all the time by using the
350 C<\octave> command: These two notes have the same pitch.
351
352         c''     \octave{2} c
353
354 By default the setting of C<\octave> is 0.
355
356 =head2 Lyrics
357
358 Lyrics in Mudela resemble Simple mudela a lot, with notes substituted
359 by text. 
360
361 All syllables are entered separately, separated by whitespace 
362
363         Twin-4 kle4 twin-4 kle4 ... 
364
365 Two syllables or words that compose a single
366 duration entry are bound together using an underscore 
367
368         He_could4 not4
369
370 =head2  Music direction
371
372 Mudela reads left to right, but LilyPond can stack voices and
373 Voice_elements which are produced in two directions: horizontal
374 (voice like) and vertical (chord like)
375
376 You can start horizontal music by enclosing a sequence of notes with { and }
377
378         { c c g g a a g2 }      % twinkle twinkle
379
380 You can start vertical music (a "chord") by enclosing a sequence of
381 notes with < and >. Example:
382
383         <a cis e'>      % a-major chord
384
385 You can also put vertical music inside horizontal music:
386
387         { c < c e > <c e g> <c e g c'> }        % 4 increasing chords
388
389 And vice versa
390
391         < \multivoice
392           {c c g g a a g2}              
393           {r2  r2  c c g g a a g2} >    % a canon
394
395 The duration of a chord equals the union of the durations of each of
396 its elements.  The C<\multivoice> is a construct which is explained
397 below.
398
399 =head2 Rhythms
400
401 Rhythms in Mudela are entered identical to Simple mudela.
402 The melodic part of the information is ignored.
403
404 =head1 STRUCTURE
405
406 In concrete, a piece of Mudela has the following structure:
407
408         % declare pieces of music:
409         melody = \music{ <simple mudela> }
410         accompany = \music{ <simple mudela> }
411
412         % instantiate (=create tex, midi output) the score:
413         \score{ 
414                 \staff{ melody }
415                 \staff{ accompany }
416                 \commands{ <score global commands> }
417                 \midi{ <midi definitions> }
418                 \paper{ <paper and layout definitions }
419         }
420
421 =head2 Examples
422
423 Examples are included with the LilyPond distribution. For the sake of
424 maintenance no long examples are included in this document.
425
426
427 =head2 Requests
428
429 =head2 Voice
430
431 =head2 Voice_element
432
433 =head2 Voice groups
434
435 =head2 Other
436
437 LilyPond first reads F<symbol.ini>, which contains declarations crucial
438 to proper operation of LilyPond (symbol tables, note names).
439
440 =head1 HISTORY
441
442
443 This language has a number of roots. First and foremost, LilyPond's
444 predecessor mpp was the inspiration of simple Mudela.  Secondly, the
445 hierarchical structure looks a lot like Rayce's (Rayce is a raytracer
446 that I've written as a hobby project. ), which in turn owes a lot to
447 POVRay.
448
449 Now, we know, musictypesetting and raytracing do not necessarily
450 require the same input format, and we know that a lot more ways exist
451 to convert music to ASCII, but we did give this language some
452 thoughts. As always suggestions are appreciated.
453