]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/global.itely
Add "fit as much as possible onto this page" example.
[lilypond.git] / Documentation / user / global.itely
1 @c -*- coding: latin-1; 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 Output formats
9 @chapter Output formats
10
11 This is a placeholder until I can write a nice intro for this chapter.
12
13 @menu
14 * Paper output::                
15 * Sound output::                
16 @end menu
17
18
19 @node Paper output
20 @section Paper output
21
22 The global paper layout is determined by three factors: the page layout, the
23 line breaks, and the spacing.  These all influence each other.  The
24 choice of spacing determines how densely each system of music is set.
25 This influences where line breaks are chosen, and thus ultimately, how
26 many pages a piece of music takes.
27
28 Globally spoken, this procedure happens in three steps: first,
29 flexible distances (``springs'') are chosen, based on durations.  All
30 possible line breaking combinations are tried, and the one with the
31 best results -- a layout that has uniform density and requires as
32 little stretching or cramping as possible -- is chosen.
33
34 After spacing and linebreaking, the systems are distributed across
35 pages, taking into account the size of the page, and the size of the
36 titles.
37
38
39
40 @menu
41 * Setting global staff size::   
42 * Selecting notation font size::  
43 * Paper size::                  
44 * Page formatting::             
45 * Score layout::                
46 * Vertical spacing::            
47 * Vertical spacing of piano staves::  
48 * Horizontal spacing::          
49 * Line length::                 
50 * Line breaking::               
51 * Page breaking::               
52 * Multiple movements::          
53 * Creating titles::             
54 @end menu
55
56
57 @node Setting global staff size
58 @subsection Setting global staff size
59
60 @cindex font size, setting
61 @cindex staff size, setting
62 @cindex @code{layout} file
63
64 To set the global staff size, use @code{set-global-staff-size}.
65
66 @example
67 #(set-global-staff-size 14)
68 @end example
69
70 @noindent
71 This sets the global default size to 14pt staff height and scales all
72 fonts accordingly.
73
74 The Feta font provides musical symbols at eight different
75 sizes.  Each font is tuned for a different staff size: at a smaller size
76 the font becomes heavier, to match the relatively heavier staff lines.
77 The recommended font sizes are listed in the following table:
78
79 @quotation
80 @multitable @columnfractions .15 .2 .22 .2
81
82 @item @b{font name}
83 @tab @b{staff height (pt)}
84 @tab @b{staff height (mm)}
85 @tab @b{use}
86
87 @item feta11
88 @tab 11.22
89 @tab 3.9 
90 @tab pocket scores
91
92 @item feta13
93 @tab 12.60
94 @tab 4.4
95 @tab
96  
97 @item feta14
98 @tab 14.14
99 @tab 5.0
100 @tab 
101
102 @item feta16
103 @tab 15.87
104 @tab 5.6
105 @tab 
106
107 @item feta18
108 @tab 17.82
109 @tab 6.3
110 @tab song books
111
112 @item feta20
113 @tab 20
114 @tab 7.0
115 @tab standard parts 
116
117 @item feta23
118 @tab 22.45 
119 @tab 7.9
120 @tab 
121
122 @item feta26
123 @tab 25.2 
124 @tab 8.9
125 @tab
126 @c modern rental material?
127
128 @end multitable
129 @end quotation
130
131 These fonts are available in any sizes.  The context property
132 @code{fontSize} and the layout property @code{staff-space} (in
133 @internalsref{StaffSymbol}) can be used to tune the size for individual
134 staves.  The sizes of individual staves are relative to the global size.
135
136 @example
137
138 @end example
139
140 @seealso
141
142 This manual: @ref{Selecting notation font size}.
143
144
145 @node Selecting notation font size
146 @subsection Selecting notation font size
147
148 The easiest method of setting the font size of any context, is by
149 setting the @code{fontSize} property.
150
151 @lilypond[quote,fragment,relative=1,verbatim]
152 c8
153 \set fontSize = #-4
154 c f
155 \set fontSize = #3
156 g
157 @end lilypond
158
159 @noindent
160 It does not change the size of variable symbols, such as beams or
161 slurs.
162
163 Internally, the @code{fontSize} context property will cause the
164 @code{font-size} property to be set in all layout objects.  The value
165 of @code{font-size} is a number indicating the size relative to the
166 standard size for the current staff height.  Each step up is an
167 increase of approximately 12% of the font size.  Six steps is exactly a
168 factor two.  The Scheme function @code{magstep} converts a
169 @code{font-size} number to a scaling factor.
170
171 @lilypond[quote,fragment,relative=1,verbatim]
172 c8
173 \override NoteHead #'font-size = #-4
174 c f
175 \override NoteHead #'font-size = #3
176 g
177 @end lilypond
178
179 LilyPond has fonts in different design sizes.  The music fonts for
180 smaller sizes are chubbier, while the text fonts are relatively wider.
181 Font size changes are achieved by scaling the design size that is
182 closest to the desired size.  The standard font size (for
183 @code{font-size} equals 0), depends on the standard staff height.  For
184 a 20pt staff, a 10pt font is selected.
185
186 The @code{font-size} property can only be set on layout objects that
187 use fonts. These are the ones supporting the
188 @internalsref{font-interface} layout interface.
189
190 @refcommands
191
192 The following commands set @code{fontSize} for the current voice:
193
194 @cindex @code{\tiny}
195 @code{\tiny}, 
196 @cindex @code{\small}
197 @code{\small}, 
198 @cindex @code{\normalsize}
199 @code{\normalsize}.
200
201
202 @node Paper size
203 @subsection Paper size
204
205 @cindex paper size
206 @cindex page size
207 @cindex @code{papersize}
208
209 To change the paper size, there are two commands,
210 @example
211 #(set-default-paper-size "a4")
212 \paper @{
213   #(set-paper-size "a4")
214 @}
215 @end example
216
217 The first command sets the size of all pages.  The second command sets the size
218 of the pages that the @code{\paper} block applies to -- if the @code{\paper}
219 block is at the top of the file, then it will apply to all pages.  If the
220 @code{\paper} block is inside a @code{\book}, then the paper size will only
221 apply to that book.
222
223 The following paper sizes are supported: @code{a6}, @code{a5}, @code{a4},
224 @code{a3}, @code{legal}, @code{letter}, @code{tabloid}.
225
226 @cindex orientation
227 @cindex landscape
228
229 If the symbol @code{landscape} is supplied as an argument to
230 @code{set-default-paper-size}, the pages will be rotated by 90 degrees,
231 and wider line widths will be set correspondingly.
232
233 @example
234 #(set-default-paper-size "a6" 'landscape)
235 @end example 
236
237
238 @node Page formatting
239 @subsection Page formatting
240
241 @cindex page formatting
242 @cindex margins
243 @cindex header, page
244 @cindex footer, page
245
246 LilyPond will do page layout, set margins, and add headers and
247 footers to each page.
248
249 The default layout responds to the following settings in the
250 @code{\paper} block.
251
252 @cindex @code{\paper}
253
254 @quotation
255 @table @code
256 @item firstpagenumber
257 The value of the page number of the first page.  Default is@tie{}1.
258
259 @item printfirstpagenumber
260 If set to true, will print the page number in the first page.  Default is
261 false.
262
263 @item printpagenumber
264 If set to false, page numbers will not be printed.
265
266 @item hsize
267 The width of the page.
268
269 @item vsize
270 The height of the page.
271
272 @item topmargin
273 Margin between header and top of the page.
274
275 @item bottommargin
276 Margin between footer and bottom of the page.
277
278 @item leftmargin
279 Margin between the left side of the page and the beginning of the music.
280
281 @item linewidth
282 The length of the systems.
283
284 @item headsep
285 Distance between the top-most music system and the page header.
286
287 @item footsep
288 Distance between the bottom-most music system and the page footer.
289
290 @item raggedbottom
291 If set to true, systems will not be spread across the page.
292
293 This should be set false for pieces that have only two or three
294 systems per page, for example orchestral scores.
295  
296 @item raggedlastbottom
297 If set to false, systems will be spread to fill the last page.
298
299 Pieces that amply fill two pages or more should have this set to
300 true.
301
302 @item betweensystemspace
303 This dimensions determines the distance between systems.  It is the
304 ideal distance between the center of the bottom staff of one system
305 and the center of the top staff of the next system.
306
307 Increasing this will provide a more even appearance of the page at the
308 cost of using more vertical space.
309
310 @item betweensystempadding
311 This dimension is the minimum amount of white space that will always
312 be present between the bottom-most symbol of one system, and the
313 top-most of the next system.
314
315 Increasing this will put systems whose bounding boxes almost touch
316 farther apart.
317
318
319 @item horizontalshift
320 All systems (including titles and system separators) are shifted by
321 this amount to the right. Page markup, such as headers and footers are
322 not affected by this. The purpose of this variable is to make space
323 for instrument names at the left.
324
325
326 @item aftertitlespace
327 Amount of space between the title and the first system.
328
329 @item beforetitlespace 
330 Amount of space between the last system of the previous piece and the
331 title of the next.
332
333 @item betweentitlespace
334 Amount of space between consecutive titles (e.g., the title of the
335 book and the title of a piece).
336
337 @item printallheaders
338 Setting this to #t will print all headers for each \score in a
339 \book.  Normally only the piece and opus \headers are printed.
340
341 @item systemSeparatorMarkup
342 This contains a markup object, which will be inserted between
343 systems.  This is often used for orchestral scores.
344
345 The markup command @code{\slashSeparator} is provided as a sensible
346 default,  for example
347
348 @lilypond[raggedright]
349 \paper {
350   systemSeparatorMarkup = \slashSeparator
351 }
352
353 \relative { c1 \break c1 }
354 @end lilypond
355
356
357 @end table
358 @end quotation
359
360 Example:
361
362 @example
363 \paper@{
364   hsize = 2\cm
365   topmargin = 3\cm
366   bottommargin = 3\cm
367   raggedlastbottom = ##t
368 @}
369 @end example
370
371 You can also define these values in Scheme.  In that case @code{mm},
372 @code{in}, @code{pt}, and @code{cm} are variables defined in
373 @file{paper-defaults.ly} with values in millimeters.  That's why the
374 value has to be multiplied in the example
375
376 @example
377 \paper @{
378   #(define bottommargin (* 2 cm)) 
379 @}
380 @end example
381
382 @cindex copyright
383 @cindex tagline
384
385 The default footer is empty, except for the first page, where the
386 @code{copyright} field from @code{\header} is inserted, and the last
387 page, where @code{tagline} from @code{\header} is added.  The default
388 tagline is ``Music engraving by LilyPond (@var{version})''.@footnote{Nicely
389 printed parts are good PR for us, so please leave the tagline if you
390 can.}
391
392 The header and footer are created by the functions @code{make-footer}
393 and @code{make-header}, defined in @code{\paper}.  The default
394 implementations are in @file{scm/@/page@/-layout@/.scm}.
395
396 The page layout itself is done by two functions in the
397 @code{\paper} block, @code{page-music-height} and
398 @code{page-make-stencil}.  The former tells the line-breaking algorithm
399 how much space can be spent on a page, the latter creates the actual
400 page given the system to put on it.
401
402
403 @refbugs
404
405 The option rightmargin is defined but doesn't set the right margin
406 yet.  The value for the right margin has to be defined adjusting the
407 values of the leftmargin and linewidth.
408
409 The default page header puts the page number and the @code{instrument}
410 field from the @code{\header} block on a line.
411
412
413 @node Score layout
414 @subsection Score layout
415
416 @cindex @code{\layout}
417
418 While @code{\paper} contains settings that relate to the page formatting
419 of the whole document, @code{\layout} contains settings for score-specific
420 layout.
421
422 @example
423 \layout @{
424   indent = 2.0\cm
425   \context @{ \Staff
426     minimumVerticalExtent = #'(-6 . 6
427   @}
428   \context @{ \Voice
429     \override TextScript #'padding = #1.0
430     \override Glissando #'thickness = #3
431   @}
432 @}
433 @end example
434
435
436 @seealso
437
438 This manual: @ref{Changing context default settings}
439
440
441 @node Vertical spacing
442 @subsection Vertical spacing
443
444 @cindex vertical spacing
445 @cindex distance between staves
446 @cindex staff distance
447 @cindex between staves, distance
448 @cindex staves per page
449 @cindex space between staves
450
451 The height of each system is determined automatically.  To prevent
452 systems from bumping into each other, some minimum distances are set.
453 By changing these, you can put staves closer together, and thus put
454 more systems onto one page.
455
456 Normally staves are stacked vertically.  To make staves maintain a
457 distance, their vertical size is padded.  This is done with the
458 property @code{minimumVerticalExtent}.  It takes a pair of numbers, so
459 if you want to make it smaller than its default @code{#'(-4 . 4)},
460 then you could set
461
462 @example
463 \set Staff.minimumVerticalExtent = #'(-3 . 3)
464 @end example
465
466 @noindent
467 This sets the vertical size of the current staff to 3 staff spaces on
468 either side of the center staff line.  The argument of
469 @code{minimumVerticalExtent} is interpreted as an interval, where the
470 center line is the 0, so the first number is generally negative.  The
471 staff can be made larger at the bottom by setting it to @code{(-6 . 4)}. 
472
473 To change the amount of space between systems, use
474 @code{betweensystemspace}.  A score with only one staff is still
475 considered to have systems, so setting @code{betweensystemspace}
476 will be much more useful than changing @code{minimumVerticalExtent}.
477
478 @example
479 \paper @{
480   betweensystemspace = 10\mm
481 @}
482 @end example
483
484 If you simply want to tell LilyPond ``fit as much as possible onto
485 these pages, then expand to fill any available space on the pages,''
486 then use the following
487
488 @example
489 \paper @{
490   betweensystempadding = #1
491   raggedbottom=##f
492   raggedlastbottom=##f
493 @}
494 @end example
495
496
497 @seealso
498
499 Internals: Vertical alignment of staves is handled by the
500 @internalsref{VerticalAlignment} object. The context parameters
501 specifying  the vertical extent are described in connection with 
502 the @internalsref{Axis_group_engraver}.
503
504 @refbugs
505
506 @code{minimumVerticalExtent} is syntactic sugar for setting
507 @code{minimum-Y-extent} of the @internalsref{VerticalAxisGroup} of the
508 current context.  It can only be changed score wide.
509
510
511
512
513 @node Vertical spacing of piano staves
514 @subsection Vertical spacing of piano staves
515
516 The distance between staves of a @internalsref{PianoStaff} cannot be
517 computed during formatting.  Rather, to make cross-staff beaming work
518 correctly, that distance has to be fixed beforehand.
519  
520 The distance of staves in a @code{PianoStaff} is set with the
521 @code{forced-distance} property of the
522 @internalsref{VerticalAlignment} object, created in
523 @internalsref{PianoStaff}.
524
525 It can be adjusted as follows
526 @example
527 \new PianoStaff \with @{
528   \override VerticalAlignment #'forced-distance = #7
529 @} @{
530   ...
531 @}
532 @end example
533
534 @noindent
535 This would bring the staves together at a distance of 7 staff spaces,
536 measured from the center line of each staff.
537
538 The difference is demonstrated in the following example,
539 @lilypond[quote,verbatim]
540 \relative <<
541   \new PianoStaff \with {
542     \override VerticalAlignment #'forced-distance = #7
543   } <<
544     \new Staff { c1 }
545     \new Staff { c }
546   >>
547   \new PianoStaff <<
548     \new Staff { c }
549     \new Staff { c }
550   >>
551 >>    
552 @end lilypond
553
554
555
556 @refbugs
557
558 @code{forced-distance} cannot be changed per system.
559
560
561 @node Horizontal spacing
562 @subsection Horizontal Spacing
563
564 The spacing engine translates differences in durations into
565 stretchable distances (``springs'') of differring lengths.  Longer
566 durations get more space, shorter durations get less.  The shortest
567 durations get a fixed amount of space (which is controlled by
568 @code{shortest-duration-space} in the @internalsref{SpacingSpanner} object). 
569 The longer the duration, the more space it gets: doubling a
570 duration adds a fixed amount (this amount is controlled by
571 @code{spacing-increment}) of space to the note.
572
573 For example, the following piece contains lots of half, quarter, and
574 8th notes; the eighth note is followed by 1 note head width (NHW). 
575 The quarter note is followed by 2 NHW, the half by 3 NHW, etc.
576
577 @lilypond[quote,fragment,verbatim,relative=1]
578 c2 c4. c8 c4. c8 c4. c8 c8
579 c8 c4 c4 c4
580 @end lilypond
581
582 Normally, @code{spacing-increment} is set to 1.2 staff space, which is
583 approximately the width of a note head, and
584 @code{shortest-duration-space} is set to 2.0, meaning that the
585 shortest note gets 2.4 staff space (2.0 times the
586 @code{spacing-increment}) of horizontal space.  This space is counted
587 from the left edge of the symbol, so the shortest notes are generally
588 followed by one NHW of space.
589
590 If one would follow the above procedure exactly, then adding a single
591 32nd note to a score that uses 8th and 16th notes, would widen up the
592 entire score a lot.  The shortest note is no longer a 16th, but a 32nd,
593 thus adding 1 NHW to every note.  To prevent this, the shortest
594 duration for spacing is not the shortest note in the score, but rather
595 the one which occurs most frequently.
596
597
598 The most common shortest duration is determined as follows: in every
599 measure, the shortest duration is determined.  The most common shortest
600 duration is taken as the basis for the spacing, with the stipulation
601 that this shortest duration should always be equal to or shorter than
602 an 8th note.  The shortest duration is printed when you run
603 @code{lilypond} with the @code{--verbose} option.
604
605 These durations may also be customized.  If you set the
606 @code{common-shortest-duration} in @internalsref{SpacingSpanner}, then
607 this sets the base duration for spacing.  The maximum duration for this
608 base (normally an 8th), is set through @code{base-shortest-duration}.
609
610 @cindex @code{common-shortest-duration}
611 @cindex @code{base-shortest-duration}
612 @cindex @code{stem-spacing-correction}
613 @cindex @code{spacing}
614
615 Notes that are even shorter than the common shortest note are
616 followed by a space that is proportional to their duration relative to
617 the common shortest note.  So if we were to add only a few 16th notes
618 to the example above, they would be followed by half a NHW:
619
620 @lilypond[quote,fragment,verbatim,relative=2]
621 c2 c4. c8 c4. c16[ c] c4. c8 c8 c8 c4 c4 c4
622 @end lilypond
623
624
625 In the introduction (see @ref{Engraving}), it was explained that stem
626 directions influence spacing.  This is controlled with the
627 @code{stem-spacing-correction} property in the
628 @internalsref{NoteSpacing}, object.  These are generated for every
629 @internalsref{Voice} context.  The @code{StaffSpacing} object
630 (generated in @internalsref{Staff} context) contains the same property
631 for controlling the stem/bar line spacing.  The following example shows
632 these corrections, once with default settings, and once with
633 exaggerated corrections:
634
635 @lilypond[quote,raggedright]
636 {
637   c'4 e''4 e'4 b'4 |
638   b'4 e''4 b'4 e''4|
639   \override Staff.NoteSpacing #'stem-spacing-correction = #1.5
640   \override Staff.StaffSpacing #'stem-spacing-correction = #1.5
641   c'4 e''4 e'4 b'4 |
642   b'4 e''4 b'4 e''4|      
643 }
644 @end lilypond
645
646
647 @seealso
648
649 Internals: @internalsref{SpacingSpanner}, @internalsref{NoteSpacing},
650 @internalsref{StaffSpacing}, @internalsref{SeparationItem}, and
651 @internalsref{SeparatingGroupSpanner}.
652
653 @refbugs
654
655 Spacing is determined on a score wide basis.  If you have a score that
656 changes its character (measured in durations) halfway during the
657 score, the part containing the longer durations will be spaced too
658 widely.
659
660 There is no convenient mechanism to manually override spacing.  The
661 following work-around may be used to insert extra space into a score.
662 @example
663  \once \override Score.SeparationItem #'padding = #1
664 @end example
665
666 No work-around exists for decreasing the amount of space.
667
668 @node Line length
669 @subsection Line length
670
671 @cindex page breaks
672 @cindex breaking pages
673
674 @cindex @code{indent}
675 @cindex @code{linewidth}
676
677 @c Although linewidth can be set in \layout, it should be set in paper
678 @c block, to get page layout right.
679 @c Setting indent in \paper block makes not much sense, but it works.
680
681 @c Bit verbose and vague, use examples?
682 The most basic settings influencing the spacing are @code{indent} and
683 @code{linewidth}.  They are set in the @code{\layout} block.  They
684 control the indentation of the first line of music, and the lengths of
685 the lines.
686
687 If @code{raggedright} is set to true in the @code{\layout} block, then
688 the lines are justified at their natural length.  This is useful for
689 short fragments, and for checking how tight the natural spacing is.
690
691 @cindex page layout
692 @cindex vertical spacing
693
694 The option @code{raggedlast} is similar to @code{raggedright}, but
695 only affects the last line of the piece.  No restrictions are put on
696 that line.  The result is similar to formatting text paragraphs.  In a
697 paragraph, the last line simply takes its natural length.
698 @c Note that for text there are several options for the last line.
699 @c While Knuth TeX uses natural length, lead typesetters use the same
700 @c stretch as the previous line.  eTeX uses \lastlinefit to
701 @c interpolate between both these solutions.
702
703 @node Line breaking
704 @subsection Line breaking
705
706 @cindex line breaks
707 @cindex breaking lines
708
709 Line breaks are normally computed automatically.  They are chosen so
710 that lines look neither cramped nor loose, and that consecutive lines
711 have similar density.
712
713 Occasionally you might want to override the automatic breaks; you can
714 do this by specifying @code{\break}.  This will force a line break at
715 this point.  Line breaks can only occur at places where there are bar
716 lines.  If you want to have a line break where there is no bar line,
717 you can force an invisible bar line by entering @code{\bar
718 ""}.  Similarly, @code{\noBreak} forbids a line break at a 
719 point.
720
721
722 @cindex regular line breaks
723 @cindex four bar music. 
724
725 For line breaks at regular intervals use @code{\break} separated by
726 skips and repeated with @code{\repeat}:
727 @example
728 << \repeat unfold 7 @{
729          s1 \noBreak s1 \noBreak
730          s1 \noBreak s1 \break @}
731    @emph{the real music}
732 >> 
733 @end example
734
735 @noindent
736 This makes the following 28 measures (assuming 4/4 time) be broken every
737 4 measures, and only there.
738
739 @refcommands
740
741 @code{\break}, and @code{\noBreak}.
742 @cindex @code{\break}
743 @cindex @code{\noBreak}
744
745 @seealso
746
747 Internals: @internalsref{BreakEvent}.
748
749
750 @node Page breaking
751 @subsection Page breaking
752
753 The default page breaking may be overriden by inserting
754 @code{\pageBreak} or @code{\noPageBreak} commands.  These commands are
755 analogous to @code{\break} and @code{\noBreak}.  They should be
756 inserted at a bar line.  These commands force and forbid a page-break
757 from happening.  Of course, the @code{\pageBreak} command also forces
758 a line break.
759
760 Page breaks are computed by the @code{page-breaking} function in the
761 @code{\paper} block. 
762
763 To force a new page for a new piece (in a collection of pieces or a
764 piece in several movements), use @code{breakbefore} in the header.
765
766 @example
767 \header@{
768   breakbefore = ##t
769 @}
770 @end example
771
772 @refcommands
773
774 @cindex @code{\pageBreak}
775 @code{\pageBreak}
776 @cindex @code{\noPageBreak} 
777 @code{\noPageBreak} 
778
779
780 @node Multiple movements
781 @subsection Multiple movements
782
783 @cindex bibliographic information
784 @cindex titles
785 @cindex composer
786 @cindex Music engraving by LilyPond
787
788 A document may contain multiple pieces of music and texts.  Examples
789 of these are an etude book, or an orchestral part with multiple
790 movements.  Each movement is entered with a @code{\score} block,
791
792 @example
793 \score @{
794   @var{..music..}
795 @}
796 @end example
797
798 and texts are entered with a @code{\markup} block,
799
800 @example
801 \markup @{
802   @var{..text..}
803 @}
804 @end example
805
806 @cindex @code{\book}
807
808 The movements and texts are combined together in a @code{\book} block,
809 like
810
811 @example
812 \book @{
813   \score @{
814     @var{..}
815   @}
816   \markup @{
817     @var{..}
818   @}
819   \score @{
820     @var{..}
821   @}
822 @}
823 @end example
824
825
826 The header for each piece of music can be put inside the @code{\score}
827 block.  The @code{piece} name from the header will be printed before
828 each movement.  The title for the entire book can be put inside the
829 @code{\book}, but if it is not present, the @code{\header} which is at
830 the top of the file is inserted.
831
832 @cindex Engraved by LilyPond
833 @cindex signature line
834
835 @example 
836 \book @{
837   \header @{
838     title = "Eight miniatures" 
839     composer = "Igor Stravinsky"
840   @}
841   \score @{
842     @dots{}
843     \header @{ piece = "Romanze" @}
844   @}
845   \markup @{
846      ..text of second verse..
847   @}
848   \markup @{
849      ..text of third verse..
850   @}
851   \score @{
852     @dots{}
853     \header @{ piece = "Menuetto" @}
854   @}
855 @}
856 @end example
857
858
859 @node Creating titles
860 @subsection Creating titles
861
862 Titles are created for each @code{\score} block, and over a
863 @code{\book}.
864
865 The contents of the titles are taken from the @code{\header} blocks.
866 The header block for a book supports the following
867 @table @code
868 @item dedication
869 The dedicatee of the music, centered at the top of the first page.
870
871 @item title
872 The title of the music, centered just below the dedication.
873
874 @item subtitle
875 Subtitle, centered below the title.
876
877 @item subsubtitle
878 Subsubtitle, centered below the subtitle.
879
880 @item poet
881 Name of the poet, flush-left below the subtitle.
882
883 @item composer
884 Name of the composer, flush-right below the subtitle.
885
886 @item meter
887 Meter string, flush-left below the poet.
888
889 @item opus
890 Name of the opus, flush-right below the composer.
891
892 @item arranger
893 Name of the arranger, flush-right below the opus.
894
895 @item instrument
896 Name of the instrument, centered below the arranger.  Also
897 centered at the top of pages (other than the first page).
898
899 @item piece
900 Name of the piece, flush-left below the instrument.
901
902 @cindex page breaks, forcing
903 @item breakbefore
904 This forces the title to start on a new page (set to ##t or ##f).
905
906 @item copyright
907 Copyright notice, centered at the bottom of the first page.  To
908 insert the copyright symbol, see @ref{Text encoding}.
909
910 @item tagline
911 Centered at the bottom of the last page.
912
913 @end table
914
915 Here is a demonstration of the fields available.  Note that you
916 may use any @ref{Text markup} commands in the header.
917
918 @lilypond[quote,verbatim,linewidth=11.0\cm]
919 \paper {
920   linewidth = 9.0\cm
921   vsize = 10.0\cm
922 }
923
924 \book {
925   \header {
926     dedication = "dedicated to me"
927     title = \markup \center-align { "Title first line" "Title second line, longer" }
928     subtitle = "the subtitle,"
929     subsubtitle = #(string-append "subsubtitle LilyPond version " (lilypond-version))
930     poet = "Poet"
931     composer =  \markup \center-align { "composer" \small "(1847-1973)" }
932     texttranslator = "Text Translator"
933     meter = \markup { \teeny "m" \tiny "e" \normalsize "t" \large "e" \huge "r" }
934     arranger = "Arranger"
935     opus = \markup { \fontsize #8.5 "o" \fontsize #2.5 "p" \fontsize #-2.5 "u" \fontsize #-5.3 "s" \fontsize #7.5 "       " }
936     instrument = \markup \bold \italic "instrument"
937     piece = "Piece"
938   }
939
940   \score {
941     { c'1 }
942     \header {
943       piece = "piece1"
944       opus = "opus1" 
945     }
946   }
947   \markup {
948       and now...
949   }
950   \score {
951     { c'1 }
952     \header {
953       piece = "piece2"
954       opus = "opus2" 
955     }
956   }
957 }
958 @end lilypond
959
960 As demonstrated before, you can use multiple @code{\header} blocks. 
961 When same fields appear in different blocks, the latter is used.  
962 Here is a short example.
963
964 a@example 
965 \header @{
966   composer = "Composer"
967 @}
968 \header @{
969   title = "Title"
970 @}
971 \score @{
972   \new Staff @{ c'4 @}
973   \header @{
974     title = "New title"  % overwrite previous one
975   @}
976 @}
977 @end example
978
979 If you define the @code{\header} inside the @code{\score} block, then
980 normally only the @code{piece} and @code{opus} headers will be printed.
981
982 @lilypond[quote,verbatim,linewidth=11.0\cm]
983 \score {
984   { c'4 }
985   \header {
986     title = "title"  % not printed
987     piece = "piece"
988     opus = "opus"
989   }
990 }
991 @end lilypond
992
993 @noindent
994 You may change this behavior (and print all the headers when defining
995 @code{\header} inside @code{\score}) by using
996
997 @example
998 \paper@{
999   printallheaders=##t
1000 @}
1001 @end example
1002
1003
1004 @commonprop
1005
1006 A more advanced option is to change the definitions of the following
1007 variables in the @code{\paper} block.  The init file
1008 @file{ly/titling-init.ly} lists the default layout.
1009
1010 @table @code
1011 @item bookTitleMarkup
1012   This is the title put over an entire @code{\book} block.  Typically,
1013   it has the composer and the title of the piece
1014   
1015 @item scoreTitleMarkup
1016   This is the title put over a @code{\score} block within a
1017 @code{\book}.  Typically, it has the name of the movement (@code{piece}
1018 field).
1019
1020 @item oddHeaderMarkup
1021   This is the page header for odd-numbered pages. 
1022
1023   @item evenHeaderMarkup
1024   This is the page header for even-numbered pages.  If unspecified,
1025   the odd header is used instead.
1026
1027   By default, headers are defined such that the page number is on the
1028   outside edge, and the instrument is centered.
1029
1030 @item oddFooterMarkup
1031   This is the page footer for odd-numbered pages. 
1032   
1033 @item evenFooterMarkup
1034   This is the page footer for even-numbered pages.  If unspecified,
1035   the odd header is used instead.
1036
1037   By default, the footer has the copyright notice on the first, and
1038   the tagline on the last page.
1039 @end table
1040
1041
1042 @cindex \paper
1043 @cindex header
1044 @cindex footer
1045 @cindex page layout
1046 @cindex titles
1047
1048 The following definition will put the title flush left, and the
1049 composer flush right on a single line.
1050
1051 @verbatim
1052 \paper {
1053   bookTitleMarkup = \markup {
1054    \fill-line {
1055      \fromproperty #'header:title
1056      \fromproperty #'header:composer
1057    }
1058   }
1059 }
1060 @end verbatim
1061
1062
1063
1064 @node Sound output
1065 @section Sound output
1066
1067 @cindex Sound
1068 @cindex MIDI
1069
1070 MIDI (Musical Instrument Digital Interface) is a standard for
1071 connecting and controlling digital instruments.  A MIDI file is a
1072 series of notes in a number of tracks.  It is not an actual
1073 sound file; you need special software to translate between the
1074 series of notes and actual sounds.
1075
1076 Pieces of music can be converted to MIDI files, so you can listen to
1077 what was entered.  This is convenient for checking the music; octaves
1078 that are off or accidentals that were mistyped stand out very much
1079 when listening to the MIDI output.
1080
1081 @refbugs
1082
1083 Many musically interesting effects, such as swing, articulation,
1084 slurring, etc., are not translated to midi.
1085
1086 The midi output allocates a channel for each staff, and one for global
1087 settings.  Therefore the midi file should not have more than 15 staves
1088 (or 14 if you do not use drums).  Other staves will remain silent.
1089
1090 Not all midi players correctly handle tempo changes in the midi
1091 output.  Players that are known to work include
1092 @uref{http://@/timidity@/.sourceforge@/.net/,timidity}.
1093
1094 @menu
1095 * Creating MIDI files::         
1096 * MIDI block::                  
1097 * MIDI instrument names::       
1098 @end menu
1099
1100 @node Creating MIDI files
1101 @subsection Creating MIDI files 
1102
1103 To create a MIDI from a music piece of music, add a @code{\midi} block
1104 to a score, for example,
1105
1106 @example 
1107 \score @{
1108   @var{...music...}
1109   \midi @{ \tempo 4=72 @}
1110 @}
1111 @end example 
1112
1113 The tempo is specified using the @code{\tempo} command.  In this
1114 example the tempo of quarter notes is set to 72 beats per minute.
1115
1116
1117 If there is a @code{\midi} command in a @code{\score}, only MIDI will
1118 be produced.  When notation is needed too, a @code{\layout} block must
1119 be added
1120
1121 @example 
1122 \score @{
1123   @var{...music...}
1124   \midi @{ \tempo 4=72 @}
1125   \layout @{ @}
1126 @}
1127 @end example 
1128 @cindex layout block
1129
1130
1131
1132 Ties, dynamics, and tempo changes are interpreted.  Dynamic marks,
1133 crescendi and decrescendi translate into MIDI volume levels.  Dynamic
1134 marks translate to a fixed fraction of the available MIDI volume
1135 range, crescendi and decrescendi make the volume vary linearly between
1136 their two extremes.  The fractions can be adjusted by
1137 @code{dynamicAbsoluteVolumeFunction} in @internalsref{Voice} context.
1138 For each type of MIDI instrument, a volume range can be defined.  This
1139 gives a basic equalizer control, which can enhance the quality of
1140 the MIDI output remarkably.  The equalizer can be controlled by
1141 setting @code{instrumentEqualizer}.
1142
1143
1144 @node MIDI block
1145 @subsection MIDI block
1146 @cindex MIDI block
1147
1148
1149 The MIDI block is analogous to the layout block, but it is somewhat
1150 simpler.  The @code{\midi} block can contain
1151 @cindex MIDI block
1152
1153 @itemize @bullet
1154   @item a @code{\tempo} definition, and
1155   @item context definitions.
1156 @end itemize
1157
1158 A number followed by a period is interpreted as a real number, so
1159 for setting the tempo for dotted notes, an extra space should be
1160 inserted, for example
1161
1162 @example
1163 \midi @{ \tempo 4 . = 120 @} 
1164 @end example
1165
1166
1167 @cindex context definition
1168
1169 Context definitions follow precisely the same syntax as within the
1170 \layout block.  Translation modules for sound are called performers.
1171 The contexts for MIDI output are defined in @file{ly/@/performer@/-init@/.ly}.
1172
1173
1174 @node MIDI instrument names
1175 @subsection MIDI instrument names
1176
1177 @cindex instrument names
1178 @cindex @code{Staff.midiInstrument}
1179
1180 The MIDI instrument name is set by the @code{Staff.midiInstrument}
1181 property.  The instrument name should be chosen from the list in
1182 @ref{MIDI instruments}.
1183
1184 @example
1185 \set Staff.midiInstrument = "glockenspiel"
1186 @var{...notes...}
1187 @end example
1188
1189 If the selected instrument does not exactly match an instrument from
1190 the list of MIDI instruments, the Grand Piano (@code{"acoustic grand"})
1191 instrument is used.
1192