5.4.2 Within-staff objects

We have already seen how the commands \voiceXXX affect the direction of slurs, ties, fingering and everything else which depends on the direction of the stems – see Explicitly instantiating voices. These commands are essential when writing polyphonic music to permit interweaving melodic lines to be distinguished. But occasionally it may be necessary to override this automatic behavior. This can be done for whole sections of music or even for an individual note. The property which controls this behavior is the direction property of each layout object. We first explain what this does, and then introduce a number of ready-made commands which avoid your having to code explicit overrides for the more common modifications.

Some layout objects like slurs and ties curve, bend or point either up or down; others like stems and flags also move to right or left when they point up or down. This is controlled automatically when direction is set.


The direction property

The following example shows the default positioning of slurs in the first bar, with slurs starting on high notes positioned above the notes and those starting on low notes positioned below, followed by a bar with both slurs forced down, a bar with both slurs forced up, and finally a bar with both slurs reverted back to the default behavior.

a'4( g') c''( a') |
\override Slur.direction = #DOWN
a'4( g') c''( a') |
\override Slur.direction = #UP
a'4( g') c''( a') |
\revert Slur.direction
a'4( g') c''( a') |

[image of music]

Here we have used the constants DOWN and UP. These have the values -1 and +1 respectively, and these numerical values may be used instead. The value 0 may also be used in some cases. It is simply treated as meaning UP for slurs, but for some objects it means ‘center’. There is a constant, CENTER which has the value 0.

However, these explicit overrides are not usually used, as there are simpler equivalent predefined commands available. Here is a table of the commonest. The meaning of each is stated where it is not obvious.

Down/LeftUp/RightRevertEffect
\arpeggioArrowDown\arpeggioArrowUp\arpeggioNormalArrow is at bottom, at top, or no arrow
\dotsDown\dotsUp\dotsNeutralDirection of movement to avoid staff lines
\dynamicDown\dynamicUp\dynamicNeutral
\phrasingSlurDown\phrasingSlurUp\phrasingSlurNeutralNote: distinct from slur commands
\slurDown\slurUp\slurNeutral
\stemDown\stemUp\stemNeutral
\textSpannerDown\textSpannerUp\textSpannerNeutralText entered as spanner is below/above staff
\tieDown\tieUp\tieNeutral
\tupletDown\tupletUp\tupletNeutralTuplets are below/above notes

The neutral/normal variants of these commands are implemented using \revert and these may not be preceded by \once. If you wish to limit the effect of the other commands (which are implemented using \override) to a single timestep, you can precede them with \once like you would do with explicit overrides.

Or, if just a single layout object needs to be forced up or down, the direction indicators, ^ or _, may be used:

a'4( g') c''( a') |
a'4^( g') c''_( a') |

[image of music]


Fingering

The placement of fingering on single notes can also be controlled by the direction property, but changing direction has no effect on chords. As we shall see, there are special commands which allow the fingering of individual notes of chords to be controlled, with the fingering being placed above, below, to the left or to the right of each note.

First, here’s the effect of direction on the fingering attached to single notes. The first bar shows the default behavior, and the following two bars shows the effect of specifying DOWN and UP:

\relative {
  c''4-5 a-3 f-1 c'-5 |
  \override Fingering.direction = #DOWN
  c4-5 a-3 f-1 c'-5 |
  \override Fingering.direction = #UP
  c4-5 a-3 f-1 c'-5 |
}

[image of music]

However, overriding the direction property is not the easiest way of manually setting the fingering above or below the notes; using _ or ^ instead of - before the fingering number is usually preferable. Here is the previous example using this method:

\relative {
  c''4-5 a-3 f-1 c'-5 |
  c4_5 a_3 f_1 c'_5 |
  c4^5 a^3 f^1 c'^5 |
}

[image of music]

The direction property is ignored for chords, but the directional prefixes, _ and ^ do work. By default, the fingering is automatically placed both above and below the notes of a chord, as shown:

\relative {
  <c''-5 g-3>4
  <c-5 g-3 e-2>4
  <c-5 g-3 e-2 c-1>4
}

[image of music]

but this may be overridden to manually force all or any of the individual fingering numbers above or below:

\relative {
  <c''-5 g-3 e-2 c-1>4
  <c^5 g_3 e_2 c_1>4
  <c^5 g^3 e^2 c_1>4
}

[image of music]

Even greater control over the placement of fingering of the individual notes in a chord is possible by using the \set fingeringOrientations command. The format of this command is:

\set fingeringOrientations = #'([up] [left/right] [down])

\set is used because fingeringOrientations is a property of the Voice context, created and used by the New_fingering_engraver.

The property may be set to a list of one to three values. It controls whether fingerings may be placed above (if up appears in the list), below (if down appears), to the left (if left appears, or to the right (if right appears). Conversely, if a location is not listed, no fingering is placed there. LilyPond takes these constraints and works out the best placement for the fingering of the notes of the following chords. Note that left and right are mutually exclusive – fingering may be placed only on one side or the other, not both.

Note: To control the placement of the fingering of a single note using this command it is necessary to write it as a single note chord by placing angle brackets round it.

Here are a few examples:

\relative {
  \set fingeringOrientations = #'(left)
  <f'-2>4
  <c-1 e-2 g-3 b-5>4
  \set fingeringOrientations = #'(left)
  <f-2>4
  <c-1 e-2 g-3 b-5>4 |
  \set fingeringOrientations = #'(up left down)
  <f-2>4
  <c-1 e-2 g-3 b-5>4
  \set fingeringOrientations = #'(up left)
  <f-2>4
  <c-1 e-2 g-3 b-5>4 |
  \set fingeringOrientations = #'(right)
  <f-2>4
  <c-1 e-2 g-3 b-5>4
}

[image of music]

If the fingering seems a little crowded the font-size could be reduced. The default value can be seen from the Fingering object in the IR to be -5, so let’s try -7:

\relative {
  \override Fingering.font-size = #-7
  \set fingeringOrientations = #'(left)
  <f'-2>4
  <c-1 e-2 g-3 b-5>4
  \set fingeringOrientations = #'(left)
  <f-2>4
  <c-1 e-2 g-3 b-5>4 |
  \set fingeringOrientations = #'(up left down)
  <f-2>4
  <c-1 e-2 g-3 b-5>4
  \set fingeringOrientations = #'(up left)
  <f-2>4
  <c-1 e-2 g-3 b-5>4 |
  \set fingeringOrientations = #'(right)
  <f-2>4
  <c-1 e-2 g-3 b-5>4
}

[image of music]


LilyPond — Learning Manual v2.23.82 (development-branch).