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