]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/non-music.itely
Refine check-translation error message
[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 * Input files::                 
22 * Titles and headers::          
23 * MIDI output::                 
24 * Displaying LilyPond notation::  
25 * Skipping corrected music::    
26 @end menu
27
28
29 @node Input files
30 @section Input files
31
32 The main format of input for LilyPond are text files.  By convention,
33 these files end with @samp{.ly}.
34
35 @menu
36 * File structure (introduction)::  
37 * File structure::              
38 * A single music expression::   
39 * Multiple scores in a book::   
40 * Extracting fragments of notation::  
41 * Including LilyPond files::    
42 * Text encoding::               
43 @end menu
44
45
46 @node File structure (introduction)
47 @subsection File structure (introduction)
48
49 A basic example of a lilypond input file is
50
51 @example
52 \version "2.11.15"
53 \score @{
54   @{ @}     % this is a single music expression;
55             % all the music goes in here.
56   \header @{ @}
57   \layout @{ @}
58   \midi @{ @}
59 @}
60 @end example
61
62 @noindent
63 There are many variations of this basic pattern, but this
64 example serves as a useful starting place.
65
66 The major part of this manual is concerned with entering various
67 forms of music in LilyPond.  However, many music expressions are not
68 valid input on their own, for example, a @code{.ly} file containing
69 only a note
70 @example
71 c'4
72 @end example
73
74 @noindent
75 will result in a parsing error.  Instead, music should be inside other
76 expressions, which may be put in a file by themselves.  Such
77 expressions are called toplevel expressions; see @ref{File structure}, for
78 a list of all such expressions.
79
80
81 @node File structure
82 @subsection File structure
83
84 A @code{.ly} file contains any number of toplevel expressions, where a
85 toplevel expression is one of the following
86
87 @itemize @bullet
88 @item
89 An output definition, such as @code{\paper}, @code{\midi}, and
90 @code{\layout}.  Such a definition at the toplevel changes the default
91 settings for the block entered.
92
93 @item
94 A direct scheme expression, such as
95 @code{#(set-default-paper-size "a7" 'landscape)} or
96 @code{#(ly:set-option 'point-and-click #f)}.
97
98 @item
99 A @code{\header} block.  This sets the global header block.  This
100 is the block containing the definitions for book-wide settings, like
101 composer, title, etc.
102
103 @item
104 A @code{\score} block.  This score will be collected with other
105 toplevel scores, and combined as a single @code{\book}.
106
107 This behavior can be changed by setting the variable
108 @code{toplevel-score-handler} at toplevel.  The default handler is
109 defined in the init file @file{scm/@/lily@/.scm}.
110
111 The @code{\score} must begin with a music expression, and may
112 contain only one music expression.
113
114 @item
115 A @code{\book} block logically combines multiple movements
116 (i.e., multiple @code{\score} blocks) in one document.  If there are
117 a number of @code{\scores}, one output file will be created for
118 each @code{\book} block, in which all corresponding movements are
119 concatenated. The only reason to explicitly specify @code{\book} blocks
120 in a @code{.ly} file is if you wish multiple output files from a single
121 input file. One exception is within lilypond-book documents, where you
122 explicitly have to add a @code{\book} block if you want more than a
123 single @code{\score} or @code{\markup} in the same example.
124
125 This behavior can be changed by setting the variable
126 @code{toplevel-book-handler} at toplevel.  The default handler is
127 defined in the init file @file{scm/@/lily@/.scm}.
128
129 @item
130 A compound music expression, such as
131 @example
132 @{ c'4 d' e'2 @}
133 @end example
134
135 This will add the piece in a @code{\score} and format it in a
136 single book together with all other toplevel @code{\score}s and music
137 expressions.  In other words, a file containing only the above
138 music expression will be translated into
139
140 @example
141 \book @{
142   \score @{
143     \new Staff @{
144       \new Voice @{
145         @{ c'4 d' e'2 @}
146       @}
147     @}
148   @}
149         \layout @{ @}
150         \header @{ @}
151 @}
152 @end example
153
154 This behavior can be changed by setting the variable
155 @code{toplevel-music-handler} at toplevel.  The default handler is
156 defined in the init file @file{scm/@/lily@/.scm}.
157
158 @item
159 A markup text, a verse for example
160 @example
161 \markup @{
162    2.  The first line verse two.
163 @}
164 @end example
165
166 Markup texts are rendered above, between or below the scores or music
167 expressions, wherever they appear.
168
169 @cindex variables
170 @cindex identifiers
171
172 @item
173 An identifier, such as
174 @example
175 foo = @{ c4 d e d @}
176 @end example
177
178 This can be used later on in the file by entering @code{\foo}.  The
179 name of an identifier should have alphabetic characters only; no
180 numbers, underscores or dashes.
181
182 @end itemize
183
184 The following example shows three things that may be entered at
185 toplevel
186
187 @example
188 \layout @{
189   % movements are non-justified by default
190   ragged-right = ##t
191 @}
192
193 \header @{
194    title = "Do-re-mi"
195 @}
196
197 @{ c'4 d' e2 @}
198 @end example
199
200
201 At any point in a file, any of the following lexical instructions can
202 be entered:
203
204 @itemize @bullet
205 @item @code{\version}
206 @item @code{\include}
207 @item @code{\sourcefilename}
208 @item @code{\sourcefileline}
209
210 @end itemize
211
212
213 @node A single music expression
214 @subsection A single music expression
215
216 A @code{\score} must contain a single music expression.  However,
217 this music expression may be of any size.  Recall that music
218 expressions may be included inside other expressions to form
219 larger expressions.  All of these examples are single music
220 expressions; note the curly braces @{ @} or angle brackets <<
221 >> at the beginning and ending of the music.
222
223 @example
224 @{ c'4 c' c' c' @}
225 @end example
226
227 @lilypond[ragged-right,verbatim,quote]
228 {
229   { c'4 c' c' c'}
230   { d'4 d' d' d'}
231 }
232 @end lilypond
233
234 @lilypond[ragged-right,verbatim,quote]
235 <<
236   \new Staff { c'4 c' c' c' }
237   \new Staff { d'4 d' d' d' }
238 >>
239 @end lilypond
240
241 @example
242 @{
243   \new GrandStaff <<
244     \new StaffGroup <<
245       \new Staff @{ \flute @}
246       \new Staff @{ \oboe @}
247     >>
248     \new StaffGroup <<
249       \new Staff @{ \violinI @}
250       \new Staff @{ \violinII @}
251     >>
252   >>
253 @}
254 @end example
255
256
257 @node Multiple scores in a book
258 @subsection Multiple scores in a book
259
260 @funindex \book
261 @cindex movements, multiple
262
263 A document may contain multiple pieces of music and texts.  Examples
264 of these are an etude book, or an orchestral part with multiple
265 movements.  Each movement is entered with a @code{\score} block,
266
267 @example
268 \score @{
269   @var{..music..}
270 @}
271 @end example
272
273 and texts are entered with a @code{\markup} block,
274
275 @example
276 \markup @{
277   @var{..text..}
278 @}
279 @end example
280
281 @funindex \book
282
283 All the movements and texts which appear in the same @code{.ly} file 
284 will normally be typeset in the form of a single output file. 
285
286 @example
287 \score @{
288   @var{..}
289 @}
290 \markup @{
291   @var{..}
292 @}
293 \score @{
294   @var{..}
295 @}
296 @end example
297
298 However, if you want multiple output files from the same @code{.ly}
299 file, then you can add multiple @code{\book} blocks, where each such
300 @code{\book} block will result in a separate output. If you do not
301 specify any @code{\book} block in the file, LilyPond will implicitly
302 treat the full file as a single @code{\book} block, see @ref{File
303 structure}. One important exception is within lilypond-book documents,
304 where you explicitly have to add a @code{\book} block, otherwise only
305 the first @code{\score} or @code{\markup} will appear in the output.
306
307 The header for each piece of music can be put inside the @code{\score}
308 block.  The @code{piece} name from the header will be printed before
309 each movement.  The title for the entire book can be put inside the
310 @code{\book}, but if it is not present, the @code{\header} which is at
311 the top of the file is inserted.
312
313 @example
314 \header @{
315   title = "Eight miniatures"
316   composer = "Igor Stravinsky"
317 @}
318 \score @{
319   @dots{}
320   \header @{ piece = "Romanze" @}
321 @}
322 \markup @{
323    ..text of second verse..
324 @}
325 \markup @{
326    ..text of third verse..
327 @}
328 \score @{
329   @dots{}
330   \header @{ piece = "Menuetto" @}
331 @}
332 @end example
333
334 @node Extracting fragments of notation
335 @subsection Extracting fragments of notation
336
337 It is possible to quote small fragments of a large score directly from
338 the output. This can be compared to clipping a piece of a paper score
339 with scissors.
340
341 This is done by definining the measures that need to be cut out
342 separately. For example, including the following definition
343
344
345 @verbatim
346 \layout {
347   clip-regions
348   = #(list
349       (cons
350        (make-rhythmic-location 5 1 2)
351        (make-rhythmic-location 7 3 4)))
352 }       
353 @end verbatim
354
355 @noindent
356 will extract a fragment starting halfway the fifth measure, ending in
357 the seventh measure. The meaning of @code{5 1 2} is: after a 1/2 note
358 in measure 5, and @code{7 3 4} after 3 quarter notes in measure 7.
359
360 More clip regions can be defined by adding more pairs of
361 rhythmic-locations to the list. 
362
363 In order to use this feature, LilyPond must be invoked with
364 @code{-dclip-systems}. The clips are output as EPS files, and are
365 converted to PDF and PNG if these formats are switched on as well.
366
367 For more information on output formats, see @rprogram{Invoking lilypond}.
368
369 @seealso
370
371 Examples: @lsr{non-notation,clip-systems.ly}
372
373
374 @node Including LilyPond files
375 @subsection Including LilyPond files
376
377 @funindex \include
378 @cindex including files
379
380 A large project may be split up into separate files.  To refer to another
381 file, use
382
383 @example
384 \include "otherfile.ly"
385 @end example
386
387 The line @code{\include "file.ly"} is equivalent to pasting the contents
388 of file.ly into the current file at the place where you have the
389 \include.  For example, for a large project you might write separate files
390 for each instrument part and create a @q{full score} file which brings
391 together the individual instrument files.
392
393 The initialization of LilyPond is done in a number of files that are
394 included by default when you start the program, normally transparent to the
395 user.  Run lilypond --verbose to see a list of paths and files that Lily
396 finds.
397
398 Files placed in directory @file{PATH/TO/share/lilypond/VERSION/ly/} (where
399 VERSION is in the form @q{2.6.1}) are on the path and available to
400 @code{\include}.  Files in the
401 current working directory are available to \include, but a file of the same
402 name in LilyPond's installation takes precedence.  Files are
403 available to \include from directories in the search path specified as an
404 option when invoking @code{lilypond --include=DIR} which adds DIR to the
405 search path.
406
407 The @code{\include} statement can use full path information, but with the Unix
408 convention @samp{/} rather than the DOS/Windows @samp{\}.  For example,
409 if @file{stuff.ly} is located one directory higher than the current working
410 directory, use
411
412 @example
413 \include "../stuff.ly"
414 @end example
415
416
417 @node Text encoding
418 @subsection Text encoding
419
420 LilyPond uses the Pango library to format multi-lingual texts, and
421 does not perform any input-encoding conversions.  This means that any
422 text, be it title, lyric text, or musical instruction containing
423 non-ASCII characters, must be utf-8.  The easiest way to enter such text is
424 by using a Unicode-aware editor and saving the file with utf-8 encoding.  Most
425 popular modern editors have utf-8 support, for example, vim, Emacs,
426 jEdit, and GEdit do.
427
428 @c  Currently not working
429 @ignore
430 Depending on the fonts installed, the following fragment shows Hebrew
431 and Cyrillic lyrics,
432
433 @cindex Cyrillic
434 @cindex Hebrew
435 @cindex ASCII, non
436
437 @li lypondfile[fontload]{utf-8.ly}
438
439 The @TeX{} backend does not handle encoding specially at all.  Strings
440 in the input are put in the output as-is.  Extents of text items in the
441 @TeX{} backend, are determined by reading a file created via the
442 @file{texstr} backend,
443
444 @example
445 lilypond -dbackend=texstr input/les-nereides.ly
446 latex les-nereides.texstr
447 @end example
448
449 The last command produces @file{les-nereides.textmetrics}, which is
450 read when you execute
451
452 @example
453 lilypond -dbackend=tex input/les-nereides.ly
454 @end example
455
456 Both @file{les-nereides.texstr} and @file{les-nereides.tex} need
457 suitable LaTeX wrappers to load appropriate La@TeX{} packages for
458 interpreting non-ASCII strings.
459
460 @end ignore
461
462 To use a Unicode escape sequence, use
463
464 @example
465 #(ly:export (ly:wide-char->utf-8 #x2014))
466 @end example
467
468
469 @seealso
470
471 @lsr{text,utf-8.ly}
472
473
474
475 @node Titles and headers
476 @section Titles and headers
477
478 Almost all printed music includes a title and the composer's name;
479 some pieces include a lot more information.
480
481 @menu
482 * Creating titles::             
483 * Custom titles::               
484 * Reference to page numbers::   
485 * Table of contents::           
486 @end menu
487
488
489 @node Creating titles
490 @subsection Creating titles
491
492 Titles are created for each @code{\score} block, as well as for the full
493 input file (or @code{\book} block).
494
495 The contents of the titles are taken from the @code{\header} blocks.
496 The header block for a book supports the following
497
498
499 @table @code
500 @funindex dedication
501 @item dedication
502 The dedicatee of the music, centered at the top of the first page.
503
504 @funindex title
505 @item title
506 The title of the music, centered just below the dedication.
507
508 @funindex subtitle
509 @item subtitle
510 Subtitle, centered below the title.
511
512 @funindex subsubtitle
513 @item subsubtitle
514 Subsubtitle, centered below the subtitle.
515
516 @funindex poet
517 @item poet
518 Name of the poet, flush-left below the subtitle.
519
520 @funindex composer
521 @item composer
522 Name of the composer, flush-right below the subtitle.
523
524 @funindex meter
525 @item meter
526 Meter string, flush-left below the poet.
527
528 @funindex opus
529 @item opus
530 Name of the opus, flush-right below the composer.
531
532 @funindex arranger
533 @item arranger
534 Name of the arranger, flush-right below the opus.
535
536 @funindex instrument
537 @item instrument
538 Name of the instrument, centered below the arranger.  Also
539 centered at the top of pages (other than the first page).
540
541 @funindex piece
542 @item piece
543 Name of the piece, flush-left below the instrument.
544
545 @cindex page breaks, forcing
546 @funindex breakbefore
547 @item breakbefore
548 This forces the title to start on a new page (set to ##t or ##f).
549
550 @funindex copyright
551 @item copyright
552 Copyright notice, centered at the bottom of the first page.  To
553 insert the copyright symbol, see @ref{Text encoding}.
554
555 @funindex tagline
556 @item tagline
557 Centered at the bottom of the last page.
558
559 @end table
560
561 Here is a demonstration of the fields available.  Note that you
562 may use any @ref{Text markup}, commands in the header.
563
564 @lilypond[quote,verbatim,line-width=11.0\cm]
565 \paper {
566   line-width = 9.0\cm
567   paper-height = 10.0\cm
568 }
569
570 \book {
571   \header {
572     dedication = "dedicated to me"
573     title = \markup \center-align { "Title first line" "Title second line,
574 longer" }
575     subtitle = "the subtitle,"
576     subsubtitle = #(string-append "subsubtitle LilyPond version "
577 (lilypond-version))
578     poet = "Poet"
579     composer =  \markup \center-align { "composer" \small "(1847-1973)" }
580     texttranslator = "Text Translator"
581     meter = \markup { \teeny "m" \tiny "e" \normalsize "t" \large "e" \huge
582 "r" }
583     arranger = \markup { \fontsize #8.5 "a" \fontsize #2.5 "r" \fontsize
584 #-2.5 "r" \fontsize #-5.3 "a" \fontsize #7.5 "nger" }
585     instrument = \markup \bold \italic "instrument"
586     piece = "Piece"
587   }
588
589   \score {
590     { c'1 }
591     \header {
592       piece = "piece1"
593       opus = "opus1"
594     }
595   }
596   \markup {
597       and now...
598   }
599   \score {
600     { c'1 }
601     \header {
602       piece = "piece2"
603       opus = "opus2"
604     }
605   }
606 }
607 @end lilypond
608
609 As demonstrated before, you can use multiple @code{\header} blocks.
610 When same fields appear in different blocks, the latter is used.
611 Here is a short example.
612
613 @example
614 \header @{
615   composer = "Composer"
616 @}
617 \header @{
618   piece = "Piece"
619 @}
620 \score @{
621   \new Staff @{ c'4 @}
622   \header @{
623     piece = "New piece"  % overwrite previous one
624   @}
625 @}
626 @end example
627
628 If you define the @code{\header} inside the @code{\score} block, then
629 normally only the @code{piece} and @code{opus} headers will be printed.
630 Note that the music expression must come before the @code{\header}.
631
632 @lilypond[quote,verbatim,line-width=11.0\cm]
633 \score {
634   { c'4 }
635   \header {
636     title = "title"  % not printed
637     piece = "piece"
638     opus = "opus"
639   }
640 }
641 @end lilypond
642
643 @funindex printallheaders
644 @noindent
645 You may change this behavior (and print all the headers when defining
646 @code{\header} inside @code{\score}) by using
647
648 @example
649 \paper@{
650   printallheaders=##t
651 @}
652 @end example
653
654 @cindex copyright
655 @cindex tagline
656
657 The default footer is empty, except for the first page, where the
658 @code{copyright} field from @code{\header} is inserted, and the last
659 page, where @code{tagline} from @code{\header} is added.  The default
660 tagline is @qq{Music engraving by LilyPond (@var{version})}.@footnote{Nicely
661 printed parts are good PR for us, so please leave the tagline if you
662 can.}
663
664 Headers may be completely removed by setting them to false.
665
666 @example
667 \header @{
668   tagline = ##f
669   composer = ##f
670 @}
671 @end example
672
673
674 @node Custom titles
675 @subsection Custom titles
676
677 A more advanced option is to change the definitions of the following
678 variables in the @code{\paper} block.  The init file
679 @file{ly/titling-init.ly} lists the default layout.
680
681 @table @code
682 @funindex bookTitleMarkup
683 @item bookTitleMarkup
684   This is the title added at the top of the entire output document.
685 Typically, it has the composer and the title of the piece
686
687 @funindex scoreTitleMarkup
688 @item scoreTitleMarkup
689   This is the title put over a @code{\score} block.  Typically, it has
690 the name of the movement (@code{piece} field).
691
692 @funindex oddHeaderMarkup
693 @item oddHeaderMarkup
694   This is the page header for odd-numbered pages.
695
696 @funindex evenHeaderMarkup
697 @item evenHeaderMarkup
698   This is the page header for even-numbered pages.  If unspecified,
699   the odd header is used instead.
700
701   By default, headers are defined such that the page number is on the
702   outside edge, and the instrument is centered.
703
704 @funindex oddFooterMarkup
705 @item oddFooterMarkup
706   This is the page footer for odd-numbered pages.
707
708 @funindex evenFooterMarkup
709 @item evenFooterMarkup
710   This is the page footer for even-numbered pages.  If unspecified,
711   the odd header is used instead.
712
713   By default, the footer has the copyright notice on the first, and
714   the tagline on the last page.
715 @end table
716
717
718 @cindex \paper
719 @cindex header
720 @cindex footer
721 @cindex page layout
722 @cindex titles
723
724 The following definition will put the title flush left, and the
725 composer flush right on a single line.
726
727 @verbatim
728 \paper {
729   bookTitleMarkup = \markup {
730    \fill-line {
731      \fromproperty #'header:title
732      \fromproperty #'header:composer
733    }
734   }
735 }
736 @end verbatim
737
738 @node Reference to page numbers
739 @subsection Reference to page numbers
740
741 A particular place of a score can be marked using the @code{\label}
742 command, either at top-level or inside music.  This label can then be
743 refered to in a markup, to get the number of the page where the marked
744 point is placed, using the @code{\page-ref} markup command.
745
746 @lilypond[verbatim,line-width=11.0\cm]
747 \header { tagline = ##f }
748 \book {
749   \label #'firstScore
750   \score {
751     {
752       c'1
753       \pageBreak \mark A \label #'markA
754       c'
755     }
756   }
757
758   \markup { The first score begins on page \page-ref #'firstScore "0" "?" }
759   \markup { Mark A is on page \page-ref #'markA "0" "?" }
760 }
761 @end lilypond
762
763 The @code{\page-ref} markup command takes three arguments:
764 @enumerate
765 @item the label, a scheme symbol, eg. @code{#'firstScore};
766 @item a markup that will be used as a gauge to estimate the dimensions
767 of the markup;
768 @item a markup that will be used in place of the page number if the label 
769 is not known;
770 @end enumerate
771
772 The reason why a gauge is needed is that, at the time markups are
773 interpreted, the page breaking has not yet occured, so the page numbers
774 are not yet known.  To work around this issue, the actual markup
775 interpretation is delayed to a later time; however, the dimensions of
776 the markup have to be known before, so a gauge is used to decide these
777 dimensions.  If the book has between 10 and 99 pages, it may be "00",
778 ie. a two digit number.
779
780 @refcommands
781
782 @funindex \label
783 @code{\label}
784 @funindex \page-ref
785 @code{\page-ref}
786
787 @node Table of contents
788 @subsection Table of contents
789 A table of contents is included using the @code{\markuplines \table-of-contents}
790 command.  The elements which should appear in the table of contents are
791 entered with the @code{\tocItem} command, which may be used either at
792 top-level, or inside a music expression.
793
794 @verbatim
795 \markuplines \table-of-contents
796 \pageBreak
797
798 \tocItem \markup "First score"
799 \score { 
800   {
801     c'  % ...
802     \tocItem \markup "Some particular point in the first score"
803     d'  % ... 
804   }
805 }
806
807 \tocItem \markup "Second score"
808 \score {
809   {
810     e' % ...
811   }
812 }
813 @end verbatim
814
815 The markups which are used to format the table of contents are defined
816 in the @code{\paper} block. The default ones are @code{tocTitleMarkup},
817 for formatting the title of the table, and @code{tocItemMarkup}, for
818 formatting the toc elements, composed of the element title and page
819 number. These variables may be changed by the user:
820
821 @verbatim
822 \paper {
823   %% Translate the toc title into French:
824   tocTitleMarkup = \markup \huge \column {
825     \fill-line { \null "Table des matières" \null }
826     \hspace #1
827   }
828   %% use larfer font size
829   tocItemMarkup = \markup \large \fill-line {
830     \fromproperty #'toc:text \fromproperty #'toc:page
831   }
832 }
833 @end verbatim
834
835 Note how the toc element text and page number are refered to in
836 the @code{tocItemMarkup} definition.
837
838 New commands and markups may also be defined to build more elaborated
839 table of contents:
840 @itemize @bullet
841 @item first, define a new markup variable in the @code{\paper} block
842 @item then, define a music function which aims at adding a toc element
843 using this markup paper variable.
844 @end itemize
845
846 In the following example, a new style is defined for entering act names
847 in the table of contents of an opera:
848
849 @verbatim
850 \paper {
851   tocActMarkup = \markup \large \column {
852     \hspace #1
853     \fill-line { \null \italic \fromproperty #'toc:text \null }
854     \hspace #1
855   }
856 }
857
858 tocAct = 
859 #(define-music-function (parser location text) (markup?)
860    (add-toc-item! 'tocActMarkup text))
861 @end verbatim
862
863 @lilypond[line-width=11.0\cm]
864 \header { tagline = ##f }
865 \paper {
866   tocActMarkup = \markup \large \column {
867     \hspace #1
868     \fill-line { \null \italic \fromproperty #'toc:text \null }
869     \hspace #1
870   }
871 }
872
873 tocAct = 
874 #(define-music-function (parser location text) (markup?)
875    (add-toc-item! 'tocActMarkup text))
876
877 \book {
878   \markuplines \table-of-contents
879   \tocAct \markup { Atto Primo }
880   \tocItem \markup { Coro. Viva il nostro Alcide }
881   \tocItem \markup { Cesare. Presti omai l'Egizzia terra }
882   \tocAct \markup { Atto Secondo }
883   \tocItem \markup { Sinfonia }
884   \tocItem \markup { Cleopatra. V'adoro, pupille, saette d'Amore }
885   \markup \null
886 }
887 @end lilypond
888
889 @seealso
890
891 Init files: @file{ly/@/toc@/-init@/.ly}.
892
893 @refcommands
894
895 @funindex \table-of-contents
896 @code{\table-of-contents}
897 @funindex \tocItem
898 @code{\tocItem}
899
900 @node MIDI output
901 @section MIDI output
902
903 @cindex Sound
904 @cindex MIDI
905
906 MIDI (Musical Instrument Digital Interface) is a standard for
907 connecting and controlling digital instruments.  A MIDI file is a
908 series of notes in a number of tracks.  It is not an actual
909 sound file; you need special software to translate between the
910 series of notes and actual sounds.
911
912 Pieces of music can be converted to MIDI files, so you can listen to
913 what was entered.  This is convenient for checking the music; octaves
914 that are off or accidentals that were mistyped stand out very much
915 when listening to the MIDI output.
916
917 @refbugs
918
919 Many musically interesting effects, such as swing, articulation,
920 slurring, etc., are not translated to midi.
921
922 The midi output allocates a channel for each staff, and one for global
923 settings.  Therefore the midi file should not have more than 15 staves
924 (or 14 if you do not use drums).  Other staves will remain silent.
925
926 Not all midi players correctly handle tempo changes in the midi
927 output.  Players that are known to work include
928 @uref{http://@/timidity@/.sourceforge@/.net/,timidity}.
929
930 @menu
931 * Creating MIDI files::         
932 * MIDI block::                  
933 * MIDI instrument names::       
934 @end menu
935
936 @node Creating MIDI files
937 @subsection Creating MIDI files
938
939 To create a MIDI from a music piece of music, add a @code{\midi} block
940 to a score, for example,
941
942 @example
943 \score @{
944   @var{...music...}
945    \midi @{
946      \context @{
947        \Score
948        tempoWholesPerMinute = #(ly:make-moment 72 4)
949        @}
950      @}
951 @}
952 @end example
953
954 The tempo can be specified using the @code{\tempo} command within the 
955 actual music, see @ref{Metronome marks}.  An alternative, which does not
956 result in a metronome mark in the printed score, is shown in the example
957 above. In this example the tempo of quarter notes is set to 72 beats per
958 minute. 
959 This kind of tempo
960 specification can not take dotted note lengths as an argument. In this
961 case, break the dotted notes into smaller units. For example, a tempo
962 of 90 dotted quarter notes per minute can be specified as 270 eighth
963 notes per minute
964
965 @example
966 tempoWholesPerMinute = #(ly:make-moment 270 8)
967 @end example
968
969 If there is a @code{\midi} command in a @code{\score}, only MIDI will
970 be produced.  When notation is needed too, a @code{\layout} block must
971 be added
972
973 @example
974 \score @{
975   @var{...music...}
976   \midi @{ @}
977   \layout @{ @}
978 @}
979 @end example
980 @cindex layout block
981
982
983
984 Ties, dynamics, and tempo changes are interpreted.  Dynamic marks,
985 crescendi and decrescendi translate into MIDI volume levels.  Dynamic
986 marks translate to a fixed fraction of the available MIDI volume
987 range, crescendi and decrescendi make the volume vary linearly between
988 their two extremes.  The fractions can be adjusted by
989 @code{dynamicAbsoluteVolumeFunction} in @internalsref{Voice} context.
990 For each type of MIDI instrument, a volume range can be defined.  This
991 gives a basic equalizer control, which can enhance the quality of
992 the MIDI output remarkably.  The equalizer can be controlled by
993 setting @code{instrumentEqualizer}, or by setting
994
995 @example
996 \set Staff.midiMinimumVolume = #0.2
997 \set Staff.midiMaximumVolume = #0.8
998 @end example
999
1000 To remove dynamics from the MIDI output, insert the following lines
1001 in the @code{\midi@{@}} section.
1002
1003 @example
1004 \midi @{
1005   ...
1006   \context @{
1007     \Voice
1008     \remove "Dynamic_performer"
1009   @}
1010 @}
1011 @end example
1012
1013
1014 @refbugs
1015
1016 Unterminated (de)crescendos will not render properly in the midi file,
1017 resulting in silent passages of music.  The workaround is to explicitly
1018 terminate the (de)crescendo.  For example,
1019
1020 @example
1021 @{ a\< b c d\f @}
1022 @end example
1023
1024 @noindent
1025 will not work properly but
1026
1027 @example
1028 @{ a\< b c d\!\f @}
1029 @end example
1030
1031 @noindent
1032 will.
1033
1034
1035 MIDI output is only created when the @code{\midi} command is within
1036 a @code{\score} block.  If you put it within an explicitly instantiated
1037 context ( i.e. @code{\new Score} ) the file will fail.  To solve this,
1038 enclose the @code{\new Score} and the @code{\midi} in a @code{\score} block.
1039
1040 @example
1041 \score @{
1042   \new Score @{ @dots{}notes@dots{} @}
1043   \midi
1044 @}
1045 @end example
1046
1047
1048 @node MIDI block
1049 @subsection MIDI block
1050 @cindex MIDI block
1051
1052
1053 The MIDI block is analogous to the layout block, but it is somewhat
1054 simpler.  The @code{\midi} block is similar to @code{\layout}. It can contain
1055 context definitions.
1056
1057
1058 @cindex context definition
1059
1060 Context definitions follow precisely the same syntax as within the
1061 \layout block.  Translation modules for sound are called performers.
1062 The contexts for MIDI output are defined in @file{ly/@/performer@/-init@/.ly}.
1063
1064
1065 @node MIDI instrument names
1066 @subsection MIDI instrument names
1067
1068 @cindex instrument names
1069 @funindex Staff.midiInstrument
1070
1071 The MIDI instrument name is set by the @code{Staff.midiInstrument}
1072 property.  The instrument name should be chosen from the list in
1073 @ref{MIDI instruments}.
1074
1075 @example
1076 \set Staff.midiInstrument = "glockenspiel"
1077 @var{...notes...}
1078 @end example
1079
1080 If the selected instrument does not exactly match an instrument from
1081 the list of MIDI instruments, the Grand Piano (@code{"acoustic grand"})
1082 instrument is used.
1083
1084
1085 @c  Yes, this is a cop-out; this info doesn't belong in the Scheme
1086 @c  chapter, but I'm not certain where to stick it.
1087 @c  I think I'll eventually split this chapter into a "paper/layout"
1088 @c  chapter and a "misc issues" chapter.  -gp
1089 @node Displaying LilyPond notation
1090 @section Displaying LilyPond notation
1091
1092 @funindex \displayLilyMusc
1093 Displaying a music expression in LilyPond notation can be
1094 done using the music function @code{\displayLilyMusic}.  For example,
1095
1096 @example
1097 @{
1098   \displayLilyMusic \transpose c a, @{ c e g a bes @}
1099 @}
1100 @end example
1101
1102 will display
1103
1104 @example
1105 @{ a, cis e fis g @}
1106 @end example
1107
1108 By default, LilyPond will print these messages to the console along
1109 with all the other messages.  To split up these messages and save
1110 the results of @code{\display@{STUFF@}}, redirect the output to
1111 a file.
1112
1113 @example
1114 lilypond file.ly >display.txt
1115 @end example
1116
1117
1118 @node Skipping corrected music
1119 @section Skipping corrected music
1120
1121
1122 @funindex skipTypesetting
1123 @funindex showLastLength
1124
1125 When entering or copying music, usually only the music near the end (where
1126 you
1127 are adding notes) is interesting to view and correct.  To speed up
1128 this correction process, it is possible to skip typesetting of all but
1129 the last few measures. This is achieved by putting
1130
1131 @verbatim
1132 showLastLength = R1*5
1133 \score { ... }
1134 @end verbatim
1135
1136 @noindent
1137 in your source file. This will render only the last 5 measures
1138 (assuming 4/4 time signature) of every @code{\score} in the input
1139 file. For longer pieces, rendering only a small part is often an order
1140 of magnitude quicker than rendering it completely
1141
1142 Skipping parts of a score can be controlled in a more fine-grained
1143 fashion with the property @code{Score.skipTypesetting}.  When it is
1144 set, no typesetting is performed at all.
1145
1146 This property is also used to control output to the MIDI file. Note that
1147 it skips all events, including tempo and instrument changes. You have
1148 been warned.
1149
1150 @lilypond[quote,fragment,ragged-right,verbatim]
1151 \relative c'' {
1152   c8 d
1153   \set Score.skipTypesetting = ##t
1154   e e e e e e e e
1155   \set Score.skipTypesetting = ##f
1156   c d b bes a g c2 }
1157 @end lilypond
1158
1159 In polyphonic music, @code{Score.skipTypesetting} will affect all
1160 voices and staves, saving even more time.
1161
1162
1163