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