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