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