1 @c -*- coding: latin-1; mode: texinfo; -*-
2 @c This file is part of lilypond.tely
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
9 @chapter Output formats
11 This is a placeholder until I can write a nice intro for this chapter.
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.
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.
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
41 * Setting global staff size::
42 * Selecting notation font size::
47 * Vertical spacing of piano staves::
48 * Horizontal spacing::
52 * Multiple movements::
57 @node Setting global staff size
58 @subsection Setting global staff size
60 @cindex font size, setting
61 @cindex staff size, setting
62 @cindex @code{layout} file
64 To set the global staff size, use @code{set-global-staff-size}.
67 #(set-global-staff-size 14)
71 This sets the global default size to 14pt staff height and scales all
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:
80 @multitable @columnfractions .15 .2 .22 .2
83 @tab @b{staff height (pt)}
84 @tab @b{staff height (mm)}
126 @c modern rental material?
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.
142 This manual: @ref{Selecting font sizes}.
145 @node Selecting notation font size
146 @subsection Selecting notation font size
148 The easiest method of setting the font size of any context, is by
149 setting the @code{fontSize} property.
151 @lilypond[quote,fragment,relative=1,verbatim]
160 It does not change the size of variable symbols, such as beams or
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.
171 @lilypond[quote,fragment,relative=1,verbatim]
173 \override NoteHead #'font-size = #-4
175 \override NoteHead #'font-size = #3
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.
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.
192 The following commands set @code{fontSize} for the current voice:
196 @cindex @code{\small}
198 @cindex @code{\normalsize}
203 @subsection Paper size
207 @cindex @code{papersize}
209 To change the paper size, there are two commands,
211 #(set-default-paper-size "a4")
213 #(set-paper-size "a4")
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
223 The following paper sizes are supported: @code{a6}, @code{a5}, @code{a4},
224 @code{a3}, @code{legal}, @code{letter}, @code{tabloid}.
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.
234 #(set-default-paper-size "a6" 'landscape)
238 @node Page formatting
239 @subsection Page formatting
241 @cindex page formatting
246 LilyPond will do page layout, set margins, and add headers and
247 footers to each page.
249 The default layout responds to the following settings in the
252 @cindex @code{\paper}
256 @item firstpagenumber
257 The value of the page number of the first page. Default is@tie{}1.
259 @item printfirstpagenumber
260 If set to true, will print the page number in the first page. Default is
264 The width of the page.
267 The height of the page.
270 Margin between header and top of the page.
273 Margin between footer and bottom of the page.
276 Margin between the left side of the page and the beginning of the music.
279 The length of the systems.
282 Distance between the top-most music system and the page header.
285 Distance between the bottom-most music system and the page footer.
288 If set to true, systems will not be spread across the page.
290 This should be set false for pieces that have only two or three
291 systems per page, for example orchestral scores.
293 @item raggedlastbottom
294 If set to false, systems will be spread to fill the last page.
296 Pieces that amply fill two pages or more should have this set to
299 @item betweensystemspace
300 This dimensions determines the distance between systems. It is the
301 ideal distance between the center of the bottom staff of one system
302 and the center of the top staff of the next system.
304 Increasing this will provide a more even appearance of the page at the
305 cost of using more vertical space.
307 @item betweensystempadding
308 This dimension is the minimum amount of white space that will always
309 be present between the bottom-most symbol of one system, and the
310 top-most of the next system.
312 Increasing this will put systems whose bounding boxes almost touch
315 @item aftertitlespace
316 Amount of space between the title and the first system.
318 @item beforetitlespace
319 Amount of space between the last system of the previous piece and the
322 @item betweentitlespace
323 Amount of space between consecutive titles (e.g., the title of the
324 book and the title of a piece).
326 @item systemSeparatorMarkup
327 This contains a markup object, which will be inserted between
328 systems. This is often used for orchestral scores.
330 The markup command @code{\slashSeparator} is provided as a sensible
333 @lilypond[raggedright]
335 systemSeparatorMarkup = \slashSeparator
338 \relative { c1 \break c1 }
352 raggedlastbottom = ##t
356 You can also define these values in Scheme. In that case @code{mm},
357 @code{in}, @code{pt}, and @code{cm} are variables defined in
358 @file{paper-defaults.ly} with values in millimeters. That's why the
359 value has to be multiplied in the example
363 #(define bottommargin (* 2 cm))
370 The default footer is empty, except for the first page, where the
371 @code{copyright} field from @code{\header} is inserted, and the last
372 page, where @code{tagline} from @code{\header} is added. The default
373 tagline is ``Music engraving by LilyPond (@var{version})''.@footnote{Nicely
374 printed parts are good PR for us, so please leave the tagline if you
377 The header and footer are created by the functions @code{make-footer}
378 and @code{make-header}, defined in @code{\paper}. The default
379 implementations are in @file{scm/@/page@/-layout@/.scm}.
381 The page layout itself is done by two functions in the
382 @code{\paper} block, @code{page-music-height} and
383 @code{page-make-stencil}. The former tells the line-breaking algorithm
384 how much space can be spent on a page, the latter creates the actual
385 page given the system to put on it.
390 The option rightmargin is defined but doesn't set the right margin
391 yet. The value for the right margin has to be defined adjusting the
392 values of the leftmargin and linewidth.
394 The default page header puts the page number and the @code{instrument}
395 field from the @code{\header} block on a line.
399 @subsection Score layout
401 @cindex @code{\layout}
403 While @code{\paper} contains settings that relate to the page formatting
404 of the whole document, @code{\layout} contains settings for score-specific
411 minimumVerticalExtent = #'(-6 . 6
414 \override TextScript #'padding = #1.0
415 \override Glissando #'thickness = #3
423 This manual: @ref{Changing context default settings}
426 @node Vertical spacing
427 @subsection Vertical spacing
429 @cindex vertical spacing
430 @cindex distance between staves
431 @cindex staff distance
432 @cindex between staves, distance
433 @cindex staves per page
434 @cindex space between staves
436 The height of each system is determined automatically. To prevent
437 systems from bumping into each other, some minimum distances are set.
438 By changing these, you can put staves closer together, and thus put
439 more systems onto one page.
441 Normally staves are stacked vertically. To make staves maintain a
442 distance, their vertical size is padded. This is done with the
443 property @code{minimumVerticalExtent}. It takes a pair of numbers, so
444 if you want to make it smaller than its default @code{#'(-4 . 4)},
448 \set Staff.minimumVerticalExtent = #'(-3 . 3)
452 This sets the vertical size of the current staff to 3 staff spaces on
453 either side of the center staff line. The argument of
454 @code{minimumVerticalExtent} is interpreted as an interval, where the
455 center line is the 0, so the first number is generally negative. The
456 staff can be made larger at the bottom by setting it to @code{(-6 . 4)}.
458 To change the amount of space between systems, use
459 @code{betweensystemspace}. A score with only one staff is still
460 considered to have systems, so setting @code{betweensystemspace}
461 will be much more useful than changing @code{minimumVerticalExtent}.
465 betweensystemspace = 10\mm
472 Internals: Vertical alignment of staves is handled by the
473 @internalsref{VerticalAlignment} object.
477 @code{minimumVerticalExtent} is syntactic sugar for setting
478 @code{minimum-Y-extent} of the @internalsref{VerticalAxisGroup} of the
479 current context. It can only be changed score wide.
484 @node Vertical spacing of piano staves
485 @subsection Vertical spacing of piano staves
487 The distance between staves of a @internalsref{PianoStaff} cannot be
488 computed during formatting. Rather, to make cross-staff beaming work
489 correctly, that distance has to be fixed beforehand.
491 The distance of staves in a @code{PianoStaff} is set with the
492 @code{forced-distance} property of the
493 @internalsref{VerticalAlignment} object, created in
494 @internalsref{PianoStaff}.
496 It can be adjusted as follows
498 \new PianoStaff \with @{
499 \override VerticalAlignment #'forced-distance = #7
506 This would bring the staves together at a distance of 7 staff spaces,
507 measured from the center line of each staff.
509 The difference is demonstrated in the following example,
510 @lilypond[quote,verbatim]
512 \new PianoStaff \with {
513 \override VerticalAlignment #'forced-distance = #7
529 @code{forced-distance} cannot be changed per system.
532 @node Horizontal spacing
533 @subsection Horizontal Spacing
535 The spacing engine translates differences in durations into
536 stretchable distances (``springs'') of differring lengths. Longer
537 durations get more space, shorter durations get less. The shortest
538 durations get a fixed amount of space (which is controlled by
539 @code{shortest-duration-space} in the @internalsref{SpacingSpanner} object).
540 The longer the duration, the more space it gets: doubling a
541 duration adds a fixed amount (this amount is controlled by
542 @code{spacing-increment}) of space to the note.
544 For example, the following piece contains lots of half, quarter, and
545 8th notes; the eighth note is followed by 1 note head width (NHW).
546 The quarter note is followed by 2 NHW, the half by 3 NHW, etc.
548 @lilypond[quote,fragment,verbatim,relative=1]
549 c2 c4. c8 c4. c8 c4. c8 c8
553 Normally, @code{spacing-increment} is set to 1.2 staff space, which is
554 approximately the width of a note head, and
555 @code{shortest-duration-space} is set to 2.0, meaning that the
556 shortest note gets 2.4 staff space (2.0 times the
557 @code{spacing-increment}) of horizontal space. This space is counted
558 from the left edge of the symbol, so the shortest notes are generally
559 followed by one NHW of space.
561 If one would follow the above procedure exactly, then adding a single
562 32nd note to a score that uses 8th and 16th notes, would widen up the
563 entire score a lot. The shortest note is no longer a 16th, but a 32nd,
564 thus adding 1 NHW to every note. To prevent this, the shortest
565 duration for spacing is not the shortest note in the score, but rather
566 the one which occurs most frequently.
569 The most common shortest duration is determined as follows: in every
570 measure, the shortest duration is determined. The most common shortest
571 duration is taken as the basis for the spacing, with the stipulation
572 that this shortest duration should always be equal to or shorter than
573 an 8th note. The shortest duration is printed when you run
574 @code{lilypond} with the @code{--verbose} option.
576 These durations may also be customized. If you set the
577 @code{common-shortest-duration} in @internalsref{SpacingSpanner}, then
578 this sets the base duration for spacing. The maximum duration for this
579 base (normally an 8th), is set through @code{base-shortest-duration}.
581 @cindex @code{common-shortest-duration}
582 @cindex @code{base-shortest-duration}
583 @cindex @code{stem-spacing-correction}
584 @cindex @code{spacing}
586 Notes that are even shorter than the common shortest note are
587 followed by a space that is proportional to their duration relative to
588 the common shortest note. So if we were to add only a few 16th notes
589 to the example above, they would be followed by half a NHW:
591 @lilypond[quote,fragment,verbatim,relative=2]
592 c2 c4. c8 c4. c16[ c] c4. c8 c8 c8 c4 c4 c4
596 In the introduction (see @ref{Engraving}), it was explained that stem
597 directions influence spacing. This is controlled with the
598 @code{stem-spacing-correction} property in the
599 @internalsref{NoteSpacing}, object. These are generated for every
600 @internalsref{Voice} context. The @code{StaffSpacing} object
601 (generated in @internalsref{Staff} context) contains the same property
602 for controlling the stem/bar line spacing. The following example shows
603 these corrections, once with default settings, and once with
604 exaggerated corrections:
606 @lilypond[quote,raggedright]
610 \override Staff.NoteSpacing #'stem-spacing-correction = #1.5
611 \override Staff.StaffSpacing #'stem-spacing-correction = #1.5
620 Internals: @internalsref{SpacingSpanner}, @internalsref{NoteSpacing},
621 @internalsref{StaffSpacing}, @internalsref{SeparationItem}, and
622 @internalsref{SeparatingGroupSpanner}.
626 Spacing is determined on a score wide basis. If you have a score that
627 changes its character (measured in durations) halfway during the
628 score, the part containing the longer durations will be spaced too
631 There is no convenient mechanism to manually override spacing. The
632 following work-around may be used to insert extra space into a score.
634 \once \override Score.SeparationItem #'padding = #1
637 No work-around exists for decreasing the amount of space.
640 @subsection Line length
643 @cindex breaking pages
645 @cindex @code{indent}
646 @cindex @code{linewidth}
648 @c Although linewidth can be set in \layout, it should be set in paper
649 @c block, to get page layout right.
650 @c Setting indent in \paper block makes not much sense, but it works.
652 @c Bit verbose and vague, use examples?
653 The most basic settings influencing the spacing are @code{indent} and
654 @code{linewidth}. They are set in the @code{\layout} block. They
655 control the indentation of the first line of music, and the lengths of
658 If @code{raggedright} is set to true in the @code{\layout} block, then
659 the lines are justified at their natural length. This is useful for
660 short fragments, and for checking how tight the natural spacing is.
663 @cindex vertical spacing
665 The option @code{raggedlast} is similar to @code{raggedright}, but
666 only affects the last line of the piece. No restrictions are put on
667 that line. The result is similar to formatting text paragraphs. In a
668 paragraph, the last line simply takes its natural length.
669 @c Note that for text there are several options for the last line.
670 @c While Knuth TeX uses natural length, lead typesetters use the same
671 @c stretch as the previous line. eTeX uses \lastlinefit to
672 @c interpolate between both these solutions.
675 @subsection Line breaking
678 @cindex breaking lines
680 Line breaks are normally computed automatically. They are chosen so
681 that lines look neither cramped nor loose, and that consecutive lines
682 have similar density.
684 Occasionally you might want to override the automatic breaks; you can
685 do this by specifying @code{\break}. This will force a line break at
686 this point. Line breaks can only occur at places where there are bar
687 lines. If you want to have a line break where there is no bar line,
688 you can force an invisible bar line by entering @code{\bar
689 ""}. Similarly, @code{\noBreak} forbids a line break at a
693 @cindex regular line breaks
694 @cindex four bar music.
696 For line breaks at regular intervals use @code{\break} separated by
697 skips and repeated with @code{\repeat}:
699 << \repeat unfold 7 @{
700 s1 \noBreak s1 \noBreak
701 s1 \noBreak s1 \break @}
702 @emph{the real music}
707 This makes the following 28 measures (assuming 4/4 time) be broken every
708 4 measures, and only there.
712 @code{\break}, and @code{\noBreak}.
713 @cindex @code{\break}
714 @cindex @code{\noBreak}
718 Internals: @internalsref{BreakEvent}.
722 @subsection Page breaking
724 The default page breaking may be overriden by inserting
725 @code{\pageBreak} or @code{\noPageBreak} commands. These commands are
726 analogous to @code{\break} and @code{\noBreak}. They should be
727 inserted at a bar line. These commands force and forbid a page-break
728 from happening. Of course, the @code{\pageBreak} command also forces
731 Page breaks are computed by the @code{page-breaking} function in the
734 To force a new page for a new piece (in a collection of pieces or a
735 piece in several movements), use @code{breakbefore} in the header.
745 @cindex @code{\pageBreak}
747 @cindex @code{\noPageBreak}
751 @node Multiple movements
752 @subsection Multiple movements
754 @cindex bibliographic information
757 @cindex Music engraiving by LilyPond
759 A document may contain multiple pieces of music and texts. Examples
760 of these are an etude book, or an orchestral part with multiple
761 movements. Each movement is entered with a @code{\score} block,
769 and texts are entered with a @code{\markup} block,
779 The movements and texts are combined together in a @code{\book} block,
797 The header for each piece of music can be put inside the @code{\score}
798 block. The @code{piece} name from the header will be printed before
799 each movement. The title for the entire book can be put inside the
800 @code{\book}, but if it is not present, the @code{\header} which is at
801 the top of the file is inserted.
803 @cindex Engraved by LilyPond
804 @cindex signature line
809 title = "Eight miniatures"
810 composer = "Igor Stravinsky"
814 \header @{ piece = "Romanze" @}
817 ..text of second verse..
820 ..text of third verse..
824 \header @{ piece = "Menuetto" @}
830 @node Creating titles
831 @subsection Creating titles
833 Titles are created for each @code{\score} block, and over a
836 The contents of the titles are taken from the @code{\header} blocks.
837 The header block for a book supports the following
840 The dedicatee of the music, centered at the top of the first page.
843 The title of the music, centered just below the dedication.
846 Subtitle, centered below the title.
849 Subsubtitle, centered below the subtitle.
852 Name of the poet, flush-left below the subtitle.
855 Name of the composer, flush-right below the subtitle.
858 Meter string, flush-left below the poet.
861 Name of the opus, flush-right below the composer.
864 Name of the arranger, flush-right below the opus.
867 Name of the instrument, centered below the arranger.
870 Name of the piece, flush-left below the instrument.
872 @cindex page breaks, forcing
874 This forces the title to start on a new page (set to ##t or ##f).
877 Here is a demonstration of the fields available. Note that you
878 may use any @ref{Text markup} commands in the header.
880 @lilypond[quote,verbatim,linewidth=11.0\cm]
888 dedication = "dedicated to me"
889 title = \markup \center-align { "Title first line" "Title second line, longer" }
890 subtitle = "the subtitle,"
891 subsubtitle = #(string-append "subsubtitle LilyPond version " (lilypond-version))
893 composer = \markup \center-align { "composer" \small "(1847-1973)" }
894 texttranslator = "Text Translator"
895 meter = \markup { \teeny "m" \tiny "e" \normalsize "t" \large "e" \huge "r" }
896 arranger = "Arranger"
897 opus = \markup { \fontsize #8.5 "o" \fontsize #2.5 "p" \fontsize #-2.5 "u" \fontsize #-5.3 "s" \fontsize #7.5 " " }
898 instrument = \markup \bold \italic "instrument"
922 A more advanced option is to change the definitions of the following
923 variables in the @code{\paper} block. The init file
924 @file{ly/titling-init.ly} lists the default layout.
927 @item bookTitleMarkup
928 This is the title put over an entire @code{\book} block. Typically,
929 it has the composer and the title of the piece
931 @item scoreTitleMarkup
932 This is the title put over a @code{\score} block within a
933 @code{\book}. Typically, it has the name of the movement (@code{piece}
936 @item oddHeaderMarkup
937 This is the page header for odd-numbered pages.
939 @item evenHeaderMarkup
940 This is the page header for even-numbered pages. If unspecified,
941 the odd header is used instead.
943 By default, headers are defined such that the page number is on the
944 outside edge, and the instrument is centered.
946 @item oddFooterMarkup
947 This is the page footer for odd-numbered pages.
949 @item evenFooterMarkup
950 This is the page footer for even-numbered pages. If unspecified,
951 the odd header is used instead.
953 By default, the footer has the copyright notice on the first, and
954 the tagline on the last page.
964 The following definition will put the title flush left, and the
965 composer flush right on a single line.
969 bookTitleMarkup = \markup {
971 \fromproperty #'header:title
972 \fromproperty #'header:composer
981 @section Sound output
986 MIDI (Musical Instrument Digital Interface) is a standard for
987 connecting and controlling digital instruments. A MIDI file is a
988 series of notes in a number of tracks. It is not an actual
989 sound file; you need special software to translate between the
990 series of notes and actual sounds.
992 Pieces of music can be converted to MIDI files, so you can listen to
993 what was entered. This is convenient for checking the music; octaves
994 that are off or accidentals that were mistyped stand out very much
995 when listening to the MIDI output.
999 Many musically interesting effects, such as swing, articulation,
1000 slurring, etc., are not translated to midi.
1002 The midi output allocates a channel for each staff, and one for global
1003 settings. Therefore the midi file should not have more than 15 staves
1004 (or 14 if you do not use drums). Other staves will remain silent.
1006 Not all midi players correctly handle tempo changes in the midi
1007 output. Players that are known to work include
1008 @uref{http://@/timidity@/.sourceforge@/.net/,timidity}.
1011 * Creating MIDI files::
1013 * MIDI instrument names::
1016 @node Creating MIDI files
1017 @subsection Creating MIDI files
1019 To create a MIDI from a music piece of music, add a @code{\midi} block
1020 to a score, for example,
1025 \midi @{ \tempo 4=72 @}
1029 The tempo is specified using the @code{\tempo} command. In this
1030 example the tempo of quarter notes is set to 72 beats per minute.
1033 If there is a @code{\midi} command in a @code{\score}, only MIDI will
1034 be produced. When notation is needed too, a @code{\layout} block must
1040 \midi @{ \tempo 4=72 @}
1044 @cindex layout block
1048 Ties, dynamics, and tempo changes are interpreted. Dynamic marks,
1049 crescendi and decrescendi translate into MIDI volume levels. Dynamic
1050 marks translate to a fixed fraction of the available MIDI volume
1051 range, crescendi and decrescendi make the volume vary linearly between
1052 their two extremes. The fractions can be adjusted by
1053 @code{dynamicAbsoluteVolumeFunction} in @internalsref{Voice} context.
1054 For each type of MIDI instrument, a volume range can be defined. This
1055 gives a basic equalizer control, which can enhance the quality of
1056 the MIDI output remarkably. The equalizer can be controlled by
1057 setting @code{instrumentEqualizer}.
1061 @subsection MIDI block
1065 The MIDI block is analogous to the layout block, but it is somewhat
1066 simpler. The @code{\midi} block can contain
1070 @item a @code{\tempo} definition, and
1071 @item context definitions.
1074 A number followed by a period is interpreted as a real number, so
1075 for setting the tempo for dotted notes, an extra space should be
1076 inserted, for example
1079 \midi @{ \tempo 4 . = 120 @}
1083 @cindex context definition
1085 Context definitions follow precisely the same syntax as within the
1086 \layout block. Translation modules for sound are called performers.
1087 The contexts for MIDI output are defined in @file{ly/@/performer@/-init@/.ly}.
1090 @node MIDI instrument names
1091 @subsection MIDI instrument names
1093 @cindex instrument names
1094 @cindex @code{Staff.midiInstrument}
1096 The MIDI instrument name is set by the @code{Staff.midiInstrument}
1097 property. The instrument name should be chosen from the list in
1098 @ref{MIDI instruments}.
1101 \set Staff.midiInstrument = "glockenspiel"
1105 If the selected instrument does not exactly match an instrument from
1106 the list of MIDI instruments, the Grand Piano (@code{"acoustic grand"})