]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/tex/mudela-book-doc.doc
release: 1.2.4
[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[veryverbatim, intertext="produces this music:"]{mudela}
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[veryverbatim, intertext="produces this music:"]{mudela}
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[veryverbatim, intertext="produce a well known harmonic progression:"]{mudela}
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[eps]{mudela}
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[eps]{mudela}
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[eps]{mudela}
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[eps]{mudela}
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[13pt, eps]{mudela}
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[11pt, eps]{mudela}
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[13pt, eps]{mudela}
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[16pt, eps]{mudela}
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[20pt, eps]{mudela}
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[26pt, eps]{mudela}
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 \def\obsolete{
193 Mudela-book defines the \verb|\mudela| command, and let you define
194 your own commands in a file specified by 
195 the command line option \verb|--initfile=filename|. The format for the
196 file is a definition of a python dictionary:
197
198 \begin{verbatim}
199 {    'mudela': r"""
200 \begin[eps \fontoptions]{mudela}
201     \maininput
202 \end{mudela}
203 """,
204     'mudelaRhythm': r"""
205 \begin[eps \fontoptions]{mudela}
206 \score{
207     \context RhythmicStaff{
208         \notes{\stemup \maininput}
209     }
210     \paper{linewidth = -1.\cm;}
211 }
212 \end{mudela}
213 """
214 }
215 \end{verbatim}
216 The above code show how \verb|\mudela| could have been defined, and
217 also defines a new command \verb|mudelaRhythm|. Notice that you can
218 send fontsize options to the defined commands. 
219 \verb|\mudelaRhythm[11pt]{c4 c8 [c16 c] c4 c}| produce this music:
220 \begin[eps, 11pt]{mudela}
221 \score{
222   \context RhythmicStaff{
223     \notes{ \stemup c4 r8 [c16 c] c4 c }
224   }
225   \paper{linewidth = -1.\cm;}
226 }
227 \end{mudela}
228 }
229
230 \section{More options}
231 \begin{itemize}
232 \item The \verb|singleline| option set \verb|linewidth| to -1.0.
233 \item The \verb|multiline| option set \verb|linewidth| to a value letting
234 the music be aligned to the right margin. The music can span several
235 lines. 
236 \end{itemize}
237
238 \section{Just in case...}
239 The options \verb|fragment| and \verb|nonfragment| will override
240 mudela-book when it scans the mudela code to see if it is voice
241 contents or complete code. This might be useful if mudela-book choose
242 wrong. 
243
244 Since there is no finder's fee which doubles every year, there is no
245 need to wait for the price money to grow. So send a bug report today
246 if you need this one of these options.
247
248 \section{Examples}
249 This was all options to \verb|\begin|. The rest of the{mudela}
250 document will show some ways you can use mudela in
251 \LaTeX~documents. It will also act as a simple test-suite for
252 mudela-book. You 
253 \marginpar{
254 marginpar!
255 \begin[eps, 11pt]{mudela}
256  \relative c'' {\key c \minor; r4 [g8 g g] es2}
257 \end{mudela}
258 }can place \verb|eps| mudela in footnotes\footnote{
259 footnote!
260 \begin[eps, 11pt]{mudela}
261  \relative c'' {\key c \minor;r4 [g8 g g] es2}
262 \end{mudela}
263 }
264 and marginspars just as any other included eps graphics. 
265
266 \begin{floatingfigure}[r]{7cm}
267 \begin{mudela}
268 \score{
269   \notes\relative c'{ 
270         \time 12/8;  
271         r4-\fermata [b16-.( )b-.] [f'8-- dis16-.( )dis-. gis8--]
272         [f16-.( )f-. dis8-- gis16-.( )gis-.] cis4.-\fermata |
273         
274         r4.-\fermata [cis,16 cis g'8 f16 f b8][g16 g f8 b16 b] dis4.-\fermata
275   }
276   \paper{linewidth = 7.\cm;}
277 }
278 \end{mudela}
279 \end{floatingfigure}
280
281 To the right you can see some bars from the trumpet fanfara from the
282 beginning of the fantastic street opera ``Houdini the Great'', by the
283 danish composer Andy Pape. The music is put inside a
284 \verb|floatingfigure| environment, and the music will be aligned by
285 the right marging if you set floatingfigure width and mudela linewidth
286 to the same value. The code looks like this:
287
288 \verb|\begin{floatingfigure}{7cm}|
289 \begin[verbatim]{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-.] cis8.-\fermata |
295         
296     r4.-\fermata [cis,16 cis g'8 f16 f b8]
297     [g16 g f8 b16 b] dis4.-\fermata
298   }
299   \paper{linewidth = 7.\cm;}
300 }
301 \end{mudela}
302 \verb|\end{floatingfigure}|
303
304 \twocolumn[\large The following is written in two columns just to show
305 what mudela-book can do..\normalsize]
306
307 Tabulars is also nice. Here you have a chance to learn the norwegian
308 names of some triads:
309 \vspace{1em}
310
311 \begin{tabular}{|l|l|}
312 \hline
313
314 dur &
315 \begin[eps, fragment]{mudela}
316 <c' e g>
317 \end{mudela}
318 \\
319 \hline moll &
320 \begin[eps]{mudela}
321 <c' es g>
322 \end{mudela}
323 \\
324 \hline forminsket &
325 \begin[eps]{mudela}
326 <c' es ges>
327 \end{mudela}
328 \\
329 \hline forstørret &
330 \begin[eps]{mudela}
331 <c' e gis>
332 \end{mudela}
333 \\
334 \hline 
335 \end{tabular}
336
337 \vspace{1em}
338 If you have a lot of small music examples
339 like this in the middle of your text, you might get a nicer look by
340 using ``double'' line spacing. Put the \verb|\linespread{1.6}| command
341 into the preamble of your document. Then the line spacing will not be
342 increased between the lines where you have music printed with the
343 smallest font size.
344
345 Since the version number is quite low, you should be careful not to
346 mix braces that belongs to mudela-book and \LaTeX~on the same
347 line. The following code will probably break:
348
349 \begin{verbatim}
350 \footnote{\begin{mudela}
351 \relative c''{ \key es; r8 [g g g] es2}
352 \end}{mudela}
353 \end{verbatim}
354 Mudela-book does know about \verb|\onecolumn| and \verb|\twocolumn|. 
355 So the music will be adjusted to the new linewith:
356 \begin[veryverbatim, intertext="produces"]{mudela}
357 \score{
358     \notes\relative c'{c d e f | g2 g | a4 a a a | g1 |
359          f4 f f f | e2 e | d4 d d d | c1}
360 }
361 \end{mudela}
362
363 Verbatim environments will also ignore the page margins. That is
364 a feature of \LaTeX. (But you usually put things inside a verbatim
365 environment when you don't want \LaTeX~to do any linebreaking)
366
367
368 \end{document}
369
370
371
372
373
374