]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/tex/mudela-book-doc.doc
release: 1.1.15
[lilypond.git] / Documentation / tex / mudela-book-doc.doc
1 \documentclass[a4paper, 12pt]{article}
2
3 \usepackage{t1enc,isolatin1}
4 \usepackage{graphics}
5 %\usepackage[dvips]{graphicx}
6 \usepackage[rflt]{floatflt}
7 %\usepackage{showframe}
8 %\sloppy
9 \def\postMudelaExample{\setlength{\parindent}{1em}}
10 \title{Mudela-book tutorial}
11 \begin{document}
12 \maketitle
13 %\printparam
14
15 \section{Introduction}
16
17 Mudela-book is a script that process your \LaTeX~file and with great
18 help from GNU LilyPond it translates blocks of mudela code it finds
19 inside \verb|mudela| environments to tex or eps graphics. It then
20 creates a new file that can be sendt through \LaTeX~to create a .dvi
21 file with lines of music integrated with text. 
22
23 Mudela-book will do its best to try to align the music to the left and
24 right margins. Currently the most used papersizes and one- and
25 twocolumn mode is supported, but if you use the geometry-package from
26 \LaTeX~or change the margins things will break.
27
28 This document assumes you have basic knowledge of GNU LilyPond and
29 \LaTeX. If the authors not-so-good english irritates you, please
30 send a patch.
31
32 So what does this look like? Well, here is an example:
33
34 \begin{mudela}[verbatim]
35 \score{
36   \notes\relative c'{
37     \time 5/8;
38     [e16( g b c a g][e a b d] | )e2 d,8 |
39     [e16( g b c a g][e a b d] | )b2 [a16( f] |
40     [e a b d] )e4 c8 | [es16( bes a as g es][d c b! )g] |
41     [f( a b d b a][f a b d] | )e2
42   }
43 }
44 \end{mudela}
45
46 \noindent produces this music:
47
48 \begin{mudela}
49 \score{
50   \notes\relative c'{
51     \time 5/8;
52     [e16( g b c a g][e a b d] | )e2 d,8 |
53     [e16( g b c a g][e a b d] | )b2 [a16( f] |
54     [e a b d] )e4 c8 | [es16( bes a as g es][d c b! )g] |
55     [f( a b d b a][f a b d] | )e2
56   }
57 }
58 \end{mudela}
59
60 If you are lucky, the above example show a nice feature of LilyPond
61 and \LaTeX. Since LilyPond can output the music as \TeX~graphics,
62 \LaTeX~can insert pagebreaks between the lines of music.
63
64 Notice that there is no \verb|\paper| statement in the example
65 above. Mudela-book will insert some code for you that defines the
66 linewidth and the font to use. If you don't want to change the default, 
67 there is no need to put an empty \verb|\paper{}| inside the \verb|\score|.
68 In the example above, something like
69 this might be inserted before your code:
70 \begin{verbatim}
71 \include "paper16.ly"
72 \paper{ \paper_sixteen
73     linewidth = 390.\pt;
74     castingalgorithm = \Gourlay;
75 }
76 \end{verbatim}
77 The actual values for linewidth will differ depending on papersize and
78 number of columns. Also, if you use a different fontsize for the
79 music, another file than \verb|paper16.ly| will be included.
80
81 If you want to make the music not so wide, you can insert a
82 \verb|\paper| statement that set the linewidth:
83
84 \begin{mudela}[verbatim]
85 \score{
86   \notes\relative c'{
87     \time 5/8;
88     [e16( g b c a g][e a b d] | )e2 d,8 |
89     [e16( g b c a g][e a b d] | )b2 [a16( f] |
90     [e a b d] )e4 c8 | [es16( bes a as g es][d c b! )g] |
91     [f( a b d b a][f a b d] | )e2
92   }
93   \paper{linewidth = 10.\cm;}
94 }
95 \end{mudela}
96
97 \noindent produces this music:
98
99 \begin{mudela}
100 % dette er en kommentar
101 \score{
102   \notes\relative c'{
103     \time 5/8;
104     [e16( g b c a g][e a b d] | )e2 d,8 |
105     [e16( g b c a g][e a b d] | )b2 [a16( f] |
106     [e a b d] )e4 c8 | [es16( bes a as g es][d c b! )g] |
107     [f( a b d b a][f a b d] | )e2
108   }
109   \paper{linewidth = 10.\cm;}
110 }
111 \end{mudela}
112
113 Very often, if you mix music and text, the music is often only a 
114 few notes or at most a few bars. This music should be as short as
115 possible and not stretched to be aligned to the right margin.
116
117 If you only write voice-contents in the mudela block, mudela-book 
118 will set the \verb|linewidth| variable to -1, so Lilypond
119 will make the music as short as possible but without breaking the
120 line. Here is a well know harmonic progression:
121 \begin{mudela}
122 % dette er en kommentar
123   <c' e' g'> <b d' g'> <c'2 e' g'>
124 \end{mudela}
125 \noindent that is made by this code:
126 \begin{mudela}[verbatim]
127   <c' e' g'> <b d' g'> <c'2 e' g'>
128 \end{mudela}
129
130 If you want to place music examples in the text,
131 \begin{mudela}[eps]
132   <c' e' g'> <b d' g'> <c'2 e' g'>
133 \end{mudela}
134 , you can use the \verb|eps| option. This will create the music as
135 eps graphics and include it into the document with the 
136 \verb|\includegraphics| command.
137
138 The code used look like this:
139 \begin{mudela}[eps, verbatim]
140   <c' e' g'> <b d' g'> <c'2 e' g'>
141 \end{mudela}
142
143 You can also use the \verb|eps| option if the block is a complete
144 mudela source. This 5 cm long empty line, 
145 \begin{mudela}[eps]
146 \score{
147   \notes{s}
148   \paper{ linewidth = 5.\cm;}
149 }
150 \end{mudela}
151 was created with this code:
152 \begin{mudela}[eps, verbatim]
153 \score{
154   \notes{s}
155   \paper{ linewidth = 5.\cm;}
156 }
157 \end{mudela}
158 To avoid that \LaTeX~places the music on a line of its one, there should
159 be no empty lines between the normal text and the mudela
160 environment. 
161
162 \section{Fontsize options}
163 You can use all lilypond fontsizes in mudela-book. 
164 % LONG line just to test multiple mudela on one line
165 The default 16pt fontsize, \mudela{<c' e' g'>}, is probably to big to be included in the middle of the text. 11pt, \mudela[11pt]{<c' e' g'>} or 13pt, \mudela[13pt]{<c' e' g'>} is probably better.
166 The code can look like this:
167 \begin{mudela}[13pt, eps, verbatim]
168 <c' e' g'>
169 \end{mudela}
170
171 The following options set the fontsize:
172 \begin{itemize}
173 \item \verb|11pt|
174 \begin{mudela}[11pt, eps]
175   \relative c'{
176     r16 [c d e][f d e c] [g'8 c][b-\prall c] |
177     [d16 g, a b][c a b g][d'8 g f-\prall g]
178   }
179 \end{mudela}
180 \item \verb|13pt|
181 \begin{mudela}[13pt, eps]
182   \relative c'{
183     r16 [c d e][f d e c] [g'8 c][b-\prall c] |
184     [d16 g, a b][c a b g][d'8 g f-\prall g]
185   }
186 \end{mudela}
187 \item \verb|16pt|
188 \begin{mudela}[16pt, eps]
189   \relative c'{
190     r16 [c d e][f d e c] [g'8 c][b-\prall c] |
191     [d16 g, a b][c a b g][d'8 g f-\prall g]
192   }
193 \end{mudela}
194 \item \verb|20pt|
195 \begin{mudela}[20pt, eps]
196   \relative c'{
197     r16 [c d e][f d e c] [g'8 c][b-\prall c] |
198     [d16 g, a b][c a b g][d'8 g f-\prall g]
199   }
200 \end{mudela}
201 \item \verb|26pt|
202 \begin{mudela}[26pt, eps]
203   \relative c'{
204     r16 [c d e][f d e c] [g'8 c][b-\prall c] |
205     [d16 g, a b][c a b g][d'8 g f-\prall g]
206   }
207 \end{mudela}
208 \end{itemize}
209
210 \section{User defined commands}
211 There is an even shorter way to write small musical fragments. This
212 triad, \mudela{<c' e' g'>}, was created with this code:
213 \verb|\mudela{<c' e' g'>}|
214
215 Mudela-book defines the \verb|\mudela| command, and let you define
216 your own commands in a file specified by 
217 the command line option \verb|--initfile=filename|. The format for the
218 file is a definition of a python dictionary:
219 % mudela-book should really respect \begin{verbatim}
220
221 \verb|{    'mudela': r"""|
222
223 \verb|\begin|\verb|{mudela}[eps \fontoptions]|
224
225 \verb|    \maininput|
226
227 \verb|\end|\verb|{mudela}|
228
229 \verb|""",|
230
231 \verb|    'mudelaRhythm': r"""|
232
233 \verb|\begin|\verb|{mudela}[eps \fontoptions]|
234 \begin{verbatim}
235 \score{
236     \type RhythmicStaff{
237         \notes{\stemup \maininput}
238     }
239     \paper{linewidth = -1.\cm;}
240 }
241 \end{verbatim}
242 \verb|\end|\verb|{mudela}|
243
244 \verb|"""|
245
246 \verb|}|
247
248 The above code show how \verb|\mudela| could have been defined, and
249 also defines a new command \verb|mudelaRhythm|. Notice that you can
250 send fontsize options to the defined commands. 
251 \verb|\mudelaRhytm[11pt]{c4 c8 [c16 c] c4 c}| produce this music:
252 \begin{mudela}[eps, 11pt]
253 \score{
254   \type RhythmicStaff{
255     \notes{ \stemup c4 r8 [c16 c] c4 c }
256   }
257   \paper{linewidth = -1.\cm;}
258 }
259 \end{mudela}
260
261 \section{Just in case...}
262 The options \verb|fragment| and \verb|nonfragment| will override
263 mudela-book when it scans the mudela code to see if it is staff
264 contents or complete code. This might be useful if mudela-book choose
265 wrong. 
266
267 Since there is no finder's fee which doubles every year, there is no
268 need to wait for the price money to grow. So send a bug report today
269 if you need this one of this options.
270
271 \section{Examples}
272 This was all options to \verb|\begin{mudela}|. The rest of the
273 document will show some ways you can use mudela in
274 \LaTeX~documents. It will also act as a simple test-suite for
275 mudela-book. You \marginpar{
276 marginpar!
277 \begin{mudela}[eps, 11pt]
278  \relative c'' {\key c \minor; r4 [g8 g g] es2}
279 \end{mudela}
280 }can place \verb|eps| mudela in footnotes\footnote{
281 footnote!
282 \begin{mudela}[eps, 11pt]
283  \relative c'' {\key c \minor;r4 [g8 g g] es2}
284 \end{mudela}
285 }
286 and marginspars just as any other included eps graphics. 
287
288 \begin{floatingfigure}[r]{7cm}
289 \begin{mudela}
290 \score{
291   \notes\relative c'{ 
292         \time 12/8;  
293         r4-\fermata [b16-.( )b-.] [f'8-- dis16-.( )dis-. gis8--]
294         [f16-.( )f-. dis8-- gis16-.( )gis-.] cis4.-\fermata |
295         
296         r4.-\fermata [cis,16 cis g'8 f16 f b8][g16 g f8 b16 b] dis4.-\fermata
297   }
298   \paper{linewidth = 7.\cm;}
299 }
300 \end{mudela}
301 \end{floatingfigure}
302
303 To the right you can see some bars from the trumpet fanfara from the
304 beginning of the fantastic street opera ``Houdini the Great'', by the
305 danish composer Andy Pape. The music is put inside a
306 \verb|floatingfigure| environment, and the music will be aligned by
307 the right marging if you set floatingfigure width and mudela linewidth
308 to the same value. The code looks like this:
309
310 \verb|\begin{floatingfigure}{7cm}|
311 \begin{mudela}[verbatim]
312 \score{
313   \notes\relative c'{ 
314     \time 12/8;  
315     r4.-\fermata [b16-.( )b-.] [f'8-- dis16-.( )dis-. gis8--]
316     [f16-.( )f-. dis8-- gis16-.( )gis-.] cis8.-\fermata |
317         
318     r4.-\fermata [cis,16 cis g'8 f16 f b8]
319     [g16 g f8 b16 b] dis4.-\fermata
320   }
321   \paper{linewidth = 7.\cm;}
322 }
323 \end{mudela}
324 \verb|\end{floatingfigure}|
325
326 \twocolumn[\large The following is written in two columns just to show
327 what mudela-book can do..\normalsize]
328
329 Tabulars is also nice. Here you have a chance to learn the norwegian
330 names of some triads:
331 \vspace{1em}
332
333 \begin{tabular}{|l|l|}
334 \hline
335
336 dur &
337 \begin{mudela}[eps]
338 <c' e' g'>
339 \end{mudela} 
340 \\
341 \hline moll &
342 \begin{mudela}[eps]
343 <c' ees' g'>
344 \end{mudela}
345 \\
346 \hline forminsket &
347 \begin{mudela}[eps]
348 <c' es' ges'>
349 \end{mudela}
350 \\
351 \hline forstørret &
352 \begin{mudela}[eps]
353 <c' e' gis'>
354 \end{mudela}
355 \\
356 \hline 
357 \end{tabular}
358
359 \vspace{1em}
360 If you have a lot of small music examples
361 like this in the middle of your text, you might get a nicer look by
362 using ``double'' line spacing. Put the \verb|\linespread{1.6}| command
363 into the preamble of your document. Then the line spacing will not be
364 increased between the lines where you have music printed with the
365 smallest font size.
366
367 Sinse the version number is quite low, you should be careful not to
368 mix braces that belongs to mudela-book and \LaTeX~on the same
369 line. The following code will probably break:
370
371 \verb|\footnote{\begin{mudela}|
372
373 \verb|\relative c''{ \key es; r8 [g g g] es2} |
374
375 \verb|\end{mudela}}|
376
377 Mudela-book does know about \verb|\onecolumn| and \verb|\twocolumn|. 
378 So the music will be adjusted to the new linewith:
379 \begin{mudela}[verbatim]
380 \score{
381     \notes\relative c'{c d e f | g2 g | a4 a a a | g1 |
382          f4 f f f | e2 e | d4 d d d | c1}
383 }
384 \end{mudela}
385 produces
386 \begin{mudela}
387 \score{
388     \notes\relative c'{c d e f | g2 g | a4 a a a | g1 |
389          f4 f f f | e2 e | d4 d d d | c1}
390 }
391 \end{mudela}
392
393 Verbatim environments will also ignore the page margins. That is
394 a feature of \LaTeX. (But you usually put things inside a verbatim
395 environment when you don't want \LaTeX~to do any linebreaking)
396
397 \end{document}
398