2 % this document should be run through the mudela-book script after lilypond
6 \documentclass{article}
8 \title{Mudela and LilyPond crash course}
9 \author{Han-Wen Nienhuys}
10 \def\file#1{{\texttt{#1}}}
14 \def\interexample{\par Produces the following:\par}
15 \def\preexample{\par\medskip}
16 \def\postexample{\par\medskip}
18 \emph{This document is not complete yet. It's just a brief blurb which
19 skimps some features of Mudela}
23 This document describes two different things
25 \item[Mudela] A language for defining music.
27 \item[LilyPond] A package (the only one existing :-) which can
28 read a mudela file and interpret it.
30 The name ``LilyPond'' does not have much to do with the purpose of
31 the package, but we have a special emotional attachment with the
32 name. (Of course we are not telling why we chose it; this is an
33 excercise for the reader, most of the vital clues are contained in
34 the documentation and the source code. If you have guess, then let
41 Let's start with a very simple example, we will enter ``twinkle twinkle
42 little star.'' We start with the most important part: the notes.
44 Imagine being in a music-lesson, and that you made an error playing
45 ``twinkle twinkle''. Your teacher asks you to read out loud the
46 melody of the song, just to verify your eyesight. You would probably
49 A quarter note C, Another quarter note C, a quarter G, another one, etc.
52 Mudela tries to capture this verbal presentation of sheet music, in
53 the following way. The first line of twinkle twinkle is written in
60 The notes are entered with names (a, b, c) combined with numbers
61 (2,4). The names designate the pitches, the numbers the durations: 4
62 is a quarter note, 2 a half note, etc.
64 Now all we have to specify what should be done with the music. We
65 want a paper version, so we combine the music with a ``output this on
66 paper'' statement. These two are combined in ``score'' block. This
67 is the final result with its output. We add a comment (the line
68 starting with \verb+%+).
70 called \file{twinkle.ly}
84 there are a few things to note about this example:
86 The braces are grouping characters. In general, in mudela data entry
87 for a data section called ``foobar'' looks like this:
93 To see if it actually works, we run it through LilyPond. Invoke the
98 When LilyPond starts working it will produce various ``operator
99 pacification'' messages, which you can safely ignore for now. The run
100 should have left a file called \file{lelie.tex} in your working
101 directory. You can process that file with TeX, and it will look like
114 As you can see, this is the song that we wanted, albeit a little
115 low-pitched. You would probably want a version of the song which has
116 all notes an octave higher. This can be done by adding a
117 \verb+\octave+ command to the source. This sets the default octave
118 for all notes. Another convenience is the default duration: if you do
119 not specify a duration with the notename, the last explicitly entered
120 is used. The improved version reads thus
123 \begin[verbatim]{mudela}
137 \begin[verbatim]{mudela}
139 \melodic { % {...} is a voice
140 c'4 g'4 % c and g are pitches, 4 is the duration
141 % (crotchet/quarter note)
142 c''4 ''c4 % c' is 1 octave up, 'c 1 down.
143 <c'4 g'4> % <...> is a chord
149 \begin[fragment,verbatim]{mudela}
153 Basics: the \verb+%+ introduces a comment. All music is inside a
154 \verb+\score+ block which represents one movement, ie one contiguous
155 block of music. Voices are grouped by \verb+{+ and \verb+}+ and
156 chords by \verb+<+ and \verb+>+.
159 The \verb+\octave+ command controls the default pitch (octave). If you
160 do not specify duration, the last one entered is used. The
161 \verb+\paper+ block contains parameters for spacing and dimensions.
163 \begin[verbatim]{mudela}
165 % twinkle twinkle little star
169 f4 f e e d [d8. e16] c2
172 \paper { linewidth = 5.\cm; }
176 A more complex example; The multi command controls at what level the
177 different components of a chord are interpreted. The LilyPond chord
178 is much more general than a traditional chord. Multiple voices on a
179 staff are entered as a chord of voices. A score is a chord of staffs,
182 \begin[verbatim]{mudela}
187 < \multi 1; { c2 c2 } { c'2 c'2 } >
188 < \multi 2; { \stem -1; c2 c2 } { \stem 1; c'2 c'2 } >
190 { \clef "bass"; c2 c2 }
191 { \meter 2/4;\bar "||";
192 \key fis cis gis; c'2 c'2 } >
195 < \multi 1; < \multi 3;
196 { \meter 2/4; \clef "violin"; c2 c2 }
197 { \meter 2/4; \clef "bass"; c2 c2 }
200 { \meter 2/4; \clef "violin"; c2 c2 }
201 { \meter 2/4; \clef "bass"; c2 c2 }
210 LilyPond is designed to handle complicated stuff automatically.
211 Expertise should be in the program, not in the user.
213 The following example shows how multiple voices on the same staff are
214 handled graciously (well, somewhat). If the noteheads of different
215 voices collide, they are moved horizontally. Rests are moved
218 \begin[verbatim]{mudela}
221 { \octave c'; \stem -1;
222 c4 d e f g2~ g4 a [c8 d e f] c2| }
224 g4 f e g ~ g2 g2 c4 g4 g2 }
228 two_voice_steminvert = \melodic
230 { \octave c'; \stem 1;
231 % the f and g on 4th beat are exceptionally ugh.
238 three_voice = \melodic
242 { \hshift 1; \stem 1;
252 { \stem 1; g'8 f' e' d' c' b a g f e d c }
253 { \stem -1; r r r r r r r r r r r r }
257 < \multi2; r8 r8 r8 >
258 < \multi2; r8 r8 r8 r8 >
267 \melodic { \$two_voice \$two_voice_steminvert
268 \$three_voice \restsII }