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 \date{October 20, 1997}
11 \def\file#1{{\texttt{#1}}}
15 \def\interexample{\par Produces the following:\par}
16 \def\preexample{\par\medskip}
17 \def\postexample{\par\medskip}
19 \emph{This document is not complete yet. It's just a brief blurb which
20 skims some features of Mudela}
24 This document describes two different things
26 \item[Mudela] A language for defining music.
28 \item[LilyPond] A package (the only one existing :-) which can
29 read a mudela file and interpret it.
31 The name ``LilyPond'' does not have much to do with the purpose of
32 the package, but we have a special emotional attachment with the
33 name. (Of course we are not telling why we chose it; this is an
34 excercise for the reader, most of the vital clues are contained in
35 the documentation and the source code. If you have guess, then let
42 Let's start with a very simple example, we will enter ``twinkle twinkle
43 little star.'' We start with the most important part: the notes.
45 Imagine being in a music-lesson, and that you made an error playing
46 ``twinkle twinkle''. Your teacher asks you to read out loud the
47 melody of the song, just to verify your eyesight. You would probably
50 A quarter note C, Another quarter note C, a quarter G, another one, etc.
53 Mudela tries to capture this verbal presentation of sheet music, in
54 the following way. The first line of twinkle twinkle is written in
61 The notes are entered with names (a, b, c) combined with numbers
62 (2,4). The names designate the pitches, the numbers the durations: 4
63 is a quarter note, 2 a half note, etc.
65 Now all we have to specify what should be done with the music. We
66 want a paper version, so we combine the music with a ``output this on
67 paper'' statement. These two are combined in ``score'' block. This
68 is the final result with its output. We add a comment (the line
69 starting with \verb+%+).
71 called \file{twinkle.ly}
85 there are a few things to note about this example:
87 The braces are grouping characters. In general, in mudela data entry
88 for a data section called ``foobar'' looks like this:
94 To see if it actually works, we run it through LilyPond. Invoke the
99 When LilyPond starts working it will produce various ``operator
100 pacification'' messages, which you can safely ignore for now. The run
101 should have left a file called \file{lelie.tex} in your working
102 directory. You can process that file with \TeX, and it will look like
115 As you can see, this is the song that we wanted, albeit a little
116 low-pitched. You would probably want a version of the song which has
117 all notes an octave higher. This can be done by adding a
118 \verb+\octave+ command to the source. This sets the default octave
119 for all notes. Another convenience is the default duration: if you do
120 not specify a duration with the notename, the last explicitly entered
121 is used. The improved version reads thus
124 \begin[verbatim]{mudela}
138 FIXME rewrite starting here.
140 \begin[verbatim]{mudela}
142 \melodic { % {...} is a voice
143 c'4 g'4 % c and g are pitches, 4 is the duration
144 % (crotchet/quarter note)
145 c''4 ''c4 % c' is 1 octave up, 'c 1 down.
146 <c'4 g'4> % <...> is a chord
152 \begin[fragment,verbatim]{mudela}
156 Basics: the \verb+%+ introduces a comment. All music is inside a
157 \verb+\score+ block which represents one movement, ie one contiguous
158 block of music. Voices are grouped by \verb+{+ and \verb+}+ and
159 chords by \verb+<+ and \verb+>+.
162 The \verb+\octave+ command controls the default pitch (octave). If you
163 do not specify duration, the last one entered is used. The
164 \verb+\paper+ block contains parameters for spacing and dimensions.
166 \begin[verbatim]{mudela}
168 % twinkle twinkle little star
172 f4 f e e d [d8. e16] c2
175 \paper { linewidth = 5.\cm; }
179 A more complex example; The multi command controls at what level the
180 different components of a chord are interpreted. The LilyPond chord
181 is much more general than a traditional chord. Multiple voices on a
182 staff are entered as a chord of voices. A score is a chord of staffs,
185 \begin[verbatim]{mudela}
190 \multi 1 < { c2 c2 } { c'2 c'2 } >
191 \multi 2 < { \stemdown c2 c2 } { \stemup c'2 c'2 } >
193 { \clef "bass"; c2 c2 }
194 { \meter 2/4;\bar "||";
195 \key fis cis gis; c'2 c'2 } >
199 { \meter 2/4; \clef "violin"; c2 c2 }
200 { \meter 2/4; \clef "bass"; c2 c2 }
203 { \meter 2/4; \clef "violin"; c2 c2 }
204 { \meter 2/4; \clef "bass"; c2 c2 }
213 LilyPond is designed to handle complicated stuff automatically.
214 Expertise should be in the program, not in the user.
216 The following example shows how multiple voices on the same staff are
217 handled graciously (well, somewhat). If the noteheads of different
218 voices collide, they are moved horizontally. Rests are moved
223 \begin[verbatim]{mudelaXX}
226 { \octave c'; \stemdown
227 c4 d e f g2~ g4 a [c8 d e f] c2| }
229 g4 f e g ~ g2 g2 c4 g4 g2 }
233 two_voice_steminvert = \melodic
235 { \octave c'; \stemup
236 % the f and g on 4th beat are exceptionally ugh.
243 three_voice = \melodic
247 { \property Voice.hshift = 1 \stemup
257 { \stemup g'8 f' e' d' c' b a g f e d c }
258 { \stemdown r r r r r r r r r r r r }
262 \multi 2 < r8 r8 r8 >
263 \multi 2 < r8 r8 r8 r8 >
272 \melodic { \$two_voice \$two_voice_steminvert
273 \$three_voice \restsII }