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