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