]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/global.itely
Minor changes from mailist.
[lilypond.git] / Documentation / user / global.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond.tely
3
4 @c A menu is needed before every deeper *section nesting of @node's; run 
5 @c     M-x texinfo-all-menus-update
6 @c to automatically fill in these menus before saving changes
7
8 @node Global issues
9 @chapter Global issues
10
11 This section deals with general lilypond issues, rather than
12 specific notation.
13
14 @menu
15 * Input files::                 
16 * Music expressions again::     
17 * Titles and headers::          
18 * Paper and pages::             
19 * Music layout::                
20 * Multiple movements::          
21 * MIDI output::                 
22 @end menu
23
24
25 @node Input files
26 @section Input files
27
28 The main format of input for LilyPond are text files.  By convention,
29 these files end with ``@code{.ly}''.
30
31 @menu
32 * File structure (introduction)::  
33 * File structure::              
34 * Including LilyPond files::    
35 * Text encoding::               
36 @end menu
37
38
39 @node File structure (introduction)
40 @subsection File structure (introduction)
41
42 A basic example of a lilypond input file is
43
44 @example
45 \version "2.8.0"
46 \score @{
47   @{ @}     % this is a single music expression;
48             % all the music goes in here.
49   \header @{ @}
50   \layout @{ @}
51   \midi @{ @}
52 @}
53 @end example
54
55 @noindent
56 There are many variations of this basic pattern, but this
57 example serves as a useful starting place.
58
59 The major part of this manual is concerned with entering various
60 forms of music in LilyPond.  However, many music expressions are not
61 valid input on their own, for example, a @code{.ly} file containing
62 only a note
63 @example
64 c'4
65 @end example
66
67 @noindent
68 will result in a parsing error.  Instead, music should be inside other
69 expressions, which may be put in a file by themselves.  Such
70 expressions are called toplevel expressions.  The next section enumerates
71 them all.
72
73
74 @node File structure
75 @subsection File structure
76
77 A @code{.ly} file contains any number of toplevel expressions, where a
78 toplevel expression is one of the following
79
80 @itemize @bullet
81 @item
82 An output definition, such as @code{\paper}, @code{\midi}, and
83 @code{\layout}.  Such a definition at the toplevel changes the default
84 settings for the block entered.
85
86 @item
87 A direct scheme expression, such as
88 @code{#(set-default-paper-size "a7" 'landscape)} or
89 @code{#(ly:set-option 'point-and-click #f)}.
90
91 @item
92 A @code{\header} block.  This sets the global header block.  This
93 is the block containing the definitions for book-wide settings, like
94 composer, title, etc. 
95
96 @item
97 An @code{\addquote} statement.  See @ref{Quoting other voices}
98 for more information.
99
100 @item
101 A @code{\score} block.  This score will be collected with other
102 toplevel scores, and combined as a single @code{\book}.
103
104 This behavior can be changed by setting the variable
105 @code{toplevel-score-handler} at toplevel.  The default handler is
106 defined in the init file @file{scm/@/lily@/.scm}.
107
108 The @code{\score} must begin with music, and may contain only
109 one music block.
110
111 @item
112 A @code{\book} block logically combines multiple movements
113 (i.e., multiple @code{\score} blocks) in one document.  A number of
114 @code{\scores} creates a single output file, where all movement are
115 concatenated.
116
117 This behavior can be changed by setting the variable
118 @code{toplevel-book-handler} at toplevel.  The default handler is
119 defined in the init file @file{scm/@/lily@/.scm}.
120
121 @item
122 A compound music expression, such as
123 @example
124 @{ c'4 d' e'2 @}
125 @end example
126
127 This will add the piece in a @code{\score} and format it in a
128 single book together with all other toplevel @code{\score}s and music
129 expressions.  In other words, a file containing only the above
130 music expression will be translated into
131
132 @example
133 \book @{
134   \score @{
135     \new Staff @{
136       \new Voice @{
137         @{ c'4 d' e'2 @}
138       @}
139     @}
140   @}
141         \layout @{ @}
142         \header @{ @}
143 @}
144 @end example
145  
146 This behavior can be changed by setting the variable
147 @code{toplevel-music-handler} at toplevel.  The default handler is
148 defined in the init file @file{scm/@/lily@/.scm}.
149
150 @item
151 A markup text, a verse for example
152 @example
153 \markup @{
154    2.  The first line verse two.
155 @}
156 @end example
157
158 Markup texts are rendered above, between or below the scores or music
159 expressions, wherever they appear.
160
161 @item
162 An identifier, such as
163 @example
164 foo = @{ c4 d e d @}
165 @end example
166
167 This can be used later on in the file by entering @code{\foo}.  The
168 name of an identifier should have alphabetic characters only; no
169 numbers, underscores or dashes.
170
171 @end itemize
172
173 The following example shows three things that may be entered at
174 toplevel
175
176 @example
177 \layout @{
178   % movements are non-justified by default    
179   ragged-right = ##t
180 @}
181
182 \header @{
183    title = "Do-re-mi"
184 @}
185    
186 @{ c'4 d' e2 @}
187 @end example
188
189
190 At any point in a file, any of the following lexical instructions can
191 be entered:
192
193 @itemize @bullet
194 @item @code{\version}
195 @item @code{\include}
196 @item @code{\renameinput}
197 @end itemize 
198
199
200 @node Including LilyPond files
201 @subsection Including LilyPond files
202
203 @cindex @code{\include}
204 @cindex including files
205
206 A large project may be split up into separate files.  To refer to another
207 file, use
208
209 @example
210 \include "otherfile.ly"
211 @end example
212
213 The line @code{\include "file.ly"} is equivalent to pasting the contents
214 of file.ly into the current file at the place where you have the
215 \include.  For example, for a large project you might write separate files
216 for each instrument part and create a ``full score'' file which brings
217 together the individual instrument files.
218
219 The initialization of LilyPond is done in a number of files that are
220 included by default when you start the program, normally transparent to the
221 user.  Run lilypond --verbose to see a list of paths and files that Lily
222 finds.
223
224 Files placed in directory @file{PATH/TO/share/lilypond/VERSION/ly/} (where
225 VERSION is in the form ``2.6.1'') are on the path and available to
226 @code{\include}.  Files in the
227 current working directory are available to \include, but a file of the same
228 name in LilyPond's installation takes precedence.  Files are
229 available to \include from directories in the search path specified as an
230 option when invoking @code{lilypond --include=DIR} which adds DIR to the search
231 path.
232
233 The @code{\include} statement can use full path information, but with the Unix
234 convention @code{"/"} rather than the DOS/Windows @code{"\"}.  For example,
235 if @file{stuff.ly} is located one directory higher than the current working
236 directory, use
237
238 @example
239 \include "../stuff.ly"
240 @end example
241
242
243 @node Text encoding
244 @subsection Text encoding
245
246 LilyPond uses the Pango library to format multi-lingual texts, and
247 does not perform any input-encoding conversions.  This means that any
248 text, be it title, lyric text, or musical instruction containing
249 non-ASCII characters, must be utf-8.  The easiest way to enter such text is
250 by using a Unicode-aware editor and saving the file with utf-8 encoding.  Most
251 popular modern editors have utf-8 support, for example, vim, Emacs,
252 jEdit, and GEdit do.
253
254 Depending on the fonts installed, the following fragment shows Hebrew
255 and Cyrillic lyrics,
256
257 @cindex Cyrillic
258 @cindex Hebrew
259 @cindex ASCII, non
260
261 @lilypondfile[fontload]{utf-8.ly}
262
263 The @TeX{} backend does not handle encoding specially at all.  Strings
264 in the input are put in the output as-is.  Extents of text items in the
265 @TeX{} backend, are determined by reading a file created via the
266 @file{texstr} backend,
267
268 @example
269 lilypond -b texstr input/les-nereides.ly
270 latex les-nereides.texstr
271 @end example
272
273 The last command produces @file{les-nereides.textmetrics}, which is
274 read when you execute
275
276 @example
277 lilypond -b tex input/les-nereides.ly
278 @end example
279
280 Both @file{les-nereides.texstr} and @file{les-nereides.tex} need
281 suitable LaTeX wrappers to load appropriate La@TeX{} packages for
282 interpreting non-ASCII strings.
283
284 To use a Unicode escape sequence, use
285
286 @example
287 #(ly:export (ly:wide-char->utf-8 #x2014))
288 @end example
289
290
291 @seealso
292
293 @inputfileref{input/regression,utf-8.ly}
294
295
296
297 @c  FIXME: --must-- delete/modify this before 2.8.0!!!  -gp
298 @node Music expressions again
299 @section Music expressions again
300
301 Should we include anything about this here?
302
303
304 @node Titles and headers
305 @section Titles and headers
306
307 Almost all printed music includes a title and the composer's name;
308 some pieces include a lot more information.
309
310 @menu
311 * Creating titles::             
312 * Custom titles::               
313 @end menu
314
315
316 @node Creating titles
317 @subsection Creating titles
318
319 Titles are created for each @code{\score} block, and over a
320 @code{\book}.
321
322 The contents of the titles are taken from the @code{\header} blocks.
323 The header block for a book supports the following
324 @table @code
325 @item dedication
326 The dedicatee of the music, centered at the top of the first page.
327
328 @item title
329 The title of the music, centered just below the dedication.
330
331 @item subtitle
332 Subtitle, centered below the title.
333
334 @item subsubtitle
335 Subsubtitle, centered below the subtitle.
336
337 @item poet
338 Name of the poet, flush-left below the subtitle.
339
340 @item composer
341 Name of the composer, flush-right below the subtitle.
342
343 @item meter
344 Meter string, flush-left below the poet.
345
346 @item opus
347 Name of the opus, flush-right below the composer.
348
349 @item arranger
350 Name of the arranger, flush-right below the opus.
351
352 @item instrument
353 Name of the instrument, centered below the arranger.  Also
354 centered at the top of pages (other than the first page).
355
356 @item piece
357 Name of the piece, flush-left below the instrument.
358
359 @cindex page breaks, forcing
360 @item breakbefore
361 This forces the title to start on a new page (set to ##t or ##f).
362
363 @item copyright
364 Copyright notice, centered at the bottom of the first page.  To
365 insert the copyright symbol, see @ref{Text encoding}.
366
367 @item tagline
368 Centered at the bottom of the last page.
369
370 @end table
371
372 Here is a demonstration of the fields available.  Note that you
373 may use any @ref{Text markup} commands in the header.
374
375 @lilypond[quote,verbatim,line-width=11.0\cm]
376 \paper {
377   line-width = 9.0\cm
378   paper-height = 10.0\cm
379 }
380
381 \book {
382   \header {
383     dedication = "dedicated to me"
384     title = \markup \center-align { "Title first line" "Title second line, longer" }
385     subtitle = "the subtitle,"
386     subsubtitle = #(string-append "subsubtitle LilyPond version " (lilypond-version))
387     poet = "Poet"
388     composer =  \markup \center-align { "composer" \small "(1847-1973)" }
389     texttranslator = "Text Translator"
390     meter = \markup { \teeny "m" \tiny "e" \normalsize "t" \large "e" \huge "r" }
391     arranger = \markup { \fontsize #8.5 "a" \fontsize #2.5 "r" \fontsize #-2.5 "r" \fontsize #-5.3 "a" \fontsize #7.5 "nger" }
392     instrument = \markup \bold \italic "instrument"
393     piece = "Piece"
394   }
395
396   \score {
397     { c'1 }
398     \header {
399       piece = "piece1"
400       opus = "opus1" 
401     }
402   }
403   \markup {
404       and now...
405   }
406   \score {
407     { c'1 }
408     \header {
409       piece = "piece2"
410       opus = "opus2" 
411     }
412   }
413 }
414 @end lilypond
415
416 As demonstrated before, you can use multiple @code{\header} blocks. 
417 When same fields appear in different blocks, the latter is used.  
418 Here is a short example.
419
420 @example 
421 \header @{
422   composer = "Composer"
423 @}
424 \header @{
425   title = "Title"
426 @}
427 \score @{
428   \new Staff @{ c'4 @}
429   \header @{
430     title = "New title"  % overwrite previous one
431   @}
432 @}
433 @end example
434
435 If you define the @code{\header} inside the @code{\score} block, then
436 normally only the @code{piece} and @code{opus} headers will be printed.
437 Note that the music expression must come before the @code{\header}.
438
439 @lilypond[quote,verbatim,line-width=11.0\cm]
440 \score {
441   { c'4 }
442   \header {
443     title = "title"  % not printed
444     piece = "piece"
445     opus = "opus"
446   }
447 }
448 @end lilypond
449
450 @cindex @code{printallheaders}
451 @noindent
452 You may change this behavior (and print all the headers when defining
453 @code{\header} inside @code{\score}) by using
454
455 @example
456 \paper@{
457   printallheaders=##t
458 @}
459 @end example
460
461
462 @node Custom titles
463 @subsection Custom titles
464
465 A more advanced option is to change the definitions of the following
466 variables in the @code{\paper} block.  The init file
467 @file{ly/titling-init.ly} lists the default layout.
468
469 @table @code
470 @cindex @code{bookTitleMarkup}
471 @item bookTitleMarkup
472   This is the title put over an entire @code{\book} block.  Typically,
473   it has the composer and the title of the piece
474   
475 @cindex @code{scoreTitleMarkup}
476 @item scoreTitleMarkup
477   This is the title put over a @code{\score} block within a
478 @code{\book}.  Typically, it has the name of the movement (@code{piece}
479 field).
480
481 @cindex @code{oddHeaderMarkup}
482 @item oddHeaderMarkup
483   This is the page header for odd-numbered pages. 
484
485 @cindex @code{evenHeaderMarkup}
486 @item evenHeaderMarkup
487   This is the page header for even-numbered pages.  If unspecified,
488   the odd header is used instead.
489
490   By default, headers are defined such that the page number is on the
491   outside edge, and the instrument is centered.
492
493 @cindex @code{oddFooterMarkup}
494 @item oddFooterMarkup
495   This is the page footer for odd-numbered pages. 
496   
497 @cindex @code{evenFotterMarkup}
498 @item evenFooterMarkup
499   This is the page footer for even-numbered pages.  If unspecified,
500   the odd header is used instead.
501
502   By default, the footer has the copyright notice on the first, and
503   the tagline on the last page.
504 @end table
505
506
507 @cindex \paper
508 @cindex header
509 @cindex footer
510 @cindex page layout
511 @cindex titles
512
513 The following definition will put the title flush left, and the
514 composer flush right on a single line.
515
516 @verbatim
517 \paper {
518   bookTitleMarkup = \markup {
519    \fill-line {
520      \fromproperty #'header:title
521      \fromproperty #'header:composer
522    }
523   }
524 }
525 @end verbatim
526
527
528 @refbugs
529
530 The @code{breakbefore=##t} header requires that there is a @code{piece} header as well.  It may be used as a normal header, or left  blank (@code{=""}) as in the example above, but it must be present.
531
532
533
534 @node Paper and pages
535 @section Paper and pages
536
537 This section deals with the display of music on physical paper.
538
539 @menu
540 * Paper size::                  
541 * Page formatting::             
542 @end menu
543
544
545 @node Paper size
546 @subsection Paper size
547
548 @cindex paper size
549 @cindex page size
550 @cindex @code{papersize}
551
552 To change the paper size, there are two commands,
553 @example
554 #(set-default-paper-size "a4")
555 \paper @{
556   #(set-paper-size "a4")
557 @}
558 @end example
559
560 The first command sets the size of all pages.  The second command sets the size
561 of the pages that the @code{\paper} block applies to -- if the @code{\paper}
562 block is at the top of the file, then it will apply to all pages.  If the
563 @code{\paper} block is inside a @code{\book}, then the paper size will only
564 apply to that book.
565
566 Support for the following paper sizes are included by default,
567 @code{a6}, @code{a5}, @code{a4}, @code{a3}, @code{legal}, @code{letter},
568 @code{11x17} (also known as tabloid).
569
570 Extra sizes may be added by editing the definition for
571 @code{paper-alist} in the initialization file @file{scm/paper.scm}.
572
573 @cindex orientation
574 @cindex landscape
575
576 If the symbol @code{landscape} is supplied as an argument to
577 @code{set-default-paper-size}, the pages will be rotated by 90 degrees,
578 and wider line widths will be set correspondingly.
579
580 @example
581 #(set-default-paper-size "a6" 'landscape)
582 @end example 
583
584
585 @node Page formatting
586 @subsection Page formatting
587
588 @cindex page formatting
589 @cindex margins
590 @cindex header, page
591 @cindex footer, page
592
593 LilyPond will do page layout, set margins, and add headers and
594 footers to each page.
595
596 The default layout responds to the following settings in the
597 @code{\paper} block.
598
599 @cindex @code{\paper}
600
601 @quotation
602 @table @code
603 @cindex @code{first-page-number}
604 @item first-page-number
605 The value of the page number of the first page.  Default is@tie{}1.
606
607 @cindex @code{printfirst-page-number}
608 @item printfirst-page-number
609 If set to true, will print the page number in the first page.  Default is
610 false.
611
612 @cindex @code{print-page-number}
613 @item print-page-number
614 If set to false, page numbers will not be printed.
615
616 @cindex @code{paper-width}
617 @item paper-width
618 The width of the page.
619
620 @cindex @code{paper-height}
621 @item paper-height
622 The height of the page.
623
624 @cindex @code{top-margin}
625 @item top-margin
626 Margin between header and top of the page.
627
628 @cindex @code{bottom-margin}
629 @item bottom-margin
630 Margin between footer and bottom of the page.
631
632 @cindex @code{left-margin}
633 @item left-margin
634 Margin between the left side of the page and the beginning of the music.
635
636 @cindex @code{line-width}
637 @item line-width
638 The length of the systems.
639
640 @cindex @code{head-separation}
641 @item head-separation
642 Distance between the top-most music system and the page header.
643
644 @cindex @code{foot-separation}
645 @item foot-separation
646 Distance between the bottom-most music system and the page footer.
647
648 @cindex @code{page-top-space}
649 Distance from the top of the printable area to the center of the first
650 staff. This only works for staves which are vertically small. Big staves
651 are set with the top of their bounding box aligned to the top of the
652 printable area.
653
654 @cindex @code{ragged-bottom}
655 @item ragged-bottom
656 If set to true, systems will not be spread across the page.
657
658 This should be set to true for pieces that have only two or three
659 systems per page, for example orchestral scores.
660  
661 @cindex @code{ragged-last-bottom}
662 @item ragged-last-bottom
663 If set to false, systems will be spread to fill the last page.
664
665 Pieces that amply fill two pages or more should have this set to
666 true.
667
668 @cindex @code{system-count}
669 @item system-count
670 This variable, if set, specifies into how many lines a score should be
671 broken.
672
673 @cindex @code{between-system-space}
674 @item between-system-space
675 This dimensions determines the distance between systems.  It is the
676 ideal distance between the center of the bottom staff of one system
677 and the center of the top staff of the next system.
678
679 Increasing this will provide a more even appearance of the page at the
680 cost of using more vertical space.
681
682 @cindex @code{between-system-padding}
683 @item between-system-padding
684 This dimension is the minimum amount of white space that will always
685 be present between the bottom-most symbol of one system, and the
686 top-most of the next system.
687
688 Increasing this will put systems whose bounding boxes almost touch
689 farther apart.
690
691
692 @cindex @code{horizontal-shift}
693 @item horizontal-shift
694 All systems (including titles and system separators) are shifted by
695 this amount to the right. Page markup, such as headers and footers are
696 not affected by this. The purpose of this variable is to make space
697 for instrument names at the left.
698
699 @cindex @code{after-title-space}
700 @item after-title-space
701 Amount of space between the title and the first system.
702
703 @cindex @code{after-title-space}
704 @item before-title-space 
705 Amount of space between the last system of the previous piece and the
706 title of the next.
707
708 @cindex @code{between-title-space}
709 @item between-title-space
710 Amount of space between consecutive titles (e.g., the title of the
711 book and the title of a piece).
712
713 @cindex @code{printallheaders}
714 @item printallheaders
715 Setting this to #t will print all headers for each \score in a
716 \book.  Normally only the piece and opus \headers are printed.
717
718 @cindex @code{systemSeparatorMarkup}
719 @item systemSeparatorMarkup
720 This contains a markup object, which will be inserted between
721 systems.  This is often used for orchestral scores.
722
723 The markup command @code{\slashSeparator} is provided as a sensible
724 default,  for example
725
726 @lilypond[ragged-right]
727 \paper {
728   systemSeparatorMarkup = \slashSeparator
729 }
730
731 \relative { c1 \break c1 }
732 @end lilypond
733
734
735 @end table
736 @end quotation
737
738 Example:
739
740 @example
741 \paper@{
742   paper-width = 2\cm
743   top-margin = 3\cm
744   bottom-margin = 3\cm
745   ragged-last-bottom = ##t
746 @}
747 @end example
748
749 You can also define these values in Scheme.  In that case @code{mm},
750 @code{in}, @code{pt}, and @code{cm} are variables defined in
751 @file{paper-defaults.ly} with values in millimeters.  That's why the
752 value has to be multiplied in the example
753
754 @example
755 \paper @{
756   #(define bottom-margin (* 2 cm)) 
757 @}
758 @end example
759
760 @cindex copyright
761 @cindex tagline
762
763 The default footer is empty, except for the first page, where the
764 @code{copyright} field from @code{\header} is inserted, and the last
765 page, where @code{tagline} from @code{\header} is added.  The default
766 tagline is ``Music engraving by LilyPond (@var{version})''.@footnote{Nicely
767 printed parts are good PR for us, so please leave the tagline if you
768 can.}
769
770 The header and footer are created by the functions @code{make-footer}
771 and @code{make-header}, defined in @code{\paper}.  The default
772 implementations are in @file{scm/@/page@/-layout@/.scm}.
773
774 The page layout itself is done by two functions in the
775 @code{\paper} block, @code{page-music-height} and
776 @code{page-make-stencil}.  The former tells the line-breaking algorithm
777 how much space can be spent on a page, the latter creates the actual
778 page given the system to put on it.
779
780
781 @refbugs
782
783 The option right-margin is defined but doesn't set the right margin
784 yet.  The value for the right margin has to be defined adjusting the
785 values of @code{left-margin} and @code{line-width}.
786
787 The default page header puts the page number and the @code{instrument}
788 field from the @code{\header} block on a line.
789
790
791
792 @node Music layout
793 @section Music layout
794
795 This section deals with the manner in which the music is printed
796 within the boundaries defined by the @code{\paper} block.
797
798 The global paper layout is determined by three factors: the page layout, the
799 line breaks, and the spacing.  These all influence each other.  The
800 choice of spacing determines how densely each system of music is set.
801 This influences where line breaks are chosen, and thus ultimately, how
802 many pages a piece of music takes.
803
804 Globally spoken, this procedure happens in three steps: first,
805 flexible distances (``springs'') are chosen, based on durations.  All
806 possible line breaking combinations are tried, and the one with the
807 best results -- a layout that has uniform density and requires as
808 little stretching or cramping as possible -- is chosen.
809
810 After spacing and linebreaking, the systems are distributed across
811 pages, taking into account the size of the page, and the size of the
812 titles.
813
814 @menu
815 * Setting global staff size::   
816 * Selecting notation font size::  
817 * Score layout::                
818 * Vertical spacing::            
819 * Vertical spacing of piano staves::  
820 * Horizontal spacing::          
821 * Line length::                 
822 * Line breaking::               
823 * Page breaking::               
824 @end menu
825
826
827 @node Setting global staff size
828 @subsection Setting global staff size
829
830 @cindex font size, setting
831 @cindex staff size, setting
832 @cindex @code{layout} file
833
834 To set the global staff size, use @code{set-global-staff-size}.
835
836 @example
837 #(set-global-staff-size 14)
838 @end example
839
840 @noindent
841 This sets the global default size to 14pt staff height and scales all
842 fonts accordingly.
843
844 The Feta font provides musical symbols at eight different
845 sizes.  Each font is tuned for a different staff size: at a smaller size
846 the font becomes heavier, to match the relatively heavier staff lines.
847 The recommended font sizes are listed in the following table:
848
849 @quotation
850 @multitable @columnfractions .15 .2 .22 .2
851
852 @item @b{font name}
853 @tab @b{staff height (pt)}
854 @tab @b{staff height (mm)}
855 @tab @b{use}
856
857 @item feta11
858 @tab 11.22
859 @tab 3.9 
860 @tab pocket scores
861
862 @item feta13
863 @tab 12.60
864 @tab 4.4
865 @tab
866  
867 @item feta14
868 @tab 14.14
869 @tab 5.0
870 @tab 
871
872 @item feta16
873 @tab 15.87
874 @tab 5.6
875 @tab 
876
877 @item feta18
878 @tab 17.82
879 @tab 6.3
880 @tab song books
881
882 @item feta20
883 @tab 20
884 @tab 7.0
885 @tab standard parts 
886
887 @item feta23
888 @tab 22.45 
889 @tab 7.9
890 @tab 
891
892 @item feta26
893 @tab 25.2 
894 @tab 8.9
895 @tab
896 @c modern rental material?
897
898 @end multitable
899 @end quotation
900
901 These fonts are available in any sizes.  The context property
902 @code{fontSize} and the layout property @code{staff-space} (in
903 @internalsref{StaffSymbol}) can be used to tune the size for individual
904 staves.  The sizes of individual staves are relative to the global size.
905
906 @example
907
908 @end example
909
910 @seealso
911
912 This manual: @ref{Selecting notation font size}.
913
914
915 @node Selecting notation font size
916 @subsection Selecting notation font size
917
918 The easiest method of setting the font size of any context, is by
919 setting the @code{fontSize} property.
920
921 @lilypond[quote,fragment,relative=1,verbatim]
922 c8
923 \set fontSize = #-4
924 c f
925 \set fontSize = #3
926 g
927 @end lilypond
928
929 @noindent
930 It does not change the size of variable symbols, such as beams or
931 slurs.
932
933 Internally, the @code{fontSize} context property will cause the
934 @code{font-size} property to be set in all layout objects.  The value
935 of @code{font-size} is a number indicating the size relative to the
936 standard size for the current staff height.  Each step up is an
937 increase of approximately 12% of the font size.  Six steps is exactly a
938 factor two.  The Scheme function @code{magstep} converts a
939 @code{font-size} number to a scaling factor.
940
941 @lilypond[quote,fragment,relative=1,verbatim]
942 c8
943 \override NoteHead #'font-size = #-4
944 c f
945 \override NoteHead #'font-size = #3
946 g
947 @end lilypond
948
949 LilyPond has fonts in different design sizes.  The music fonts for
950 smaller sizes are chubbier, while the text fonts are relatively wider.
951 Font size changes are achieved by scaling the design size that is
952 closest to the desired size.  The standard font size (for
953 @code{font-size} equals 0), depends on the standard staff height.  For
954 a 20pt staff, a 10pt font is selected.
955
956 The @code{font-size} property can only be set on layout objects that
957 use fonts. These are the ones supporting the
958 @internalsref{font-interface} layout interface.
959
960 @refcommands
961
962 The following commands set @code{fontSize} for the current voice:
963
964 @cindex @code{\tiny}
965 @code{\tiny}, 
966 @cindex @code{\small}
967 @code{\small}, 
968 @cindex @code{\normalsize}
969 @code{\normalsize}.
970
971
972 @node Score layout
973 @subsection Score layout
974
975 @cindex @code{\layout}
976
977 While @code{\paper} contains settings that relate to the page formatting
978 of the whole document, @code{\layout} contains settings for score-specific
979 layout.
980
981 @example
982 \layout @{
983   indent = 2.0\cm
984   \context @{ \Staff
985     \override VerticalAxisGroup #'minimum-Y-extent = #'(-6 . 6)
986   @}
987   \context @{ \Voice
988     \override TextScript #'padding = #1.0
989     \override Glissando #'thickness = #3
990   @}
991 @}
992 @end example
993
994
995 @seealso
996
997 This manual: @ref{Changing context default settings}
998
999
1000 @node Vertical spacing
1001 @subsection Vertical spacing
1002
1003 @cindex vertical spacing
1004 @cindex distance between staves
1005 @cindex staff distance
1006 @cindex between staves, distance
1007 @cindex staves per page
1008 @cindex space between staves
1009
1010 The height of each system is determined automatically.  To prevent
1011 systems from bumping into each other, some minimum distances are set.
1012 By changing these, you can put staves closer together, and thus put
1013 more systems onto one page.
1014
1015 Normally staves are stacked vertically.  To make staves maintain a
1016 distance, their vertical size is padded.  This is done with the
1017 property @code{minimum-Y-extent}.  It takes a pair of numbers, so
1018 if you want to make it smaller than its default @code{#'(-4 . 4)},
1019 then you could set. When applied to a
1020 @internalsref{VerticalAxisGroup}, it controls the size of a horizontal
1021 line, such as a staff or a line of lyrics.  
1022
1023 @example
1024 \override Staff.VerticalAxisGroup #'minimum-Y-extent = #'(-3 . 3)
1025 @end example
1026
1027 @noindent
1028 This sets the vertical size of the current staff to 3 staff spaces on
1029 either side of the center staff line.  The value @code{(-3 . 3)} is
1030 interpreted as an interval, where the center line is the 0, so the
1031 first number is generally negative.  The staff can be made larger at
1032 the bottom by setting it to @code{(-6 . 4)}.
1033
1034 The spacing of staves in a system may also be tuned per system.  This is
1035 done with the command
1036
1037 @example
1038 \overrideProperty
1039 #"Score.NonMusicalPaperColumn"
1040 #'line-break-system-details
1041 #'((alignment-extra-space . 15))
1042 @end example
1043
1044 @noindent
1045 at the line break before the system to be changed. The distance
1046 @code{15} is distributed over all staves that have a fixed distance
1047 alignment.  For example,
1048
1049 @lilypond[ragged-right, fragment, relative=2, staffsize=13]
1050 \new StaffGroup <<
1051   \new Staff { 
1052     c1\break 
1053         
1054     \overrideProperty
1055     #"Score.NonMusicalPaperColumn"
1056     #'line-break-system-details
1057     #'((fixed-alignment-extra-space . 15))
1058
1059     c\break 
1060   }
1061   \new Staff { c c }
1062 >>
1063 @end lilypond
1064
1065 The distance for @code{alignment-extra-space} may also be negative.
1066
1067
1068 To change the amount of space between systems, use
1069 @code{between-system-space}.  A score with only one staff is still
1070 considered to have systems, so setting @code{between-system-space} will
1071 be much more useful than changing @code{minimum-Y-extent} of a Staff
1072 context.
1073
1074 @example
1075 \paper @{
1076   between-system-space = 10\mm
1077 @}
1078 @end example
1079
1080 If you simply want to tell LilyPond ``fit as much as possible onto
1081 these pages, then expand to fill any available space on the pages,''
1082 then use the following
1083
1084 @example
1085 \paper @{
1086   between-system-padding = #1
1087   ragged-bottom=##f
1088   ragged-last-bottom=##f
1089 @}
1090 @end example
1091
1092
1093 @c let's wait for a some comments before writing more.
1094
1095 The vertical spacing on a page can also be changed for each system individually.
1096 Some examples are found in the example file
1097 @inputfileref{input/regression/,page-spacing.ly}.
1098
1099 When setting @code{annotatespacing} in the @code{\paper} block LilyPond
1100 will graphically indicate the dimensions of properties that may be set
1101 for page spacing,
1102
1103 @lilypond[verbatim]
1104 #(set-default-paper-size "a7" 'landscape)
1105 \paper { annotatespacing = ##t }
1106 { c4 }
1107 @end lilypond
1108
1109 @noindent
1110 All units dimensions are measured in staff spaces. The pairs
1111 (@var{a},@var{b}) are intervals, where @var{a} is the lower edge and
1112 @var{b} the upper edge of the interval.
1113
1114 @seealso
1115
1116 Internals: Vertical alignment of staves is handled by the
1117 @internalsref{VerticalAlignment} object. The context parameters
1118 specifying  the vertical extent are described in connection with 
1119 the @internalsref{Axis_group_engraver}.
1120
1121 Example files: @inputfileref{input/regression/,page-spacing.ly},
1122 @inputfileref{input/regression/,alignment-vertical-spacing.ly}.
1123
1124
1125
1126
1127 @node Vertical spacing of piano staves
1128 @subsection Vertical spacing of piano staves
1129
1130 The distance between staves of a @internalsref{PianoStaff} cannot be
1131 computed during formatting.  Rather, to make cross-staff beaming work
1132 correctly, that distance has to be fixed beforehand.
1133  
1134 The distance of staves in a @code{PianoStaff} is set with the
1135 @code{forced-distance} property of the
1136 @internalsref{VerticalAlignment} object, created in
1137 @internalsref{PianoStaff}.
1138
1139 It can be adjusted as follows
1140 @example
1141 \new PianoStaff \with @{
1142   \override VerticalAlignment #'forced-distance = #7
1143 @} @{
1144   ...
1145 @}
1146 @end example
1147
1148 @noindent
1149 This would bring the staves together at a distance of 7 staff spaces,
1150 measured from the center line of each staff.
1151
1152 The difference is demonstrated in the following example,
1153 @lilypond[quote,verbatim]
1154 \relative c'' <<
1155   \new PianoStaff \with {
1156     \override VerticalAlignment #'forced-distance = #7
1157   } <<
1158     \new Staff { c1 }
1159     \new Staff { c }
1160   >>
1161   \new PianoStaff <<
1162     \new Staff { c }
1163     \new Staff { c }
1164   >>
1165 >>    
1166 @end lilypond
1167
1168
1169 It is also possible to change the distance between for each system
1170 individually.  This is done by including the command 
1171
1172 @example
1173 \overrideProperty
1174 #"Score.NonMusicalPaperColumn"
1175 #'line-break-system-details
1176 #'((fixed-alignment-extra-space . 15))
1177 @end example
1178
1179 @noindent
1180 at the line break before the system to be changed. The distance
1181 @code{15} is distributed over all staves that have a fixed distance
1182 alignment.  For example,
1183
1184 @lilypond[ragged-right, fragment, relative=2, staffsize=13]
1185 \new PianoStaff <<
1186   \new Staff { 
1187     c1\break 
1188         
1189     \overrideProperty
1190     #"Score.NonMusicalPaperColumn"
1191     #'line-break-system-details
1192     #'((fixed-alignment-extra-space . 15))
1193
1194     c\break 
1195   }
1196   \new Staff { c c }
1197 >>
1198 @end lilypond
1199
1200 The distance for @code{fixed-alignment-extra-space} may also be
1201 negative.
1202
1203 @seealso
1204
1205 Example files: @inputfileref{input/regression/,alignment-vertical-spacing.ly}.
1206
1207 @node Horizontal spacing
1208 @subsection Horizontal Spacing
1209
1210 The spacing engine translates differences in durations into stretchable
1211 distances (``springs'') of differring lengths.  Longer durations get
1212 more space, shorter durations get less.  The shortest durations get a
1213 fixed amount of space (which is controlled by
1214 @code{shortest-duration-space} in the @internalsref{SpacingSpanner}
1215 object).  The longer the duration, the more space it gets: doubling a
1216 duration adds a fixed amount (this amount is controlled by
1217 @code{spacing-increment}) of space to the note.
1218
1219 For example, the following piece contains lots of half, quarter, and
1220 8th notes; the eighth note is followed by 1 note head width (NHW). 
1221 The quarter note is followed by 2 NHW, the half by 3 NHW, etc.
1222
1223 @lilypond[quote,fragment,verbatim,relative=1]
1224 c2 c4. c8 c4. c8 c4. c8 c8
1225 c8 c4 c4 c4
1226 @end lilypond
1227
1228 Normally, @code{spacing-increment} is set to 1.2 staff space, which is
1229 approximately the width of a note head, and
1230 @code{shortest-duration-space} is set to 2.0, meaning that the
1231 shortest note gets 2.4 staff space (2.0 times the
1232 @code{spacing-increment}) of horizontal space.  This space is counted
1233 from the left edge of the symbol, so the shortest notes are generally
1234 followed by one NHW of space.
1235
1236 If one would follow the above procedure exactly, then adding a single
1237 32nd note to a score that uses 8th and 16th notes, would widen up the
1238 entire score a lot.  The shortest note is no longer a 16th, but a 32nd,
1239 thus adding 1 NHW to every note.  To prevent this, the shortest
1240 duration for spacing is not the shortest note in the score, but rather
1241 the one which occurs most frequently.
1242
1243
1244 The most common shortest duration is determined as follows: in every
1245 measure, the shortest duration is determined.  The most common shortest
1246 duration is taken as the basis for the spacing, with the stipulation
1247 that this shortest duration should always be equal to or shorter than
1248 an 8th note.  The shortest duration is printed when you run
1249 @code{lilypond} with the @code{--verbose} option.
1250
1251 These durations may also be customized.  If you set the
1252 @code{common-shortest-duration} in @internalsref{SpacingSpanner}, then
1253 this sets the base duration for spacing.  The maximum duration for this
1254 base (normally an 8th), is set through @code{base-shortest-duration}.
1255
1256 @cindex @code{common-shortest-duration}
1257 @cindex @code{base-shortest-duration}
1258 @cindex @code{stem-spacing-correction}
1259 @cindex @code{spacing}
1260
1261 Notes that are even shorter than the common shortest note are
1262 followed by a space that is proportional to their duration relative to
1263 the common shortest note.  So if we were to add only a few 16th notes
1264 to the example above, they would be followed by half a NHW:
1265
1266 @lilypond[quote,fragment,verbatim,relative=2]
1267 c2 c4. c8 c4. c16[ c] c4. c8 c8 c8 c4 c4 c4
1268 @end lilypond
1269
1270
1271 In the introduction (see @ref{Engraving}), it was explained that stem
1272 directions influence spacing.  This is controlled with the
1273 @code{stem-spacing-correction} property in the
1274 @internalsref{NoteSpacing}, object.  These are generated for every
1275 @internalsref{Voice} context.  The @code{StaffSpacing} object
1276 (generated in @internalsref{Staff} context) contains the same property
1277 for controlling the stem/bar line spacing.  The following example shows
1278 these corrections, once with default settings, and once with
1279 exaggerated corrections:
1280
1281 @lilypond[quote,ragged-right]
1282 {
1283   c'4 e''4 e'4 b'4 |
1284   b'4 e''4 b'4 e''4|
1285   \override Staff.NoteSpacing #'stem-spacing-correction = #1.5
1286   \override Staff.StaffSpacing #'stem-spacing-correction = #1.5
1287   c'4 e''4 e'4 b'4 |
1288   b'4 e''4 b'4 e''4|      
1289 }
1290 @end lilypond
1291
1292 Proportional notation is supported; see @ref{Proportional notation}.
1293
1294 By default, spacing in tuplets depends on various non-duration
1295 factors (such as accidentals, clef changes, etc).  To disregard
1296 such symbols and force uniform equal-duration spacing, use
1297 @code{Score.SpacingSpanner #'uniform-stretching}.  This
1298 property can only be changed at the beginning of a score,
1299
1300 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1301 \new Score \with {
1302   \override SpacingSpanner #'uniform-stretching = ##t
1303 } <<
1304   \new Staff{
1305     \times 4/5 {
1306       c8 c8 c8 c8 c8
1307     }
1308     c8 c8 c8 c8
1309   }
1310   \new Staff{
1311     c8 c8 c8 c8
1312     \times 4/5 {
1313       c8 c8 c8 c8 c8
1314     }
1315   }
1316 >>
1317 @end lilypond
1318
1319
1320 When @code{strict-note-spacing} is set, notes are spaced without
1321 regard for clefs, bar lines, and grace notes,
1322
1323 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1324 \override Score.SpacingSpanner #'strict-note-spacing = ##t 
1325 \new Staff { c8[ c \clef alto c \grace { c16[ c] } c8 c c]  c32[ c32] }
1326 @end lilypond
1327
1328
1329 @seealso
1330
1331 Internals: @internalsref{SpacingSpanner}, @internalsref{NoteSpacing},
1332 @internalsref{StaffSpacing}, @internalsref{SeparationItem}, and
1333 @internalsref{SeparatingGroupSpanner}.
1334
1335 @refbugs
1336
1337 Spacing is determined on a score wide basis.  If you have a score that
1338 changes its character (measured in durations) halfway during the
1339 score, the part containing the longer durations will be spaced too
1340 widely.
1341
1342 There is no convenient mechanism to manually override spacing.  The
1343 following work-around may be used to insert extra space into a score.
1344 @example
1345  \once \override Score.SeparationItem #'padding = #1
1346 @end example
1347
1348 No work-around exists for decreasing the amount of space.
1349
1350
1351 @node Line length
1352 @subsection Line length
1353
1354 @cindex page breaks
1355 @cindex breaking pages
1356
1357 @cindex @code{indent}
1358 @cindex @code{line-width}
1359 @cindex @code{ragged-right}
1360 @cindex @code{ragged-last}
1361
1362 @c Although line-width can be set in \layout, it should be set in paper
1363 @c block, to get page layout right.
1364 @c Setting indent in \paper block makes not much sense, but it works.
1365
1366 @c Bit verbose and vague, use examples?
1367 The most basic settings influencing the spacing are @code{indent} and
1368 @code{line-width}.  They are set in the @code{\layout} block.  They
1369 control the indentation of the first line of music, and the lengths of
1370 the lines.
1371
1372 If @code{ragged-right} is set to true in the @code{\layout} block, then
1373 the lines are justified at their natural length.  This is useful for
1374 short fragments, and for checking how tight the natural spacing is.
1375
1376 @cindex page layout
1377 @cindex vertical spacing
1378
1379 The option @code{ragged-last} is similar to @code{ragged-right}, but
1380 only affects the last line of the piece.  No restrictions are put on
1381 that line.  The result is similar to formatting text paragraphs.  In a
1382 paragraph, the last line simply takes its natural length.
1383 @c Note that for text there are several options for the last line.
1384 @c While Knuth TeX uses natural length, lead typesetters use the same
1385 @c stretch as the previous line.  eTeX uses \lastlinefit to
1386 @c interpolate between both these solutions.
1387
1388 @example
1389 \layout @{
1390   indent = #0
1391   line-width = #150
1392   ragged-last = ##t
1393 @}
1394 @end example
1395
1396
1397 @node Line breaking
1398 @subsection Line breaking
1399
1400 @cindex line breaks
1401 @cindex breaking lines
1402
1403 Line breaks are normally computed automatically.  They are chosen so
1404 that lines look neither cramped nor loose, and that consecutive lines
1405 have similar density.
1406
1407 Occasionally you might want to override the automatic breaks; you can
1408 do this by specifying @code{\break}.  This will force a line break at
1409 this point.  Line breaks can only occur at places where there are bar
1410 lines.  If you want to have a line break where there is no bar line,
1411 you can force an invisible bar line by entering @code{\bar
1412 ""}.  Similarly, @code{\noBreak} forbids a line break at a 
1413 point.
1414
1415
1416 @cindex regular line breaks
1417 @cindex four bar music. 
1418
1419 For line breaks at regular intervals use @code{\break} separated by
1420 skips and repeated with @code{\repeat}:
1421 @example
1422 << \repeat unfold 7 @{
1423          s1 \noBreak s1 \noBreak
1424          s1 \noBreak s1 \break @}
1425    @emph{the real music}
1426 >> 
1427 @end example
1428
1429 @noindent
1430 This makes the following 28 measures (assuming 4/4 time) be broken every
1431 4 measures, and only there.
1432
1433 @refcommands
1434
1435 @code{\break}, and @code{\noBreak}.
1436 @cindex @code{\break}
1437 @cindex @code{\noBreak}
1438
1439 @seealso
1440
1441 Internals: @internalsref{BreakEvent}.
1442
1443 A linebreaking configuration can now be saved as a @code{.ly} file
1444 automatically.  This allows vertical alignments to be stretched to
1445 fit pages in a second formatting run.  This is fairly new and
1446 complicated; see @inputfileref{input/regression/,page-layout-twopass.ly}
1447 for details.
1448
1449
1450 @node Page breaking
1451 @subsection Page breaking
1452
1453 The default page breaking may be overriden by inserting
1454 @code{\pageBreak} or @code{\noPageBreak} commands.  These commands are
1455 analogous to @code{\break} and @code{\noBreak}.  They should be
1456 inserted at a bar line.  These commands force and forbid a page-break
1457 from happening.  Of course, the @code{\pageBreak} command also forces
1458 a line break.
1459
1460 Page breaks are computed by the @code{page-breaking} function in the
1461 @code{\paper} block. 
1462
1463 To force a new page for a new piece (in a collection of pieces or a
1464 piece in several movements), use @code{breakbefore} in the header.
1465
1466 @example
1467 \header@{
1468   breakbefore = ##t
1469   piece = ""
1470 @}
1471 @end example
1472
1473 @refcommands
1474
1475 @cindex @code{\pageBreak}
1476 @code{\pageBreak}
1477 @cindex @code{\noPageBreak} 
1478 @code{\noPageBreak} 
1479
1480
1481 @refbugs
1482
1483 The @code{breakbefore=##t} header requires that there is a @code{piece} header as well.  It may be used as a normal header, or left  blank (@code{=""}) as in the example above, but it must be present.
1484
1485
1486
1487 @node Multiple movements
1488 @section Multiple movements
1489
1490 @cindex bibliographic information
1491 @cindex titles
1492 @cindex composer
1493 @cindex Music engraving by LilyPond
1494
1495 A document may contain multiple pieces of music and texts.  Examples
1496 of these are an etude book, or an orchestral part with multiple
1497 movements.  Each movement is entered with a @code{\score} block,
1498
1499 @example
1500 \score @{
1501   @var{..music..}
1502 @}
1503 @end example
1504
1505 and texts are entered with a @code{\markup} block,
1506
1507 @example
1508 \markup @{
1509   @var{..text..}
1510 @}
1511 @end example
1512
1513 @cindex @code{\book}
1514
1515 The movements and texts are combined together in a @code{\book} block,
1516 like
1517
1518 @example
1519 \book @{
1520   \score @{
1521     @var{..}
1522   @}
1523   \markup @{
1524     @var{..}
1525   @}
1526   \score @{
1527     @var{..}
1528   @}
1529 @}
1530 @end example
1531
1532
1533 The header for each piece of music can be put inside the @code{\score}
1534 block.  The @code{piece} name from the header will be printed before
1535 each movement.  The title for the entire book can be put inside the
1536 @code{\book}, but if it is not present, the @code{\header} which is at
1537 the top of the file is inserted.
1538
1539 @cindex Engraved by LilyPond
1540 @cindex signature line
1541
1542 @example 
1543 \book @{
1544   \header @{
1545     title = "Eight miniatures" 
1546     composer = "Igor Stravinsky"
1547   @}
1548   \score @{
1549     @dots{}
1550     \header @{ piece = "Romanze" @}
1551   @}
1552   \markup @{
1553      ..text of second verse..
1554   @}
1555   \markup @{
1556      ..text of third verse..
1557   @}
1558   \score @{
1559     @dots{}
1560     \header @{ piece = "Menuetto" @}
1561   @}
1562 @}
1563 @end example
1564
1565
1566
1567 @node MIDI output
1568 @section MIDI output
1569
1570 @cindex Sound
1571 @cindex MIDI
1572
1573 MIDI (Musical Instrument Digital Interface) is a standard for
1574 connecting and controlling digital instruments.  A MIDI file is a
1575 series of notes in a number of tracks.  It is not an actual
1576 sound file; you need special software to translate between the
1577 series of notes and actual sounds.
1578
1579 Pieces of music can be converted to MIDI files, so you can listen to
1580 what was entered.  This is convenient for checking the music; octaves
1581 that are off or accidentals that were mistyped stand out very much
1582 when listening to the MIDI output.
1583
1584 @refbugs
1585
1586 Many musically interesting effects, such as swing, articulation,
1587 slurring, etc., are not translated to midi.
1588
1589 The midi output allocates a channel for each staff, and one for global
1590 settings.  Therefore the midi file should not have more than 15 staves
1591 (or 14 if you do not use drums).  Other staves will remain silent.
1592
1593 Not all midi players correctly handle tempo changes in the midi
1594 output.  Players that are known to work include
1595 @uref{http://@/timidity@/.sourceforge@/.net/,timidity}.
1596
1597 @menu
1598 * Creating MIDI files::         
1599 * MIDI block::                  
1600 * MIDI instrument names::       
1601 @end menu
1602
1603 @node Creating MIDI files
1604 @subsection Creating MIDI files 
1605
1606 To create a MIDI from a music piece of music, add a @code{\midi} block
1607 to a score, for example,
1608
1609 @example 
1610 \score @{
1611   @var{...music...}
1612   \midi @{ \tempo 4=72 @}
1613 @}
1614 @end example 
1615
1616 The tempo is specified using the @code{\tempo} command.  In this
1617 example the tempo of quarter notes is set to 72 beats per minute.
1618
1619
1620 If there is a @code{\midi} command in a @code{\score}, only MIDI will
1621 be produced.  When notation is needed too, a @code{\layout} block must
1622 be added
1623
1624 @example 
1625 \score @{
1626   @var{...music...}
1627   \midi @{ \tempo 4=72 @}
1628   \layout @{ @}
1629 @}
1630 @end example 
1631 @cindex layout block
1632
1633
1634
1635 Ties, dynamics, and tempo changes are interpreted.  Dynamic marks,
1636 crescendi and decrescendi translate into MIDI volume levels.  Dynamic
1637 marks translate to a fixed fraction of the available MIDI volume
1638 range, crescendi and decrescendi make the volume vary linearly between
1639 their two extremes.  The fractions can be adjusted by
1640 @code{dynamicAbsoluteVolumeFunction} in @internalsref{Voice} context.
1641 For each type of MIDI instrument, a volume range can be defined.  This
1642 gives a basic equalizer control, which can enhance the quality of
1643 the MIDI output remarkably.  The equalizer can be controlled by
1644 setting @code{instrumentEqualizer}.
1645
1646 To remove dynamics from the MIDI output, insert the following lines
1647 in the @code{\midi@{@}} section.
1648
1649 @example
1650 \midi @{
1651   ...
1652   \context @{
1653     \Voice
1654     \remove "Dynamic_performer"
1655     \remove "Span_dynamic_performer"
1656   @}
1657 @}
1658 @end example
1659
1660
1661 @refbugs
1662
1663 Unterminated (de)crescendos will not render properly in the midi file,
1664 resulting in silent passages of music.  The workaround is to explicitly
1665 terminate the (de)crescendo.  For example,
1666
1667 @example
1668 @{ a\< b c d\f @}
1669 @end example
1670
1671 @noindent
1672 will not work properly but
1673
1674 @example
1675 @{ a\< b c d\!\f @}
1676 @end example
1677
1678 @noindent
1679 will.
1680
1681
1682 @node MIDI block
1683 @subsection MIDI block
1684 @cindex MIDI block
1685
1686
1687 The MIDI block is analogous to the layout block, but it is somewhat
1688 simpler.  The @code{\midi} block can contain
1689 @cindex MIDI block
1690
1691 @itemize @bullet
1692   @item a @code{\tempo} definition, and
1693   @item context definitions.
1694 @end itemize
1695
1696 A number followed by a period is interpreted as a real number, so
1697 for setting the tempo for dotted notes, an extra space should be
1698 inserted, for example
1699
1700 @example
1701 \midi @{ \tempo 4 . = 120 @} 
1702 @end example
1703
1704
1705 @cindex context definition
1706
1707 Context definitions follow precisely the same syntax as within the
1708 \layout block.  Translation modules for sound are called performers.
1709 The contexts for MIDI output are defined in @file{ly/@/performer@/-init@/.ly}.
1710
1711
1712 @node MIDI instrument names
1713 @subsection MIDI instrument names
1714
1715 @cindex instrument names
1716 @cindex @code{Staff.midiInstrument}
1717
1718 The MIDI instrument name is set by the @code{Staff.midiInstrument}
1719 property.  The instrument name should be chosen from the list in
1720 @ref{MIDI instruments}.
1721
1722 @example
1723 \set Staff.midiInstrument = "glockenspiel"
1724 @var{...notes...}
1725 @end example
1726
1727 If the selected instrument does not exactly match an instrument from
1728 the list of MIDI instruments, the Grand Piano (@code{"acoustic grand"})
1729 instrument is used.
1730