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