]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/tex/mudela-book-doc.doc
22f9d8f3b69014953e571d29ad23bda8d6ee06c3
[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}{1em}}
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 \context Voice {  <c' e' g'> <b d' g'> <c'2 e' g'>}
92 \end{mudela}
93
94 If you want to place music examples in the text,
95 \begin{mudela}[eps]
96 \context Voice {  <c' e' g'> <b d' g'> <c'2 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 \context Voice {  <c' e' g'> <b d' g'> <c'2 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.
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{Just in case...}
228 The options \verb|fragment| and \verb|nonfragment| will override
229 mudela-book when it scans the mudela code to see if it is staff
230 contents or complete code. This might be useful if mudela-book choose
231 wrong. 
232
233 Since there is no finder's fee which doubles every year, there is no
234 need to wait for the price money to grow. So send a bug report today
235 if you need this one of these options.
236
237 \section{Examples}
238 This was all options to \verb|\begin{mudela}|. The rest of the
239 document will show some ways you can use mudela in
240 \LaTeX~documents. It will also act as a simple test-suite for
241 mudela-book. You \marginpar{
242 marginpar!
243 \begin{mudela}[eps, 11pt]
244  \relative c'' {\key c \minor; r4 [g8 g g] es2}
245 \end{mudela}
246 }can place \verb|eps| mudela in footnotes\footnote{
247 footnote!
248 \begin{mudela}[eps, 11pt]
249  \relative c'' {\key c \minor;r4 [g8 g g] es2}
250 \end{mudela}
251 }
252 and marginspars just as any other included eps graphics. 
253
254 \begin{floatingfigure}[r]{7cm}
255 \begin{mudela}
256 \score{
257   \notes\relative c'{ 
258         \time 12/8;  
259         r4-\fermata [b16-.( )b-.] [f'8-- dis16-.( )dis-. gis8--]
260         [f16-.( )f-. dis8-- gis16-.( )gis-.] cis4.-\fermata |
261         
262         r4.-\fermata [cis,16 cis g'8 f16 f b8][g16 g f8 b16 b] dis4.-\fermata
263   }
264   \paper{linewidth = 7.\cm;}
265 }
266 \end{mudela}
267 \end{floatingfigure}
268
269 To the right you can see some bars from the trumpet fanfara from the
270 beginning of the fantastic street opera ``Houdini the Great'', by the
271 danish composer Andy Pape. The music is put inside a
272 \verb|floatingfigure| environment, and the music will be aligned by
273 the right marging if you set floatingfigure width and mudela linewidth
274 to the same value. The code looks like this:
275
276 \verb|\begin{floatingfigure}{7cm}|
277 \begin{mudela}[verbatim]
278 \score{
279   \notes\relative c'{ 
280     \time 12/8;  
281     r4.-\fermata [b16-.( )b-.] [f'8-- dis16-.( )dis-. gis8--]
282     [f16-.( )f-. dis8-- gis16-.( )gis-.] cis8.-\fermata |
283         
284     r4.-\fermata [cis,16 cis g'8 f16 f b8]
285     [g16 g f8 b16 b] dis4.-\fermata
286   }
287   \paper{linewidth = 7.\cm;}
288 }
289 \end{mudela}
290 \verb|\end{floatingfigure}|
291
292 \twocolumn[\large The following is written in two columns just to show
293 what mudela-book can do..\normalsize]
294
295 Tabulars is also nice. Here you have a chance to learn the norwegian
296 names of some triads:
297 \vspace{1em}
298
299 \begin{tabular}{|l|l|}
300 \hline
301
302 dur &
303 \begin{mudela}[eps]
304 \context Voice {<c' e' g'>}
305 \end{mudela} 
306 \\
307 \hline moll &
308 \begin{mudela}[eps]
309 \context Voice {<c' ees' g'>}
310 \end{mudela}
311 \\
312 \hline forminsket &
313 \begin{mudela}[eps]
314 \context Voice {<c' es' ges'>}
315 \end{mudela}
316 \\
317 \hline forstørret &
318 \begin{mudela}[eps]
319 \context Voice {<c' e' gis'>}
320 \end{mudela}
321 \\
322 \hline 
323 \end{tabular}
324
325 \vspace{1em}
326 If you have a lot of small music examples
327 like this in the middle of your text, you might get a nicer look by
328 using ``double'' line spacing. Put the \verb|\linespread{1.6}| command
329 into the preamble of your document. Then the line spacing will not be
330 increased between the lines where you have music printed with the
331 smallest font size.
332
333 Since the version number is  low, you should be careful not to
334 mix braces that belongs to mudela-book and \LaTeX~on the same
335 line. The following code will probably break:
336
337 \begin{verbatim}
338 \footnote{\begin{mudela}
339 \relative c''{ \key es; r8 [g g g] es2}
340 \end{mudela}}
341 \end{verbatim}
342 Mudela-book does know about \verb|\onecolumn| and \verb|\twocolumn|. 
343 So the music will be adjusted to the new linewith:
344 \begin{mudela}[veryverbatim, intertext="produces"]
345 \score{
346     \notes\relative c'{c d e f | g2 g | a4 a a a | g1 |
347          f4 f f f | e2 e | d4 d d d | c1}
348 }
349 \end{mudela}
350
351 Verbatim environments will also ignore the page margins. That is
352 a feature of \LaTeX. (But you usually put things inside a verbatim
353 environment when you don't want \LaTeX~to do any linebreaking)
354
355
356
357
358 \end{document}