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