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