lilypond-1.4.4
[lilypond.git] / Documentation / mudela-course.doc
bloba24d2f382ae977d9661320182467d6e312b695dd
1 % -*-LaTeX-*-
2 % this document should be run through the mudela-book script after lilypond
3 % has been installed.
6 \documentclass{article}
7 \usepackage{a4wide}
8 \title{Mudela and LilyPond crash course}
9 \author{Han-Wen Nienhuys}
10 \date{October 20, 1997}
11 \def\file#1{{\texttt{#1}}}
13 \begin{document}
14 \maketitle
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}
22 \section{Who is who}
24 This document describes various  things, but let's first point out the
25 different parts of the package, and their names.
26 \begin{description}
27 \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. 
30 \item[Feta] A (Meta)Font of musical symbols.  LilyPond uses it to
31   render sheet music.
32 \end{description}
34 \section{Overview}
36 Let's start with a very simple example, we will enter ``twinkle
37 twinkle little star.''  We start with the most important part: the
38 notes.
40 Imagine being in a music-lesson, and that you made an error playing
41 ``twinkle twinkle''.  Your teacher asks you to read out loud the
42 melody of the song, just to verify your eyesight.  You would probably
43 say something like
44 \begin{quote}
45   A quarter note C, Another quarter note C, a quarter G, another one, etc.
46 \end{quote}
48 Mudela tries to capture this verbal presentation of sheet music, in
49 the following way.  The first line of twinkle twinkle is written in
50 as follows
51 \begin{verbatim}
52 c4 c4 g4 g4 a4 a4 g2
53 f4 f4 e4 e4 d4 d4 c2
54 \end{verbatim}
56 The notes are entered with names (a, b, c) combined with numbers
57 (2,4).  The names designate the pitches, the numbers the durations: 4
58 is a quarter note, 2 a half note, etc.
60 Now all we have to specify what should be done with the music.  We
61 want a paper version, so we combine the music with a ``output this on
62 paper'' statement.  These two are combined in ``score'' block.  This
63 is the final result with its output.   We add a comment (the line
64 starting with \verb+%+).
65 Put this into a file
66 called \file{twinkle.ly}
68 \begin{verbatim}
70 % twinkle, v1
71 \score {
72         \melodic { 
73                 c4 c4 g4 g4 a4 a4 g2
74                 f4 f4 e4 e4 d4 d4 c2
75         }
76         \paper {}
77
78 \end{verbatim}
80 there are a few things to note about this example:
82 The braces are grouping characters. In general, in mudela data entry
83 for a data section called ``foobar'' looks like this:
85 \begin{verbatim}
86 \foobar { ...... }
87 \end{verbatim}
89 To see if it actually works, we run it through LilyPond.  Invoke the
90 command 
91 \begin{verbatim}
92         lilypond twinkle.ly
93 \end{verbatim}
94 When LilyPond starts working it will produce various ``operator
95 pacification'' messages, which you can safely ignore for now.  The run
96 should have left a file called \file{lelie.tex} in your working
97 directory.  You can process that file with \TeX, and it will look like
98 this:
100 \begin{mudela}
101 \score {
102         \melodic { 
103                 c4 c4 g4 g4 a4 a4 g2
104                 f4 f4 e4 e4 d4 d4 c2
105         }
106         \paper {}
108 \end{mudela}
110 As you can see, this is the song that we wanted, albeit a little
111 low-pitched.  You would probably want a version of the song which has
112 all notes an octave higher.  This can be done by adding a
113 \verb+\octave+ command to the source.  This sets the default octave
114 for all notes.  Another convenience is the default duration: if you do
115 not specify a duration with the notename, the last explicitly entered
116 is used.  The improved version reads thus
119 \begin[verbatim]{mudela}
120   % twinkle v2
121 \score {
122         \melodic { 
123                 \octave c';
124                 c4 c g g a a g2
125                 f4 f e e d d c2
126         }
127         \paper {}
129 \end{mudela}
133 FIXME rewrite starting here.
135 \begin[verbatim]{mudela}
136   \score {
137         \melodic {      % {...} is a voice
138         c'4 g'4         % c and g are pitches, 4 is the duration
139                         % (crotchet/quarter note)
140         c''4 ''c4       % c' is 1 octave up, 'c 1 down.
141         <c'4 g'4>       % <...> is a chord
142         }
144 \end{mudela}
147 \begin[fragment,verbatim]{mudela}
148   { c4 e4 g4 }
149 \end{mudela} 
151 Basics: the \verb+%+ introduces a comment. All music is inside a
152 \verb+\score+ block which represents one movement, ie one contiguous
153 block of music.  Voices are grouped by \verb+{+ and \verb+}+ and
154 chords by \verb+<+ and \verb+>+.
157 The \verb+\octave+ command controls the default pitch (octave). If you
158 do not specify duration, the last one entered is used.  The
159 \verb+\paper+ block contains parameters for spacing and dimensions.
161 \begin[verbatim]{mudela}
162 \score {
163         % twinkle twinkle little star
164         \melodic { 
165                 \octave c';
166                 c4 c g g a a g2
167                 f4 f e e d [d8. e16] c2
168                 
169         }
170         \paper { linewidth = 5.\cm; }
172 \end{mudela}
174 A more complex example; The multi command controls at what level the
175 different components of a chord are interpreted.  The LilyPond chord
176 is much more general than a traditional chord.  Multiple voices on a
177 staff are entered as a chord of voices.  A score is a chord of staffs,
178 etc.
180 \begin[verbatim]{mudela}
181         
182 \score{
183   \melodic 
184     { \octave c'; c4 c4 
185        \multi 1 <  { c2 c2 } { c'2 c'2 } > 
186        \multi 2 <  { \stemdown c2 c2 } { \stemup c'2 c'2 } > 
187        \multi 3 <
188         { \clef "bass"; c2 c2 }
189         { \meter 2/4;\bar "||";
190           \key fis cis gis; c'2 c'2 } > 
191          c2 c1 
192       c1 c1
193        \multi 1< \multi 3 <
194       { \meter 2/4; \clef "violin"; c2 c2 }
195         { \meter 2/4; \clef "bass"; c2 c2 }
196       >
197       \multi 3 <
198         { \meter 2/4; \clef "violin"; c2 c2 }
199         { \meter 2/4; \clef "bass"; c2 c2 }
200       >
201       >
202     }
205 \end{mudela}
208 LilyPond is designed to handle complicated stuff automatically.
209 Expertise should be in the program, not in the user.
211 The following example shows how multiple voices on the same staff are
212 handled graciously (well, somewhat). If the noteheads of different
213 voices collide, they are moved horizontally. Rests are moved
214 vertically.
216 [FIXME]
217 \def\bla{
218 \begin[verbatim]{mudelaXX}
219 two_voice = \melodic 
220          \multi 2 <
221           {     \octave c'; \stemdown
222                 c4 d e f g2~  g4 a [c8 d e f] c2| }
223           { \stemup
224                 g4 f e g ~ g2 g2  c4 g4 g2 } 
226         >
228 two_voice_steminvert = \melodic 
229         \multi 2 <  
230           {     \octave c'; \stemup
231 % the f and g on 4th beat are exceptionally ugh.
232                 c4 d e f g2 g4 a | }
233           { \stemdown
234                 g4 f e g  g2 g2 } 
236         >
238 three_voice = \melodic 
239         \multi 2 <
240         { \stemup 
241                 g4 f e f g a g2 }
242         { \property Voice.hshift = 1 \stemup 
243                 e2  e2  e2  e2 }
244         { \stemdown
245                 c4 d e d c d es }
246         >
249 restsII = \melodic {
250         \octave c'; 
251                         \multi2 <
252                                 { \stemup  g'8 f' e' d' c' b a g f e d c }
253                                 { \stemdown r  r  r  r  r  r r r r r r r }
254                         >
255                         r8 r4
256                         \multi 2 <  r8 r8 >
257                         \multi 2 <  r8 r8 r8 >
258                         \multi 2 <  r8 r8 r8 r8 >
259                         \multi 2 <  r r >
260                         \multi 2 <  r r r >
261                         \stemup
262                         [c''8 r8 c''8 c''8]
263                         [c8 r8 c8 c8]
266 \score{
267         \melodic {  \$two_voice  \$two_voice_steminvert 
268                         \$three_voice  \restsII }
272 \end{document}