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