lilypond-0.1.55
[lilypond.git] / Documentation / mudela.pod
blob633c9b588db9411d1bf38b07fe6532b597625d3b
1 =head1 NAME
3 Mudela -  GNU LilyPond input format 0.1
5 =head1 DESCRIPTION
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>).
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]
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.
20 =head1 Overview
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.
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>):
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.
34 =head2 Files
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:
39         \include "a_file.ly"
41 =head2 Comments
43 Line comments are introduced by a C<%>. Block comments are delimited
44 by C<%{> and C<%}>. They do not nest.
46 =head2 Versions
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,
53         \version "0.0.50";
55 A perl-script which tries to convert to newer versions
56 (F<convert-mudela>) is included in the LilyPond distribution.
58 =head2 Words
60 Keywords are preceded by a backslash: '\'. They contain alphabetic
61 characters only. 
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:
67         $i'm_a_weird###identifier
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<%>.
73         \$i'm_a_weird###escaped_word
75 =head2 Nesting characters
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.
81 =head2 Constants
83 Please note that -.5 is no Real.
85         "I am a string"
86         -1.2e3          % a real
87         12              % an int
90         
91 =head2 Identifiers
93 =head2 Hierarchical structures
95 The general structure consists of declarations:
97         IDENTIFIER = \TYPE{
98                 <type specific data>
99         }
101 and instantiations:
103         \TYPE{ <type specific data> }
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)
108 Most instantiations that use an IDENTIFIER are specified as follows:
110         \TYPE{ IDENTIFIER [...] }
112 Some exceptions on this rule have been made to prevent inputting
113 Mudela becoming tedious
116 =head2 Simple mudela
118 The actual musical part of Mudela that defines a melody, is known as 
119 I<simple mudela>. 
121 Simple mudela is the most common type of music.  It consists of a list
122 of notes or lyrics, chords, and commands.
124 =head2 Modes:
126 To simplify different aspects of music definition (entering the notes
127 and manipulating them) Mudela has a number of different input "modes":
129 =over 4
131 =item Normal mode
133 At the start of parsing, Mudela assumes normal mode.
134 In Normal mode, a word is looked up in the following order:
136         word    identifier, string
137         \word   keyword, identifier, string
139 In normalmode, a word is assumed to start with an alphabetic
140 character, followed by alpha-numeric characters.
142 =item Note mode
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:
147         word    notename, string
148         \word   keyword, identifier, string
150 In Note mode a word is considered to have alphabetic characters only.
152 =item Lyric mode
154 Lyrics mode (and thus Simple mudela)  is introduced by the keyword C<\lyrics>.
156 In Lyrics mode, a word is looked up in the following order:
158         word    string
159         \word   keyword, identifier, string
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.
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
169 =back
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
175 =head2 Notes
177 Simple mudela basically is a sequence of the notes you want to
178 enter. 
180         a'4     % dutch names
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:
185         'a      % 110
186         a       % 220
187         a'      % 440
188         a''     % 880
190 another example:
192         'as4.*2/3
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.
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"
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
216 The standard notenames also have uppercase versions, which octavate
217 down:
219         a       % 220 concert-pitch
220         A       % 110
221         'A      % 55
222         A'      % 220
223         Cisis
225 Rests are named r or s
227         r       % print a rest
228         s       % a "space" rest, nothing is printed.
230 These notenames along with duration are enough material to construct
231 simple melodies:
233         c4 c4 g4 g4 a4 a4 g2
234         f4 f4 e4 e4 d4 d4 c2
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.
241         []      START/STOP a beam
242         ()      START/STOP a slur
245 example: 
247         [c8 () d8 () e8 ]
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. 
253         [c8 e8(] [)g8 <c'8] e'8>
254                                 % NO nesting!
255         [2/3 c8 c8 c8]1/1       % a triplet
258 =head2 Slurs and Ties
260 Ties connect the noteheads of adjecent notes. They are entered as follows:
262         a4 ~ a4
264 Slurs connect whole chords, and try to avoid crossing stems. They are
265 entered as follows:
267         a4(  )a4
269 =head2 Scripts
271 Symbols which can be put at either side (above or below) of a staff
272 are entered as follows:
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
280 Dynamics can be put after the notename:
282         a4 \dynamic { 0 } % 0 = fff, 7 = ppp
284 Mudela defines the following dynamic identifiers:
286         ppp pp p mp mf df ff fff        % df iso f, f is a notename.
288 and the following abbreviations:
290         \<      %start crescendo
291         \>      % start decrescendo
292         \!      % end crescendo/decrescendo
294 =head2 Text
296 To accompany a note with a text (eg, "marcato"), you should say: 
298         c_"marcato"
299         c^"marcato"
300         c-"marcato"
302 the c- construct chooses the default up/down direction.
307 =head2 Defaults
309 If omit the duration of a, a default value is substituted. For this
310 default value, there are two modes:
312 =over 4
314 =item 1
316 Use the last duration explicitly entered
318 =item 2
320 Use the explicitly set "default duration"
322 =back
324 Thus the following inputs are  equivalent
326         c4 c4 c16 c16 c16 s16 c4 c16
328         \duration { "last" }
329         c4 c c16 c c c c4 c16
331         \duration { 4 }
332         c c c16 c16 c16 c16 c c16
334         \duration { 16 }
335         c4 c4 c c c c c4 
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.
341         c'' d'' e''     
342         \octave{c''} c d e
344 By default the setting of C<\octave> is 0.
346 =head2 Lyrics
348 Lyrics in Mudela resemble Simple mudela a lot, with notes substituted
349 by text. 
351 All syllables are entered separately, separated by whitespace 
353         Twin-4 kle4 twin-4 kle4 ... 
355 Two syllables or words that compose a single
356 duration entry are bound together using an underscore 
358         He_could4 not4
360 =head2  Music direction
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)
366 A sequence of notes (horizontal) is called simple horizontal, eg
368         c4 c4 g4 g4
371 You can also glue two pieces of simple horizontal music together with the
372 concatenation operator:
374         horOne = \melodic { c c g g }
375         horTwo = \melodic { a a g2 }
376         twinkle = \melodic { \horOne ++ \horTwo }
378 If you enclose simple horizontal music in braces ( { } ), then you get
379 horizontal music:
381         { c c g g a a g2 }      % twinkle twinkle
383 You can start vertical music (a "chord") by enclosing a sequence of
384 notes with < and >. Example:
386         <a cis e'>      % a-major chord
388 You can also put vertical music inside horizontal music:
390         { c <c e> <c e g> <c e g c'> }  % 4 increasing chords
392 And vice versa
394         < \multivoice
395           {c c g g a a g2}              
396           {r2  r2  c c g g a a g2} >    % a canon
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.
403 =head2 Transposition
405 You can transpose horizontal music in the following way:
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         }
417 The result is, as you can see, again simple horizontal music.
420 =head2 Voicegroups
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:
426         - dynamics
427         - text
428         - beams and stems
429         - scripts
431 For the actual list, see the init file F<register.ini>
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. 
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         ///     ...
455         \staff { 
456                 melodicregs \melodic{ oboeI }
457                 \melodic { oboeII}
458         }
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.
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
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.)
474 The construct
476         < { .... } {......} >
478 makes a chord (all horizontal parts are in the same voicegroup). The construct
480         < \multivoice { ....} { .... } >
482 creates horizontal parts which behave independently. You will have to
483 set voicegroup features by hand (\stem and \hshift. See examples)
488 =head2 Rhythms
490 Rhythms in Mudela are entered identical to Simple mudela.
491 The melodic part of the information is ignored.
493 =head2 Durations
495 A duration always starts with the duration type (1,2,4 etc), and then
496 any optional multipliers/dots
498 =head2 Meters/groupings
500 A meter has this form:
502         \meter 3/4 ;
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
508         \grouping  8*2 8*3 ;
510 You can start the piece with a partial measure, the command takes the
511 same syntax as grouping: 
513         \partial 16*3 4;
515 Make the piece start with a partial measure [transl?]  lasting 1 3/4
516 quaver.
518 These commands are also "voice elements", and constitute simple mudela
519 (consisting of stuff with duration 0).
521 =head1 STRUCTURE
523 In concrete, a piece of Mudela has the following structure:
525         % declare pieces of music:
526         melody = \music{ <simple mudela> }
527         accompany = \music{ <simple mudela> }
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         }
537 =head2 Examples
539 Examples are included with the GNU LilyPond distribution. For the sake of
540 maintenance no long examples are included in this document.
542 =head2 Staff
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:
548 =over 4
550 =item melodicregs
552 This makes the staff into a single five line melodic staff.
554 =item lyricregs
556 This makes the staff into a staff which will only set Lyric_requests.
558 =back
561 =head1 HISTORY
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.
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.