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