]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/non-music.itely
Merge branch 'master' of git://git.sv.gnu.org/lilypond
[lilypond.git] / Documentation / user / non-music.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond.tely
3 @ignore
4     Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
5
6     When revising a translation, copy the HEAD committish of the
7     version that you are working on.  See TRANSLATION for details.
8 @end ignore
9
10 @c A menu is needed before every deeper *section nesting of @node's; run
11 @c     M-x texinfo-all-menus-update
12 @c to automatically fill in these menus before saving changes
13
14 @node Non-musical notation
15 @chapter Non-musical notation
16
17 This section deals with general lilypond issues, rather than
18 specific notation.
19
20 @menu
21 * Titles and headers::          
22 * MIDI output::                 
23 * other midi::                  
24 @end menu
25
26
27 @node Titles and headers
28 @section Titles and headers
29
30 Almost all printed music includes a title and the composer's name;
31 some pieces include a lot more information.
32
33 @menu
34 * Creating titles::             
35 * Custom titles::               
36 * Reference to page numbers::   
37 * Table of contents::           
38 @end menu
39
40
41 @node Creating titles
42 @subsection Creating titles
43
44 Titles are created for each @code{\score} block, as well as for the full
45 input file (or @code{\book} block).
46
47 The contents of the titles are taken from the @code{\header} blocks.
48 The header block for a book supports the following
49
50
51 @table @code
52 @funindex dedication
53 @item dedication
54 The dedicatee of the music, centered at the top of the first page.
55
56 @funindex title
57 @item title
58 The title of the music, centered just below the dedication.
59
60 @funindex subtitle
61 @item subtitle
62 Subtitle, centered below the title.
63
64 @funindex subsubtitle
65 @item subsubtitle
66 Subsubtitle, centered below the subtitle.
67
68 @funindex poet
69 @item poet
70 Name of the poet, flush-left below the subtitle.
71
72 @funindex composer
73 @item composer
74 Name of the composer, flush-right below the subtitle.
75
76 @funindex meter
77 @item meter
78 Meter string, flush-left below the poet.
79
80 @funindex opus
81 @item opus
82 Name of the opus, flush-right below the composer.
83
84 @funindex arranger
85 @item arranger
86 Name of the arranger, flush-right below the opus.
87
88 @funindex instrument
89 @item instrument
90 Name of the instrument, centered below the arranger.  Also
91 centered at the top of pages (other than the first page).
92
93 @funindex piece
94 @item piece
95 Name of the piece, flush-left below the instrument.
96
97 @cindex page breaks, forcing
98 @funindex breakbefore
99 @item breakbefore
100 This forces the title to start on a new page (set to ##t or ##f).
101
102 @funindex copyright
103 @item copyright
104 Copyright notice, centered at the bottom of the first page.  To
105 insert the copyright symbol, see @ref{Text encoding}.
106
107 @funindex tagline
108 @item tagline
109 Centered at the bottom of the last page.
110
111 @end table
112
113 Here is a demonstration of the fields available.  Note that you
114 may use any @ref{Text markup}, commands in the header.
115
116 @lilypond[quote,verbatim,line-width=11.0\cm]
117 \paper {
118   line-width = 9.0\cm
119   paper-height = 10.0\cm
120 }
121
122 \book {
123   \header {
124     dedication = "dedicated to me"
125     title = \markup \center-align { "Title first line" "Title second line,
126 longer" }
127     subtitle = "the subtitle,"
128     subsubtitle = #(string-append "subsubtitle LilyPond version "
129 (lilypond-version))
130     poet = "Poet"
131     composer =  \markup \center-align { "composer" \small "(1847-1973)" }
132     texttranslator = "Text Translator"
133     meter = \markup { \teeny "m" \tiny "e" \normalsize "t" \large "e" \huge
134 "r" }
135     arranger = \markup { \fontsize #8.5 "a" \fontsize #2.5 "r" \fontsize
136 #-2.5 "r" \fontsize #-5.3 "a" \fontsize #7.5 "nger" }
137     instrument = \markup \bold \italic "instrument"
138     piece = "Piece"
139   }
140
141   \score {
142     { c'1 }
143     \header {
144       piece = "piece1"
145       opus = "opus1"
146     }
147   }
148   \markup {
149       and now...
150   }
151   \score {
152     { c'1 }
153     \header {
154       piece = "piece2"
155       opus = "opus2"
156     }
157   }
158 }
159 @end lilypond
160
161 As demonstrated before, you can use multiple @code{\header} blocks.
162 When same fields appear in different blocks, the latter is used.
163 Here is a short example.
164
165 @example
166 \header @{
167   composer = "Composer"
168 @}
169 \header @{
170   piece = "Piece"
171 @}
172 \score @{
173   \new Staff @{ c'4 @}
174   \header @{
175     piece = "New piece"  % overwrite previous one
176   @}
177 @}
178 @end example
179
180 If you define the @code{\header} inside the @code{\score} block, then
181 normally only the @code{piece} and @code{opus} headers will be printed.
182 Note that the music expression must come before the @code{\header}.
183
184 @lilypond[quote,verbatim,line-width=11.0\cm]
185 \score {
186   { c'4 }
187   \header {
188     title = "title"  % not printed
189     piece = "piece"
190     opus = "opus"
191   }
192 }
193 @end lilypond
194
195 @funindex printallheaders
196 @noindent
197 You may change this behavior (and print all the headers when defining
198 @code{\header} inside @code{\score}) by using
199
200 @example
201 \paper@{
202   printallheaders=##t
203 @}
204 @end example
205
206 @cindex copyright
207 @cindex tagline
208
209 The default footer is empty, except for the first page, where the
210 @code{copyright} field from @code{\header} is inserted, and the last
211 page, where @code{tagline} from @code{\header} is added.  The default
212 tagline is @qq{Music engraving by LilyPond (@var{version})}.@footnote{Nicely
213 printed parts are good PR for us, so please leave the tagline if you
214 can.}
215
216 Headers may be completely removed by setting them to false.
217
218 @example
219 \header @{
220   tagline = ##f
221   composer = ##f
222 @}
223 @end example
224
225
226 @node Custom titles
227 @subsection Custom titles
228
229 A more advanced option is to change the definitions of the following
230 variables in the @code{\paper} block.  The init file
231 @file{ly/titling-init.ly} lists the default layout.
232
233 @table @code
234 @funindex bookTitleMarkup
235 @item bookTitleMarkup
236   This is the title added at the top of the entire output document.
237 Typically, it has the composer and the title of the piece
238
239 @funindex scoreTitleMarkup
240 @item scoreTitleMarkup
241   This is the title put over a @code{\score} block.  Typically, it has
242 the name of the movement (@code{piece} field).
243
244 @funindex oddHeaderMarkup
245 @item oddHeaderMarkup
246   This is the page header for odd-numbered pages.
247
248 @funindex evenHeaderMarkup
249 @item evenHeaderMarkup
250   This is the page header for even-numbered pages.  If unspecified,
251   the odd header is used instead.
252
253   By default, headers are defined such that the page number is on the
254   outside edge, and the instrument is centered.
255
256 @funindex oddFooterMarkup
257 @item oddFooterMarkup
258   This is the page footer for odd-numbered pages.
259
260 @funindex evenFooterMarkup
261 @item evenFooterMarkup
262   This is the page footer for even-numbered pages.  If unspecified,
263   the odd header is used instead.
264
265   By default, the footer has the copyright notice on the first, and
266   the tagline on the last page.
267 @end table
268
269
270 @cindex \paper
271 @cindex header
272 @cindex footer
273 @cindex page layout
274 @cindex titles
275
276 The following definition will put the title flush left, and the
277 composer flush right on a single line.
278
279 @verbatim
280 \paper {
281   bookTitleMarkup = \markup {
282    \fill-line {
283      \fromproperty #'header:title
284      \fromproperty #'header:composer
285    }
286   }
287 }
288 @end verbatim
289
290 @node Reference to page numbers
291 @subsection Reference to page numbers
292
293 A particular place of a score can be marked using the @code{\label}
294 command, either at top-level or inside music.  This label can then be
295 refered to in a markup, to get the number of the page where the marked
296 point is placed, using the @code{\page-ref} markup command.
297
298 @lilypond[verbatim,line-width=11.0\cm]
299 \header { tagline = ##f }
300 \book {
301   \label #'firstScore
302   \score {
303     {
304       c'1
305       \pageBreak \mark A \label #'markA
306       c'
307     }
308   }
309
310   \markup { The first score begins on page \page-ref #'firstScore "0" "?" }
311   \markup { Mark A is on page \page-ref #'markA "0" "?" }
312 }
313 @end lilypond
314
315 The @code{\page-ref} markup command takes three arguments:
316 @enumerate
317 @item the label, a scheme symbol, eg. @code{#'firstScore};
318 @item a markup that will be used as a gauge to estimate the dimensions
319 of the markup;
320 @item a markup that will be used in place of the page number if the label 
321 is not known;
322 @end enumerate
323
324 The reason why a gauge is needed is that, at the time markups are
325 interpreted, the page breaking has not yet occured, so the page numbers
326 are not yet known.  To work around this issue, the actual markup
327 interpretation is delayed to a later time; however, the dimensions of
328 the markup have to be known before, so a gauge is used to decide these
329 dimensions.  If the book has between 10 and 99 pages, it may be "00",
330 ie. a two digit number.
331
332 @refcommands
333
334 @funindex \label
335 @code{\label}
336 @funindex \page-ref
337 @code{\page-ref}
338
339 @node Table of contents
340 @subsection Table of contents
341 A table of contents is included using the @code{\markuplines \table-of-contents}
342 command.  The elements which should appear in the table of contents are
343 entered with the @code{\tocItem} command, which may be used either at
344 top-level, or inside a music expression.
345
346 @verbatim
347 \markuplines \table-of-contents
348 \pageBreak
349
350 \tocItem \markup "First score"
351 \score { 
352   {
353     c'  % ...
354     \tocItem \markup "Some particular point in the first score"
355     d'  % ... 
356   }
357 }
358
359 \tocItem \markup "Second score"
360 \score {
361   {
362     e' % ...
363   }
364 }
365 @end verbatim
366
367 The markups which are used to format the table of contents are defined
368 in the @code{\paper} block.  The default ones are @code{tocTitleMarkup},
369 for formatting the title of the table, and @code{tocItemMarkup}, for
370 formatting the toc elements, composed of the element title and page
371 number.  These variables may be changed by the user:
372
373 @verbatim
374 \paper {
375   %% Translate the toc title into French:
376   tocTitleMarkup = \markup \huge \column {
377     \fill-line { \null "Table des matières" \null }
378     \hspace #1
379   }
380   %% use larfer font size
381   tocItemMarkup = \markup \large \fill-line {
382     \fromproperty #'toc:text \fromproperty #'toc:page
383   }
384 }
385 @end verbatim
386
387 Note how the toc element text and page number are refered to in
388 the @code{tocItemMarkup} definition.
389
390 New commands and markups may also be defined to build more elaborated
391 table of contents:
392 @itemize
393 @item first, define a new markup variable in the @code{\paper} block
394 @item then, define a music function which aims at adding a toc element
395 using this markup paper variable.
396 @end itemize
397
398 In the following example, a new style is defined for entering act names
399 in the table of contents of an opera:
400
401 @verbatim
402 \paper {
403   tocActMarkup = \markup \large \column {
404     \hspace #1
405     \fill-line { \null \italic \fromproperty #'toc:text \null }
406     \hspace #1
407   }
408 }
409
410 tocAct = 
411 #(define-music-function (parser location text) (markup?)
412    (add-toc-item! 'tocActMarkup text))
413 @end verbatim
414
415 @lilypond[line-width=11.0\cm]
416 \header { tagline = ##f }
417 \paper {
418   tocActMarkup = \markup \large \column {
419     \hspace #1
420     \fill-line { \null \italic \fromproperty #'toc:text \null }
421     \hspace #1
422   }
423 }
424
425 tocAct = 
426 #(define-music-function (parser location text) (markup?)
427    (add-toc-item! 'tocActMarkup text))
428
429 \book {
430   \markuplines \table-of-contents
431   \tocAct \markup { Atto Primo }
432   \tocItem \markup { Coro. Viva il nostro Alcide }
433   \tocItem \markup { Cesare. Presti omai l'Egizzia terra }
434   \tocAct \markup { Atto Secondo }
435   \tocItem \markup { Sinfonia }
436   \tocItem \markup { Cleopatra. V'adoro, pupille, saette d'Amore }
437   \markup \null
438 }
439 @end lilypond
440
441 @seealso
442
443 Init files: @file{ly/@/toc@/-init@/.ly}.
444
445 @refcommands
446
447 @funindex \table-of-contents
448 @code{\table-of-contents}
449 @funindex \tocItem
450 @code{\tocItem}
451
452 @node MIDI output
453 @section MIDI output
454
455 @cindex Sound
456 @cindex MIDI
457
458 MIDI (Musical Instrument Digital Interface) is a standard for
459 connecting and controlling digital instruments.  A MIDI file is a
460 series of notes in a number of tracks.  It is not an actual
461 sound file; you need special software to translate between the
462 series of notes and actual sounds.
463
464 Pieces of music can be converted to MIDI files, so you can listen to
465 what was entered.  This is convenient for checking the music; octaves
466 that are off or accidentals that were mistyped stand out very much
467 when listening to the MIDI output.
468
469 @refbugs
470
471 Many musically interesting effects, such as swing, articulation,
472 slurring, etc., are not translated to midi.
473
474 The midi output allocates a channel for each staff, and one for global
475 settings.  Therefore the midi file should not have more than 15 staves
476 (or 14 if you do not use drums).  Other staves will remain silent.
477
478 Not all midi players correctly handle tempo changes in the midi
479 output.  Players that are known to work include
480 @uref{http://@/timidity@/.sourceforge@/.net/,timidity}.
481
482 @menu
483 * Creating MIDI files::         
484 * MIDI block::                  
485 * MIDI instrument names::       
486 * What goes into the MIDI?  FIXME::  
487 @end menu
488
489 @node Creating MIDI files
490 @subsection Creating MIDI files
491
492 To create a MIDI from a music piece of music, add a @code{\midi} block
493 to a score, for example,
494
495 @example
496 \score @{
497   @var{...music...}
498    \midi @{
499      \context @{
500        \Score
501        tempoWholesPerMinute = #(ly:make-moment 72 4)
502        @}
503      @}
504 @}
505 @end example
506
507 The tempo can be specified using the @code{\tempo} command within the 
508 actual music, see @ref{Metronome marks}.  An alternative, which does not
509 result in a metronome mark in the printed score, is shown in the example
510 above.  In this example the tempo of quarter notes is set to 72 beats per
511 minute. 
512 This kind of tempo
513 specification can not take dotted note lengths as an argument.  In this
514 case, break the dotted notes into smaller units.  For example, a tempo
515 of 90 dotted quarter notes per minute can be specified as 270 eighth
516 notes per minute
517
518 @example
519 tempoWholesPerMinute = #(ly:make-moment 270 8)
520 @end example
521
522 If there is a @code{\midi} command in a @code{\score}, only MIDI will
523 be produced.  When notation is needed too, a @code{\layout} block must
524 be added
525
526 @example
527 \score @{
528   @var{...music...}
529   \midi @{ @}
530   \layout @{ @}
531 @}
532 @end example
533 @cindex layout block
534
535
536
537 Ties, dynamics, and tempo changes are interpreted.  Dynamic marks,
538 crescendi and decrescendi translate into MIDI volume levels.  Dynamic
539 marks translate to a fixed fraction of the available MIDI volume
540 range, crescendi and decrescendi make the volume vary linearly between
541 their two extremes.  The fractions can be adjusted by
542 @code{dynamicAbsoluteVolumeFunction} in @internalsref{Voice} context.
543 For each type of MIDI instrument, a volume range can be defined.  This
544 gives a basic equalizer control, which can enhance the quality of
545 the MIDI output remarkably.  The equalizer can be controlled by
546 setting @code{instrumentEqualizer}, or by setting
547
548 @example
549 \set Staff.midiMinimumVolume = #0.2
550 \set Staff.midiMaximumVolume = #0.8
551 @end example
552
553 To remove dynamics from the MIDI output, insert the following lines
554 in the @code{\midi@{@}} section.
555
556 @example
557 \midi @{
558   ...
559   \context @{
560     \Voice
561     \remove "Dynamic_performer"
562   @}
563 @}
564 @end example
565
566
567 @refbugs
568
569 Unterminated (de)crescendos will not render properly in the midi file,
570 resulting in silent passages of music.  The workaround is to explicitly
571 terminate the (de)crescendo.  For example,
572
573 @example
574 @{ a\< b c d\f @}
575 @end example
576
577 @noindent
578 will not work properly but
579
580 @example
581 @{ a\< b c d\!\f @}
582 @end example
583
584 @noindent
585 will.
586
587
588 MIDI output is only created when the @code{\midi} command is within
589 a @code{\score} block.  If you put it within an explicitly instantiated
590 context ( i.e. @code{\new Score} ) the file will fail.  To solve this,
591 enclose the @code{\new Score} and the @code{\midi} in a @code{\score} block.
592
593 @example
594 \score @{
595   \new Score @{ @dots{}notes@dots{} @}
596   \midi
597 @}
598 @end example
599
600
601 @node MIDI block
602 @subsection MIDI block
603 @cindex MIDI block
604
605
606 The MIDI block is analogous to the layout block, but it is somewhat
607 simpler.  The @code{\midi} block is similar to @code{\layout}.  It can contain
608 context definitions.
609
610
611 @cindex context definition
612
613 Context definitions follow precisely the same syntax as within the
614 \layout block.  Translation modules for sound are called performers.
615 The contexts for MIDI output are defined in @file{ly/@/performer@/-init@/.ly}.
616
617
618 @node MIDI instrument names
619 @subsection MIDI instrument names
620
621 @cindex instrument names
622 @funindex Staff.midiInstrument
623
624 The MIDI instrument name is set by the @code{Staff.midiInstrument}
625 property.  The instrument name should be chosen from the list in
626 @ref{MIDI instruments}.
627
628 @example
629 \set Staff.midiInstrument = "glockenspiel"
630 @var{...notes...}
631 @end example
632
633 If the selected instrument does not exactly match an instrument from
634 the list of MIDI instruments, the Grand Piano (@code{"acoustic grand"})
635 instrument is used.
636
637
638 @node What goes into the MIDI?  FIXME
639 @subsection What goes into the MIDI?  FIXME
640
641 @menu
642 * Repeats and MIDI::            
643 @end menu
644
645 @node Repeats and MIDI
646 @unnumberedsubsubsec Repeats and MIDI
647
648 @cindex expanding repeats
649 @funindex \unfoldRepeats
650
651 With a little bit of tweaking, all types of repeats can be present
652 in the MIDI output.  This is achieved by applying the
653 @code{\unfoldRepeats} music function.  This function changes all
654 repeats to unfold repeats.
655
656 @lilypond[quote,verbatim,fragment,line-width=8.0\cm]
657 \unfoldRepeats {
658   \repeat tremolo 8 {c'32 e' }
659   \repeat percent 2 { c''8 d'' }
660   \repeat volta 2 {c'4 d' e' f'}
661   \alternative {
662     { g' a' a' g' }
663     {f' e' d' c' }
664   }
665 }
666 \bar "|."
667 @end lilypond
668
669 When creating a score file using @code{\unfoldRepeats} for MIDI,
670 it is necessary to make two @code{\score} blocks: one for MIDI
671 (with unfolded repeats) and one for notation (with volta, tremolo,
672 and percent repeats).  For example,
673
674 @example
675 \score @{
676   @var{..music..}
677   \layout @{ .. @}
678 @}
679 \score @{
680   \unfoldRepeats @var{..music..}
681   \midi @{ .. @}
682 @}
683 @end example
684
685
686 @node other midi
687 @section other midi
688
689 Micro tones are also exported to the MIDI file.
690
691
692
693