1 @c -*- coding: utf-8; mode: texinfo; -*-
4 Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
6 When revising a translation, copy the HEAD committish of the
7 version that you are working on. For details, see the Contributors'
8 Guide, node Updating translation committishes..
14 @chapter Tweaking output
16 This chapter discusses how to modify output. LilyPond is extremely
17 configurable; virtually every fragment of output may be changed.
22 * The Internals Reference manual::
23 * Appearance of objects::
24 * Placement of objects::
26 * Collisions of objects::
31 @section Tweaking basics
34 * Introduction to tweaks::
35 * Objects and interfaces::
36 * Naming conventions of objects and properties::
40 @node Introduction to tweaks
41 @subsection Introduction to tweaks
43 @q{Tweaking} is a LilyPond term for the various methods available
44 to the user for modifying the actions taken during interpretation
45 of the input file and modifying the appearance of the printed
46 output. Some tweaks are very easy to use; others are more
47 complex. But taken together the methods available for tweaking
48 permit almost any desired appearance of the printed music to be
51 In this section we cover the basic concepts required to understand
52 tweaking. Later we give a variety of ready-made commands which can
53 simply be copied to obtain the same effect in your own scores, and
54 at the same time we show how these commands may be constructed so
55 that you may learn how to develop your own tweaks.
57 Before starting on this Chapter you may wish to review the section
58 @ref{Contexts and engravers}, as Contexts, Engravers, and the
59 Properties contained within them are fundamental to understanding
60 and constructing Tweaks.
62 @node Objects and interfaces
63 @subsection Objects and interfaces
69 @cindex properties, object
70 @cindex object properties
72 @cindex object, layout
75 Tweaking involves modifying the internal operation and structures
76 of the LilyPond program, so we must first introduce some terms
77 which are used to describe those internal operations and
80 The term @q{Object} is a generic term used to refer to the
81 multitude of internal structures built by LilyPond during the
82 processing of an input file. So when a command like @code{\new
83 Staff} is encountered a new object of type @code{Staff} is
84 constructed. That @code{Staff} object then holds all the
85 properties associated with that particular staff, for example, its
86 name and its key signature, together with details of the engravers
87 which have been assigned to operate within that staff's context.
88 Similarly, there are objects to hold the properties of all other
89 contexts, such as @code{Voice} objects, @code{Score} objects,
90 @code{Lyrics} objects, as well as objects to represent all
91 notational elements such as bar lines,
92 note heads, ties, dynamics, etc. Every object has its own set of
95 Some types of object are given special names. Objects which represent
96 items of notation on the printed output such as note heads, stems,
97 slurs, ties, fingering, clefs, etc are called @q{Layout objects},
98 often known as @q{Graphical Objects}, or @q{Grobs} for short. These
99 are still objects in the generic sense above, and so they too all have
100 properties associated with them, such as their position, size, color,
103 Some layout objects are still more specialized. Phrasing slurs,
104 crescendo hairpins, ottava marks, and many other grobs are not
105 localized in a single place -- they have a starting point, an
106 ending point, and maybe other properties concerned with their
107 shape. Objects with an extended shape like these are called
110 It remains to explain what @q{Interfaces} are. Many objects, even
111 though they are quite different, share common features which need to
112 be processed in the same way. For example, all grobs have a color, a
113 size, a position, etc, and all these properties are processed in the
114 same way during LilyPond's interpretation of the input file. To
115 simplify these internal operations these common actions and properties
116 are grouped together in an object called a @code{grob-interface}.
117 There are many other groupings of common properties like this, each
118 one given a name ending in @code{interface}. In total there are over
119 100 such interfaces. We shall see later why this is of interest and
122 These, then, are the main terms relating to objects which we
123 shall use in this chapter.
125 @node Naming conventions of objects and properties
126 @subsection Naming conventions of objects and properties
128 @cindex naming conventions for objects
129 @cindex naming conventions for properties
130 @cindex objects, naming conventions
131 @cindex properties, naming conventions
133 We met some object naming conventions previously, in
134 @ref{Contexts and engravers}. Here for reference is a list
135 of the most common object and property types together with
136 the conventions for naming them and a couple of examples of
137 some real names. We have used @q{A} to stand for any capitalized
138 alphabetic character and @q{aaa} to stand for any number of
139 lower-case alphabetic characters. Other characters are used
142 @multitable @columnfractions .33 .33 .33
143 @headitem Object/property type
144 @tab Naming convention
147 @tab Aaaa or AaaaAaaaAaaa
148 @tab Staff, GrandStaff
150 @tab Aaaa or AaaaAaaaAaaa
153 @tab Aaaa_aaa_engraver
154 @tab Clef_engraver, Note_heads_engraver
156 @tab aaa-aaa-interface
157 @tab grob-interface, break-aligned-interface
158 @item Context Properties
159 @tab aaa or aaaAaaaAaaa
160 @tab alignAboveContext, skipBars
161 @item Layout Object Properties
162 @tab aaa or aaa-aaa-aaa
163 @tab direction, beam-thickness
166 As we shall see shortly, the properties of different types of object are
167 modified by different commands, so it is useful to be able to recognize
168 the types of objects and properties from their names.
171 @node Tweaking methods
172 @subsection Tweaking methods
174 @cindex tweaking methods
177 * The \override command::
178 * The \revert command::
180 * The \overrideProperty command::
181 * The \tweak command::
184 @node The \override command
185 @unnumberedsubsubsec The @code{\override} command
187 @cindex override command
188 @cindex override syntax
193 We have already met the commands @code{\set} and @code{\with}, used to
194 change the properties of @strong{contexts} and to remove and add
195 @strong{engravers}, in @ref{Modifying context properties}, and
196 @ref{Adding and removing engravers}. We must now introduce some more
199 The command to change the properties of @strong{layout objects} is
200 @code{\override}. Because this command has to modify
201 internal properties deep within LilyPond its syntax is not
202 as simple as the commands you have used so far. It needs to
203 know precisely which property of which object in which context
204 has to be modified, and what its new value is to be. Let's see
207 The general syntax of this command is:
210 \override @var{Context}.@var{LayoutObject}.@var{layout-property} = #@var{value}
214 This will set the property with the name @var{layout-property} of the
215 layout object with the name @var{LayoutObject}, which is a member of
216 the @var{Context} context, to the value @var{value}.
218 The @var{Context} may be omitted (and usually is) when the
219 required context is unambiguously implied and is one of lowest
220 level contexts, i.e., @code{Voice}, @code{ChordNames} or
221 @code{Lyrics}, and we shall omit it in many of the following
222 examples. We shall see later when it must be specified.
224 Later sections deal comprehensively with properties and their
225 values, see @ref{Types of properties}. But in this section we shall
226 use just a few simple properties and values which are easily
227 understood in order to illustrate the format and use of these
230 LilyPond's primary expressions are musical items like notes,
231 durations, and markups. More basic expressions like numbers,
232 strings, and lists are processed in @q{Scheme mode}, which is
233 invoked by prefixing the value with @samp{#}. Although the
234 values may sometimes have a valid representation in LilyPond's
235 musical mode, this manual will always use @samp{#} for their
236 entry for the sake of consistency. For more information about
237 Scheme mode, see @rextend{LilyPond Scheme syntax}.
239 @code{\override} is the most common command used in tweaking, and
240 most of the rest of this chapter will be directed to presenting
241 examples of how it is used. Here is a simple example to change the
242 color of the note head:
244 @cindex color property, example
245 @cindex NoteHead, example of overriding
247 @lilypond[quote,fragment,ragged-right,verbatim,relative=1]
249 \override NoteHead.color = #red
251 \override NoteHead.color = #green
256 @node The \revert command
257 @unnumberedsubsubsec The @code{\revert} command
259 @cindex revert command
264 Once overridden, the property retains its new value until it is
265 overridden again or a @code{\revert} command is encountered.
266 The @code{\revert} command has the following syntax and causes
267 the value of the property to revert to its original default
268 value; note, not its previous value if several @code{\override}
269 commands have been issued.
272 \revert @var{Context}.@var{LayoutObject}.@var{layout-property}
275 Again, just like @var{Context} in the @code{\override} command,
276 @var{Context} is often not needed. It will be omitted
277 in many of the following examples. Here we revert the color
278 of the note head to the default value for the final two notes:
280 @cindex color property, example
281 @cindex NoteHead, example of overriding
283 @lilypond[quote,fragment,ragged-right,verbatim,relative=1]
285 \override NoteHead.color = #red
287 \override NoteHead.color = #green
289 \revert NoteHead.color
294 @node The \once prefix
295 @unnumberedsubsubsec The @code{\once} prefix
300 Both the @code{\override} and the @code{\set} commands may be prefixed
301 by @code{\once}. This causes the following @code{\override} or
302 @code{\set} command to be effective only during the current musical
303 moment before the property reverts back to its previous value (this can
304 be different from the default if another @code{\override} is still in
305 effect). Using the same example, we can change the color of a single
308 @cindex color property, example
309 @cindex NoteHead, example of overriding
311 @lilypond[quote,verbatim,relative=1]
313 \override NoteHead.color = #red
315 \once \override NoteHead.color = #green
317 \revert NoteHead.color
321 The @code{\once} prefix may also be used in front of many
322 predefined commands to limit their effect to one musical moment:
324 @lilypond[quote,verbatim,relative=1]
333 However, predefined commands of the form @code{\@dots{}Neutral},
334 @code{\@dots{}Off} and @code{\un@dots{}} use @code{\revert} internally
335 rather than @code{\override} so prefixing these with @code{\once} has no
339 @node The \overrideProperty command
340 @unnumberedsubsubsec The @code{\overrideProperty} command
342 @cindex overrideProperty command
344 @funindex \overrideProperty
345 @funindex overrideProperty
347 There is another form of the override command,
348 @code{\overrideProperty}, which is occasionally required.
349 We mention it here for completeness, but for details see
350 @rextend{Difficult tweaks}.
351 @c Maybe explain in a later iteration -td
354 @node The \tweak command
355 @unnumberedsubsubsec The @code{\tweak} command
357 @cindex tweak command
362 The final tweaking command which is available is @code{\tweak}. This
363 should be used when several objects occur at the same musical moment,
364 but you only want to change the properties of selected ones, such as a
365 single note within a chord. Using @code{\override} would affect all the
366 notes within a chord, whereas @code{\tweak} affects just the following
367 item in the input stream.
369 Here's an example. Suppose we wish to change the size of the
370 middle note head (the E) in a C major chord. Let's first see what
371 @code{\once \override} would do:
373 @cindex font-size property, example
374 @cindex NoteHead, example of overriding
376 @lilypond[quote,fragment,ragged-right,verbatim,relative=1]
378 \once \override NoteHead.font-size = #-3
383 We see the override affects @emph{all} the note heads in the chord.
384 This is because all the notes of a chord occur at the same
385 @emph{musical moment}, and the action of @code{\once} is to
386 apply the override to all layout objects of the type specified
387 which occur at the same musical moment as the @code{\override}
390 The @code{\tweak} command operates in a different way. It acts on
391 the immediately following item in the input stream. In its simplest
392 form, it is effective only on objects which are created directly
393 from the following item, essentially note heads and articulations.
395 So to return to our example, the size of the middle note of
396 a chord would be changed in this way:
398 @cindex font-size property, example
399 @cindex @code{\tweak}, example
401 @lilypond[quote,fragment,ragged-right,verbatim,relative=1]
403 <c \tweak font-size #-3 e g>4
406 Note that the syntax of @code{\tweak} is different from that of the
407 @code{\override} command. The context should not be specified; in
408 fact, it would generate an error to do so. Both context and layout
409 object are implied by the following item in the input stream. Note
410 also that an equals sign should not be present. So the simple form
411 of the @code{\tweak} command is
414 \tweak @var{layout-property} #@var{value}
417 A @code{\tweak} command can also be used to modify just one in
418 a series of articulations, as shown here:
420 @cindex color property, example
421 @cindex @code{\tweak}, example
423 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
425 -\tweak color #red ^"Red"
426 -\tweak color #green _"Green"
430 Note that the @code{\tweak} command must be preceded by an articulation
431 mark since the tweaked expression needs to be applied as an articulation
432 itself. In case of multiple direction overrides (@code{^} or @code{_}),
433 the leftmost override wins since it is applied last.
435 @cindex @code{\tweak}, Accidental
436 @cindex @code{\tweak}, specific layout object
438 Objects such as stems and accidentals are created later, and not
439 directly from the following event. It is still possible to use
440 @code{\tweak} on such indirectly created objects by explicitly naming
441 the layout object, provided that LilyPond can trace its origin back to
444 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
445 <\tweak Accidental.color #red cis4
446 \tweak Accidental.color #green es
450 This long form of the @code{\tweak} command can be described as
453 \tweak @var{layout-object}.@var{layout-property} @var{value}
456 @cindex tuplets, nested
457 @cindex triplets, nested
458 @cindex bracket, tuplet
459 @cindex bracket, triplet
460 @cindex tuplet bracket
461 @cindex triplet bracket
463 @funindex TupletBracket
465 The @code{\tweak} command must also be used to change the
466 appearance of one of a set of nested tuplets which begin at the
467 same musical moment. In the following example, the long tuplet
468 bracket and the first of the three short brackets begin at the
469 same musical moment, so any @code{\override} command would apply
470 to both of them. In the example, @code{\tweak} is used to
471 distinguish between them. The first @code{\tweak} command
472 specifies that the long tuplet bracket is to be placed above the
473 notes and the second one specifies that the tuplet number is to be
474 printed in red on the first short tuplet bracket.
476 @cindex @code{\tweak}, example
477 @cindex direction property, example
478 @cindex color property, example
480 @lilypond[quote,ragged-right,verbatim,fragment,relative=2]
484 \tuplet 3/2 { c8[ c c] }
485 \tuplet 3/2 { c8[ c c] }
486 \tuplet 3/2 { c8[ c c] }
490 If nested tuplets do not begin at the same moment, their
491 appearance may be modified in the usual way with
492 @code{\override} commands:
494 @cindex text property, example
495 @cindex tuplet-number function, example
496 @cindex transparent property, example
497 @cindex TupletNumber, example of overriding
499 @lilypond[quote,ragged-right,verbatim,fragment,relative=1]
500 \tuplet 3/2 { c8[ c c] }
501 \once \override TupletNumber.text = #tuplet-number::calc-fraction-text
505 \once \override TupletNumber.transparent = ##t
506 \tuplet 3/2 { c8[ c c] }
507 \tuplet 3/2 { c8[ c c] }
514 @ruser{The tweak command}.
517 @node The Internals Reference manual
518 @section The Internals Reference manual
520 @cindex Internals Reference
523 * Properties of layout objects::
524 * Properties found in interfaces::
525 * Types of properties::
528 @node Properties of layout objects
529 @subsection Properties of layout objects
531 @cindex properties of layout objects
532 @cindex properties of grobs
533 @cindex grobs, properties of
534 @cindex layout objects, properties of
535 @cindex Internals Reference manual
537 Suppose you have a slur in a score which, to your mind,
538 appears too thin and you'd like to draw it a little heavier.
539 How do you go about doing this? You know from the statements
540 earlier about the flexibility of LilyPond that such a thing
541 should be possible, and you would probably guess that an
542 @code{\override} command would be needed. But is there a
543 heaviness property for a slur, and if there is, how might it
544 be modified? This is where the Internals Reference manual
545 comes in. It contains all the information you might need to
546 construct this and all other @code{\override} commands.
548 Before we look at the Internals Reference a word of warning.
549 This is a @strong{reference} document, which means there is
550 little or no explanation contained within it: its purpose is
551 to present information precisely and concisely. This
552 means it might look daunting at first sight. Don't worry!
553 The guidance and explanation presented here will enable you
554 to extract the information from the Internals Reference for
555 yourself with just a little practice.
557 @cindex override example
558 @cindex Internals Reference, example of using
559 @cindex @code{\addlyrics} example
561 Let's use a concrete example with a simple fragment of real
564 @c Mozart, Die Zauberflöte Nr.7 Duett
566 @lilypond[quote,verbatim,relative=2]
571 r4 bes8 bes[( g]) g |
572 g8[( es]) es d[( f]) as |
576 The man who | feels love's sweet e -- | mo -- tion
581 Suppose now that we decide we would like the slurs to be a
582 little heavier. Is this possible? The slur is certainly a
583 layout object, so the question is, @q{Is there a property
584 belonging to a slur which controls the heaviness?} To answer
585 this we must look in the Internals Reference, or IR for short.
587 The IR for the version of LilyPond you are using may be found
588 on the LilyPond website at @uref{http://lilypond.org}. Go to the
589 documentation page and click on the Internals Reference link.
590 For learning purposes you should use the standard HTML version,
591 not the @q{one big page} or the PDF. For the next few
592 paragraphs to make sense you will need to actually do this
595 Under the heading @strong{Top} you will see five links. Select
596 the link to the @emph{Backend}, which is where information about
597 layout objects is to be found. There, under the heading
598 @strong{Backend}, select the link to @emph{All layout objects}.
599 The page that appears lists all the layout objects used in your
600 version of LilyPond, in alphabetic order. Select the link to
601 Slur, and the properties of Slurs are listed.
603 An alternative way of finding this page is from the Notation
604 Reference. On one of the pages that deals with slurs you may find a
605 link to the Internals Reference. This link will take you directly to
606 this page, but if you have an idea about the name of the layout object
607 to be tweaked, it is easier to go straight to the IR and search there.
609 This Slur page in the IR tells us first that Slur objects are created
610 by the Slur_engraver. Then it lists the standard settings. Browse
611 through them looking for a property that might control the heaviness of
612 slurs, and you should find
615 @code{thickness} (number)
617 Line thickness, generally measured in @code{line-thickness}
620 This looks a good bet to change the heaviness. It tells us that
621 the value of @code{thickness} is a simple @emph{number},
622 that the default value is 1.2, and that the units are
623 in another property called @code{line-thickness}.
625 As we said earlier, there are few to no explanations in the IR,
626 but we already have enough information to try changing the
627 slur thickness. We see that the name of the layout object
628 is @code{Slur}, that the name of the property to change is
629 @code{thickness} and that the new value should be a number
630 somewhat larger than 1.2 if we are to make slurs thicker.
632 We can now construct the @code{\override} command by simply
633 substituting the values we have found for the names, omitting
634 the context. Let's use a very large value for the thickness
635 at first, so we can be sure the command is working. We get:
638 \override Slur.thickness = #5.0
641 Don't forget the@tie{}@code{#} preceding the new value!
643 The final question is, @q{Where should this command be
644 placed?} While you are unsure and learning, the best
645 answer is, @q{Within the music, before the first slur and
646 close to it.} Let's do that:
648 @cindex Slur example of overriding
649 @cindex thickness property, example
651 @lilypond[quote,verbatim,relative=2]
656 % Increase thickness of all following slurs from 1.2 to 5.0
657 \override Slur.thickness = #5.0
658 r4 bes8 bes[( g]) g |
659 g8[( es]) es d[( f]) as |
663 The man who | feels love's sweet e -- | mo -- tion
669 and we see that the slur is indeed heavier.
671 So this is the basic way of constructing @code{\override}
672 commands. There are a few more complications that we
673 shall meet in later sections, but you now know all the
674 essentials required to make up your own -- but you will
675 still need some practice. This is provided in the examples
678 @subsubsubheading Finding the context
680 @cindex context, finding
681 @cindex context, identifying correct
683 But first, what if we had needed to specify the Context?
684 What should it be? We could guess that slurs are in
685 the Voice context, as they are clearly closely associated
686 with individual lines of music, but can we be sure? To
687 find out, go back to the top of the IR page describing the
688 Slur, where it says @q{Slur objects are created by: Slur
689 engraver}. So slurs will be created in whichever context
690 the @code{Slur_engraver} is in. Follow the link to the
691 @code{Slur_engraver} page. At the very bottom it tells
692 us that @code{Slur_engraver} is part of seven Voice contexts,
693 including the standard voice context, @code{Voice}, so our
694 guess was correct. And because @code{Voice} is one of the
695 lowest level contexts which is implied unambiguously by
696 the fact that we are entering notes, we can omit it in this
699 @subsubsubheading Overriding once only
701 @cindex overriding once only
702 @cindex once override
707 As you can see, @emph{all} the slurs are thicker in the final example
708 above. But what if we wanted just the first slur to be thicker? This
709 is achieved with the @code{\once} command. Placed immediately before
710 the @code{\override} command it causes it to change only the slur
711 which begins on the @strong{immediately following} note. If the
712 immediately following note does not begin a slur the command has no
713 effect at all -- it is not remembered until a slur is encountered, it
714 is simply discarded. So the command with @code{\once} must be
715 repositioned as follows:
717 @cindex Slur, example of overriding
718 @cindex thickness property, example
720 @lilypond[quote,verbatim,relative=2]
726 % Increase thickness of immediately following slur only
727 \once \override Slur.thickness = #5.0
729 g8[( es]) es d[( f]) as |
733 The man who | feels love's sweet e -- | mo -- tion
739 Now only the first slur is made heavier.
741 The @code{\once} command can also be used before the @code{\set}
744 @subsubsubheading Reverting
747 @cindex default properties, reverting to
752 Finally, what if we wanted just the first two slurs to be
753 heavier? Well, we could use two commands, each preceded by
754 @code{\once} placed immediately before each of the notes where
757 @cindex Slur, example of overriding
758 @cindex thickness property, example
760 @lilypond[quote,verbatim,relative=2]
766 % Increase thickness of immediately following slur only
767 \once \override Slur.thickness = #5.0
769 % Increase thickness of immediately following slur only
770 \once \override Slur.thickness = #5.0
771 g8[( es]) es d[( f]) as |
775 The man who | feels love's sweet e -- | mo -- tion
781 or we could omit the @code{\once} command and use the @code{\revert}
782 command to return the @code{thickness} property to its default value
783 after the second slur:
785 @cindex Slur, example of overriding
786 @cindex thickness property, example
788 @lilypond[quote,verbatim,relative=2]
794 % Increase thickness of all following slurs from 1.2 to 5.0
795 \override Slur.thickness = #5.0
798 % Revert thickness of all following slurs to default of 1.2
799 \revert Slur.thickness
804 The man who | feels love's sweet e -- | mo -- tion
810 The @code{\revert} command can be used to return any property
811 changed with @code{\override} back to its default value.
812 You may use whichever method best suits what you want to do.
814 That concludes our introduction to the IR, and the basic
815 method of tweaking. Several examples follow in the later
816 sections of this Chapter, partly to introduce you to some of the
817 additional features of the IR, and partly to give you more
818 practice in extracting information from it. These examples will
819 contain progressively fewer words of guidance and explanation.
822 @node Properties found in interfaces
823 @subsection Properties found in interfaces
826 @cindex interface properties
827 @cindex properties in interfaces
829 Suppose now that we wish to print the lyrics in italics. What form of
830 @code{\override} command do we need to do this? We first look in the
831 IR page listing @q{All layout objects}, as before, and look for an
832 object that might control lyrics. We find @code{LyricText}, which
833 looks right. Clicking on this shows the settable properties for lyric
834 text. These include the @code{font-series} and @code{font-size}, but
835 nothing that might give an italic shape. This is because the shape
836 property is one that is common to all font objects, so, rather than
837 including it in every layout object, it is grouped together with other
838 similar common properties and placed in an @strong{Interface}, the
839 @code{font-interface}.
841 So now we need to learn how to find the properties of interfaces,
842 and to discover what objects use these interface properties.
844 Look again at the IR page which describes LyricText. At the bottom of
845 the page is a list of clickable interfaces which LyricText supports.
846 The list has several items, including @code{font-interface}. Clicking
847 on this brings up the properties associated with this interface, which
848 are also properties of all the objects which support it, including
851 Now we see all the user-settable properties which control fonts,
852 including @code{font-shape(symbol)}, where @code{symbol} can be
853 set to @code{upright}, @code{italics} or @code{caps}.
855 You will notice that @code{font-series} and @code{font-size} are also
856 listed there. This immediately raises the question: Why are the
857 common font properties @code{font-series} and @code{font-size} listed
858 under @code{LyricText} as well as under the interface
859 @code{font-interface} but @code{font-shape} is not? The answer is
860 that @code{font-series} and @code{font-size} are changed from their
861 global default values when a @code{LyricText} object is created, but
862 @code{font-shape} is not. The entries in @code{LyricText} then tell
863 you the values for those two properties which apply to
864 @code{LyricText}. Other objects which support @code{font-interface}
865 will set these properties differently when they are created.
867 Let's see if we can now construct the @code{\override} command
868 to change the lyrics to italics. The object is @code{LyricText},
869 the property is @code{font-shape} and the value is
870 @code{italic}. As before, we'll omit the context.
872 As an aside, although it is an important one, note that some
873 properties take values that are symbols, like @code{italic}, and
874 must be preceded by an apostrophe, @code{'}. Symbols are then
875 read internally by LilyPond. Note the distinction from arbitrary
876 text strings, which would appear as @code{"a text string"}; for
877 more details about symbols and strings, see @rextend{Scheme tutorial}.
879 So we see that the @code{\override} command needed to print the lyrics
883 \override LyricText.font-shape = #'italic
887 This should be placed just in front of the lyrics we wish to affect,
890 @cindex font-shape property, example
891 @cindex italic, example
892 @cindex LyricText, example of overriding
893 @cindex @code{\addlyrics}, example
895 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
900 r4 bes8 bes[( g]) g |
901 g8[( es]) es d[( f]) as |
905 \override LyricText.font-shape = #'italic
906 The man who | feels love's sweet e -- | mo -- tion
912 and the lyrics are all printed in italics.
914 @warning{In lyrics always leave whitespace between the final
915 syllable and the terminating brace.}
919 Extending: @rextend{Scheme tutorial}.
922 @node Types of properties
923 @subsection Types of properties
925 @cindex property types
927 So far we have seen two types of property: @code{number} and
928 @code{symbol}. To be valid, the value given to a property
929 must be of the correct type and obey the rules for that type.
930 The type of property is always shown in brackets after the
931 property name in the IR. Here is a list of the types you may
932 need, together with the rules for that type, and some examples.
933 You must always add a hash symbol, @code{#}, of course,
934 to the front of these values when they are entered in the
935 @code{\override} command, even if the value itself already
936 starts with@tie{}@code{#}. We only give examples for constants
937 here: if you want to compute a value using Scheme, see
938 @rextend{Calculations in Scheme}.
940 @multitable @columnfractions .2 .45 .35
941 @headitem Property type
945 @tab Either True or False, represented by #t or #f
946 @tab @code{#t}, @code{#f}
947 @item Dimension (in staff space)
948 @tab A decimal number (in units of staff space)
949 @tab @code{2.5}, @code{0.34}
951 @tab A valid direction constant or its numerical equivalent
952 (@code{0} or @code{CENTER} indicate a neutral direction)
953 @tab @code{LEFT}, @code{CENTER}, @code{UP},
954 @code{1}, @w{@code{-1}}
957 @tab @code{3}, @code{-1}
959 @tab A sequence of constants or symbols separated by spaces, enclosed
961 and preceded by an apostrophe (quote mark)
962 @tab @code{'(left-edge staff-bar)}, @code{'(1)}, @code{'()},
963 @code{'(1.0 0.25 0.5)}
965 @tab Any valid markup
966 @tab @code{\markup @{ \italic "cresc." @}}, @code{"bagpipe"}
968 @tab A fraction of a whole note constructed with the
970 @tab @code{(ly:make-moment 1/4)},
971 @code{(ly:make-moment 3/8)}
973 @tab Any positive or negative, possibly decimal, value
974 @tab @code{3}, @w{@code{-2.45}}
975 @item Pair (of numbers)
976 @tab Two numbers separated by a @q{space . space} and enclosed
977 in brackets preceded by an apostrophe
978 @tab @code{'(2 . 3.5)}, @code{'(0.1 . -3.2)}
980 @tab Any of the set of permitted symbols for that property,
981 preceded by an apostrophe
982 @tab @code{'italic}, @code{'inside}
984 @tab A procedure, or @code{#f} to cause no action
985 @tab @code{bend::print}, @code{ly:text-interface::print},
989 enclosed in @code{#(}@dots{}@code{)}.
990 @tab @code{#(#t #t #f)}
995 Extending: @rextend{Scheme tutorial}.
998 @node Appearance of objects
999 @section Appearance of objects
1001 Let us now put what we have learned into practice with a few
1002 examples which show how tweaks may be used to change the
1003 appearance of the printed music.
1006 * Visibility and color of objects::
1008 * Length and thickness of objects::
1011 @node Visibility and color of objects
1012 @subsection Visibility and color of objects
1014 In the educational use of music we might wish to print a score
1015 with certain elements omitted as an exercise for the student,
1016 who is required to supply them. As a simple example,
1017 let us suppose the exercise is to supply the missing bar lines
1018 in a piece of music. But the bar lines are normally inserted
1019 automatically. How do we prevent them printing?
1021 Before we tackle this, let us remember that object properties are
1022 grouped in what are called @emph{interfaces} -- see @ref{Properties
1023 found in interfaces}. This is simply to group together those
1024 properties that may be used together to tweak a graphical object -- if
1025 one of them is allowed for an object, so are the others. Some objects
1026 then use the properties in some interfaces, others use them from other
1027 interfaces. The interfaces which contain the properties used by a
1028 particular grob are listed in the IR at the bottom of the page
1029 describing that grob, and those properties may be viewed by looking at
1032 We explained how to find information about grobs in @ref{Properties of
1033 layout objects}. Using the same approach, we go to the IR to find the
1034 layout object which prints bar lines. Going via @emph{Backend} and
1035 @emph{All layout objects} we find there is a layout object called
1036 @code{BarLine}. Its properties include two that control its
1037 visibility: @code{break-visibility} and @code{stencil}. Barline also
1038 supports a number of interfaces, including the @code{grob-interface},
1039 where we find the @code{transparent} and the @code{color} properties.
1040 All of these can affect the visibility of bar lines (and, of course,
1041 by extension, many other layout objects too.) Let's consider each of
1045 * The stencil property::
1046 * The break-visibility property::
1047 * The transparent property::
1048 * The color property::
1051 @node The stencil property
1052 @unnumberedsubsubsec The @code{stencil} property
1054 @cindex stencil property
1056 This property controls the appearance of the bar lines by specifying
1057 the symbol (glyph) which should be printed. In common
1058 with many other properties, it can be set to print nothing by
1059 setting its value to @code{#f}. Let's try it, as before, omitting
1060 the implied Context, @code{Voice}:
1062 @cindex BarLine, example of overriding
1063 @cindex stencil property, example
1065 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1068 \override BarLine.stencil = ##f
1070 g,8 a16 b8 c d4 e16 |
1075 The bar lines are still printed. What is wrong? Go back to the IR
1076 and look again at the page giving the properties of BarLine. At the
1077 top of the page it says @qq{Barline objects are created by:
1078 Bar_engraver}. Go to the @code{Bar_engraver} page. At the bottom it
1079 gives a list of Contexts in which the bar engraver operates. All of
1080 them are of the type @code{Staff}, so the reason the @code{\override}
1081 command failed to work as expected is because @code{Barline} is not in
1082 the default @code{Voice} context. If the context is specified
1083 incorrectly, the command simply does not work. No error message is
1084 produced, and nothing is logged in the log file. Let's try correcting
1085 it by adding the correct context:
1087 @cindex BarLine, example of overriding
1088 @cindex stencil property, example
1090 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1093 \override Staff.BarLine.stencil = ##f
1095 g,8 a16 b8 c d4 e16 |
1100 Now the bar lines have vanished. Setting the @code{stencil}
1101 property to @code{#f} is such a frequent operation that there is a
1102 shorthand for it called @code{\omit}:
1105 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1110 g,8 a16 b8 c d4 e16 |
1115 Note, though, that setting the @code{stencil} property to @code{#f}
1116 will cause errors when the dimensions of the object are required for
1117 correct processing. For example, errors will be generated if the
1118 @code{stencil} property of the @code{NoteHead} object is set to
1119 @code{#f}. If this is the case, you can instead use the
1120 @code{point-stencil} function, which sets the stencil to an object
1123 @lilypond[quote,verbatim,relative=2]
1126 \once \override NoteHead.stencil = #point-stencil
1131 @node The break-visibility property
1132 @unnumberedsubsubsec The @code{break-visibility} property
1134 @cindex break-visibility property
1136 We see from the @code{BarLine} properties in the IR that the
1137 @code{break-visibility} property requires a vector of three booleans.
1138 These control respectively whether bar lines are printed at the end of
1139 a line, in the middle of lines, and at the beginning of lines. For
1140 our example we want all bar lines to be suppressed, so the value we
1141 need is @code{#(#f #f #f)} (also available
1142 under the name @code{all-invisible}). Let's try that, remembering to include
1143 the @code{Staff} context. Note also that in writing this value we
1144 have @code{##} before the opening parenthesis. One @code{#} is required
1145 as part of vector constant syntax, and the first@tie{}@code{#} is
1146 required, as always, to precede the value itself in the
1147 @code{\override} command.
1149 @cindex BarLine, example of overriding
1150 @cindex break-visibility property, example
1152 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1155 \override Staff.BarLine.break-visibility = ##(#f #f #f)
1157 g,8 a16 b8 c d4 e16 |
1162 And we see this too removes all the bar lines.
1164 @node The transparent property
1165 @unnumberedsubsubsec The @code{transparent} property
1167 @cindex transparent property
1168 @cindex transparency
1170 We see from the properties specified in the @code{grob-interface} page
1171 in the IR that the @code{transparent} property is a boolean. This
1172 should be set to @code{#t} to make the grob transparent. In this next
1173 example let us make the time signature invisible rather than the bar
1174 lines. To do this we need to find the grob name for the time
1175 signature. Back to the @q{All layout objects} page in the IR to find
1176 the properties of the @code{TimeSignature} layout object. This is
1177 produced by the @code{Time_signature_engraver} which you can check
1178 also lives in the @code{Staff} context and also supports the
1179 @code{grob-interface}. So the command to make the time signature
1182 @cindex TimeSignature, example of overriding
1183 @cindex transparent property, example
1185 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1188 \override Staff.TimeSignature.transparent = ##t
1190 g,8 a16 b8 c d4 e16 |
1196 Again, setting the @code{transparent} property is a rather
1197 frequent operation, so we have a shorthand for it called
1201 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1204 \hide Staff.TimeSignature
1206 g,8 a16 b8 c d4 e16 |
1212 In either case, the time signature is gone, but this command
1214 the time signature should be. Maybe this is what is wanted for
1215 an exercise for the student to fill it in, but in other
1216 circumstances a gap might be undesirable. To remove it, the
1217 stencil for the time signature should be set to @code{#f}
1220 @cindex TimeSignature, example of overriding
1221 @cindex stencil property, example
1223 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1226 \omit Staff.TimeSignature
1228 g,8 a16 b8 c d4 e16 |
1234 and the difference is obvious: setting the stencil to @code{#f}
1235 (possibly via @code{\omit})
1236 removes the object entirely; making the object @code{transparent}
1237 (which can be done using @code{\hide})
1238 leaves it where it is, but makes it invisible.
1240 @node The color property
1241 @unnumberedsubsubsec The @code{color} property
1243 @cindex color property
1245 Finally let us try making the bar lines invisible by coloring
1246 them white. (There is a difficulty with this in that the
1247 white bar line may or may not blank out the staff lines where
1248 they cross. You may see in some of the examples below that this
1249 happens unpredictably. The details of why this is so and how to
1250 control it are covered in @ruser{Painting objects white}. But at
1251 the moment we are learning about color, so please just accept this
1252 limitation for now.)
1254 The @code{grob-interface} specifies that the
1255 color property value is a list, but there is no
1256 explanation of what that list should be. The list it
1257 requires is actually a list of values in internal units,
1258 but, to avoid having to know what these are, several ways
1259 are provided to specify colors. The first way is to use one
1260 of the @q{normal} colors listed in the first table in
1261 @ruser{List of colors}. To set the bar lines to white
1264 @cindex BarLine, example of overriding
1265 @cindex color property, example
1267 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1270 \override Staff.BarLine.color = #white
1272 g,8 a16 b8 c d4 e16 |
1278 and again, we see the bar lines are not visible. Note that
1279 @emph{white} is not preceded by an apostrophe -- it is not
1280 a symbol, but a @emph{variable}. When evaluated, it provides
1281 the list of internal values required to set the color to
1282 white. The other colors in the normal list are variables
1283 too. To convince yourself this is working you might like
1284 to change the color to one of the other variables in the
1292 The second way of changing the color is to use the list of
1293 X11 color names in the second list in @ruser{List of colors}.
1294 However, these are mapped to the actual values by the function
1295 @code{x11-color} which
1296 converts X11 color symbols into the list of internal values like this:
1298 @cindex BarLine, example of overriding
1299 @cindex color property, example
1301 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1304 \override Staff.BarLine.color = #(x11-color 'white)
1306 g,8 a16 b8 c d4 e16 |
1312 Note that in this case the function @code{x11-color} takes
1313 a symbol as an argument, so the symbol must be preceded by
1314 an apostrophe to keep it from being evaluated as a variable, and
1315 the whole function call has to be enclosed in parentheses.
1322 There is another function, one which converts RGB values into
1323 internal colors -- the @code{rgb-color} function. This takes
1324 three arguments giving the intensities of the red, green and
1325 blue colors. These take values in the range 0 to 1. So to
1326 set the color to red the value should be @code{(rgb-color 1 0 0)}
1327 and to white it should be @code{(rgb-color 1 1 1)}:
1329 @cindex BarLine, example of overriding
1330 @cindex color property, example
1332 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1335 \override Staff.BarLine.color = #(rgb-color 1 1 1)
1337 g,8 a16 b8 c d4 e16 |
1342 Finally, there is also a grey scale available as part of the
1343 X11 set of colors. These range from black, @code{'grey0},
1344 to white, @code{'grey100}, in steps of 1. Let's illustrate
1345 this by setting all the layout objects in our example to
1346 various shades of grey:
1348 @cindex StaffSymbol, example of overriding
1349 @cindex TimeSignature, example of overriding
1350 @cindex Clef, example of overriding
1351 @cindex NoteHead, example of overriding
1352 @cindex Stem, example of overriding
1353 @cindex BarLine, example of overriding
1354 @cindex color property, example
1355 @cindex x11-color, example of using
1357 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1360 \override Staff.StaffSymbol.color = #(x11-color 'grey30)
1361 \override Staff.TimeSignature.color = #(x11-color 'grey60)
1362 \override Staff.Clef.color = #(x11-color 'grey60)
1363 \override Voice.NoteHead.color = #(x11-color 'grey85)
1364 \override Voice.Stem.color = #(x11-color 'grey85)
1365 \override Staff.BarLine.color = #(x11-color 'grey10)
1367 g,8 a16 b8 c d4 e16 |
1373 Note the contexts associated with each of the layout objects.
1374 It is important to get these right, or the commands will not
1375 work! Remember, the context is the one in which the appropriate
1376 engraver is placed. The default context for engravers can be
1377 found by starting from the layout object, going from there to
1378 the engraver which produces it, and on the engraver page in the
1379 IR it tells you in which context the engraver will normally be
1383 @node Size of objects
1384 @subsection Size of objects
1386 @cindex changing size of objects
1387 @cindex size of objects
1388 @cindex objects, size of
1389 @cindex objects, changing size of
1391 Let us begin by looking again at the earlier example
1392 (see @ref{Nesting music expressions}) which showed
1393 how to introduce a new temporary staff, as in an @rglos{ossia}.
1395 @cindex alignAboveContext property, example
1396 @cindex @code{\with}, example
1398 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1399 \new Staff ="main" {
1406 alignAboveContext = #"main" }
1414 Ossia are normally written without clef and time signature, and
1415 are usually printed slightly smaller than the main staff. We
1416 already know now how to remove the clef and time signature --
1417 we simply set the stencil of each to @code{#f}, as follows:
1419 @cindex alignAboveContext property, example
1420 @cindex @code{\with}, example
1422 @cindex Clef, example of overriding
1423 @cindex TimeSignature, example of overriding
1425 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1426 \new Staff ="main" {
1433 alignAboveContext = #"main"
1437 \omit Staff.TimeSignature
1447 where the extra pair of braces after the @code{\with} clause are
1448 required to ensure the enclosed overrides and music are applied
1451 But what is the difference between modifying the staff context by
1452 using @code{\with} and modifying the stencils of the clef and the
1453 time signature with @code{\override}, or in this case
1455 The main difference is that
1456 changes made in a @code{\with} clause are made at the time the
1457 context is created, and remain in force as the @strong{default}
1458 values for the duration of that context, whereas
1459 @code{\set} or @code{\override} commands embedded in the
1460 music are dynamic -- they make changes synchronized with
1461 a particular point in the music. If changes are unset or
1462 reverted using @code{\unset} or @code{\revert} they return to
1463 their default values, which will be the ones set in the
1464 @code{\with} clause, or if none have been set there, the normal
1467 Some context properties can be modified only in @code{\with} clauses.
1468 These are those properties which cannot sensibly be changed after the
1469 context has been created. @code{alignAboveContext} and its partner,
1470 @code{alignBelowContext}, are two such properties -- once the staff
1471 has been created its alignment is decided and it would make no sense
1472 to try to change it later.
1474 The default values of layout object properties can also be set
1475 in @code{\with} clauses. Simply use the normal @code{\override}
1476 command leaving out the context name, since this is unambiguously
1477 defined as the context which the @code{\with} clause is modifying.
1478 If fact, an error will be generated if a context is specified
1481 So we could replace the example above with
1483 @cindex alignAboveContext property, example
1484 @cindex @code{\with}, example
1485 @cindex Clef, example of overriding
1486 @cindex TimeSignature, example of overriding
1488 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1489 \new Staff ="main" {
1496 alignAboveContext = #"main"
1497 % Don't print clefs in this staff
1498 \override Clef.stencil = ##f
1499 % Don't print time signatures in this staff
1500 \override TimeSignature.stencil = ##f
1509 It turns out that we can also employ the shorthands @code{\hide}
1510 and @code{\omit} for setting the @code{transparent} property and
1511 clearing the @code{stencil} here, leading to the result
1513 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1514 \new Staff ="main" {
1521 alignAboveContext = #"main"
1522 % Don't print clefs in this staff
1524 % Don't print time signatures in this staff
1534 Finally we come to changing the size of layout objects.
1536 Some layout objects are created as glyphs selected from a typeface
1537 font. These include note heads, accidentals, markup, clefs, time
1538 signatures, dynamics and lyrics. Their size is changed by modifying
1539 the @code{font-size} property, as we shall shortly see. Other layout
1540 objects such as slurs and ties -- in general, spanner objects -- are
1541 drawn individually, so there is no @code{font-size} associated with
1542 them. These objects generally derive their size from the objects to
1543 which they are attached, so usually there is no need to change their
1544 size manually. Still other properties such as the length of stems and
1545 bar lines, thickness of beams and other lines, and the separation of
1546 staff lines all need to be modified in special ways.
1548 Returning to the ossia example, let us first change the font-size.
1549 We can do this in two ways. We can either change the size of the
1550 fonts of each object type, like @code{NoteHead}s with commands
1554 \override NoteHead.font-size = #-2
1557 or we can change the size of all fonts by setting a special
1558 property, @code{fontSize}, using @code{\set}, or by including
1559 it in a @code{\with} clause (but without the @code{\set}).
1565 Both of these statements would cause the font size to be reduced
1566 by 2 steps from its previous value, where each
1567 step reduces or increases the size by approximately 12%.
1569 Let's try it in our ossia example:
1571 @cindex alignAboveContext property, example
1572 @cindex @code{\with}, example
1573 @cindex Clef, example of overriding
1574 @cindex TimeSignature, example of overriding
1575 @cindex fontSize property, example
1577 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1578 \new Staff ="main" {
1585 alignAboveContext = #"main"
1588 % Reduce all font sizes by ~24%
1598 This is still not quite right. The note heads and flags are
1599 smaller, but the stems are too long in proportion and the
1600 staff lines are spaced too widely apart. These need to be
1601 scaled down in proportion to the font reduction. The next
1602 sub-section discusses how this is done.
1604 @node Length and thickness of objects
1605 @subsection Length and thickness of objects
1611 @cindex size, changing
1612 @cindex stem length, changing
1613 @cindex staff line spacing, changing
1615 Distances and lengths in LilyPond are generally measured in
1616 staff-spaces, the distance between adjacent lines in the staff,
1617 (or occasionally half staff spaces) while most @code{thickness}
1618 properties are measured in units of an internal property called
1619 @code{line-thickness.} For example, by default, the lines of
1620 hairpins are given a thickness of 1 unit of @code{line-thickness},
1621 while the @code{thickness} of a note stem is 1.3. Note, though,
1622 that some thickness properties are different; for example, the
1623 thickness of beams is controlled by the value of the
1624 @code{beam-thickness} property, which is measured in staff-spaces.
1626 So how are lengths to be scaled in proportion to the font size?
1627 This can be done with the help of a special function called
1628 @code{magstep} provided for exactly this purpose. It takes
1629 one argument, the change in font size (#-2 in the example above)
1630 and returns a scaling factor suitable for reducing other
1631 objects in proportion. It is used like this:
1633 @cindex alignAboveContext property, example
1634 @cindex @code{\with}, example
1635 @cindex Clef, example of overriding
1636 @cindex TimeSignature, example of overriding
1637 @cindex fontSize property, example
1638 @cindex StaffSymbol, example of overriding
1639 @cindex magstep function, example of using
1640 @cindex staff-space property, example
1641 @cindex stencil property, example
1643 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1644 \new Staff ="main" {
1651 alignAboveContext = #"main"
1655 % Reduce stem length and line spacing to match
1656 \override StaffSymbol.staff-space = #(magstep -2)
1666 Since the length of stems and many other length-related properties are
1667 always calculated relative to the value of the @code{staff-space}
1668 property these are automatically scaled down in length too. Note that
1669 this affects only the vertical scale of the ossia -- the horizontal
1670 scale is determined by the layout of the main music in order to remain
1671 synchronized with it, so it is not affected by any of these changes in
1672 size. Of course, if the scale of all the main music were changed in
1673 this way then the horizontal spacing would be affected. This is
1674 discussed later in the layout section.
1676 This, then, completes the creation of an ossia. The sizes and
1677 lengths of all other objects may be modified in analogous ways.
1679 For small changes in scale, as in the example above, the
1680 thickness of the various drawn lines such as bar lines,
1681 beams, hairpins, slurs, etc does not usually require global
1682 adjustment. If the thickness of any particular layout object
1683 needs to be adjusted this can be best achieved by overriding its
1684 @code{thickness} property. An example of changing the thickness
1685 of slurs was shown above in @ref{Properties of layout objects}.
1686 The thickness of all drawn objects (i.e., those not produced
1687 from a font) may be changed in the same way.
1690 @node Placement of objects
1691 @section Placement of objects
1694 * Automatic behavior::
1695 * Within-staff objects::
1696 * Outside-staff objects::
1700 @node Automatic behavior
1701 @subsection Automatic behavior
1703 @cindex within-staff objects
1704 @cindex outside-staff objects
1705 @cindex objects, within-staff
1706 @cindex objects, outside-staff
1708 There are some objects in musical notation that belong to
1709 the staff and there are other objects that should be
1710 placed outside the staff. These are called within-staff
1711 objects and outside-staff objects respectively.
1713 Within-staff objects are those that are located on the staff
1714 -- note heads, stems, accidentals, etc. The positions of
1715 these are usually fixed by the music itself -- they are
1716 vertically positioned on specific lines of the staff or are
1717 tied to other objects that are so positioned. Collisions of
1718 note heads, stems and accidentals in closely set chords are
1719 normally avoided automatically. There are commands and
1720 overrides which can modify this automatic behavior, as we
1723 Objects belonging outside the staff include things such as
1724 rehearsal marks, text and dynamic markings. LilyPond's rule for
1725 the vertical placement of outside-staff objects is to place them
1726 as close to the staff as possible but not so close that they
1727 collide with any other object. LilyPond uses the
1728 @code{outside-staff-priority} property to determine the order in
1729 which the objects should be placed, as follows.
1731 First, LilyPond places all the within-staff objects.
1732 Then it sorts the outside-staff objects according to their
1733 @code{outside-staff-priority}. The outside-staff objects are
1734 taken one by one, beginning with the object with the lowest
1735 @code{outside-staff-priority}, and placed so that they do not
1736 collide with any objects that have already been placed. That is,
1737 if two outside-staff grobs are competing for the same space, the
1738 one with the lower @code{outside-staff-priority} will be placed
1739 closer to the staff. If two objects have the same
1740 @code{outside-staff-priority} the one encountered first will be
1741 placed closer to the staff.
1743 In the following example all the markup texts have the same
1744 priority (since it is not explicitly set). Note that @q{Text3}
1745 is automatically positioned close to the staff again, nestling
1748 @cindex markup example
1750 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1757 Staves are also positioned, by default, as closely together as
1758 possible (subject to a minimum separation). If notes project
1759 a long way towards an adjacent staff they will force the
1760 staves further apart only if an overlap of the notation
1761 would otherwise occur. The following example demonstrates
1762 this @q{nestling} of the notes on adjacent staves:
1764 @lilypond[quote,ragged-right,verbatim]
1767 \relative c' { c4 a, }
1770 \relative c'''' { c4 a, }
1776 @node Within-staff objects
1777 @subsection Within-staff objects
1779 We have already seen how the commands @code{\voiceXXX} affect the
1780 direction of slurs, ties, fingering and everything else which depends on
1781 the direction of the stems -- see @ref{Explicitly instantiating voices}.
1782 These commands are essential when writing polyphonic music to permit
1783 interweaving melodic lines to be distinguished. But occasionally it may
1784 be necessary to override this automatic behavior. This can be done for
1785 whole sections of music or even for an individual note. The property
1786 which controls this behavior is the @code{direction} property of each
1787 layout object. We first explain what this does, and then introduce a
1788 number of ready-made commands which avoid your having to code explicit
1789 overrides for the more common modifications.
1791 Some layout objects like slurs and ties curve, bend or point
1792 either up or down; others like stems and flags also move to
1793 right or left when they point up or down. This is controlled
1794 automatically when @code{direction} is set.
1797 * The direction property::
1801 @node The direction property
1802 @unnumberedsubsubsec The @code{direction} property
1809 The following example shows in bar 1 the default behavior of stems,
1810 with those on high notes pointing down and those on low notes pointing
1811 up, followed by four notes with all stems forced down, four notes with
1812 all stems forced up, and finally four notes reverted back to the
1815 @cindex Stem, example of overriding
1816 @cindex direction property, example
1818 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
1820 \override Stem.direction = #DOWN
1822 \override Stem.direction = #UP
1824 \revert Stem.direction
1828 Here we use the constants @code{DOWN} and @code{UP}.
1829 These have the values @w{@code{-1}} and @code{+1} respectively, and
1830 these numerical values may be used instead. The value @code{0}
1831 may also be used in some cases. It is simply treated as meaning
1832 @code{UP} for stems, but for some objects it means @q{center}.
1833 There is a constant, @code{CENTER} which has the value @code{0}.
1835 However, these explicit overrides are not usually used, as there are
1836 simpler equivalent predefined commands available. Here is a table of
1837 the commonest. The meaning of each is stated where it is not obvious.
1839 @multitable @columnfractions .2 .2 .25 .35
1844 @item @code{\arpeggioArrowDown}
1845 @tab @code{\arpeggioArrowUp}
1846 @tab @code{\arpeggioNormal}
1847 @tab Arrow is at bottom, at top, or no arrow
1848 @item @code{\dotsDown}
1850 @tab @code{\dotsNeutral}
1851 @tab Direction of movement to avoid staff lines
1852 @item @code{\dynamicDown}
1853 @tab @code{\dynamicUp}
1854 @tab @code{\dynamicNeutral}
1856 @item @code{\phrasingSlurDown}
1857 @tab @code{\phrasingSlurUp}
1858 @tab @code{\phrasingSlurNeutral}
1859 @tab Note: distinct from slur commands
1860 @item @code{\slurDown}
1862 @tab @code{\slurNeutral}
1864 @item @code{\stemDown}
1866 @tab @code{\stemNeutral}
1868 @item @code{\textSpannerDown}
1869 @tab @code{\textSpannerUp}
1870 @tab @code{\textSpannerNeutral}
1871 @tab Text entered as spanner is below/above staff
1872 @item @code{\tieDown}
1874 @tab @code{\tieNeutral}
1876 @item @code{\tupletDown}
1877 @tab @code{\tupletUp}
1878 @tab @code{\tupletNeutral}
1879 @tab Tuplets are below/above notes
1882 The neutral/normal variants of these commands are implemented
1883 using @code{\revert} and may @strong{not} be
1884 preceded by @code{\once}. If you wish to limit the
1885 effect of the other commands (which are implemented using
1886 @code{\override}) to a single timestep, you can precede them with
1887 @code{\once} like you would do with explicit overrides.
1890 @unnumberedsubsubsec Fingering
1892 @cindex fingering, placement
1893 @cindex fingering, chords
1895 The placement of fingering on single notes can also be controlled
1896 by the @code{direction} property, but changing @code{direction}
1897 has no effect on chords. As we shall see, there are special
1898 commands which allow the fingering of individual notes
1899 of chords to be controlled, with the fingering being placed
1900 above, below, to the left or to the right of each note.
1902 First, here's the effect of @code{direction} on the fingering
1903 attached to single notes. The first bar shows the default
1904 behaviour, and the following two bars shows the effect of
1905 specifying @code{DOWN} and @code{UP}:
1907 @cindex Fingering, example of overriding
1908 @cindex direction property, example
1910 @lilypond[quote,verbatim,relative=2]
1912 \override Fingering.direction = #DOWN
1914 \override Fingering.direction = #UP
1918 However, overriding the @code{direction} property is not the
1919 easiest way of manually setting the fingering above or below
1920 the notes; using @code{_} or @code{^} instead of @code{-} before
1921 the fingering number is usually preferable. Here is the previous
1922 example using this method:
1924 @cindex fingering example
1926 @lilypond[quote,verbatim,relative=2]
1932 The @code{direction} property is ignored for chords, but the
1933 directional prefixes, @code{_} and @code{^} do work. By default,
1934 the fingering is automatically placed both above and below the
1935 notes of a chord, as shown:
1937 @cindex fingering example
1939 @lilypond[quote,verbatim,relative=2]
1946 but this may be overridden to manually force all or any of the
1947 individual fingering numbers above or below:
1949 @cindex fingering example
1951 @lilypond[quote,verbatim,relative=2]
1957 Even greater control over the placement of fingering of the
1958 individual notes in a chord is possible by using the
1959 @code{\set fingeringOrientations} command. The format of this
1963 @code{\set fingeringOrientations = #'([up] [left/right] [down])}
1967 @code{\set} is used because @code{fingeringOrientations} is a
1968 property of the @code{Voice} context, created and used by the
1969 @code{New_fingering_engraver}.
1971 The property may be set to a list of one to three values.
1972 It controls whether fingerings may be placed above (if
1973 @code{up} appears in the list), below (if @code{down} appears),
1974 to the left (if @code{left} appears, or to the right
1975 (if @code{right} appears). Conversely, if a location is not
1976 listed, no fingering is placed there. LilyPond takes these
1977 constraints and works out the best placement for the fingering
1978 of the notes of the following chords. Note that @code{left} and
1979 @code{right} are mutually exclusive -- fingering may be placed
1980 only on one side or the other, not both.
1982 @warning{To control the placement of the fingering of a single
1983 note using this command it is necessary to write it as a single
1984 note chord by placing angle brackets round it.}
1986 Here are a few examples:
1988 @cindex fingering example
1989 @cindex @code{\set}, example of using
1990 @cindex fingeringOrientations property, example
1992 @lilypond[quote,fragment,ragged-right,verbatim,relative=1]
1993 \set fingeringOrientations = #'(left)
1996 \set fingeringOrientations = #'(left)
1998 <c-1 e-2 g-3 b-5>4 |
1999 \set fingeringOrientations = #'(up left down)
2002 \set fingeringOrientations = #'(up left)
2004 <c-1 e-2 g-3 b-5>4 |
2005 \set fingeringOrientations = #'(right)
2011 If the fingering seems a little crowded the @code{font-size}
2012 could be reduced. The default value can be seen from the
2013 @code{Fingering} object in the IR to be @w{@code{-5}}, so let's
2016 @lilypond[quote,fragment,ragged-right,verbatim,relative=1]
2017 \override Fingering.font-size = #-7
2018 \set fingeringOrientations = #'(left)
2021 \set fingeringOrientations = #'(left)
2023 <c-1 e-2 g-3 b-5>4 |
2024 \set fingeringOrientations = #'(up left down)
2027 \set fingeringOrientations = #'(up left)
2029 <c-1 e-2 g-3 b-5>4 |
2030 \set fingeringOrientations = #'(right)
2035 @node Outside-staff objects
2036 @subsection Outside-staff objects
2038 Outside-staff objects are automatically placed to avoid collisions.
2039 There are several ways to override the automatic placement if the
2040 positioning is not optimum.
2043 * The outside-staff-priority property::
2044 * The \textLengthOn command::
2045 * Dynamics placement::
2050 @node The outside-staff-priority property
2051 @unnumberedsubsubsec The @code{outside-staff-priority} property
2053 Objects with the lower value of the @code{outside-staff-priority}
2054 property are placed nearer to the staff, and other outside-staff
2055 objects are then raised as far as necessary to avoid collisions.
2056 The @code{outside-staff-priority} is defined in the
2057 @code{grob-interface} and so is a property of all layout objects.
2058 By default it is set to @code{#f} for all within-staff objects,
2059 and to a numerical value appropriate to each outside-staff object
2060 when the object is created. The following table shows the default
2061 numerical values for some of the commonest outside-staff objects.
2065 Note the unusual names for some of the objects: spanner objects
2066 are automatically created to control the vertical positioning of
2067 grobs which (might) start and end at different musical moments, so
2068 changing the @code{outside-staff-priority} of the underlying grob
2069 will have no effect. For example, changing
2070 @code{outside-staff-priority} of the @code{Hairpin} object will
2071 have no effect on the vertical positioning of hairpins -- you must
2072 change @code{outside-staff-priority} of the associated
2073 @code{DynamicLineSpanner} object instead. This override must be
2074 placed at the start of the spanner, which might include several
2075 linked hairpins and dynamics.
2077 @multitable @columnfractions .3 .3 .3
2078 @headitem Layout Object
2080 @tab Controls position of:
2081 @item @code{RehearsalMark}
2083 @tab Rehearsal marks
2084 @item @code{MetronomeMark}
2086 @tab Metronome marks
2087 @item @code{VoltaBracketSpanner}
2090 @item @code{TextScript}
2093 @item @code{MultiMeasureRestText}
2095 @tab Markup text over full-bar rests
2096 @item @code{OttavaBracket}
2098 @tab Ottava brackets
2099 @item @code{TextSpanner}
2102 @item @code{DynamicLineSpanner}
2104 @tab All dynamic markings
2105 @item @code{BarNumber}
2108 @item @code{TrillSpanner}
2110 @tab Spanning trills
2113 Here is an example showing the default placement of some of
2116 @cindex text spanner
2117 @cindex ottava bracket
2119 @funindex \startTextSpan
2120 @funindex startTextSpan
2121 @funindex \stopTextSpan
2122 @funindex stopTextSpan
2124 @cindex TextSpanner, example of overriding
2125 @cindex bound-details property, example
2127 @lilypond[quote,fragment,ragged-right,verbatim,relative=1]
2128 % Set details for later Text Spanner
2129 \override TextSpanner.bound-details.left.text
2130 = \markup { \small \bold Slower }
2131 % Place dynamics above staff
2133 % Start Ottava Bracket
2136 % Add Dynamic Text and hairpin
2142 % Add Dynamic Text and terminate hairpin
2143 c4\ff c \stopTextSpan |
2144 % Stop Ottava Bracket
2149 This example also shows how to create Text Spanners --
2150 text with extender lines above a section of music. The
2151 spanner extends from the @code{\startTextSpan} command to
2152 the @code{\stopTextSpan} command, and the format of the
2153 text is defined by the @code{\override TextSpanner} command.
2154 For more details see @ruser{Text spanners}.
2156 It also shows how ottava brackets are created.
2158 @cindex tweaking bar number placement
2159 @cindex bar numbers, tweaking placement
2160 @cindex tweaking metronome mark placement
2161 @cindex metronome mark, tweaking placement
2162 @cindex tweaking rehearsal mark placement
2163 @cindex rehearsal marks, tweaking placement
2165 If the default values of @code{outside-staff-priority} do not give you
2166 the placing you want, the priority of any of the objects may be
2167 overridden. Suppose we would like the ottava bracket to be placed
2168 below the text spanner in the example above. All we need to do is to
2169 look up the priority of @code{OttavaBracket} in the IR or in the
2170 tables above, and reduce it to a value lower than that of a
2171 @code{TextSpanner}, remembering that @code{OttavaBracket} is created
2172 in the @code{Staff} context:
2174 @cindex TextSpanner, example of overriding
2175 @cindex bound-details property, example
2177 @lilypond[quote,fragment,ragged-right,verbatim,relative=1]
2178 % Set details for later Text Spanner
2179 \override TextSpanner.bound-details.left.text
2180 = \markup { \small \bold Slower }
2181 % Place dynamics above staff
2183 % Place following Ottava Bracket below Text Spanners
2184 \once \override Staff.OttavaBracket.outside-staff-priority = #340
2185 % Start Ottava Bracket
2190 % Add Dynamic Line Spanner
2196 c4\ff c \stopTextSpan |
2197 % Stop Ottava Bracket
2202 Note that some of these objects, in particular bar numbers,
2203 metronome marks and rehearsal marks, live by default in the
2204 @code{Score} context, so be sure to use the correct context
2205 when these are being overriden.
2207 @cindex slurs and outside-staff-priority
2208 @cindex slurs and articulations
2209 @cindex articulations and slurs
2211 Slurs by default are classed as within-staff objects, but
2212 they often appear above the staff if the notes to
2213 which they are attached are high on the staff. This can push
2214 outside-staff objects such as articulations too high, as the slur
2215 will be placed first. The @code{avoid-slur} property of the
2216 articulation can be set to @code{'inside} to bring the articulation
2217 inside the slur, but the @code{avoid-slur} property is effective
2218 only if the @code{outside-staff-priority} is also set to @code{#f}.
2219 Alternatively, the @code{outside-staff-priority} of the slur
2220 can be set to a numerical value to cause it to be placed along with
2221 other outside-staff objects according to that value. Here's an
2222 example showing the effect of the two methods:
2224 @lilypond[quote,verbatim,relative=2]
2225 c4( c^\markup { \tiny \sharp } d4.) c8 |
2227 \once \override TextScript.avoid-slur = #'inside
2228 \once \override TextScript.outside-staff-priority = ##f
2229 c4^\markup { \tiny \sharp } d4.) c8 |
2230 \once \override Slur.outside-staff-priority = #500
2231 c4( c^\markup { \tiny \sharp } d4.) c8 |
2234 Changing the @code{outside-staff-priority} can also be used to
2235 control the vertical placement of individual objects, although
2236 the results may not always be desirable. Suppose we would
2237 like @qq{Text3} to be placed above @qq{Text4} in the example
2238 under Automatic behavior, above (see @ref{Automatic behavior}).
2239 All we need to do is to look up the priority of @code{TextScript}
2240 in the IR or in the tables above, and increase the priority of
2241 @qq{Text3} to a higher value:
2243 @cindex TextScript, example of overriding
2244 @cindex outside-staff-priority property, example
2246 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
2249 \once \override TextScript.outside-staff-priority = #500
2254 This certainly lifts @qq{Text3} above @qq{Text4} but it also lifts it
2255 above @qq{Text2}, and @qq{Text4} now drops down. Perhaps this is not
2256 so good. What we would really like to do is to position all the
2257 annotation at the same distance above the staff. To do this, we
2258 clearly will need to space the notes out horizontally to make more
2259 room for the text. This is done using the @code{textLengthOn}
2262 @node The \textLengthOn command
2263 @unnumberedsubsubsec The @code{\textLengthOn} command
2265 @cindex notes, spreading out with text
2267 @funindex \textLengthOn
2268 @funindex textLengthOn
2269 @funindex \textLengthOff
2270 @funindex textLengthOff
2272 By default, text produced by markup takes up no horizontal space
2273 as far as laying out the music is concerned. The @code{\textLengthOn}
2274 command reverses this behavior, causing the notes to be spaced
2275 out as far as is necessary to accommodate the text:
2277 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
2278 \textLengthOn % Cause notes to space out to accommodate text
2285 The command to revert to the default behavior is
2286 @code{\textLengthOff}. Alternatively, @code{\once} may be used
2287 with @code{\textLengthOn} if the effect is to be limited to just a
2288 single musical moment.
2289 The corresponding spacing behavior for rehearsal marks and tempo
2290 indications is independently controlled with the commands
2291 @code{\markLengthOn} and @code{\markLengthOff}.
2293 @cindex markup text, allowing collisions
2295 Markup text will also avoid notes which project above the staff.
2296 If this is not desired, the automatic displacement upwards may
2297 be turned off by setting the priority to @code{#f}. Here's an
2298 example to show how markup text interacts with such notes.
2300 @cindex TextScript, example of overriding
2301 @cindex outside-staff-priority property, example
2303 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
2304 % This markup is short enough to fit without collision
2308 % This is too long to fit, so it is displaced upwards
2312 % Turn off collision avoidance
2313 \once \override TextScript.outside-staff-priority = ##f
2314 c,,2^"Long Text " c'' |
2317 % Turn off collision avoidance
2318 \once \override TextScript.outside-staff-priority = ##f
2319 \textLengthOn % and turn on textLengthOn
2320 c,,2^"Long Text " % Spaces at end are honored
2324 @node Dynamics placement
2325 @unnumberedsubsubsec Dynamics placement
2327 @cindex tweaking dynamics placement
2328 @cindex dynamics, tweaking placement
2330 Dynamic markings will normally be positioned beneath the
2331 staff, but may be positioned above with the @code{\dynamicUp}
2332 command. They will be positioned vertically relative to the
2333 note to which they are attached, and will float below (or above)
2334 all within-staff objects such as phrasing slurs and bar numbers.
2335 This can give quite acceptable results, as this example
2338 @lilypond[quote,fragment,ragged-right,verbatim,relative=1]
2343 bes4.~\f\< \( bes4 bes8 des4\ff\> c16 bes\! |
2344 ees,2.~\)\mf ees4 r8 |
2347 However, if the notes and attached dynamics are close
2348 together the automatic placement will avoid collisions
2349 by displacing later dynamic markings further away, but this may
2350 not be the optimum placement, as this rather artificial example
2353 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
2359 Should a similar situation arise in @q{real} music, it may be
2360 preferable to space out the notes a little further, so the dynamic
2361 markings can all fit at the same vertical distance from the staff. We
2362 were able to do this for markup text by using the @code{\textLengthOn}
2363 command, but there is no equivalent command for dynamic marks. So we
2364 shall have to work out how to do this using @code{\override} commands.
2367 @unnumberedsubsubsec Grob sizing
2370 @cindex sizing grobs
2372 First we must learn how grobs are sized. All grobs have a
2373 reference point defined within them which is used to position
2374 them relative to their parent object. This point in the grob
2375 is then positioned at a horizontal distance, @code{X-offset},
2376 and at a vertical distance, @code{Y-offset}, from its parent.
2377 The horizontal extent of the object is given by a pair of
2378 numbers, @code{X-extent}, which say where the left and right
2379 edges are relative to the reference point. The vertical extent
2380 is similarly defined by a pair of numbers, @code{Y-extent}.
2381 These are properties of all grobs which support the
2382 @code{grob-interface}.
2384 @cindex @code{extra-spacing-width}
2386 By default, outside-staff objects are given a width of zero so
2387 that they may overlap in the horizontal direction. This is done
2388 by the trick of making the leftmost extent infinity and
2389 the rightmost extent minus infinity by setting the
2390 @code{extra-spacing-width} to @code{'(+inf.0 . -inf.0)}. To
2391 ensure they do not overlap in the horizontal direction we
2392 must override this value of @code{extra-spacing-width} to give them
2393 a little extra spacing. The units are the space between two staff
2394 lines, so moving the left edge half a unit to the left and the
2395 right edge half a unit to the right should do it:
2398 \override DynamicText.extra-spacing-width = #'(-0.5 . 0.5)
2402 Let's see if this works in our previous example:
2404 @cindex DynamicText, example of overriding
2405 @cindex extra-spacing-width property, example
2408 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
2410 % Extend width by 1 staff space
2411 \override DynamicText.extra-spacing-width = #'(-0.5 . 0.5)
2416 This looks better, but maybe we would prefer the dynamic marks
2417 to be aligned along the same baseline rather than going up and
2418 down with the notes. The property to do this is
2419 @code{staff-padding} which is covered in the section on collisions
2420 (see @ref{Collisions of objects}).
2423 @node Vertical spacing
2424 @section Vertical spacing
2426 As a rule, LilyPond's vertical spacing of musical objects is pretty
2427 good. Let's see how it does with a simple song, with 2 voices and
2428 piano accompaniment:
2430 @lilypond[quote,fragment,ragged-right]
2435 \new Voice = "music" {
2441 Here are some lyrics
2444 \clef bass e'2 f e c
2459 There's nothing wrong with the default vertical spacing. However, let's
2460 assume that you're working with a publisher with some specific
2461 requirements for vertical spacing of staves and lyrics: they want
2462 the lyrics spaced away from any notes, they want the piano
2463 accompaniment spaced away from the vocal line and they want the two
2464 piano staves pushed together tightly. Let's start with the lyrics.
2466 Lyrics sit within a system, and therefore the commands to space them
2467 are found in @ruser{Flexible vertical spacing within systems}. It
2468 tells us that lyrics are @code{non-staff lines} and therefore the
2469 command to change their spacing will refer to the @code{nonstaff}
2470 property. Spacing them away from the staff to which they relate
2471 (the top line) will use the @code{relatedstaff} property. Spacing
2472 them from the lower line will use the @code{unrelatedstaff} property.
2473 The vocal parts are part of a @code{VerticalAxisGroup}, so we need to
2474 adjust its properties. Let's try it and see if it works.
2476 @lilypond[quote,fragment,ragged-right,verbatim]
2481 \new Voice = "music" {
2486 \override VerticalAxisGroup.
2487 nonstaff-relatedstaff-spacing.padding = #5
2488 \override VerticalAxisGroup.
2489 nonstaff-unrelatedstaff-spacing.padding = #5
2492 Here are some lyrics
2495 \clef bass e'2 f e c
2510 Well - yes it does, but perhaps too well. When we set the
2511 @code{padding} to 5, LilyPond adds 5 staff spaces to the distance
2512 between objects, which is too much for us here. We'll use 2.
2514 Next, let's move the piano music away from the vocal parts. The
2515 vocal music is a @code{ChoirStaff}, so we need to increase the
2516 spacing between that group of staves and the piano staff below.
2517 We'll do this by changing the @code{basic-distance} of the
2518 @code{StaffGrouper}'s @code{staffgroup-staff-spacing}.
2520 @lilypond[quote,fragment,ragged-right,verbatim]
2522 \new ChoirStaff \with {
2523 \override StaffGrouper.
2524 staffgroup-staff-spacing.basic-distance = #15
2528 \new Voice = "music" {
2533 \override VerticalAxisGroup.
2534 nonstaff-relatedstaff-spacing.padding = #2
2535 \override VerticalAxisGroup.
2536 nonstaff-unrelatedstaff-spacing.padding = #2
2539 Here are some lyrics
2542 \clef bass e'2 f e c
2557 Excellent. Now just for the last requirement to make the piano staves
2558 closer together. To do this, we again alter the properties of the
2559 @code{StaffGrouper}, but this time we're going to reduce both
2560 the @code{basic-distance} and the @code{padding}. We can do this
2563 @lilypond[quote,fragment,ragged-right,verbatim]
2565 \new ChoirStaff \with {
2566 \override StaffGrouper.
2567 staffgroup-staff-spacing.basic-distance = #15
2571 \new Voice = "music" {
2576 \override VerticalAxisGroup.
2577 nonstaff-relatedstaff-spacing.padding = #2
2578 \override VerticalAxisGroup.
2579 nonstaff-unrelatedstaff-spacing.padding = #2
2582 Here are some lyrics
2585 \clef bass e'2 f e c
2588 \new PianoStaff \with {
2589 \override StaffGrouper.staff-staff-spacing = #'(
2590 (basic-distance . 0)
2604 That's put them really close together -- but it's what
2605 the publisher wanted. They could be moved further
2606 apart by altering the @code{padding} or @code{basic-distance}
2609 There are many ways of altering vertical spacing. A key point
2610 to remember is that the spacing between objects in a
2611 @code{StaffGroup} (like @code{GrandStaff} or
2612 @code{PianoStaff} groups) is controlled by the spacing variables
2613 of the @code{StaffGrouper}. Spacing from ungrouped staves
2614 (like @code{Lyrics} and @code{Staff}) is controlled by the
2615 variables of the @code{VerticalAxisGroup}. See the
2616 @ruser{Flexible vertical spacing \paper variables} and
2617 @ruser{Flexible vertical spacing within systems} for more
2620 @node Collisions of objects
2621 @section Collisions of objects
2625 * Fixing overlapping notation::
2626 * Real music example::
2629 @node Moving objects
2630 @subsection Moving objects
2632 @cindex moving overlapping objects
2633 @cindex moving colliding objects
2634 @cindex moving colliding grobs
2635 @cindex objects, moving colliding
2636 @cindex grobs, moving colliding
2638 This may come as a surprise, but LilyPond is not perfect. Some
2639 notation elements can overlap. This is unfortunate, but in fact
2640 rather rare. Usually the need to move objects is for clarity or
2641 aesthetic reasons -- they would look better with a little more
2642 or a little less space around them.
2644 There are three main approaches to resolving overlapping
2645 notation. They should be considered in the following order:
2649 The @strong{direction} of one of the overlapping objects may
2650 be changed using the predefined commands listed above for
2651 within-staff objects (see @ref{Within-staff objects}).
2652 Stems, slurs, beams, ties, dynamics, text and tuplets may be
2653 repositioned easily in this way. The limitation is that you
2654 have a choice of only two positions, and neither may be
2658 The @strong{object properties}, which LilyPond uses when positioning
2659 layout objects, may be modified using @code{\override}. The
2660 advantages of making changes to this type of property are (a) that
2661 some other objects will be moved automatically if necessary to make
2662 room and (b) the single override can apply to all instances of the
2663 same type of object. Such properties include:
2670 This has already been covered in some detail -- see
2671 @ref{Within-staff objects}.
2674 @code{padding}, @code{right-padding}, @code{staff-padding}
2677 @cindex padding property
2678 @cindex right-padding property
2679 @cindex staff-padding property
2681 As an object is being positioned the value of its @code{padding}
2682 property specifies the gap that must be left between itself and the
2683 nearest edge of the object against which it is being positioned. Note
2684 that it is the @code{padding} value of the object @strong{being
2685 placed} that is used; the @code{padding} value of the object which is
2686 already placed is ignored. Gaps specified by @code{padding} can be
2687 applied to all objects which support the
2688 @code{side-position-interface}.
2690 Instead of @code{padding}, the placement of groups of accidentals
2691 is controlled by @code{right-padding}. This property is to be found
2692 in the @code{AccidentalPlacement} object which, note, lives in the
2693 @strong{Staff} context. In the typesetting process the note heads
2694 are typeset first and then the accidentals, if any, are added to the
2695 left of the note heads using the @code{right-padding} property to determine
2696 the separation from the note heads and between individual accidentals.
2697 So only the @code{right-padding} property of the @code{AccidentalPlacement}
2698 object has any effect on the placement of the accidentals.
2700 The @code{staff-padding} property is closely related to the
2701 @code{padding} property: @code{padding} controls the minimum amount of
2702 space between any object which supports the
2703 @code{side-position-interface} and the nearest other object (generally
2704 the note or the staff lines); @code{staff-padding} applies only to
2705 those objects which are always set outside the staff -- it controls
2706 the minimum distance from the staff to the outside-staff object.
2707 Note that @code{staff-padding} has no effect on
2708 objects that are positioned relative to the note rather than the
2709 staff, even though it may be overridden without error for such objects
2710 -- it is simply ignored.
2712 To discover which padding property is required for the object you wish
2713 to reposition, you need to return to the IR and look up the object's
2714 properties. Be aware that the padding properties might not be located
2715 in the obvious object, so look in objects that appear to be related.
2717 All padding values are measured in staff spaces. For most
2718 objects, this value is set by default to be around 1.0 or less
2719 (it varies with each object). It may be overridden if a larger
2720 (or smaller) gap is required.
2723 @code{self-alignment-X}
2725 @cindex self-alignment-X property
2727 This property can be used to align the object to the left, to
2728 the right, or to center it with respect to the parent object's
2729 reference point. It may be used with all objects which support
2730 the @code{self-alignment-interface}. In general these are objects
2731 that contain text. The values are @code{LEFT}, @code{RIGHT}
2732 or @code{CENTER}. Alternatively, a numerical value between
2733 @w{@code{-1}} and @code{+1} may be specified, where @w{@code{-1}} is
2734 left-aligned, @code{+1} is right-aligned, and numbers in between
2735 move the text progressively from left-aligned to right-aligned.
2736 Numerical values greater than @code{1} may be specified to move
2737 the text even further to the left, or less than @w{@code{-1}} to
2738 move the text even further to the right. A change of @code{1}
2739 in the value corresponds to a movement of half the text's length.
2742 @code{extra-spacing-width}
2744 @cindex extra-spacing-width property
2746 This property is available for all objects which support the
2747 @code{item-interface}. It takes two numbers, the first is added
2748 to the leftmost extent and the second is added to the rightmost
2749 extent. Negative numbers move the edge to the left, positive to
2750 the right, so to widen an object the first number must be negative,
2751 the second positive. Note that not all objects honor both
2752 numbers. For example, the @code{Accidental} object only takes
2753 notice of the first (left edge) number.
2756 @code{staff-position}
2758 @cindex staff-position property
2760 @code{staff-position} is a property of the
2761 @code{staff-symbol-referencer-interface}, which is supported by
2762 objects which are positioned relative to the staff. It specifies
2763 the vertical position of the object relative to the center line
2764 of the staff in half staff-spaces. It is useful in resolving
2765 collisions between layout objects like multi-measure rests, ties
2766 and notes in different voices.
2771 @cindex force-hshift property
2773 Closely spaced notes in a chord, or notes occurring at the same
2774 time in different voices, are arranged in two, occasionally more,
2775 columns to prevent the note heads overlapping. These are called
2776 note columns, and an object called @code{NoteColumn} is created
2777 to lay out the notes in that column.
2779 The @code{force-hshift} property is a property of a @code{NoteColumn}
2780 (actually of the @code{note-column-interface}). Changing it permits a
2781 note column to be moved in units appropriate to a note column,
2782 viz. the note head width of the first voice note. It should be used
2783 in complex situations where the normal @code{\shiftOn} commands (see
2784 @ref{Explicitly instantiating voices}) do not resolve the note
2785 conflict. It is preferable to the @code{extra-offset} property for
2786 this purpose as there is no need to work out the distance in
2787 staff-spaces, and moving the notes into or out of a @code{NoteColumn}
2788 affects other actions such as merging note heads.
2793 Finally, when all else fails, objects may be manually repositioned
2794 relative to the staff center line vertically, or by displacing them by
2795 any distance to a new position. The disadvantages are that the
2796 correct values for the repositioning have to be worked out, often by
2797 trial and error, for every object individually, and, because the
2798 movement is done after LilyPond has placed all other objects, the user
2799 is responsible for avoiding any collisions that might ensue. But the
2800 main difficulty with this approach is that the repositioning values
2801 may need to be reworked if the music is later modified. The
2802 properties that can be used for this type of manual repositioning are:
2807 @cindex extra-offset property
2809 This property applies to any layout object supporting the
2810 @code{grob-interface}. It takes a pair of numbers which specify the
2811 extra displacement in the horizontal and vertical directions.
2812 Negative numbers move the object to the left or down. The units are
2813 staff-spaces. The extra displacement is made after the typesetting of
2814 objects is finished, so an object may be repositioned anywhere without
2815 affecting anything else.
2819 @cindex positions property
2821 This is most useful for manually adjusting the slope and height
2822 of beams, slurs, and tuplets. It takes a pair of numbers
2823 giving the position of the left and right ends of the beam, slur,
2824 etc. relative to the center line of the staff. Units are
2825 staff-spaces. Note, though, that slurs and phrasing slurs cannot
2826 be repositioned by arbitrarily large amounts. LilyPond first
2827 generates a list of possible positions for the slur and by default
2828 finds the slur that @qq{looks best}. If the @code{positions}
2829 property has been overridden the slur that is closest to the
2830 requested positions is selected from the list.
2835 A particular object may not have all of these properties.
2836 It is necessary to go to the IR to look up which properties
2837 are available for the object in question.
2839 Here is a list of the objects which are most likely to be
2840 involved in collisions, together with the name of the object which
2841 should be looked up in the IR in order to discover which properties
2842 should be used to move them.
2844 @multitable @columnfractions .5 .5
2845 @headitem Object type @tab Object name
2846 @item Articulations @tab @code{Script}
2847 @item Beams @tab @code{Beam}
2848 @item Dynamics (vertically) @tab @code{DynamicLineSpanner}
2849 @item Dynamics (horizontally) @tab @code{DynamicText}
2850 @item Fingerings @tab @code{Fingering}
2851 @item Rehearsal / Text marks @tab @code{RehearsalMark}
2852 @item Slurs @tab @code{Slur}
2853 @item Text e.g. @code{^"text"} @tab @code{TextScript}
2854 @item Ties @tab @code{Tie}
2855 @item Tuplets @tab @code{TupletBracket}
2859 @node Fixing overlapping notation
2860 @subsection Fixing overlapping notation
2862 Let's now see how the properties in the previous section can
2863 help to resolve overlapping notation.
2866 * The padding property::
2867 * The right-padding property::
2868 * The staff-padding property::
2869 * The self-alignment-X property::
2870 * The staff-position property::
2871 * The extra-offset property::
2872 * The positions property::
2873 * The force-hshift property::
2876 @node The padding property
2877 @unnumberedsubsubsec The @code{padding} property
2880 @cindex fixing overlapping notation
2881 @cindex overlapping notation
2883 The @code{padding} property can be set to increase
2884 (or decrease) the distance between symbols that are printed
2885 above or below notes.
2887 @cindex Script, example of overriding
2888 @cindex padding property, example
2890 @lilypond[quote,fragment,relative=1,verbatim]
2892 \override Script.padding = #3
2896 @cindex MetronomeMark, example of overriding
2897 @cindex padding property, example
2899 @lilypond[quote,fragment,relative=1,verbatim]
2900 % This will not work, see below
2901 \override MetronomeMark.padding = #3
2905 \override Score.MetronomeMark.padding = #3
2910 Note in the second example how important it is to figure out what
2911 context handles a certain object. Since the @code{MetronomeMark}
2912 object is handled in the @code{Score} context, property changes in the
2913 @code{Voice} context will not be noticed. For more details, see
2914 @ruser{Modifying properties}.
2916 If the @code{padding} property of an object is increased when that
2917 object is in a stack of objects being positioned according to
2918 their @code{outside-staff-priority}, then that object and all
2919 objects outside it are moved.
2922 @node The right-padding property
2923 @unnumberedsubsubsec The @code{right-padding} property
2925 @cindex right-padding property
2927 The @code{right-padding} property affects the spacing between the
2928 accidental and the note to which it applies. It is not often
2929 required, but the default spacing may be wrong for certain special
2930 accidental glyphs or combination of glyphs used in some microtonal
2931 music. These have to be entered by overriding the accidental
2932 stencil with a markup containing the desired symbol(s), like this:
2934 @cindex Accidental, example of overriding
2935 @cindex text property, example
2936 @cindex stencil property, example
2937 @cindex AccidentalPlacement, example of overriding
2938 @cindex right-padding property, example
2940 @lilypond[quote,ragged-right,verbatim]
2941 sesquisharp = \markup { \sesquisharp }
2944 % This prints a sesquisharp but the spacing is too small
2945 \once \override Accidental.stencil = #ly:text-interface::print
2946 \once \override Accidental.text = #sesquisharp
2948 % This improves the spacing
2949 \once \override Score.AccidentalPlacement.right-padding = #0.6
2950 \once \override Accidental.stencil = #ly:text-interface::print
2951 \once \override Accidental.text = #sesquisharp
2957 This necessarily uses an override for the accidental stencil which
2958 will not be covered until later. The stencil type must be a
2959 procedure, here changed to print the contents of the @code{text}
2960 property of @code{Accidental}, which itself is set to be a
2961 sesquisharp sign. This sign is then moved further away from the
2962 note head by overriding @code{right-padding}.
2966 @node The staff-padding property
2967 @unnumberedsubsubsec The @code{staff-padding} property
2969 @cindex aligning objects on a baseline
2970 @cindex objects, aligning on a baseline
2972 @code{staff-padding} can be used to align objects such as dynamics
2973 along a baseline at a fixed distance from the staff, when no other
2974 notation forces them further from the staff.
2975 It is not a property of @code{DynamicText} but of
2976 @code{DynamicLineSpanner}. This is because the baseline should apply
2977 equally to @strong{all} dynamics, including those created as extended
2978 spanners. So this is the way to align the dynamic marks in the
2979 example taken from the previous section:
2981 @cindex DynamicText, example of overriding
2982 @cindex extra-spacing-width property, example
2983 @cindex DynamicLineSpanner, example of overriding
2984 @cindex staff-padding property, example
2986 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
2987 \override DynamicLineSpanner.staff-padding = #3
2992 @node The self-alignment-X property
2993 @unnumberedsubsubsec The @code{self-alignment-X} property
2995 The following example shows how to adjust the position
2996 of a string fingering object relative to a note's stem by aligning the
2997 right edge with the reference point of the parent note:
2999 @cindex StringNumber, example of overriding
3000 @cindex self-alignment-X property, example
3002 @lilypond[quote,fragment,ragged-right,verbatim,relative=3]
3005 \once \override StringNumber.self-alignment-X = #RIGHT
3009 @node The staff-position property
3010 @unnumberedsubsubsec The @code{staff-position} property
3012 @cindex object collision within a staff
3014 Multimeasure rests in one voice can collide with notes in another.
3015 Since these rests are typeset centered between the bar lines, it
3016 would require significant effort for LilyPond to figure out which
3017 other notes might collide with it, since all the current collision
3018 handling between notes and between notes and rests is done only
3019 for notes and rests that occur at the same time. Here's an
3020 example of a collision of this type:
3022 @lilypond[quote,verbatim,fragment,ragged-right, relative=1]
3023 << { c4 c c c } \\ { R1 } >>
3026 The best solution here is to move the multimeasure rest down, since the
3027 rest is in voice two. The default in @code{\voiceTwo} (i.e. in the
3028 second voice of a @code{<<@{@dots{}@} \\ @{@dots{}@}>>} construct) is
3029 that @code{staff-position} is set to -4 for MultiMeasureRest, so we need
3030 to move it, say, four half-staff spaces down to @w{@code{-8}}.
3032 @cindex MultiMeasureRest, example of overriding
3033 @cindex staff-position property, example
3035 @lilypond[quote,verbatim,fragment,ragged-right, relative=1]
3039 \override MultiMeasureRest.staff-position = #-8
3044 This is better than using, for example, @code{extra-offset},
3045 because the ledger line above the rest is inserted automatically.
3047 @node The extra-offset property
3048 @unnumberedsubsubsec The @code{extra-offset} property
3050 @cindex positioning objects
3051 @cindex positioning grobs
3052 @cindex objects, positioning
3053 @cindex grobs, positioning
3055 The @code{extra-offset} property provides complete control over the
3056 positioning of an object both horizontally and vertically.
3058 In the following example, the second fingering is moved a little to
3059 the left, and 1.8 staff space downwards:
3061 @cindex Fingering, example of overriding
3062 @cindex extra-offset property, example
3064 @lilypond[quote,fragment,relative=1,verbatim]
3067 \once \override Fingering.extra-offset = #'(-0.3 . -1.8)
3072 @node The positions property
3073 @unnumberedsubsubsec The @code{positions} property
3075 @cindex controlling tuplets, slurs, phrasing slurs, and beams manually
3076 @cindex manually controlling tuplets, slurs, phrasing slurs, and beams
3077 @cindex tuplet beams, controlling manually
3078 @cindex slurs, controlling manually
3079 @cindex phrasing slurs, controlling manually
3080 @cindex beams, controlling manually
3082 The @code{positions} property allows the vertical position and hence
3083 the slope of tuplets, slurs, phrasing slurs and beams to be controlled
3086 Here's an example in which the phrasing slur and slur collide:
3088 @lilypond[quote,verbatim,fragment,ragged-right,relative=2]
3092 @cindex PhrasingSlur, example of overriding
3093 @cindex positions property, example
3096 One possibility would be to move the two ends of the phrasing slur
3097 higher. We can try setting the left end to 2.5 staff-spaces above the
3098 centre line and the right end to 4.5 above, and LilyPond will
3099 select the phrasing slur from the candidates it has found with its
3100 end points closest to these:
3102 @lilypond[quote,verbatim,fragment,ragged-right,relative=2]
3103 \once \override PhrasingSlur.positions = #'(2.5 . 4.5)
3107 This is an improvement, but why not lower the right end of the slur
3108 a little? If you try it you'll find it can't be done in this way.
3109 That's because there are no candidate slurs lower than the one
3110 already selected, and in this case the @code{positions} property has
3111 no effect. However, ties, slurs and phrasing slurs @emph{can} be
3112 positioned and shaped very precisely when necessary. To learn how to
3113 do this, see @ruser{Modifying ties and slurs}.
3115 Here's a further example. We see that the beams
3116 collide with the ties:
3118 @lilypond[quote,verbatim,fragment,ragged-right]
3122 { c'1 ~ c'2. e'8 f' }
3124 { e''8 e'' e'' e'' e'' e'' e'' e'' f''2 g'' }
3127 { c'1 ~ c'2. e'8 f' }
3129 { e''8 e'' e'' e'' e'' e'' e'' e'' f''2 g'' }
3135 This can be resolved by manually moving both ends of the beam
3136 up from their position at 1.81 staff-spaces below the center line to,
3139 @cindex Beam, example of overriding
3140 @cindex positions property, example
3142 @lilypond[quote,verbatim,fragment,ragged-right]
3146 { c'1 ~ c'2. e'8 f' }
3149 \override Beam.positions = #'(-1 . -1)
3150 e''8 e'' e'' e'' e'' e'' e'' e'' f''2 g''
3154 { c'1 ~ c'2. e'8 f' }
3156 { e''8 e'' e'' e'' e'' e'' e'' e'' f''2 g'' }
3162 Note that the override continues to apply in the first voice of
3163 the second measure of eighth notes, but not to any of the beams in the
3166 @node The force-hshift property
3167 @unnumberedsubsubsec The @code{force-hshift} property
3169 We can now see how to apply the final corrections to the Chopin
3170 example introduced at the end of @ref{I'm hearing Voices}, which
3171 was left looking like this:
3173 @lilypond[quote,verbatim,fragment,ragged-right]
3174 \new Staff \relative c'' {
3189 The inner note of the first chord (i.e. the A-flat in the fourth
3190 Voice) need not be shifted away from the note column of the higher
3191 note. To correct this we set @code{force-hshift}, which is a property
3192 of @code{NoteColumn}, of this note to zero.
3194 In the second chord we prefer the F to line up with the A-flat and the
3195 lowest note to be positioned slightly right to avoid a collision of
3196 stems. We achieve this by setting @code{force-hshift} in the
3197 @code{NoteColumn} of the low D-flat to move it to the right by half
3200 Here's the final result:
3202 @cindex NoteColumn, example of overriding
3203 @cindex force-hshift property, example
3205 @lilypond[quote,verbatim,fragment,ragged-right]
3206 \new Staff \relative c'' {
3213 \once \override NoteColumn.force-hshift = #0.5
3219 \override NoteColumn.force-hshift = #0
3228 @node Real music example
3229 @subsection Real music example
3231 We end this section on Tweaks by showing the steps to be taken to
3232 deal with a tricky example which needs several tweaks to produce
3233 the desired output. The example has been deliberately chosen to
3234 illustrate the use of the Notation Reference to resolve unusual
3235 problems with notation. It is not representative of the more usual
3236 engraving process, so please do not let these difficulties put
3237 you off! Fortunately, difficulties like these are not very common!
3239 The example is from Chopin's Première Ballade, Op. 23, bars 6 to
3240 9, the transition from the opening Lento to Moderato.
3241 Here, first, is what we want the output to look like, but to avoid
3242 over-complicating the example too much we have left out the
3243 dynamics, fingering and pedalling.
3245 @c The following should appear as music without code
3246 @c This example should not be indexed
3247 @c line-width ensures no break
3248 @lilypond[quote,ragged-right,line-width=6\in]
3249 rhMusic = \relative c'' {
3252 \once \override Tie.staff-position = #3.5
3256 \mergeDifferentlyHeadedOn
3257 \mergeDifferentlyDottedOn
3258 bes2.^\markup { \bold "Moderato" } r8
3264 % Reposition the c2 to the right of the merged note
3265 \once \override NoteColumn.force-hshift = #1.0
3266 % Move the c2 out of the main note column
3267 % so the merge will work
3274 % Stem on the d2 must be down to permit merging
3276 % Stem on the d2 should be invisible
3277 \tweak Stem.transparent ##t
3285 \mergeDifferentlyHeadedOff
3286 \mergeDifferentlyDottedOff
3291 lhMusic = \relative c' {
3293 <d g, d>1)\arpeggio |
3300 \new Staff = "RH" <<
3304 \new Staff = "LH" <<
3313 We note first that the right hand part in the third bar
3314 requires four voices. These are the five beamed eighth notes,
3315 the tied C, the half-note D which is merged with the eighth note
3316 D, and the dotted quarter note F-sharp, which is also merged with
3317 the eighth note at the same pitch. Everything else is in a single
3318 voice, so the easiest way is to introduce these extra three voices
3319 temporarily at the time they are needed. If you have forgotten
3320 how to do this, look at @ref{I'm hearing Voices} and @ref{Explicitly
3321 instantiating voices}. Here we choose to use explicitly instantiated
3322 voices for the polyphonic passage, as LilyPond is better able to
3323 avoid collisions if all voices are instantiated explicitly in this
3326 So let us begin by entering the notes as two variables, setting up
3327 the staff structure in a score block, and seeing what LilyPond
3328 produces by default:
3330 @c line-width ensures no break
3331 @lilypond[quote,verbatim,ragged-right,line-width=6\in]
3332 rhMusic = \relative c'' {
3338 % Start polyphonic section of four voices
3340 { c,8 d fis bes a } % continuation of main voice
3354 g2. % continuation of main voice
3358 lhMusic = \relative c' {
3367 \new Staff = "RH" <<
3371 \new Staff = "LH" <<
3380 All the notes are right, but the appearance is far from
3381 satisfactory. The tie collides with the change in time signature,
3382 some notes are not merged together, and several notation elements
3383 are missing. Let's first deal with the easier things. We can
3384 easily add the left hand slur and the right hand phrasing slur,
3385 since these were all covered in the Tutorial. Doing this gives:
3387 @c line-width ensures no break
3388 @lilypond[quote,verbatim,ragged-right,line-width=6\in]
3389 rhMusic = \relative c'' {
3395 % Start polyphonic section of four voices
3397 { c,8 d fis bes a } % continuation of main voice
3411 g2.\) % continuation of main voice
3415 lhMusic = \relative c' {
3424 \new Staff = "RH" <<
3428 \new Staff = "LH" <<
3437 The first bar is now correct. The second bar contains an arpeggio and
3438 is terminated by a double bar line. How do we do these, as they have
3439 not been mentioned in this Learning Manual? This is where we need to
3440 turn to the Notation Reference. Looking up @q{arpeggio} and @q{bar
3441 line} in the index quickly shows us that an arpeggio is produced by
3442 appending @code{\arpeggio} to a chord, and a double bar line is
3443 produced by the @code{\bar "||"} command. That's easily done. We
3444 next need to correct the collision of the tie with the time signature.
3445 This is best done by moving the tie upwards. Moving objects was
3446 covered earlier in @ref{Moving objects}, which says that objects
3447 positioned relative to the staff can be moved vertically by overriding
3448 their @code{staff-position} property, which is specified in half staff
3449 spaces relative to the center line of the staff. So the following
3450 override placed just before the first tied note would move the tie up
3451 to 3.5 half staff spaces above the center line:
3453 @code{\once \override Tie.staff-position = #3.5}
3455 This completes bar two, giving:
3457 @c line-width ensures no break
3458 @lilypond[quote,verbatim,ragged-right,line-width=6\in]
3459 rhMusic = \relative c'' {
3462 \once \override Tie.staff-position = #3.5
3467 % Start polyphonic section of four voices
3469 { c,8 d fis bes a } % continuation of main voice
3483 g2.\) % continuation of main voice
3487 lhMusic = \relative c' {
3489 <d g, d>1)\arpeggio |
3496 \new Staff = "RH" <<
3500 \new Staff = "LH" <<
3509 On to bar three and the start of the Moderato section. The tutorial
3510 showed how to add bold text with the @code{\markup} command, so
3511 adding @qq{Moderato} in bold is easy. But how do we merge notes in
3512 different voices together? This is where we need to turn again to
3513 the Notation Reference for help. A search for @qq{merge} in the
3514 Notation Reference index quickly leads us to the commands for merging
3515 differently headed and differently dotted notes in
3516 @ruser{Collision resolution}. In our example we need to merge both
3517 types of note for the duration of the polyphonic section in bar 3,
3518 so using the information we find in the Notation Reference we add
3521 \mergeDifferentlyHeadedOn
3522 \mergeDifferentlyDottedOn
3526 to the start of that section and
3529 \mergeDifferentlyHeadedOff
3530 \mergeDifferentlyDottedOff
3536 @c line-width ensures no break
3537 @lilypond[quote,ragged-right,line-width=6\in]
3538 rhMusic = \relative c'' {
3541 \once \override Tie.staff-position = #3.5
3545 bes2.^\markup { \bold "Moderato" } r8
3546 \mergeDifferentlyHeadedOn
3547 \mergeDifferentlyDottedOn
3548 % Start polyphonic section of four voices
3550 { c,8 d fis bes a } % continuation of main voice
3564 \mergeDifferentlyHeadedOff
3565 \mergeDifferentlyDottedOff
3566 g2.\) % continuation of main voice
3570 lhMusic = \relative c' {
3572 <d g, d>1)\arpeggio |
3579 \new Staff = "RH" <<
3583 \new Staff = "LH" <<
3592 These overrides have merged the two F-sharp notes, but not the two
3593 on D. Why not? The answer is there in the same section in the
3594 Notation Reference -- notes being merged must have stems in
3595 opposite directions and two notes cannot be merged successfully if
3596 there is a third note in the same note column. Here the two D's
3597 both have upward stems and there is a third note -- the C. We know
3598 how to change the stem direction using @code{\stemDown}, and
3599 the Notation Reference also says how to move the C -- apply a shift
3600 using one of the @code{\shift} commands. But which one?
3601 The C is in voice two which has shift off, and the two D's are in
3602 voices one and three, which have shift off and shift on,
3603 respectively. So we have to shift the C a further level still
3604 using @code{\shiftOnn} to avoid it interfering with the two D's.
3605 Applying these changes gives:
3607 @cindex Tie, example of overriding
3608 @cindex staff-position property, example
3610 @c line-width ensures no break
3611 @lilypond[quote,verbatim,ragged-right,line-width=6\in]
3612 rhMusic = \relative c'' {
3615 \once \override Tie.staff-position = #3.5
3619 bes2.^\markup { \bold "Moderato" } r8
3620 \mergeDifferentlyHeadedOn
3621 \mergeDifferentlyDottedOn
3622 % Start polyphonic section of four voices
3624 { c,8 d fis bes a } % continuation of main voice
3627 % Move the c2 out of the main note column
3628 % so the merge will work
3633 % Stem on the d2 must be down to permit merging
3641 \mergeDifferentlyHeadedOff
3642 \mergeDifferentlyDottedOff
3643 g2.\) % continuation of main voice
3647 lhMusic = \relative c' {
3649 <d g, d>1)\arpeggio |
3656 \new Staff = "RH" <<
3660 \new Staff = "LH" <<
3669 Nearly there. Only two problems remain: The downward stem on the
3670 merged D should not be there, and the C would be better positioned
3671 to the right of the D's. We know how to do both of these from the
3672 earlier tweaks: we make the stem transparent, and move the C with
3673 the @code{force-hshift} property. Here's the final result:
3675 @cindex NoteColumn, example of overriding
3676 @cindex force-hshift property, example
3677 @cindex Stem, example of overriding
3678 @cindex transparent property, example
3680 @c line-width ensures no break
3681 @lilypond[quote,verbatim,ragged-right,line-width=6\in]
3682 rhMusic = \relative c'' {
3685 \once \override Tie.staff-position = #3.5
3689 bes2.^\markup { \bold "Moderato" } r8
3690 \mergeDifferentlyHeadedOn
3691 \mergeDifferentlyDottedOn
3692 % Start polyphonic section of four voices
3694 { c,8 d fis bes a } % continuation of main voice
3698 % Reposition the c2 to the right of the merged note
3699 \once \override NoteColumn.force-hshift = #1.0
3700 % Move the c2 out of the main note column
3701 % so the merge will work
3708 % Stem on the d2 must be down to permit merging
3710 % Stem on the d2 should be invisible
3711 \tweak Stem.transparent ##t
3719 \mergeDifferentlyHeadedOff
3720 \mergeDifferentlyDottedOff
3721 g2.\) % continuation of main voice
3725 lhMusic = \relative c' {
3727 <d g, d>1)\arpeggio |
3734 \new Staff = "RH" <<
3738 \new Staff = "LH" <<
3748 @node Further tweaking
3749 @section Further tweaking
3752 * Other uses for tweaks::
3753 * Using variables for layout adjustments::
3755 * Other sources of information::
3756 * Advanced tweaks with Scheme::
3759 @node Other uses for tweaks
3760 @subsection Other uses for tweaks
3763 * Tying notes across voices::
3764 * Simulating a fermata in MIDI::
3767 @cindex transparent property, use of
3768 @cindex objects, making invisible
3769 @cindex removing objects
3770 @cindex objects, removing
3771 @cindex hiding objects
3772 @cindex objects, hiding
3773 @cindex invisible objects
3774 @cindex objects, invisible
3776 @node Tying notes across voices
3777 @unnumberedsubsubsec Tying notes across voices
3779 @cindex tying notes across voices
3781 The following example demonstrates how to connect notes in
3782 different voices using ties. Normally, only two notes in the
3783 same voice can be connected with ties. By using two voices,
3784 with the tied notes in one of them
3786 @lilypond[quote,fragment,relative=2]
3787 << { b8~ b\noBeam } \\ { b8[ g] } >>
3791 and blanking the first up-stem in that voice, the tie appears to
3794 @cindex Stem, example of overriding
3795 @cindex transparent property, example
3797 @lilypond[quote,fragment,relative=2,verbatim]
3800 \tweak Stem.transparent ##t
3808 To make sure that the just-blanked stem doesn't squeeze the tie
3809 too much, we can lengthen the stem by setting the
3810 @code{length} to @code{8},
3812 @lilypond[quote,fragment,relative=2,verbatim]
3815 \tweak Stem.transparent ##t
3816 \tweak Stem.length #8
3825 @cindex tweak, generated from override
3826 Now for @emph{overriding} the transparency of a graphical object,
3827 we could have used the shorthand @code{\hide} as explained above.
3828 Tweaking is a different operation, affecting only properties
3829 generated from a single music expression. It turns out that we
3830 can convert overrides into tweaks using @code{\single}, making it
3831 possible to rewrite the above example as
3833 @lilypond[quote,fragment,relative=2,verbatim]
3838 \tweak Stem.length #8
3846 In this particular case, the difference to @code{\once \hide} is
3847 not apparent. It is important when there are several objects at
3848 the same point in musical time (like noteheads in a chord). In
3849 that case, @code{\once} will affect all of those objects while
3850 @code{\single} will only affect a single one, the one generated by
3851 the immediately following music expression.
3853 @node Simulating a fermata in MIDI
3854 @unnumberedsubsubsec Simulating a fermata in MIDI
3856 @cindex stencil property, use of
3857 @cindex fermata, implementing in MIDI
3859 For outside-staff objects it is usually better to override the
3860 object's @code{stencil} property rather than its @code{transparent}
3861 property when you wish to remove it from the printed output.
3862 Setting the @code{stencil} property of an object to @code{#f} will
3863 remove that object entirely from the printed output. This means it
3864 has no effect on the placement of other objects placed relative to
3867 For example, if we wished to change the metronome setting in order
3868 to simulate a fermata in the MIDI output we would not want the
3869 metronome markings to appear in the printed output, and we would
3870 not want it to influence the spacing between the two systems or
3871 the positions of adjacent annotations on the staff. So setting
3872 its @code{stencil} property to @code{#f} would be the best way.
3873 We show here the effect of the two methods:
3875 @cindex MetronomeMark, example of overriding
3876 @cindex transparent property, example
3878 @lilypond[quote,verbatim,ragged-right]
3881 % Visible tempo marking
3884 \once \hide Score.MetronomeMark
3885 % Invisible tempo marking to lengthen fermata in MIDI
3888 % New tempo for next section
3897 @cindex MetronomeMark, example of overriding
3898 @cindex stencil property, example
3900 @lilypond[quote,verbatim,ragged-right]
3903 % Visible tempo marking
3906 \once \omit Score.MetronomeMark
3907 % Invisible tempo marking to lengthen fermata in MIDI
3910 % New tempo for next section
3920 Both methods remove the metronome mark which lengthens the fermata
3921 from the printed output, and both affect the MIDI timing as
3922 required, but the transparent metronome mark in the first line
3923 forces the following tempo indication too high while the
3924 second (with the stencil removed) does not.
3930 @node Using variables for layout adjustments
3931 @subsection Using variables for layout adjustments
3933 @cindex variables, using for overrides
3934 @cindex overrides, using variables for
3935 @cindex adjustments, using variables for
3936 @cindex layout adjustments, using variables for
3938 Override commands are often long and tedious to type, and they
3939 have to be absolutely correct. If the same overrides are to be
3940 used many times it may be worth defining variables to hold them.
3942 Suppose we wish to emphasize certain words in lyrics by printing
3943 them in bold italics. The @code{\italic} and @code{\bold}
3944 commands only work within lyrics if they are embedded, together with
3945 the word or words to be modified, within a @code{\markup} block,
3946 which makes them tedious to enter. The need to embed the words
3947 themselves prevents their use in simple variables. As an
3948 alternative can we use @code{\override} and @code{\revert} commands?
3951 @code{\override Lyrics.LyricText.font-shape = #'italic}
3952 @code{\override Lyrics.LyricText.font-series = #'bold}
3954 @code{\revert Lyrics.LyricText.font-shape}
3955 @code{\revert Lyrics.LyricText.font-series}
3958 These would also be extremely tedious to enter if there were many
3959 words requiring emphasis. But we @emph{can} define these as two
3960 variables and use those to bracket the words to be emphasized.
3961 Another advantage of using variables for these overrides is that
3962 the spaces around the dot are not necessary, since they are not
3963 being interpreted in @code{\lyricmode} directly. Here's an example
3964 of this, although in practice we would choose shorter names
3965 for the variables to make them quicker to type:
3967 @cindex LyricText, example of overriding
3968 @cindex font-shape property, example
3969 @cindex font-series property, example
3971 @lilypond[quote,verbatim]
3973 \override Lyrics.LyricText.font-shape = #'italic
3974 \override Lyrics.LyricText.font-series = #'bold
3978 \revert Lyrics.LyricText.font-shape
3979 \revert Lyrics.LyricText.font-series
3982 global = { \key c \major \time 4/4 \partial 4 }
3984 SopranoMusic = \relative c' { c4 | e4. e8 g4 g | a4 a g }
3985 AltoMusic = \relative c' { c4 | c4. c8 e4 e | f4 f e }
3986 TenorMusic = \relative c { e4 | g4. g8 c4. b8 | a8 b c d e4 }
3987 BassMusic = \relative c { c4 | c4. c8 c4 c | f8 g a b c4 }
3989 VerseOne = \lyrics {
3990 E -- | ter -- nal \emphasize Fa -- ther, | \normal strong to save,
3993 VerseTwo = \lyricmode {
3994 O | \once \emphasize Christ, whose voice the | wa -- ters heard,
3997 VerseThree = \lyricmode {
3998 O | \emphasize Ho -- ly Spi -- rit, | \normal who didst brood
4001 VerseFour = \lyricmode {
4002 O | \emphasize Tri -- ni -- ty \normal of | love and pow'r
4009 \new Voice = "Soprano" { \voiceOne \global \SopranoMusic }
4010 \new Voice = "Alto" { \voiceTwo \AltoMusic }
4011 \new Lyrics \lyricsto "Soprano" { \VerseOne }
4012 \new Lyrics \lyricsto "Soprano" { \VerseTwo }
4013 \new Lyrics \lyricsto "Soprano" { \VerseThree }
4014 \new Lyrics \lyricsto "Soprano" { \VerseFour }
4018 \new Voice = "Tenor" { \voiceOne \TenorMusic }
4019 \new Voice = "Bass" { \voiceTwo \BassMusic }
4027 @subsection Style sheets
4029 The output that LilyPond produces can be heavily modified; see
4030 @ref{Tweaking output}, for details. But what if you have many
4031 input files that you want to apply your tweaks to? Or what if you
4032 simply want to separate your tweaks from the actual music? This
4033 is quite easy to do.
4035 Let's look at an example. Don't worry if you don't understand
4036 the parts with all the @code{#()}. This is explained in
4037 @ref{Advanced tweaks with Scheme}.
4039 @lilypond[quote,verbatim,ragged-right]
4041 \tweak self-alignment-X #-0.6
4042 #(make-dynamic-script
4043 #{ \markup { \dynamic mp \normal-text \italic \bold dolce } #})
4046 #(define-music-function
4047 (parser location string)
4049 #{ <>^\markup \bold \box #string #})
4053 a4.\mpdolce d8 cis4--\glissando a |
4057 g8(\! fis)-. e( d)-. cis2 |
4061 Let's do something about the @code{mpdolce} and @code{inst} definitions.
4062 They produce the output we desire, but we might want to use them in
4063 another piece. We could simply copy-and-paste them at the top of every
4064 file, but that's an annoyance. It also leaves those definitions in our
4065 input files, and I personally find all the @code{#()} somewhat ugly.
4066 Let's hide them in another file:
4069 %%% save this to a file called "definitions.ily"
4071 \tweak self-alignment-X #-0.6
4072 #(make-dynamic-script
4073 #@{ \markup @{ \dynamic mp \normal-text \italic \bold dolce @} #@})
4076 #(define-music-function
4077 (parser location string)
4079 #@{ <>^\markup \bold \box #string #@})
4082 We will refer to this file using the @code{\include} command near
4083 the top of the music file. (The extension @file{.ily} is used to
4084 distinguish this included file, which is not meant to be compiled
4085 on its own, from the main file.)
4086 Now let's modify our music (let's save this file as @file{music.ly}).
4088 @c We have to do this awkward example/lilypond-non-verbatim
4089 @c because we can't do the \include stuff in the manual.
4092 \include "definitions.ily"
4096 a4.\mpdolce d8 cis4--\glissando a |
4100 g8(\! fis)-. e( d)-. cis2 |
4104 @lilypond[quote,ragged-right]
4106 \tweak self-alignment-X #-0.6
4107 #(make-dynamic-script
4108 #{ \markup { \dynamic mp \normal-text \italic \bold dolce } #})
4111 #(define-music-function
4112 (parser location string)
4114 #{ <>^\markup \bold \box #string #})
4118 a4.\mpdolce d8 cis4--\glissando a |
4122 g8(\! fis)-. e( d)-. cis2 |
4126 That looks better, but let's make a few changes. The glissando is hard
4127 to see, so let's make it thicker and closer to the note heads. Let's
4128 put the metronome marking above the clef, instead of over the first
4129 note. And finally, my composition professor hates @q{C} time signatures,
4130 so we'd better make that @q{4/4} instead.
4132 Don't change @file{music.ly}, though. Replace our @file{definitions.ily}
4138 \tweak self-alignment-X #-0.6
4139 #(make-dynamic-script
4140 #@{ \markup @{ \dynamic mp \normal-text \italic \bold dolce @} #@})
4143 #(define-music-function
4144 (parser location string)
4146 #@{ <>^\markup \bold \box #string #@})
4151 \override MetronomeMark.extra-offset = #'(-5 . 0)
4152 \override MetronomeMark.padding = #'3
4156 \override TimeSignature.style = #'numbered
4160 \override Glissando.thickness = #3
4161 \override Glissando.gap = #0.1
4166 @lilypond[quote,ragged-right]
4168 \tweak self-alignment-X #-0.6
4169 #(make-dynamic-script
4170 #{ \markup { \dynamic mp \normal-text \italic \bold dolce } #})
4173 #(define-music-function
4174 (parser location string)
4176 #{ <>^\markup \bold \box #string #})
4181 \override MetronomeMark.extra-offset = #'(-5 . 0)
4182 \override MetronomeMark.padding = #'3
4186 \override TimeSignature.style = #'numbered
4190 \override Glissando.thickness = #3
4191 \override Glissando.gap = #0.1
4197 a4.\mpdolce d8 cis4--\glissando a |
4201 g8(\! fis)-. e( d)-. cis2 |
4205 That looks nicer! But now suppose that I want to publish this
4206 piece. My composition professor doesn't like @q{C} time
4207 signatures, but I'm somewhat fond of them. Let's copy the
4208 current @file{definitions.ily} to @file{web-publish.ily} and
4209 modify that. Since this music is aimed at producing a pdf which
4210 will be displayed on the screen, we'll also increase the
4211 overall size of the output.
4216 \tweak self-alignment-X #-0.6
4217 #(make-dynamic-script
4218 #@{ \markup @{ \dynamic mp \normal-text \italic \bold dolce @} #@})
4221 #(define-music-function
4222 (parser location string)
4224 #@{ <>^\markup \bold \box #string #@})
4226 #(set-global-staff-size 23)
4231 \override MetronomeMark.extra-offset = #'(-5 . 0)
4232 \override MetronomeMark.padding = #'3
4239 \override Glissando.thickness = #3
4240 \override Glissando.gap = #0.1
4245 @lilypond[quote,ragged-right]
4247 \tweak self-alignment-X #-0.6
4248 #(make-dynamic-script
4249 #{ \markup { \dynamic mp \normal-text \italic \bold dolce } #})
4252 #(define-music-function
4253 (parser location string)
4255 #{ <>^\markup \bold \box #string #})
4257 #(set-global-staff-size 23)
4261 \override MetronomeMark.extra-offset = #'(-5 . 0)
4262 \override MetronomeMark.padding = #'3
4265 \override Glissando.thickness = #3
4266 \override Glissando.gap = #0.1
4272 a4.\mpdolce d8 cis4--\glissando a |
4276 g8(\! fis)-. e( d)-. cis2 |
4280 Now in our music, I simply replace
4281 @code{\include "definitions.ily"} with
4282 @code{\include "web-publish.ily"}. Of course, we could make this
4283 even more convenient. We could make a @file{definitions.ily} file which
4284 contains only the definitions of @code{mpdolce} and @code{inst}, a
4285 @file{web-publish.ily} file which contains only the @code{\layout}
4286 section listed above, and a @file{university.ily} file which
4287 contains only the tweaks to produce the output that my professor
4288 prefers. The top of @file{music.ly} would then look like this:
4291 \include "definitions.ily"
4293 %%% Only uncomment one of these two lines!
4294 \include "web-publish.ily"
4295 %\include "university.ily"
4298 This approach can be useful even if you are only producing
4299 one set of parts. I use half a dozen different
4300 @q{style sheet} files for my projects. I begin every music
4301 file with @code{\include "../global.ily"}, which contains
4305 \version @w{"@version{}"}
4307 #(ly:set-option 'point-and-click #f)
4309 \include "../init/init-defs.ly"
4310 \include "../init/init-layout.ly"
4311 \include "../init/init-headers.ly"
4312 \include "../init/init-paper.ly"
4316 @node Other sources of information
4317 @subsection Other sources of information
4319 The Internals Reference documentation contains a lot of information
4320 about LilyPond, but even more information can be gathered by
4321 looking at the internal LilyPond files. To explore these, you must
4322 first find the directory appropriate to your system. The location
4323 of this directory depends (a) on whether you obtained LilyPond
4324 by downloading a precompiled binary from lilypond.org
4325 or whether you installed it from a package manager (i.e.
4326 distributed with GNU/Linux, or installed under fink or cygwin) or
4327 compiled it from source, and (b) on which operating system it is
4330 @subsubsubheading Downloaded from lilypond.org
4337 @file{@var{INSTALLDIR}/lilypond/usr/@/share/lilypond/current/}
4344 @file{@var{INSTALLDIR}/LilyPond.app/Contents/@/Resources/share/lilypond/current/}
4347 by either @code{cd}-ing into this directory from the
4348 Terminal, or control-clicking on the LilyPond application and
4349 selecting @q{Show Package Contents}.
4353 Using Windows Explorer, navigate to
4355 @file{@var{INSTALLDIR}/LilyPond/usr/@/share/lilypond/current/}
4360 @subsubsubheading Installed from a package manager or compiled from source
4363 @file{@var{PREFIX}/share/lilypond/@var{X.Y.Z}/}, where
4364 @var{PREFIX} is set by your package manager or @code{configure}
4365 script, and @var{X.Y.Z} is the LilyPond version number.
4369 Within this directory the two interesting subdirectories are
4372 @item @file{ly/} - contains files in LilyPond format
4373 @item @file{scm/} - contains files in Scheme format
4376 Let's begin by looking at some files in @file{ly/}.
4377 Open @file{ly/property-init.ly} in a text editor. The one
4378 you normally use for @code{.ly} files will be fine. This file
4379 contains the definitions of all the standard LilyPond predefined
4380 commands, such as @code{\stemUp} and @code{\slurDotted}. You will
4381 see that these are nothing more than definitions of variables
4382 containing one or a group of @code{\override} commands. For
4383 example, @code{/tieDotted} is defined to be:
4387 \override Tie.dash-period = #0.75
4388 \override Tie.dash-fraction = #0.1
4392 If you do not like the default values these predefined commands can
4393 be redefined easily, just like any other variable, at the
4394 head of your input file.
4396 The following are the most useful files to be found in
4399 @multitable @columnfractions .4 .6
4402 @item @file{ly/engraver-init.ly}
4403 @tab Definitions of engraver Contexts
4404 @item @file{ly/paper-defaults-init.ly}
4405 @tab Specifications of paper-related defaults
4406 @item @file{ly/performer-init.ly}
4407 @tab Definitions of performer Contexts
4408 @item @file{ly/property-init.ly}
4409 @tab Definitions of all common predefined commands
4410 @item @file{ly/spanner-init.ly}
4411 @tab Definitions of spanner-related predefined commands
4414 Other settings (such as the definitions of markup commands) are
4415 stored as @file{.scm} (Scheme) files. The Scheme programming
4416 language is used to provide a programmable interface into
4417 LilyPond internal operation. Further explanation of these files
4418 is currently outside the scope of this manual, as a knowledge of
4419 the Scheme language is required. Users should be warned that
4420 a substantial amount of technical knowledge or time is required
4421 to understand Scheme and these files (see @rextend{Scheme tutorial}).
4423 If you have this knowledge, the Scheme files which may be of
4426 @multitable @columnfractions .4 .6
4429 @item @file{scm/auto-beam.scm}
4430 @tab Sub-beaming defaults
4431 @item @file{scm/define-grobs.scm}
4432 @tab Default settings for grob properties
4433 @item @file{scm/define-markup-commands.scm}
4434 @tab Specify all markup commands
4435 @item @file{scm/midi.scm}
4436 @tab Default settings for MIDI output
4437 @item @file{scm/output-lib.scm}
4438 @tab Settings that affect appearance of frets, colors,
4439 accidentals, bar lines, etc
4440 @item @file{scm/parser-clef.scm}
4441 @tab Definitions of supported clefs
4442 @item @file{scm/script.scm}
4443 @tab Default settings for articulations
4447 @node Advanced tweaks with Scheme
4448 @subsection Advanced tweaks with Scheme
4450 Although many things are possible with the @code{\override} and
4451 @code{\tweak} commands, an even more powerful way of modifying
4452 the action of LilyPond is available through a programmable
4453 interface to the LilyPond internal operation. Code written in
4454 the Scheme programming language can be incorporated directly in
4455 the internal operation of LilyPond. Of course, at least a basic
4456 knowledge of programming in Scheme is required to do this, and an
4457 introduction is provided in the @rextend{Scheme tutorial}.
4459 As an illustration of one of the many possibilities, instead of
4460 setting a property to a constant it can be set to a Scheme
4461 procedure which is then called whenever that property is accessed
4462 by LilyPond. The property can then be set dynamically to a value
4463 determined by the procedure at the time it is called. In this
4464 example we color the note head in accordance with its position on
4467 @cindex x11-color function, example of using
4468 @cindex NoteHead, example of overriding
4469 @cindex color property, setting to Scheme procedure
4471 @lilypond[quote,verbatim,ragged-right]
4472 #(define (color-notehead grob)
4473 "Color the notehead according to its position on the staff."
4474 (let ((mod-position (modulo (ly:grob-property grob 'staff-position)
4477 ;; Return rainbow colors
4478 ((1) (x11-color 'red )) ; for C
4479 ((2) (x11-color 'orange )) ; for D
4480 ((3) (x11-color 'yellow )) ; for E
4481 ((4) (x11-color 'green )) ; for F
4482 ((5) (x11-color 'blue )) ; for G
4483 ((6) (x11-color 'purple )) ; for A
4484 ((0) (x11-color 'violet )) ; for B
4488 % Arrange to obtain color from color-notehead procedure
4489 \override NoteHead.color = #color-notehead
4490 a2 b | c2 d | e2 f | g2 a |
4494 Further examples showing the use of these programmable interfaces
4495 can be found in @rextend{Callback functions}.