]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/global.itely
*** empty log message ***
[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
344 @cindex @code{horizontalshift}
345 @item horizontalshift
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{aftertitlespace}
352 @item aftertitlespace
353 Amount of space between the title and the first system.
354
355 @cindex @code{aftertitlespace}
356 @item beforetitlespace 
357 Amount of space between the last system of the previous piece and the
358 title of the next.
359
360 @cindex @code{betweentitlespace}
361 @item betweentitlespace
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[raggedright]
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   hsize = 2\cm
395   topmargin = 3\cm
396   bottommargin = 3\cm
397   raggedlastbottom = ##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 bottommargin (* 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 rightmargin 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 the leftmargin and linewidth.
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     minimumVerticalExtent = #'(-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 @c TODO: junk explanation of minimumVerticalExtent
487
488 Normally staves are stacked vertically.  To make staves maintain a
489 distance, their vertical size is padded.  This is done with the
490 property @code{minimumVerticalExtent}.  It takes a pair of numbers, so
491 if you want to make it smaller than its default @code{#'(-4 . 4)},
492 then you could set
493
494 @example
495 \set Staff.minimumVerticalExtent = #'(-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 argument of
501 @code{minimumVerticalExtent} is interpreted as an interval, where the
502 center line is the 0, so the first number is generally negative.  The
503 staff can be made larger at 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[raggedright, 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{betweensystemspace}.  A score with only one staff is still
541 considered to have systems, so setting @code{betweensystemspace}
542 will be much more useful than changing @code{minimumVerticalExtent}.
543
544 @example
545 \paper @{
546   betweensystemspace = 10\mm
547 @}
548 @end example
549
550 If you simply want to tell LilyPond ``fit as much as possible onto
551 these pages, then expand to fill any available space on the pages,''
552 then use the following
553
554 @example
555 \paper @{
556   betweensystempadding = #1
557   raggedbottom=##f
558   raggedlastbottom=##f
559 @}
560 @end example
561
562
563 @c let's wait for a some comments before writing more.
564
565 The vertical spacing on a page can also be changed for each system individually.
566 Some examples are found in the example file
567 @inputfileref{input/regression/,page-spacing.ly}.
568
569 When setting @code{annotatespacing} in the @code{\paper} block LilyPond
570 will graphically indicate the dimensions of properties that may be set
571 for page spacing,
572
573 @lilypond[verbatim]
574 #(set-default-paper-size "a7" 'landscape)
575 \paper { annotatespacing = ##t }
576 { c4 }
577 @end lilypond
578
579 @noindent
580 All units dimensions are measured in staff spaces. The pairs
581 (@var{a},@var{b}) are intervals, where @var{a} is the lower edge and
582 @var{b} the upper edge of the interval.
583
584 @seealso
585
586 Internals: Vertical alignment of staves is handled by the
587 @internalsref{VerticalAlignment} object. The context parameters
588 specifying  the vertical extent are described in connection with 
589 the @internalsref{Axis_group_engraver}.
590
591 Example files: @inputfileref{input/regression/,page-spacing.ly},
592 @inputfileref{input/regression/,alignment-vertical-spacing.ly}.
593
594
595 @refbugs
596
597 @code{minimumVerticalExtent} is syntactic sugar for setting
598 @code{minimum-Y-extent} of the @internalsref{VerticalAxisGroup} of the
599 current context.  It can only be changed score wide.
600
601
602
603
604 @node Vertical spacing of piano staves
605 @subsection Vertical spacing of piano staves
606
607 The distance between staves of a @internalsref{PianoStaff} cannot be
608 computed during formatting.  Rather, to make cross-staff beaming work
609 correctly, that distance has to be fixed beforehand.
610  
611 The distance of staves in a @code{PianoStaff} is set with the
612 @code{forced-distance} property of the
613 @internalsref{VerticalAlignment} object, created in
614 @internalsref{PianoStaff}.
615
616 It can be adjusted as follows
617 @example
618 \new PianoStaff \with @{
619   \override VerticalAlignment #'forced-distance = #7
620 @} @{
621   ...
622 @}
623 @end example
624
625 @noindent
626 This would bring the staves together at a distance of 7 staff spaces,
627 measured from the center line of each staff.
628
629 The difference is demonstrated in the following example,
630 @lilypond[quote,verbatim]
631 \relative c'' <<
632   \new PianoStaff \with {
633     \override VerticalAlignment #'forced-distance = #7
634   } <<
635     \new Staff { c1 }
636     \new Staff { c }
637   >>
638   \new PianoStaff <<
639     \new Staff { c }
640     \new Staff { c }
641   >>
642 >>    
643 @end lilypond
644
645
646 It is also possible to change the distance between for each system
647 individually.  This is done by including the command 
648
649 @example
650 \overrideProperty
651 #"Score.NonMusicalPaperColumn"
652 #'line-break-system-details
653 #'((fixed-alignment-extra-space . 15))
654 @end example
655
656 @noindent
657 at the line break before the system to be changed. The distance
658 @code{15} is distributed over all staves that have a fixed distance
659 alignment.  For example,
660
661 @lilypond[raggedright, fragment, relative=2, staffsize=13]
662 \new PianoStaff <<
663   \new Staff { 
664     c1\break 
665         
666     \overrideProperty
667     #"Score.NonMusicalPaperColumn"
668     #'line-break-system-details
669     #'((fixed-alignment-extra-space . 15))
670
671     c\break 
672   }
673   \new Staff { c c }
674 >>
675 @end lilypond
676
677 The distance for @code{fixed-alignment-extra-space} may also be
678 negative.
679
680 @seealso
681
682 Example files: @inputfileref{input/regression/,alignment-vertical-spacing.ly}.
683
684 @node Horizontal spacing
685 @subsection Horizontal Spacing
686
687 The spacing engine translates differences in durations into stretchable
688 distances (``springs'') of differring lengths.  Longer durations get
689 more space, shorter durations get less.  The shortest durations get a
690 fixed amount of space (which is controlled by
691 @code{shortest-duration-space} in the @internalsref{SpacingSpanner}
692 object).  The longer the duration, the more space it gets: doubling a
693 duration adds a fixed amount (this amount is controlled by
694 @code{spacing-increment}) of space to the note.
695
696 For example, the following piece contains lots of half, quarter, and
697 8th notes; the eighth note is followed by 1 note head width (NHW). 
698 The quarter note is followed by 2 NHW, the half by 3 NHW, etc.
699
700 @lilypond[quote,fragment,verbatim,relative=1]
701 c2 c4. c8 c4. c8 c4. c8 c8
702 c8 c4 c4 c4
703 @end lilypond
704
705 Normally, @code{spacing-increment} is set to 1.2 staff space, which is
706 approximately the width of a note head, and
707 @code{shortest-duration-space} is set to 2.0, meaning that the
708 shortest note gets 2.4 staff space (2.0 times the
709 @code{spacing-increment}) of horizontal space.  This space is counted
710 from the left edge of the symbol, so the shortest notes are generally
711 followed by one NHW of space.
712
713 If one would follow the above procedure exactly, then adding a single
714 32nd note to a score that uses 8th and 16th notes, would widen up the
715 entire score a lot.  The shortest note is no longer a 16th, but a 32nd,
716 thus adding 1 NHW to every note.  To prevent this, the shortest
717 duration for spacing is not the shortest note in the score, but rather
718 the one which occurs most frequently.
719
720
721 The most common shortest duration is determined as follows: in every
722 measure, the shortest duration is determined.  The most common shortest
723 duration is taken as the basis for the spacing, with the stipulation
724 that this shortest duration should always be equal to or shorter than
725 an 8th note.  The shortest duration is printed when you run
726 @code{lilypond} with the @code{--verbose} option.
727
728 These durations may also be customized.  If you set the
729 @code{common-shortest-duration} in @internalsref{SpacingSpanner}, then
730 this sets the base duration for spacing.  The maximum duration for this
731 base (normally an 8th), is set through @code{base-shortest-duration}.
732
733 @cindex @code{common-shortest-duration}
734 @cindex @code{base-shortest-duration}
735 @cindex @code{stem-spacing-correction}
736 @cindex @code{spacing}
737
738 Notes that are even shorter than the common shortest note are
739 followed by a space that is proportional to their duration relative to
740 the common shortest note.  So if we were to add only a few 16th notes
741 to the example above, they would be followed by half a NHW:
742
743 @lilypond[quote,fragment,verbatim,relative=2]
744 c2 c4. c8 c4. c16[ c] c4. c8 c8 c8 c4 c4 c4
745 @end lilypond
746
747
748 In the introduction (see @ref{Engraving}), it was explained that stem
749 directions influence spacing.  This is controlled with the
750 @code{stem-spacing-correction} property in the
751 @internalsref{NoteSpacing}, object.  These are generated for every
752 @internalsref{Voice} context.  The @code{StaffSpacing} object
753 (generated in @internalsref{Staff} context) contains the same property
754 for controlling the stem/bar line spacing.  The following example shows
755 these corrections, once with default settings, and once with
756 exaggerated corrections:
757
758 @lilypond[quote,raggedright]
759 {
760   c'4 e''4 e'4 b'4 |
761   b'4 e''4 b'4 e''4|
762   \override Staff.NoteSpacing #'stem-spacing-correction = #1.5
763   \override Staff.StaffSpacing #'stem-spacing-correction = #1.5
764   c'4 e''4 e'4 b'4 |
765   b'4 e''4 b'4 e''4|      
766 }
767 @end lilypond
768
769
770 @seealso
771
772 Internals: @internalsref{SpacingSpanner}, @internalsref{NoteSpacing},
773 @internalsref{StaffSpacing}, @internalsref{SeparationItem}, and
774 @internalsref{SeparatingGroupSpanner}.
775
776 @refbugs
777
778 Spacing is determined on a score wide basis.  If you have a score that
779 changes its character (measured in durations) halfway during the
780 score, the part containing the longer durations will be spaced too
781 widely.
782
783 There is no convenient mechanism to manually override spacing.  The
784 following work-around may be used to insert extra space into a score.
785 @example
786  \once \override Score.SeparationItem #'padding = #1
787 @end example
788
789 No work-around exists for decreasing the amount of space.
790
791
792 @node Line length
793 @subsection Line length
794
795 @cindex page breaks
796 @cindex breaking pages
797
798 @cindex @code{indent}
799 @cindex @code{linewidth}
800 @cindex @code{raggedright}
801
802 @c Although linewidth can be set in \layout, it should be set in paper
803 @c block, to get page layout right.
804 @c Setting indent in \paper block makes not much sense, but it works.
805
806 @c Bit verbose and vague, use examples?
807 The most basic settings influencing the spacing are @code{indent} and
808 @code{linewidth}.  They are set in the @code{\layout} block.  They
809 control the indentation of the first line of music, and the lengths of
810 the lines.
811
812 If @code{raggedright} is set to true in the @code{\layout} block, then
813 the lines are justified at their natural length.  This is useful for
814 short fragments, and for checking how tight the natural spacing is.
815
816 @cindex page layout
817 @cindex vertical spacing
818
819 The option @code{raggedlast} is similar to @code{raggedright}, but
820 only affects the last line of the piece.  No restrictions are put on
821 that line.  The result is similar to formatting text paragraphs.  In a
822 paragraph, the last line simply takes its natural length.
823 @c Note that for text there are several options for the last line.
824 @c While Knuth TeX uses natural length, lead typesetters use the same
825 @c stretch as the previous line.  eTeX uses \lastlinefit to
826 @c interpolate between both these solutions.
827
828
829 @node Line breaking
830 @subsection Line breaking
831
832 @cindex line breaks
833 @cindex breaking lines
834
835 Line breaks are normally computed automatically.  They are chosen so
836 that lines look neither cramped nor loose, and that consecutive lines
837 have similar density.
838
839 Occasionally you might want to override the automatic breaks; you can
840 do this by specifying @code{\break}.  This will force a line break at
841 this point.  Line breaks can only occur at places where there are bar
842 lines.  If you want to have a line break where there is no bar line,
843 you can force an invisible bar line by entering @code{\bar
844 ""}.  Similarly, @code{\noBreak} forbids a line break at a 
845 point.
846
847
848 @cindex regular line breaks
849 @cindex four bar music. 
850
851 For line breaks at regular intervals use @code{\break} separated by
852 skips and repeated with @code{\repeat}:
853 @example
854 << \repeat unfold 7 @{
855          s1 \noBreak s1 \noBreak
856          s1 \noBreak s1 \break @}
857    @emph{the real music}
858 >> 
859 @end example
860
861 @noindent
862 This makes the following 28 measures (assuming 4/4 time) be broken every
863 4 measures, and only there.
864
865 @refcommands
866
867 @code{\break}, and @code{\noBreak}.
868 @cindex @code{\break}
869 @cindex @code{\noBreak}
870
871 @seealso
872
873 Internals: @internalsref{BreakEvent}.
874
875
876 @node Page breaking
877 @subsection Page breaking
878
879 The default page breaking may be overriden by inserting
880 @code{\pageBreak} or @code{\noPageBreak} commands.  These commands are
881 analogous to @code{\break} and @code{\noBreak}.  They should be
882 inserted at a bar line.  These commands force and forbid a page-break
883 from happening.  Of course, the @code{\pageBreak} command also forces
884 a line break.
885
886 Page breaks are computed by the @code{page-breaking} function in the
887 @code{\paper} block. 
888
889 To force a new page for a new piece (in a collection of pieces or a
890 piece in several movements), use @code{breakbefore} in the header.
891
892 @example
893 \header@{
894   breakbefore = ##t
895 @}
896 @end example
897
898 @refcommands
899
900 @cindex @code{\pageBreak}
901 @code{\pageBreak}
902 @cindex @code{\noPageBreak} 
903 @code{\noPageBreak} 
904
905
906 @node Multiple movements
907 @subsection Multiple movements
908
909 @cindex bibliographic information
910 @cindex titles
911 @cindex composer
912 @cindex Music engraving by LilyPond
913
914 A document may contain multiple pieces of music and texts.  Examples
915 of these are an etude book, or an orchestral part with multiple
916 movements.  Each movement is entered with a @code{\score} block,
917
918 @example
919 \score @{
920   @var{..music..}
921 @}
922 @end example
923
924 and texts are entered with a @code{\markup} block,
925
926 @example
927 \markup @{
928   @var{..text..}
929 @}
930 @end example
931
932 @cindex @code{\book}
933
934 The movements and texts are combined together in a @code{\book} block,
935 like
936
937 @example
938 \book @{
939   \score @{
940     @var{..}
941   @}
942   \markup @{
943     @var{..}
944   @}
945   \score @{
946     @var{..}
947   @}
948 @}
949 @end example
950
951
952 The header for each piece of music can be put inside the @code{\score}
953 block.  The @code{piece} name from the header will be printed before
954 each movement.  The title for the entire book can be put inside the
955 @code{\book}, but if it is not present, the @code{\header} which is at
956 the top of the file is inserted.
957
958 @cindex Engraved by LilyPond
959 @cindex signature line
960
961 @example 
962 \book @{
963   \header @{
964     title = "Eight miniatures" 
965     composer = "Igor Stravinsky"
966   @}
967   \score @{
968     @dots{}
969     \header @{ piece = "Romanze" @}
970   @}
971   \markup @{
972      ..text of second verse..
973   @}
974   \markup @{
975      ..text of third verse..
976   @}
977   \score @{
978     @dots{}
979     \header @{ piece = "Menuetto" @}
980   @}
981 @}
982 @end example
983
984
985 @node Creating titles
986 @subsection Creating titles
987
988 Titles are created for each @code{\score} block, and over a
989 @code{\book}.
990
991 The contents of the titles are taken from the @code{\header} blocks.
992 The header block for a book supports the following
993 @table @code
994 @item dedication
995 The dedicatee of the music, centered at the top of the first page.
996
997 @item title
998 The title of the music, centered just below the dedication.
999
1000 @item subtitle
1001 Subtitle, centered below the title.
1002
1003 @item subsubtitle
1004 Subsubtitle, centered below the subtitle.
1005
1006 @item poet
1007 Name of the poet, flush-left below the subtitle.
1008
1009 @item composer
1010 Name of the composer, flush-right below the subtitle.
1011
1012 @item meter
1013 Meter string, flush-left below the poet.
1014
1015 @item opus
1016 Name of the opus, flush-right below the composer.
1017
1018 @item arranger
1019 Name of the arranger, flush-right below the opus.
1020
1021 @item instrument
1022 Name of the instrument, centered below the arranger.  Also
1023 centered at the top of pages (other than the first page).
1024
1025 @item piece
1026 Name of the piece, flush-left below the instrument.
1027
1028 @cindex page breaks, forcing
1029 @item breakbefore
1030 This forces the title to start on a new page (set to ##t or ##f).
1031
1032 @item copyright
1033 Copyright notice, centered at the bottom of the first page.  To
1034 insert the copyright symbol, see @ref{Text encoding}.
1035
1036 @item tagline
1037 Centered at the bottom of the last page.
1038
1039 @end table
1040
1041 Here is a demonstration of the fields available.  Note that you
1042 may use any @ref{Text markup} commands in the header.
1043
1044 @lilypond[quote,verbatim,linewidth=11.0\cm]
1045 \paper {
1046   linewidth = 9.0\cm
1047   vsize = 10.0\cm
1048 }
1049
1050 \book {
1051   \header {
1052     dedication = "dedicated to me"
1053     title = \markup \center-align { "Title first line" "Title second line, longer" }
1054     subtitle = "the subtitle,"
1055     subsubtitle = #(string-append "subsubtitle LilyPond version " (lilypond-version))
1056     poet = "Poet"
1057     composer =  \markup \center-align { "composer" \small "(1847-1973)" }
1058     texttranslator = "Text Translator"
1059     meter = \markup { \teeny "m" \tiny "e" \normalsize "t" \large "e" \huge "r" }
1060     arranger = \markup { \fontsize #8.5 "a" \fontsize #2.5 "r" \fontsize #-2.5 "r" \fontsize #-5.3 "a" \fontsize #7.5 "nger" }
1061     instrument = \markup \bold \italic "instrument"
1062     piece = "Piece"
1063   }
1064
1065   \score {
1066     { c'1 }
1067     \header {
1068       piece = "piece1"
1069       opus = "opus1" 
1070     }
1071   }
1072   \markup {
1073       and now...
1074   }
1075   \score {
1076     { c'1 }
1077     \header {
1078       piece = "piece2"
1079       opus = "opus2" 
1080     }
1081   }
1082 }
1083 @end lilypond
1084
1085 As demonstrated before, you can use multiple @code{\header} blocks. 
1086 When same fields appear in different blocks, the latter is used.  
1087 Here is a short example.
1088
1089 @example 
1090 \header @{
1091   composer = "Composer"
1092 @}
1093 \header @{
1094   title = "Title"
1095 @}
1096 \score @{
1097   \new Staff @{ c'4 @}
1098   \header @{
1099     title = "New title"  % overwrite previous one
1100   @}
1101 @}
1102 @end example
1103
1104 If you define the @code{\header} inside the @code{\score} block, then
1105 normally only the @code{piece} and @code{opus} headers will be printed.
1106
1107 @lilypond[quote,verbatim,linewidth=11.0\cm]
1108 \score {
1109   { c'4 }
1110   \header {
1111     title = "title"  % not printed
1112     piece = "piece"
1113     opus = "opus"
1114   }
1115 }
1116 @end lilypond
1117
1118 @cindex @code{printallheaders}
1119 @noindent
1120 You may change this behavior (and print all the headers when defining
1121 @code{\header} inside @code{\score}) by using
1122
1123 @example
1124 \paper@{
1125   printallheaders=##t
1126 @}
1127 @end example
1128
1129
1130 @commonprop
1131
1132 A more advanced option is to change the definitions of the following
1133 variables in the @code{\paper} block.  The init file
1134 @file{ly/titling-init.ly} lists the default layout.
1135
1136 @table @code
1137 @cindex @code{bookTitleMarkup}
1138 @item bookTitleMarkup
1139   This is the title put over an entire @code{\book} block.  Typically,
1140   it has the composer and the title of the piece
1141   
1142 @cindex @code{scoreTitleMarkup}
1143 @item scoreTitleMarkup
1144   This is the title put over a @code{\score} block within a
1145 @code{\book}.  Typically, it has the name of the movement (@code{piece}
1146 field).
1147
1148 @cindex @code{oddHeaderMarkup}
1149 @item oddHeaderMarkup
1150   This is the page header for odd-numbered pages. 
1151
1152 @cindex @code{evenHeaderMarkup}
1153 @item evenHeaderMarkup
1154   This is the page header for even-numbered pages.  If unspecified,
1155   the odd header is used instead.
1156
1157   By default, headers are defined such that the page number is on the
1158   outside edge, and the instrument is centered.
1159
1160 @cindex @code{oddFooterMarkup}
1161 @item oddFooterMarkup
1162   This is the page footer for odd-numbered pages. 
1163   
1164 @cindex @code{evenFotterMarkup}
1165 @item evenFooterMarkup
1166   This is the page footer for even-numbered pages.  If unspecified,
1167   the odd header is used instead.
1168
1169   By default, the footer has the copyright notice on the first, and
1170   the tagline on the last page.
1171 @end table
1172
1173
1174 @cindex \paper
1175 @cindex header
1176 @cindex footer
1177 @cindex page layout
1178 @cindex titles
1179
1180 The following definition will put the title flush left, and the
1181 composer flush right on a single line.
1182
1183 @verbatim
1184 \paper {
1185   bookTitleMarkup = \markup {
1186    \fill-line {
1187      \fromproperty #'header:title
1188      \fromproperty #'header:composer
1189    }
1190   }
1191 }
1192 @end verbatim
1193
1194
1195
1196 @node Sound output
1197 @section Sound output
1198
1199 @cindex Sound
1200 @cindex MIDI
1201
1202 MIDI (Musical Instrument Digital Interface) is a standard for
1203 connecting and controlling digital instruments.  A MIDI file is a
1204 series of notes in a number of tracks.  It is not an actual
1205 sound file; you need special software to translate between the
1206 series of notes and actual sounds.
1207
1208 Pieces of music can be converted to MIDI files, so you can listen to
1209 what was entered.  This is convenient for checking the music; octaves
1210 that are off or accidentals that were mistyped stand out very much
1211 when listening to the MIDI output.
1212
1213 @refbugs
1214
1215 Many musically interesting effects, such as swing, articulation,
1216 slurring, etc., are not translated to midi.
1217
1218 The midi output allocates a channel for each staff, and one for global
1219 settings.  Therefore the midi file should not have more than 15 staves
1220 (or 14 if you do not use drums).  Other staves will remain silent.
1221
1222 Not all midi players correctly handle tempo changes in the midi
1223 output.  Players that are known to work include
1224 @uref{http://@/timidity@/.sourceforge@/.net/,timidity}.
1225
1226 @menu
1227 * Creating MIDI files::         
1228 * MIDI block::                  
1229 * MIDI instrument names::       
1230 @end menu
1231
1232 @node Creating MIDI files
1233 @subsection Creating MIDI files 
1234
1235 To create a MIDI from a music piece of music, add a @code{\midi} block
1236 to a score, for example,
1237
1238 @example 
1239 \score @{
1240   @var{...music...}
1241   \midi @{ \tempo 4=72 @}
1242 @}
1243 @end example 
1244
1245 The tempo is specified using the @code{\tempo} command.  In this
1246 example the tempo of quarter notes is set to 72 beats per minute.
1247
1248
1249 If there is a @code{\midi} command in a @code{\score}, only MIDI will
1250 be produced.  When notation is needed too, a @code{\layout} block must
1251 be added
1252
1253 @example 
1254 \score @{
1255   @var{...music...}
1256   \midi @{ \tempo 4=72 @}
1257   \layout @{ @}
1258 @}
1259 @end example 
1260 @cindex layout block
1261
1262
1263
1264 Ties, dynamics, and tempo changes are interpreted.  Dynamic marks,
1265 crescendi and decrescendi translate into MIDI volume levels.  Dynamic
1266 marks translate to a fixed fraction of the available MIDI volume
1267 range, crescendi and decrescendi make the volume vary linearly between
1268 their two extremes.  The fractions can be adjusted by
1269 @code{dynamicAbsoluteVolumeFunction} in @internalsref{Voice} context.
1270 For each type of MIDI instrument, a volume range can be defined.  This
1271 gives a basic equalizer control, which can enhance the quality of
1272 the MIDI output remarkably.  The equalizer can be controlled by
1273 setting @code{instrumentEqualizer}.
1274
1275
1276 @node MIDI block
1277 @subsection MIDI block
1278 @cindex MIDI block
1279
1280
1281 The MIDI block is analogous to the layout block, but it is somewhat
1282 simpler.  The @code{\midi} block can contain
1283 @cindex MIDI block
1284
1285 @itemize @bullet
1286   @item a @code{\tempo} definition, and
1287   @item context definitions.
1288 @end itemize
1289
1290 A number followed by a period is interpreted as a real number, so
1291 for setting the tempo for dotted notes, an extra space should be
1292 inserted, for example
1293
1294 @example
1295 \midi @{ \tempo 4 . = 120 @} 
1296 @end example
1297
1298
1299 @cindex context definition
1300
1301 Context definitions follow precisely the same syntax as within the
1302 \layout block.  Translation modules for sound are called performers.
1303 The contexts for MIDI output are defined in @file{ly/@/performer@/-init@/.ly}.
1304
1305
1306 @node MIDI instrument names
1307 @subsection MIDI instrument names
1308
1309 @cindex instrument names
1310 @cindex @code{Staff.midiInstrument}
1311
1312 The MIDI instrument name is set by the @code{Staff.midiInstrument}
1313 property.  The instrument name should be chosen from the list in
1314 @ref{MIDI instruments}.
1315
1316 @example
1317 \set Staff.midiInstrument = "glockenspiel"
1318 @var{...notes...}
1319 @end example
1320
1321 If the selected instrument does not exactly match an instrument from
1322 the list of MIDI instruments, the Grand Piano (@code{"acoustic grand"})
1323 instrument is used.
1324