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