]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/mudela.pod
633c9b588db9411d1bf38b07fe6532b597625d3b
[lilypond.git] / Documentation / mudela.pod
1 =head1 NAME
2
3 Mudela -  GNU LilyPond input format 0.1
4
5 =head1 DESCRIPTION
6
7 This document describes the the GNU LilyPond input format, which is an
8 effective language for defining music.  We call this language
9 (rather arrogantly) The Musical Definition Language (S<Mudela 0.1>).
10
11 [If anybody comes up with a better name, we'd gladly take this Gourlay
12 already uses Musical Description Language, GSharp Score Definition
13 Language. We're not being original here]
14
15 The first aim of Mudela is to define a piece of music, 
16 being complete from both from a musical typesetting, 
17 as from a musical performing point of view.
18
19
20 =head1 Overview
21
22 The Musical Definition Language (Mudela) S<version 2>, has a logical
23 structure, making use of typing and naming (using identifiers), that
24 allows for flexible input, and definition reuse. See MANIFESTO for
25 reasons and design considerations.
26
27 The below included for explanatory purposes only (i.e., for a complete
28 and up-to-date definition, see F<lily/parser.y> and F<lily/lexer.l>):
29
30 As a related note, you should take a look at the examples and the init
31 files, as this document does not cover every aspect of mudela yet, and
32 may be out of date.
33
34 =head2 Files
35
36 The de-facto extension of Mudela is F<.ly>. Files may be included by
37 entering C<include> at the start of a line:
38
39         \include "a_file.ly"
40
41 =head2 Comments
42
43 Line comments are introduced by a C<%>. Block comments are delimited
44 by C<%{> and C<%}>. They do not nest.
45
46 =head2 Versions
47
48 Occasionally, small changes in syntax across different versions of
49 Mudela might give syntax errors. To warn you about possible
50 incompatibilities, you can specify the Mudela version for which the
51 inputfile was written,
52
53         \version "0.0.50";
54
55 A perl-script which tries to convert to newer versions
56 (F<convert-mudela>) is included in the LilyPond distribution.
57
58 =head2 Words
59
60 Keywords are preceded by a backslash: '\'. They contain alphabetic
61 characters only. 
62
63 Identifiers in their normal form consist start with a alpha character,
64 followed by alpha-numerics. Identifiers can contain any characters
65 (except whitespace, C<$> and C<%>), if you use this construct:
66
67         $i'm_a_weird###identifier
68
69 (which is the identifier with the name
70 C<i'm_a_weird###identifier> ). C<$> Takes any sequence of
71 characters which are not whitespace, C<$> and C<%>.
72
73         \$i'm_a_weird###escaped_word
74
75 =head2 Nesting characters
76
77 Mudela uses the brace (C<{> and C<}>) for hierarchical structures. To
78 aid the eye in reading, for chords the < and the > are used as
79 nesting braces.
80
81 =head2 Constants
82
83 Please note that -.5 is no Real.
84
85         "I am a string"
86         -1.2e3          % a real
87         12              % an int
88
89
90         
91 =head2 Identifiers
92
93 =head2 Hierarchical structures
94
95 The general structure consists of declarations:
96
97         IDENTIFIER = \TYPE{
98                 <type specific data>
99         }
100
101 and instantiations:
102
103         \TYPE{ <type specific data> }
104
105 (Currently, C<\score> is the only type that can be instantiated
106 at top level. Currently declarations can only be done at top level)
107
108 Most instantiations that use an IDENTIFIER are specified as follows:
109
110         \TYPE{ IDENTIFIER [...] }
111
112 Some exceptions on this rule have been made to prevent inputting
113 Mudela becoming tedious
114
115
116 =head2 Simple mudela
117
118 The actual musical part of Mudela that defines a melody, is known as 
119 I<simple mudela>. 
120
121 Simple mudela is the most common type of music.  It consists of a list
122 of notes or lyrics, chords, and commands.
123
124 =head2 Modes:
125
126 To simplify different aspects of music definition (entering the notes
127 and manipulating them) Mudela has a number of different input "modes":
128
129 =over 4
130
131 =item Normal mode
132
133 At the start of parsing, Mudela assumes normal mode.
134 In Normal mode, a word is looked up in the following order:
135
136         word    identifier, string
137         \word   keyword, identifier, string
138
139 In normalmode, a word is assumed to start with an alphabetic
140 character, followed by alpha-numeric characters.
141
142 =item Note mode
143
144 Note mode (and thus Simple mudela) is introduced by the keyword C<\melodic>.
145 In Note mode, a word is looked up in the following order:
146
147         word    notename, string
148         \word   keyword, identifier, string
149
150 In Note mode a word is considered to have alphabetic characters only.
151
152 =item Lyric mode
153
154 Lyrics mode (and thus Simple mudela)  is introduced by the keyword C<\lyrics>.
155
156 In Lyrics mode, a word is looked up in the following order:
157
158         word    string
159         \word   keyword, identifier, string
160
161 In Lyric mode every sequence of non-digit and non-white characters
162 starting with an alphabetic character or the '_'is considered a word.
163
164         a&@&@&TSI|{[    % a word
165         1THtrhortho     % not a "word"
166         Leise Fl\"u\ss{}teren meine Sapfe       % 4 words
167         _ _ _ _         % 4 words: 4 spaces
168
169 =back
170
171 These modes are of a lexical nature. Normal and Note mode largely
172 resemble each other, save the possibility of entering Reals, 
173 meaning of C<_> and the resolution of words
174
175 =head2 Notes
176
177 Simple mudela basically is a sequence of the notes you want to
178 enter. 
179
180         a'4     % dutch names
181
182 is a A-1 pitched quaver. The ' signifies an octave change.  A-1 is 440
183 Hz concert-pitch. C<c'> is also known as the central c. More examples:
184
185         'a      % 110
186         a       % 220
187         a'      % 440
188         a''     % 880
189
190 another example:
191
192         'as4.*2/3
193
194 This is an A flat, (just below 110 Hz concert-pitch). The C<*2/3>
195 signifies that this note is part of a triplet (3 in stead of 2). The
196 duration is one and a half quaver (C<4.>) times 2/3.
197
198
199 Notenames are just a special kind of identifiers, and can be declared
200 for any language appropriate (see F<dutch.ini>).  The default language
201 for notenames is defined to be dutch. In dutch, the notenames are
202 a,b,c,d,e,f and g. Sharps are formed by adding the extension "is",
203 flats by adding "es"
204
205         % double sharp
206         cisis disis eisis fisis gisis aisis bisis
207         % sharps
208         cis dis eis fis gis ais bis
209         % naturals
210         c d e f g a b 
211         % flats
212         ces des es fes ges as bes
213         % double flats
214         ceses deses eses feses geses ases beses
215
216 The standard notenames also have uppercase versions, which octavate
217 down:
218
219         a       % 220 concert-pitch
220         A       % 110
221         'A      % 55
222         A'      % 220
223         Cisis
224
225 Rests are named r or s
226
227         r       % print a rest
228         s       % a "space" rest, nothing is printed.
229
230 These notenames along with duration are enough material to construct
231 simple melodies:
232
233         c4 c4 g4 g4 a4 a4 g2
234         f4 f4 e4 e4 d4 d4 c2
235
236 Music is able to express more. generally speaking, the other
237 'features' are either connected between notes (slurs, beams: spanning
238 requests) or attached to notes (eg. accents). The former are
239 implemented as START and STOP stop features and then attached to the note.
240
241         []      START/STOP a beam
242         ()      START/STOP a slur
243
244
245 example: 
246
247         [c8 () d8 () e8 ]
248
249 Please note that these two characters do I<not> necessarrily nest,
250 they should attached to the note C<[ {c4 c4} ]> will generate a parse
251 error for this reason. 
252
253         [c8 e8(] [)g8 <c'8] e'8>
254                                 % NO nesting!
255         [2/3 c8 c8 c8]1/1       % a triplet
256
257
258 =head2 Slurs and Ties
259
260 Ties connect the noteheads of adjecent notes. They are entered as follows:
261
262         a4 ~ a4
263
264 Slurs connect whole chords, and try to avoid crossing stems. They are
265 entered as follows:
266
267         a4(  )a4
268
269 =head2 Scripts
270
271 Symbols which can be put at either side (above or below) of a staff
272 are entered as follows:
273
274         a-^     % marcato, direction: default
275         a^-     % portato, direction: above note
276         a_.     % staccato, direction: below note
277         a^\script { "symbolindex"  . . . } % see script.ini for details.
278         a^\fermata      % predefined identifier
279
280 Dynamics can be put after the notename:
281
282         a4 \dynamic { 0 } % 0 = fff, 7 = ppp
283
284 Mudela defines the following dynamic identifiers:
285
286         ppp pp p mp mf df ff fff        % df iso f, f is a notename.
287
288 and the following abbreviations:
289
290         \<      %start crescendo
291         \>      % start decrescendo
292         \!      % end crescendo/decrescendo
293
294 =head2 Text
295
296 To accompany a note with a text (eg, "marcato"), you should say: 
297
298         c_"marcato"
299         c^"marcato"
300         c-"marcato"
301
302 the c- construct chooses the default up/down direction.
303
304
305
306
307 =head2 Defaults
308
309 If omit the duration of a, a default value is substituted. For this
310 default value, there are two modes:
311
312 =over 4
313
314 =item 1
315
316 Use the last duration explicitly entered
317
318 =item 2
319
320 Use the explicitly set "default duration"
321
322 =back
323
324 Thus the following inputs are  equivalent
325
326         c4 c4 c16 c16 c16 s16 c4 c16
327
328         \duration { "last" }
329         c4 c c16 c c c c4 c16
330
331         \duration { 4 }
332         c c c16 c16 c16 c16 c c16
333
334         \duration { 16 }
335         c4 c4 c c c c c4 
336
337 If you are typing music which does not lie in the "small" and "large"
338 octave, you can prevent having to type C<'> all the time by using the
339 C<\octave> command: These two lines have the same pitch.
340
341         c'' d'' e''     
342         \octave{c''} c d e
343
344 By default the setting of C<\octave> is 0.
345
346 =head2 Lyrics
347
348 Lyrics in Mudela resemble Simple mudela a lot, with notes substituted
349 by text. 
350
351 All syllables are entered separately, separated by whitespace 
352
353         Twin-4 kle4 twin-4 kle4 ... 
354
355 Two syllables or words that compose a single
356 duration entry are bound together using an underscore 
357
358         He_could4 not4
359
360 =head2  Music direction
361
362 Mudela reads left to right, but you can still stack voices and
363 Voice_elements which are produced in two directions: horizontal
364 (voice like) and vertical (chord like)
365
366 A sequence of notes (horizontal) is called simple horizontal, eg
367
368         c4 c4 g4 g4
369
370
371 You can also glue two pieces of simple horizontal music together with the
372 concatenation operator:
373
374         horOne = \melodic { c c g g }
375         horTwo = \melodic { a a g2 }
376         twinkle = \melodic { \horOne ++ \horTwo }
377
378 If you enclose simple horizontal music in braces ( { } ), then you get
379 horizontal music:
380
381         { c c g g a a g2 }      % twinkle twinkle
382
383 You can start vertical music (a "chord") by enclosing a sequence of
384 notes with < and >. Example:
385
386         <a cis e'>      % a-major chord
387
388 You can also put vertical music inside horizontal music:
389
390         { c <c e> <c e g> <c e g c'> }  % 4 increasing chords
391
392 And vice versa
393
394         < \multivoice
395           {c c g g a a g2}              
396           {r2  r2  c c g g a a g2} >    % a canon
397
398 The duration of a chord equals the union of the durations of each of
399 its elements.  The C<\multivoice> is a construct which is explained
400 below.
401
402
403 =head2 Transposition
404
405 You can transpose horizontal music in the following way:
406
407         
408         \melodic {
409                 \meter 2/4;
410                 ++
411                 \transpose { 
412                         d               % from c to the d that's one octave down 
413                         { e4 f4 }       % the horizontal music
414                 } ++ g4
415         }
416
417 The result is, as you can see, again simple horizontal music.
418
419
420 =head2 Voicegroups
421
422 If more than one "voice" is in a staff, then you have the option of
423 putting the different voices into so called voicegroups: members of
424 the same voicegroup share certain characteristics, among others:
425
426         - dynamics
427         - text
428         - beams and stems
429         - scripts
430
431 For the actual list, see the init file F<register.ini>
432
433 Putting different musical lines in to the same voicegroup effectively
434 makes LilyPond try to form chords of all those lines. Putting
435 different musical lines in to different voicegroups effectively makes
436 LilyPond try to set those lines as independently as possible. 
437
438 You can set the voicegroup of a voice with the command C<\group>, e.g.,
439         
440         oboeI = \melodic { 
441                 \group "oboes"; 
442                 [e8 f8
443                 \group "+solo";
444                 [g16 a16 g16 fis16]
445                 \group "-";
446                 g8 f8
447         }
448         oboeII = \melodic { \group "oboes";
449                 c8 d8]
450                 e4
451                 e8 d8
452         }
453         ///     ...
454
455         \staff { 
456                 melodicregs \melodic{ oboeI }
457                 \melodic { oboeII}
458         }
459
460 In this example, the two oboe voices share one staff and are initially
461 in the voicegroup called "oboes". They will share beams, dynamics etc.
462 After two quavers, oboeI "pushes" its group: a new voicegroup is
463 created, called "oboes+solo". The C<\group "-"> command makes the
464 voice enter "oboes" again.
465
466 Please do note that [] are voicegroup wide; the previous input is
467 valid: the beam, started in oboeI, voicegroup "oboes" is also ended in
468 voicegroup "oboes", albeit not in oboeI but oboeII
469
470 This concept may seem contorted, but it allows you to set the separate
471 oboe parts without changing the C<oboeI> and C<oboeII> (assuming that
472 you edit the [] in the example.)
473
474 The construct
475
476         < { .... } {......} >
477
478 makes a chord (all horizontal parts are in the same voicegroup). The construct
479
480         < \multivoice { ....} { .... } >
481
482 creates horizontal parts which behave independently. You will have to
483 set voicegroup features by hand (\stem and \hshift. See examples)
484
485
486
487
488 =head2 Rhythms
489
490 Rhythms in Mudela are entered identical to Simple mudela.
491 The melodic part of the information is ignored.
492
493 =head2 Durations
494
495 A duration always starts with the duration type (1,2,4 etc), and then
496 any optional multipliers/dots
497
498 =head2 Meters/groupings
499
500 A meter has this form:
501
502         \meter 3/4 ;
503
504 Rhythmic grouping is  a concept closely associated with this. For
505 example, in a 5/8 meter, the counts are grouped 2+3. In mudela this is
506 entered as
507
508         \grouping  8*2 8*3 ;
509
510 You can start the piece with a partial measure, the command takes the
511 same syntax as grouping: 
512
513         \partial 16*3 4;
514
515 Make the piece start with a partial measure [transl?]  lasting 1 3/4
516 quaver.
517
518 These commands are also "voice elements", and constitute simple mudela
519 (consisting of stuff with duration 0).
520
521 =head1 STRUCTURE
522
523 In concrete, a piece of Mudela has the following structure:
524
525         % declare pieces of music:
526         melody = \music{ <simple mudela> }
527         accompany = \music{ <simple mudela> }
528
529         % instantiate (=create tex, midi output) the score:
530         \score{ 
531                 \staff{ melodicregs melody }
532                 \staff{ melodicregs accompany }
533                 \midi{ <midi definitions> }
534                 \paper{ <paper and layout definitions> }
535         }
536
537 =head2 Examples
538
539 Examples are included with the GNU LilyPond distribution. For the sake of
540 maintenance no long examples are included in this document.
541
542 =head2 Staff
543
544 The staff is a simple container (containing Voices). The so-called
545 "registers" determine the characteristics of the Staff. At this time,
546 LilyPond supports the following personalities:
547
548 =over 4
549
550 =item melodicregs
551
552 This makes the staff into a single five line melodic staff.
553
554 =item lyricregs
555
556 This makes the staff into a staff which will only set Lyric_requests.
557
558 =back
559
560
561 =head1 HISTORY
562
563
564 This language has a number of roots. First and foremost, GNU LilyPond's
565 predecessor mpp was the inspiration of simple Mudela.  Secondly, the
566 hierarchical structure looks a lot like Rayce's (Rayce is a raytracer
567 that I've written as a hobby project. ), which in turn owes a lot to
568 POVRay.
569
570 Now, we know, musictypesetting and raytracing do not necessarily
571 require the same input format, and we know that a lot more ways exist
572 to convert music to ASCII, but we did give this language some
573 thoughts. As always suggestions are appreciated.
574