]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/mudela-book.tely
patch::: 1.3.95.tca2
[lilypond.git] / Documentation / user / mudela-book.tely
1 \input texinfo @c -*-texinfo-*-
2 @setfilename mudela-book.info
3 @settitle mudela-book Manual
4 @afourpaper
5 @titlepage
6 @title mudela-book Manual
7 @subtitle Integrating mudela with La@TeX{} and TeXinfo
8 @author Tom Cato Amundsen and  Han-Wen Nienhuys
9
10      Copyright @copyright{} 1999 by the authors
11
12 @vskip 0pt plus 1filll
13
14 Permission is granted to make and distribute verbatim
15 copies of this manual provided the copyright notice and
16 this permission notice are preserved on all copies.
17
18 Permission is granted to copy and distribute modified
19 versions of this manual under the conditions for
20 verbatim copying, provided also that the sections
21 entitled ``Copying'' and ``GNU General Public License''
22 are included exactly as in the original, and provided
23 that the entire resulting derived work is distributed
24 under the terms of a permission notice identical to this
25 one.
26
27 Permission is granted to copy and distribute
28 translations of this manual into another language,
29 under the above conditions for modified versions,
30 except that this permission notice may be stated in a
31 translation approved by the Free Software Foundation.
32
33 @end titlepage
34
35 @ifinfo
36 This file documents GNU LilyPond.
37
38 Copyright 1999 Tom Cato Amundsen and  Han-Wen Nienhuys
39
40
41 Permission is granted to make and distribute verbatim
42 copies of this manual provided the copyright notice and
43 this permission notice are preserved on all copies.
44
45 @ignore
46 Permission is granted to process this file through TeX
47 and print the results, provided the printed document
48 carries a copying permission notice identical to this
49 one except for the removal of this paragraph (this
50 paragraph not being relevant to the printed manual).
51
52 @end ignore
53
54 Permission is granted to copy and distribute modified
55 versions of this manual under the conditions for
56 verbatim copying, provided also that the sections
57 entitled ``Copying'' and ``GNU General Public License''
58 are included exactly as in the original, and provided
59 that the entire resulting derived work is distributed
60 under the terms of a permission notice identical to this
61 one.
62
63 Permission is granted to copy and distribute
64 translations of this manual into another language,
65 under the above conditions for modified versions,
66 except that this permission notice may be stated in a
67 translation approved by the Free Software Foundation.
68
69 @end ifinfo
70 @tex
71 \def\preMudelaExample{\vspace{0.5cm}}
72 @end tex
73
74 @contents
75 @node Top, , , (dir)
76 @top
77
78
79
80 @section Introduction
81
82 [ The tutorial part is at the moment commented out and moved to 
83 the end of this document ]
84
85
86 [TODO: THIS MANUAL IS NOT FINISHED YET. FIXME.]
87
88 @command{mudela-book} is a script that helps integrating mudela with
89 La@TeX{} or TeXinfo. @command{mudela-book} runs Lilypond on fragments
90 of mudela in your source file, and includes the results into a
91 document that can be processed with La@TeX{}, @command{makeinfo}
92 or @command{texi2dvi}.
93 The result is a text document with formatted music integrated.
94
95 @command{mudela-book} will do its best to try to align the music to
96 the left and right margins. Currently the most used papersizes and
97 one- and twocolumn mode is supported. But if you use some more
98 advances features, like the geometry-package or change the margins in
99 La@TeX{} or use @code{@@pagesize} in texinfo, will break.
100
101 This document assumes you have basic knowledge of GNU LilyPond and
102 La@TeX{} or texinfo.
103
104 @section TeXinfo reference
105
106 Your markup the mudela code like this:
107 @example
108 @@mudela[options, go, here]
109  YOUR MUDELA CODE
110 @@end mudela
111 @end example
112
113 or
114
115 @example
116 @@mudela[option, go, here]@{ YOUR MUDELA CODE @}
117 @end example
118
119 @command{mudela-book} knows the default margins, and a few papersizes.
120 These commands should be in the beginning of the document:
121 @itemize @bullet
122 @item @code{@@afourpaper}
123 @item @code{@@afourwide}
124 @item @code{@@smallbook}
125 @end itemize
126 @code{@@pagesizes} are not supported.
127
128 @subsection Examples
129
130 Two simple examples. First a complete block:
131
132 @example
133 @@mudela[26pt]
134 c' d' e' f' g'2 g'
135 @@end mudela
136 @end example
137
138 produces this music:
139 @mudela
140 c' d' e' f' g'2 g'
141 @end mudela
142
143 Then the short version:
144 @example
145 @@mudela[11pt]@{<c' e' g'>@}
146 @end example
147
148 and its music:
149
150 @mudela[11pt]{<c' e' g'>}
151
152
153 @subsection @@example and @@code
154
155 I'm not sure if this will go into the final documentation, this is
156 here mostly to remember me on why things are the way they are.
157
158 @command{mudela-book} will do nothing with special with @code{@@code} and
159 @code{@@example} environments. The 'code' and 'example' commands
160 should work just as normal. People looking at document that should be
161 processed by @command{mudela-book}, should notice nothing special, except from
162 some block like this:
163 @example
164 @@mudela
165 BLABLA
166 @@end mudela
167 @end example
168
169 or this:
170
171 @code{@@mudela@{ BLABLA @}}
172
173 Anything other is a bug in @command{mudela-book}.
174
175 So to get this in the printed manual:
176
177 @example
178 @@mudela[26pt]
179 \relative c'@{c d e f g2 g@}
180 @@end mudela
181 @end example
182
183 you have to write this:
184
185 @example
186 @@example
187 @@@@mudela[26pt]
188 \relative c'@@@{c d e f g2 g@@@}
189 @@@@end mudela
190 @@end example
191 @end example
192
193 Simply explained, every '@{', '@}' and '@@' has to be written as '@@@{',
194 '@@@}' and '@@@@'. This is how it works in plain texinfo too.
195
196 @section La@TeX{} reference
197
198 Your markup the mudela code like this:
199 @example
200 \begin[option, go, here]@{mudela@}
201  YOUR MUDELA CODE
202 \end@{mudela@}
203 @end example
204
205 or 
206
207 @example
208 \mudela@{ YOUR MUDELA CODE @}
209 @end example
210
211 The 'geometry' package is is not supported. The most popular
212 papersizes should work.
213
214 Mudela-book know about the @code{\onecolumn} and 
215 @code{\twocolumn} commands.
216
217 The music will be surrounded by @code{\preMudelaExample} and
218 @code{\postMudelaExample}. The variables are 
219 defined to nothing by default, and the user can redefine them
220 to whatever he wants.
221 @strong{[UGH: THIS DOES NOT HAPPEN WHEN
222 YOU USE THE SHORT FORM, \MUDELA@{ ... @}, CHECK OUT WHY]}
223
224 @subsection @code{landscape} package 
225 There is some simple support for landscape paper format, and this
226 can be combined with the @code{\twocolumn} command. Only a4 and
227 letter paper is supported, more to come...
228
229 A more complete
230 support, maybe also supporting the geometry package is planned, but
231 there are more work that has to be done on @command{mudela-book}
232 first.
233
234 This should work:
235 @example
236 \documentclass@{article@}
237 \usepackage@{landscape@}
238 \begin@{document@}
239 \twocolumn
240 BLA BLA BLA
241 \end@{document@}
242 @end example
243
244 @subsection Examples 
245
246 @example
247 \begin[26pt]@{mudela@}
248 c' d' e' f' g'2 g'2
249 \end@{mudela@}
250 @end example
251
252 produces this music:
253
254 @mudela[26pt]
255 c' d' e' f' g'2 g'2
256 @end mudela
257
258 Then the short version:
259 @example
260 \mudela[11pt]@{<c' e' g'>@}
261 @end example
262
263 and its music:
264
265 @mudela[11pt]{<c' e' g'>}
266
267
268 @subsection \begin@{verbatim@} and \verb|\verb| 
269
270 There work just as expected. Look at @file{mb-latex.tex} for details.
271
272 @section Options
273
274 @table @samp
275 @item eps
276     the music is created as eps graphics that can be inserted in 
277     the middle of a text line, not only as a separate paragraph.
278     (La@TeX{} only)
279 @item verbatim
280     CONTENTS is copied into the source enclosed in a verbatim block,
281     followed by any text given with the @code{intertext} option, then
282     the actual music is displayed. This option does not work with
283     the short version of the mudela blocks:
284
285     @code{ @@mudela@{ CONTENTS @} } and @code{ \mudela@{ CONTENTS @} }
286     
287 @item intertext="text inside apostrophs"
288     Used in conjunction with @code{verbatim} option.
289 @item filename=FILENAME
290     Save the mudela code to FILENAME instead of using a hash value
291     of CONTENTS.
292 @item 11pt, 13pt, 16pt, 20pt, 26pt
293     set the fontsize to use for the music
294 @item singleline
295   linewidth = -1.
296 @item multiline
297   linewidth = textwidth
298 @item fragment
299 @item nonfragment
300     Override @command{mudela-book} autodetection of what type of code is in the
301     mudela block, voice contents or complete code.
302 @end table
303
304 @section Invocation
305
306 When you run @command{mudela-book} it will generate lots of small
307 files that Lilypond will process. So to avoid all the garbage in
308 your source directory, you should either change to a temporary
309 directory, or use the @code{--outdir} commandline options:
310
311 @code{cd out && mudela-book ../yourfile.tex}
312
313 @code{mudela-book --outdir=out yourfile.tex}
314
315
316 For latex input, the file to give to latex has ext @file{.latex}.
317 TeXinfo input will be written to a file with ext @file{.texi}. So be
318 careful, don't give the source file that ext, or the file will be
319 overwritten.
320
321 @strong{[UGH: IS THIS THE BEST WAY TO DO IT. MAYBE ADD A COMMENT LINE TO THE
322 GENERATED FILE, SO MUDELA-BOOK CAN TEST IF THE FILE IT IS TO OVERWRITE
323 IS GENERATED.]}
324
325 @strong{About the input}
326
327 If the file contains the ``block''
328
329 @example 
330
331         \begin@{mudela@}
332         CONTENTS
333         \end@{mudela@}
334  
335 @end example 
336
337 then LilyPond is run on CONTENTS.  @command{mudela-book} puts the result back,
338 surrounded by @code{\preMudelaExample} and @code{\postMudelaExample}
339 commands. @code{\preMudelaExample} and @code{posMudelaExample} is
340 defined to nothing by default, and the user can redefine them
341 to whatever he wants.
342
343
344 @subsection Command line options
345
346 @table @samp
347
348 @item @option{-f}, @option{--format=}
349     Specify the document type to process, @code{latex} or @code{texi}.
350     @command{mudela-book} usually figure out this automatically.
351 @item --default-music-fontsize=??pt
352     Set the fontsize to use for mudela if no fontsize is given
353     as option.
354 @item --force-music-fontsize=??pt
355     Force all mudela to use this fontsize, overriding options
356     given to \begin@{mudela@}
357 @item -I DIR, --include=DIR
358     include path
359 @item -M, --dependencies
360         Write dependencies to out-www/filename.dep
361 @item --dep-prefix=PREF
362         prepend PREF before each -M dependency
363 @item -n, --no-lily
364         don't run lilypond
365 @item --no-pictures
366         don't generate pictures
367 @item --read-lys
368         don't write ly files. This way you can do
369         @example
370         mudela-book file.tely
371         convert-mudela
372         mudela-book --read-lys
373         @end example
374 @item --outname=FILE
375     The name of La@TeX{} file to output. If this option  is not given,
376     the output name derived from the input name.
377 @item --outdir=
378         where to place generated files
379 @item --version
380         print version information
381 @item --help
382         Print a short help message
383 @end table
384
385
386
387 @command{mudela-book} is written in python 1.5, so you have to install
388 @uref{http://www.python.org,python}.
389
390
391
392 @section Bugs
393   
394 The La@TeX{} \includeonly@{...@} command is ignored.
395
396 Ignores almost all La@TeX{} commands that changes margins and linewidths.
397
398 @section Authors
399
400 @email{hanwen@@cs.uu.nl, Han-Wen Nienhuys}, @uref{http://www.cs.uu.nl/people/hanwen}
401
402 @email{tca@@gnu.org, Tom Cato Amundsen}
403
404 @bye
405 @ignore
406
407 So what does this look like? Well, here is an example:
408 @mudela[veryverbatim, intertext="produces this music:"]
409 \score{
410   \notes\relative c'{
411     \time 5/8;
412     [e16( g b c a g][e a b d] | )e2 d,8 |
413     [e16( g b c a g][e a b d] | )b2 [a16( f] |
414     [e a b d] )e4 c8 | [es16( bes a as g es][d c b! )g] |
415     [f( a b d b a][f a b d] | )e2
416   }
417 }
418 @end mudela
419 If you are lucky, the above example show a nice feature of LilyPond
420 and La@TeX{}. Since LilyPond can output the music as @TeX{} graphics,
421 La@TeX{} can insert pagebreaks between the lines of music.
422
423 Notice that there is no @code{\paper} statement in the example
424 above. Mudela-book will insert some code for you that defines the
425 linewidth and the font to use. If you don't want to change the default, 
426 there is no need to put an empty @code{\paper@{@}} inside the @code{\score}.
427 In the example above, something like
428 this might be inserted before your code:
429 @example
430 \include "paper16.ly"
431 \paper@{ \paper_sixteen
432     linewidth = 390.\pt;
433     castingalgorithm = \Gourlay;
434 @}
435 @end example
436 The actual values for linewidth will differ depending on papersize and
437 number of columns. Also, if you use a different fontsize for the
438 music, another file than @code{paper16.ly} will be included.
439
440 If you want to make the music not so wide, you can insert a
441 @code{\paper} statement that set the linewidth:
442
443 @mudela[veryverbatim, intertext="produces this music:"]
444 \score{
445   \notes\relative c'{
446     \time 5/8;
447     [e16( g b c a g][e a b d] | )e2 d,8 |
448     [e16( g b c a g][e a b d] | )b2 [a16( f] |
449     [e a b d] )e4 c8 | [es16( bes a as g es][d c b! )g] |
450     [f( a b d b a][f a b d] | )e2
451   }
452   \paper{linewidth = 10.\cm;}
453 }
454 @end mudela
455
456 Very often, if you mix music and text, the music is often only a 
457 few notes or at most a few bars. This music should be as short as
458 possible and not stretched to be aligned to the right margin.
459
460 If you only write voice-contents in the mudela block, @command{mudela-book}
461 will set the @code{linewidth} variable to -1, so Lilypond
462 will make the music as short as possible but without breaking the
463 line. Here is a well know harmonic progression:
464 @mudela[veryverbatim, intertext="produce a well known harmonic progression:"]
465   \context Voice { <c' e g> <b d g> <c2 e g> }
466 @end mudela
467
468 If you want to place music examples in the text,
469 @mudela[eps]
470 \context Voice {  <c' e g> <b d g> <c2 e g>}
471 @end mudela
472 , you can use the @code{eps} option. This will create the music as
473 eps graphics and include it into the document with the 
474 @code{\includegraphics} command.
475
476 The code used look like this:
477 @example
478 @@mudela[eps]
479  \context Voice { <c' e g> <b d g> <c2 e g> }
480 @@end mudela
481 @end example
482
483 You can also use the @code{eps} option if the block is a complete
484 mudela source. This 5 cm long empty line, 
485 @mudela[eps]
486 \score{
487   \notes{s}
488   \paper{ linewidth = 5.\cm;}
489 }
490 @end mudela
491 was created with this code:
492 @example
493 @@mudela[eps]
494 \score@{
495   \notes@{s@}
496   \paper@{ linewidth = 5.\cm;@}
497 @}
498 @@end mudela
499 @end example
500
501 To avoid that La@TeX{} places the music on a line of its one, there should
502 be no empty lines between the normal text and the mudela
503 environment. 
504
505 You can also use @code{mudelafile} (on a separate line, FIXME), to
506 include another file.
507
508 @section Fontsize options You can use all lilypond fontsizes in
509 @command{mudela-book}.  The default 16pt fontsize is probably to big to be
510 included in the middle of the text, 11pt or 13pt is probably better.
511
512 The code can look like this:
513 @example
514 @@mudela[13pt, eps]
515 <c' e g>
516 @@end mudela
517 @end example
518
519 The following options set the fontsize:
520 @itemize
521 @item @code{11pt}
522 @mudela[11pt, eps]
523   \relative c'{
524     r16 [c d e][f d e c] [g'8 c][b-\prall c] |
525     [d16 g, a b][c a b g][d'8 g f-\prall g]
526   }
527 @end mudela
528 @item @code{13pt}
529 @mudela[13pt, eps]
530   \relative c'{
531     r16 [c d e][f d e c] [g'8 c][b-\prall c] |
532     [d16 g, a b][c a b g][d'8 g f-\prall g]
533   }
534 @end mudela
535 @item @code{16pt}
536 @mudela[16pt, eps]
537   \relative c'{
538     r16 [c d e][f d e c] [g'8 c][b-\prall c] |
539     [d16 g, a b][c a b g][d'8 g f-\prall g]
540   }
541 @end mudela
542 @item @code{20pt}
543 @mudela[20pt, eps]
544   \relative c'{
545     r16 [c d e][f d e c] [g'8 c][b-\prall c] |
546     [d16 g, a b][c a b g][d'8 g f-\prall g]
547   }
548 @end mudela
549 @item @code{26pt}
550 @mudela[26pt, eps]
551   \relative c'{
552     r16 [c d e][f d e c] [g'8 c][b-\prall c] |
553     [d16 g, a b][c a b g][d'8 g f-\prall g]
554   }
555 @end mudela
556 @end itemize
557
558
559 @section More options
560 @itemize
561 @item The @code{singleline} option set @code{linewidth} to -1.0.
562 @item The @code{multiline} option set @code{linewidth} to a value letting
563 the music be aligned to the right margin. The music can span several
564 lines. 
565 @end itemize
566
567 @section Just in case...
568 The options @code{fragment} and @code{nonfragment} will override
569 @command{mudela-book} when it scans the mudela code to see if it is voice
570 contents or complete code. This might be useful if @command{mudela-book} choose
571 wrong. 
572
573 Since there is no finder's fee which doubles every year, there is no
574 need to wait for the price money to grow. So send a bug report today
575 if you need this one of these options.
576
577 @section Examples
578
579 This was all options to @code{\begin}. The rest of the mudela
580 document will show some ways you can use mudela in
581 La@TeX{} documents. It will also act as a simple test-suite for
582 mudela-book. You can place @code{eps} mudela in and marginspars just
583 as any other included eps graphics.
584
585 @mudela
586 \score{
587   \notes\relative c'{ 
588         \time 12/8;  
589         r4-\fermata [b16-.( )b-.] [f'8-- dis16-.( )dis-. gis8--]
590         [f16-.( )f-. dis8-- gis16-.( )gis-.] cis4.-\fermata |
591         
592         r4.-\fermata [cis,16 cis g'8 f16 f b8][g16 g f8 b16 b] dis4.-\fermata
593   }
594   \paper{linewidth = 7.\cm;}
595 }
596 @end mudela
597
598
599 To the right you can see some bars from the trumpet fanfara from the
600 beginning of the fantastic street opera ``Houdini the Great'', by the
601 Danish composer Andy Pape. The music is put inside a
602 @code{floatingfigure} environment, and the music will be aligned by
603 the right marging if you set floatingfigure width and mudela linewidth
604 to the same value. The code looks like this:
605
606 @mudela[verbatim]
607 \score{
608   \notes\relative c'{ 
609     \time 12/8;  
610     r4.-\fermata [b16-.( )b-.] [f'8-- dis16-.( )dis-. gis8--]
611     [f16-.( )f-. dis8-- gis16-.( )gis-.] cis8.-\fermata |
612         
613     r4.-\fermata [cis,16 cis g'8 f16 f b8]
614     [g16 g f8 b16 b] dis4.-\fermata
615   }
616   \paper{linewidth = 7.\cm;}
617 }
618 @end mudela
619
620 If you have a lot of small music examples like this in the middle of
621 your text, you might get a nicer look by using ``double'' line
622 spacing. Put the @code{\linespread@{1.6@}} command into the preamble of
623 your document. Then the line spacing will not be increased between the
624 lines where you have music printed with the smallest font size.
625
626 Mudela-book does know about @code{\onecolumn} and @code{\twocolumn}. 
627 So the music will be adjusted to the new linewith:
628
629 Verbatim environments will also ignore the page margins. That is
630 a feature of La@TeX{}. (But you usually put things inside a verbatim
631 environment when you don't want La@TeX{} to do any linebreaking)
632
633 @end ignore