3 DEFINEMACRO(var)(1)(whenlatex(latexcommand({\normalfont\scshape )ARG1+latexcommand(}))\
8 COMMENT( This document contains Mudela fragments. You need at least
9 Yodl-1.30.18 to convert this to tex or html.
16 htmlbodyopt(bgcolor)(white)
17 htmlcommand(<font color=black>)
19 latexpackage()(a4wide)
21 %\usepackage[latin1]{inputenc}
25 whenlatex(notableofcontents())
26 whentexinfo(notableofcontents())
28 report(Mudela, reference manual)
29 (Han-Wen Nienhuys and Jan Nieuwenhuizen)
30 (nop()PIPETHROUGH(date "+%B %d, %Y")()()nop())
36 * paragraphs have too much space.
41 latexcommand(\def\interexample{})
42 latexcommand(\def\preexample{\par})
43 latexcommand(\def\postexample{\par\medskip})
44 latexcommand(\def\file#1{{code(#1)}})
46 latexcommand(\def\texttt#1{\tt #1})
47 latexcommand(\def\textbf#1{\bf #1})
51 bf(This document is not up to date). All rendered examples of course
52 are current, but the rest probably isn't. Adjusting the tutorial was
53 considered more important than writing the reference manual. We
54 apologize for the inconvenience.
57 This document describes the the GNU LilyPond input format, which is an
58 effective language for defining music. We call this language (rather
59 arrogantly) The Musical Definition Language or Mudela, for
60 short.footnote(If anybody comes up with a better name, we'd gladly
61 take this. Gourlay already uses Musical Description Language,
62 G-Sharp Score Definition Language. ISO standard 10743 defines a
63 Standard Music Description Language. We're not being original here.)
65 The first aim of Mudela is to define a piece of music, being complete
66 from both from a musical typesetting, as from a musical performing
69 The Musical Definition Language (Mudela), has a logical structure,
70 making use of identifiers, that allows for flexible input, and
71 definition reuse. See the documentation file file(MANIFESTO), included
72 with the LilyPond sources for reasons and design considerations.
74 The below is included for explanatory purposes only (i.e., for a
75 complete and up-to-date definition, see file(lily/parser.yy) and
78 As a related note, you should take a look at the examples and the init
79 files, as this document does not cover every aspect of Mudela yet, and
80 may be out of date.footnote(Ok, I am being pessimistic here. This
81 just is a disclaimer. Docs usually are written after the program
82 itself.) This document intends to give an idea of how it works. It is
83 not a guide on how to use it.
87 The de-facto extension of Mudela is file(.ly). Files may be included by
88 entering code(\include) at the start of a line:
97 Line comments are introduced by a
99 Block comments are delimited
109 Occasionally, small changes in syntax across different versions of
110 Mudela might give syntax errors. To warn you about possible
111 incompatibilities, you can specify the Mudela version for which the
112 inputfile was written,
117 A Python-script which tries to convert to newer versions
118 (file(convert-mudela)) is included in the LilyPond distribution.
122 Keywords are preceded by a backslash: code(\). They contain
123 alphabetic characters only.
126 sect(Nesting characters)
128 Mudela uses the brace, `code({)' and `code(})' for most hierarchical
129 structures. For chords the code(<) and the code(>) are used as
143 When assigning identifiers you use
149 If you reuse identifiers, then the previous contents will be thrown
150 away after the right hand is evaluated, e.g.
152 bla = \melodic { \bla }
156 When using identifiers they have to be escaped:
159 oboe = \melodic { ... }
160 \score{ \melodic { \oboe }}
163 The left-hand part of the assignment is really a string, so
165 "Foo bar 4 2 " = \melodic { .. }
168 is also a valid assignment (but you would have trouble referencing to it)
171 sect(Hierarchical structures)
173 The general structure consists of declarations:
182 \TYPE{ <type specific data> }
185 (Currently, code(\score) is the only type that can be instantiated
188 Most instantiations that use an IDENTIFIER are specified as follows:
191 \TYPE{ \IDENTIFIER [...] }
194 Some exceptions on this rule have been made to prevent inputting
195 Mudela becoming tedious
199 To simplify different aspects of music definition (entering the notes
200 and manipulating them) Mudela has a number of different input "modes":
207 At the start of parsing, Mudela assumes normal mode.
208 In Normal mode, a word is looked up in the following order:
210 dit(code(word)) string
211 dit(code("string")) string
212 dit(code(\word)) keyword, identifier
214 In normal mode, a word is assumed to start with an alphabetic
215 character, followed by alpha-numeric characters.
217 dit(Note mode) Note mode is introduced by the keyword
218 code(\melodic). In Note mode, a word is looked up in the following
221 dit(code(word)) notename, string
222 dit(code("string")) string
223 dit(code(\word)) keyword, identifier
226 In Note mode a word is considered to have alphabetic characters only,
227 so the underscore (_) is invalid. If you accidently mistype a
228 notename, the parser will assume that you are entering a string (and
229 it will most likely complain that you should be in code(\lyric) mode to
233 dit(Lyric mode) Lyrics mode is introduced by the keyword
234 code(\lyric). Because of the various control characters that can
235 appear in lyrics, e.g., foreign language accents, the inputting a
236 string containing these has been made very easy.
238 In Lyrics mode, a word is looked up in the following order:
240 dit(code(word)) string (thus a lyric)
241 dit(code("string")) string
242 dit(code(\word)) keyword, identifier
245 In Lyric mode every sequence of non-digit and non-white characters
246 starting with an alphabetic character or the _ is considered a word.
249 a&@&@&TSI|{[ % a word
250 1THtrhortho % not a "word"
251 Leise DOEXPAND(Fl\)DOEXPAND("u\)ss{}teren meine Sapfe % 4 words
252 _ _ _ _ % 4 words: 4 spaces
256 These modes are of a lexical nature. Normal and Note mode largely
257 resemble each other, save the possibility of entering Reals,
258 meaning of code(_) and the resolution of words
264 Durations are entered as their reciprocal values
265 mudela(fragment,verbatim,center)(
266 a'1 a'2 a'4 a a'8 a a'16 a'32 a'64
268 Notice that you only have to specify the duration when it changes: Lily
269 assumes a note has the same duration as the previous one.
271 Now we can already write a little tune
272 mudela(fragment,verbatim,center)(
273 c' d' e' c' | c' d' e' c' | e' f' g'2
275 As you'll probably have guessed,
276 the vertical bar code(|) may be used to mark
279 In the scale shown above
280 we left-out the last c note of the next octave.
281 Postfixing the pitch with a quote code(')
282 produces a note by one octave higher
283 mudela(fragment,verbatim,center)(
287 Postfixing the pitch with a comma, code(,)
288 produces a note by one octave lower
289 mudela(fragment,verbatim,center)(
295 A tie connects two adjacent note heads
297 mudela(fragment,verbatim,center)(
301 Whereas a slur rather connects `chords',
302 and tries to avoid crossing stems
304 mudela(fragment,verbatim,center)(
308 And of course, such a (legato) slur can span several notes
309 mudela(fragment,verbatim,center)(
313 sect(Beams and Tuplets)
316 mudela(fragment,verbatim,center)(
317 [a'8 a'] [a'16 a' a' a']
320 Here's a beamed triplet
321 mudela(fragment,verbatim,center)(
325 a triplet without a beam
326 mudela(fragment,verbatim,center)(
331 mudela(fragment,verbatim,center)(
332 [/3 a'8 a'16 a'] a'8 \]
336 mudela(fragment,verbatim,center)(
340 mudela(fragment,verbatim,center)(
346 Lily has predefined sets of notenames
347 for various nop(languages)footnote(These
348 are Dutch, English, German, Italian and Swedish.
349 Simply include the language specific init file file(language.ly).).
350 The default set are the ones we like best are the Dutch notenames.
352 A sharp is formed by adding code(is)
353 mudela(fragment,verbatim,center)(
354 cis' dis' eis' fis' gis' ais' bis'
357 and a flat is formed by adding code(es)
358 mudela(fragment,verbatim,center)(
359 ces' des' es' fes' ges' as' bes'
362 With the obvious names for double sharps
363 mudela(fragment,verbatim)(
364 cisis' disis' eisis' fisis' gisis' aisis' bisis'
368 mudela(fragment,verbatim)(
369 ceses' deses' eses' feses' geses' ases' beses'
373 There are two special `notenames', the rest
374 mudela(fragment,verbatim,center)(
379 mudela(fragment,verbatim,center)(
380 a'2 s-"diminuendo" | a'
386 mudela(fragment,verbatim,center)(
391 mudela(fragment,verbatim,center)(
392 \clef "treble"; f' e' \clef "alto"; d' c'
395 mudela(fragment,verbatim,center)(
396 \time 3/4; c' g' g' |
399 mudela(fragment,verbatim,center)(
401 g a b cis' d' e' fis' g'
403 Note how Mudela allows you to
404 convey a musical message and doesn't force you to produce a list of typesetting commands.
405 If the music has a code(cis), you type a code(cis).
406 Depending on the key and context of the note
407 Lily will determine what accidentals to typeset.
409 A reminder accidental can be forced by
410 using an exclamation mark code(!)
411 on a pitch a reminder accidental
412 mudela(fragment,verbatim,center)(
413 cis' d' e' cis' | c'! d' e' c' |
416 mudela(fragment,verbatim)(
418 \bar "|:"; c' c' \bar ":|:"; c' c' \bar ":|"; c' c' \bar "|.";
421 sect(Chords and Voices)
423 Here's a simple chord
424 mudela(fragment,verbatim,center)(
429 mudela(fragment,verbatim,center)(
438 mudela(fragment,verbatim)(
440 { \voiceone c'4 g' c' g' }
446 sect(A complete example)
447 COMMENT(%label(se:complete))
449 A Mudela file needs some red tape
463 Lyrics are entered like notes, with pitches substituted
466 All syllables are entered separately, separated by whitespace
468 Twin-4 kle4 twin-4 kle4 ...
471 Two syllables or words that compose a single
472 duration entry are bound together using an underscore
484 mudela(verbatim,center)(
487 \melodic \transpose c'' {
493 DOEXPAND(Fr\)`e-4 re Ja- que
494 DOEXPAND(Fr\)`e- re Ja- que
502 sect(Composition: forming bigger structures)
505 The computer savy user may be interested in a more formal
506 specification. We can capture what have learned about forming
507 sentences in Mudela in a context-free grammar.
509 latexcommand(\smallskip)
512 row(cell(em(Music))cell(: em(Note)))
513 row(cell()cell(code(|) em(Rest)))
514 row(cell()cell(code(|) code({) em(MusicList) code(})))
515 row(cell()cell(code(|) code(<) em(MusicList) code(>)))
516 row(cell()cell(code(|) em(Command)))
517 row(cell()cell(code(|) code(\type) em(string) code(=) em(string) em(Music)))
519 row(cell(em(MusicList))cell(: em(empty)))
520 row(cell()cell(code(|) em(MusicList) em(Music)))
524 latexcommand(\smallskip)
530 In mathematics you can form expressions by combining expressions,
531 which are ultimately some kind of atom or terminal symbol. The same
532 goes for Mudela: there are some basic building blocks, and by
533 combining those you create complex music.
535 You can combine music in three ways:
537 it()If you enclose a sequence of music-elements in braces ( code({)
538 and code(}) ), then you form another kind of music called
541 The duration of sequential composition is the sum of the durations of its elements
543 { c c g g a a g2 } % twinkle twinkle
544 { { c c g g} { a a g2 } }
546 it()You can stack music by enclosing a sequence of music elements
547 with code(<) and code(>). This is called simultaneous music.
548 The duration of a simultaneous composition is the union of the durations
549 of its elements Example:
551 <a4 {cis8 cis8} e'4> % a-major chord
553 it()You can form music by transposing music:
556 d % from c to the d that's almost one octave down
557 { e4 f4 } % the horizontal music
561 it()verb(\translator)
565 Of course you can also combine these three mechanisms.
567 { c <c e> <c e g> <c e g \transpose d' dis > } % 4 increasing chords
573 A duration always starts with the duration type (1,2,4 etc), and then
574 any optional multipliers/dots. `Gregrorian' durations can be entered
583 sect(Time signatures/groupings)
585 A time signature specification has this form:
590 Rhythmic grouping is a concept closely associated with this. For
591 example, in a 5/8 time signature, the counts are grouped 2+3. In Mudela this is
597 You can start the piece with a partial measure, the command takes a
598 duration as an argument
603 Make the piece start with a upstep
604 lasting 1 3/4 quarter notes.
606 These commands constitute `Music', and have a duration of 0.
611 By default the same key signature is valid for all octaves, but
612 this can be changed with the property code(keyoctaviation).
615 The identifier code(\specialkey) sets the property for the Staff. A
616 key with two flats in one octave and three sharps in the next can be
617 declared with verb(\specialkey \keysignature bes es fis' cis' gis';)
619 sect(Music fragments)
620 label(tutorial:music-fragments)
622 Sometimes you only need to print a small fragment of music, perhaps
623 something much like one of the examples in this document. Back in
624 section ref(sec:running-lilypond) we told you that the music you
625 enter should be encapsulated in something like:
635 where the only interesting information is this particular example is verb(
638 The rest of the above example was already nicknamed `red tape'.
639 You may easily get bored if you have to provide this same red tape
640 for every fragmenty you nop(try)footnote(Of course, in most cases your
641 favourite text editor (TM)
644 Luckily there's a trick around this, and it's called file(.fly) files.
645 If you use the extension file(.fly) for Mudela file file(foo),
646 LilyPond will embed your file(foo.fly) nop(in)footnote(Or something very
647 similar. If you want to know exactly, see file(init/init.fly)):
657 Here's how it works. If you run LilyPond on your file file(bar.ly), you
658 may notice that she starts-off by reading quite a number of files before
659 she actually reaches your file(bar.ly). There's no magic going on, Lily
660 by default reads an initialisation file (file(init/init.ly)). In the
661 initialisation process a lot of things are defined that you'll need for
662 normal operation, such as notenames and various other mudela shortcuts,
663 engraver and perforer definitions, font sizes, musical dimensions and
664 paper sizes. When you use the extension file(.fly), Lily just starts
665 reading another initialisation file (file(init/init.fly)), that includes the
666 red tape for you too.