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