| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| 4.6.1 Moving objects | ||
| 4.6.2 Fixing overlapping notation | ||
| 4.6.3 Real music example |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This may come as a surprise, but LilyPond is not perfect. Some notation elements can overlap. This is unfortunate, but in fact rather rare. Usually the need to move objects is for clarity or aesthetic reasons – they would look better with a little more or a little less space around them.
There are three main approaches to resolving overlapping notation. They should be considered in the following order:
\override. The
advantages of making changes to this type of property are (a) that
some other objects will be moved automatically if necessary to make
room and (b) the single override can apply to all instances of the
same type of object. Such properties include:
direction
This has already been covered in some detail – see Within-staff objects.
padding, right-padding, staff-padding
As an object is being positioned the value of its padding
property specifies the gap that must be left between itself and the
nearest edge of the object against which it is being positioned. Note
that it is the padding value of the object being
placed that is used; the padding value of the object which is
already placed is ignored. Gaps specified by padding can be
applied to all objects which support the
side-position-interface.
Instead of padding, the placement of groups of accidentals
is controlled by right-padding. This property is to be found
in the AccidentalPlacement object which, note, lives in the
Staff context. In the typesetting process the note heads
are typeset first and then the accidentals, if any, are added to the
left of the note heads using the right-padding property to determine
the separation from the note heads and between individual accidentals.
So only the right-padding property of the AccidentalPlacement
object has any effect on the placement of the accidentals.
The staff-padding property is closely related to the
padding property: padding controls the minimum amount of
space between any object which supports the
side-position-interface and the nearest other object (generally
the note or the staff lines); staff-padding applies only to
those objects which are always set outside the staff – it controls
the minimum distance from the staff to the outside-staff object.
Note that staff-padding has no effect on
objects that are positioned relative to the note rather than the
staff, even though it may be overridden without error for such objects
– it is simply ignored.
To discover which padding property is required for the object you wish to reposition, you need to return to the IR and look up the object’s properties. Be aware that the padding properties might not be located in the obvious object, so look in objects that appear to be related.
All padding values are measured in staff spaces. For most objects, this value is set by default to be around 1.0 or less (it varies with each object). It may be overridden if a larger (or smaller) gap is required.
self-alignment-X
This property can be used to align the object to the left, to
the right, or to center it with respect to the parent object’s
reference point. It may be used with all objects which support
the self-alignment-interface. In general these are objects
that contain text. The values are LEFT, RIGHT
or CENTER. Alternatively, a numerical value between
-1 and +1 may be specified, where -1 is
left-aligned, +1 is right-aligned, and numbers in between
move the text progressively from left-aligned to right-aligned.
Numerical values greater than 1 may be specified to move
the text even further to the left, or less than -1 to
move the text even further to the right. A change of 1
in the value corresponds to a movement of half the text’s length.
extra-spacing-width
This property is available for all objects which support the
item-interface. It takes two numbers, the first is added
to the leftmost extent and the second is added to the rightmost
extent. Negative numbers move the edge to the left, positive to
the right, so to widen an object the first number must be negative,
the second positive. Note that not all objects honor both
numbers. For example, the Accidental object only takes
notice of the first (left edge) number.
staff-position
staff-position is a property of the
staff-symbol-referencer-interface, which is supported by
objects which are positioned relative to the staff. It specifies
the vertical position of the object relative to the center line
of the staff in half staff-spaces. It is useful in resolving
collisions between layout objects like multi-measure rests, ties
and notes in different voices.
horizontal-shift
Within a voice, all the notes occuring at the same musical moment are
grouped into a note column, and a NoteColumn object is created
to control the horizontal positioning of that group of notes (see
“Note columns” in Explicitly instantiating voices). If
and only if two or more note columns within a single Staff
context, both with stems in the same direction, occur at the same
musical moment, the values of their horizontal-shift properties
are used to rank them and the columns in the higher ranks are
progessively offset to avoid collisions of the noteheads. This
property is set by the \voiceXXX commands and may be overridden
directly with an \override command or, more usually, by the
\shiftOn commands. Note that this property is used to
rank the note columns for off-setting - it does not specify the
magnitude of the offset, which is progressively increased in steps
based on the note head’s width for each rank. The steps are usually
of half a note head’s width, but may be a full note head’s width when
a closely spaced group of notes is involved.
force-hshift
The force-hshift property is a property of a NoteColumn
(actually of the note-column-interface). Changing it permits a
note column to be moved in situations where the note columns overlap.
Note that it has no effect on note columns that do not overlap.
It is specified in units appropriate to a note column, viz. the note
head width of the first voice note. It should be used in complex
situations where the normal \shiftOn commands (see
Explicitly instantiating voices) do not resolve the note
conflict satisfactorily. It is preferable to the extra-offset
property for this purpose as there is no need to work out the distance
in staff-spaces, and moving the notes into or out of a
NoteColumn affects other actions such as merging note heads.
extra-offsetThis property applies to any layout object supporting the
grob-interface. It takes a pair of numbers which specify the
extra displacement in the horizontal and vertical directions.
Negative numbers move the object to the left or down. The units are
staff-spaces. The extra displacement is made after the typesetting of
objects is finished, so an object may be repositioned anywhere without
affecting anything else.
positionsThis is most useful for manually adjusting the slope and height
of beams, slurs, and tuplets. It takes a pair of numbers
giving the position of the left and right ends of the beam, slur,
etc. relative to the center line of the staff. Units are
staff-spaces. Note, though, that slurs and phrasing slurs cannot
be repositioned by arbitrarily large amounts. LilyPond first
generates a list of possible positions for the slur and by default
finds the slur that “looks best”. If the positions
property has been overridden the slur that is closest to the
requested positions is selected from the list.
A particular object may not have all of these properties. It is necessary to go to the IR to look up which properties are available for the object in question.
Here is a list of the objects which are most likely to be involved in collisions, together with the name of the object which should be looked up in the IR in order to discover which properties should be used to move them.
| Object type | Object name |
|---|---|
| Articulations | Script |
| Beams | Beam |
| Dynamics (vertically) | DynamicLineSpanner |
| Dynamics (horizontally) | DynamicText |
| Fingerings | Fingering |
| Rehearsal / Text marks | RehearsalMark |
| Slurs | Slur |
Text e.g. ^"text" | TextScript |
| Ties | Tie |
| Tuplets | TupletBracket |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Let’s now see how the properties in the previous section can help to resolve overlapping notation.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
padding propertyThe padding property can be set to increase
(or decrease) the distance between symbols that are printed
above or below notes.
c'2\fermata \override Script.padding = #3 b2\fermata
% This will not work, see below \override MetronomeMark.padding = #3 \tempo 4 = 120 c'1 | % This works \override Score.MetronomeMark.padding = #3 \tempo 4 = 80 d'1 |
Note in the second example how important it is to figure out what
context handles a certain object. Since the MetronomeMark
object is handled in the Score context, property changes in the
Voice context will not be noticed. For more details, see
(notation)Modifying properties section ‘Modifying properties’ in Notation Reference.
If the padding property of an object is increased when that
object is in a stack of objects being positioned according to
their outside-staff-priority, then that object and all
objects outside it are moved.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
right-padding propertyThe right-padding property affects the spacing between the
accidental and the note to which it applies. It is not often
required, but the default spacing may be wrong for certain special
accidental glyphs or combination of glyphs used in some microtonal
music. These have to be entered by overriding the accidental
stencil with a markup containing the desired symbol(s), like this:
sesquisharp = \markup { \sesquisharp } \relative { c''4 % This prints a sesquisharp but the spacing is too small \once \override Accidental.stencil = #ly:text-interface::print \once \override Accidental.text = #sesquisharp cis4 c % This improves the spacing \once \override Score.AccidentalPlacement.right-padding = #0.6 \once \override Accidental.stencil = #ly:text-interface::print \once \override Accidental.text = #sesquisharp cis4 | }
This necessarily uses an override for the accidental stencil which
will not be covered until later. The stencil type must be a
procedure, here changed to print the contents of the text
property of Accidental, which itself is set to be a
sesquisharp sign. This sign is then moved further away from the
note head by overriding right-padding.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
staff-padding propertystaff-padding can be used to align objects such as dynamics
along a baseline at a fixed distance from the staff, when no other
notation forces them further from the staff.
It is not a property of DynamicText but of
DynamicLineSpanner. This is because the baseline should apply
equally to all dynamics, including those created as extended
spanners. So this is the way to align the dynamic marks in the
example taken from the previous section:
\override DynamicLineSpanner.staff-padding = #3 \relative { a'4\f b\mf a\p b\mp }
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
self-alignment-X propertyThe following example shows how to adjust the position of a string fingering object relative to a note’s stem by aligning the right edge with the reference point of the parent note:
\voiceOne <a''\2> \once \override StringNumber.self-alignment-X = #RIGHT <a''\2>
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
staff-position propertyMultimeasure rests in one voice can collide with notes in another. Since these rests are typeset centered between the bar lines, it would require significant effort for LilyPond to figure out which other notes might collide with it, since all the current collision handling between notes and between notes and rests is done only for notes and rests that occur at the same time. Here’s an example of a collision of this type:
<< \relative { c'4 c c c } \\ { R1 } >>
The best solution here is to move the multimeasure rest down, since the
rest is in voice two. The default in \voiceTwo (i.e. in the
second voice of a <<{…} \\ {…}>> construct) is
that staff-position is set to -6 for MultiMeasureRest, so we need
to move it, say, four half-staff spaces down to -10.
<< \relative { c'4 c c c } \\ \override MultiMeasureRest.staff-position = #-10 { R1 } >>
This is better than using, for example, extra-offset,
because the ledger line above the rest is inserted automatically.
See (notation)Engraving ties manually section ‘Engraving ties manually’ in Notation Reference for the difference between exact and inexact values.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
extra-offset propertyThe extra-offset property provides complete control over the
positioning of an object both horizontally and vertically.
In the following example, the second fingering is moved a little to the left, and 1.8 staff space downwards:
f'4-5 \once \override Fingering.extra-offset = #'(-0.3 . -1.8) f'4-5
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
positions propertyThe positions property allows the vertical position and hence
the slope of tuplets, slurs, phrasing slurs and beams to be controlled
manually.
Here’s an example in which the phrasing slur and slur collide:
\relative { a'8 \( ( a'16 ) a \) }
One possibility would be to move the two ends of the phrasing slur higher. We can try setting the left end to 2.5 staff-spaces above the centre line and the right end to 4.5 above, and LilyPond will select the phrasing slur from the candidates it has found with its end points closest to these:
\once \override PhrasingSlur.positions = #'(2.5 . 4.5) a'8 \( ( a''16 ) a'' \)
This is an improvement, but why not lower the right end of the slur
a little? If you try it you’ll find it can’t be done in this way.
That’s because there are no candidate slurs lower than the one
already selected, and in this case the positions property has
no effect. However, ties, slurs and phrasing slurs can be
positioned and shaped very precisely when necessary. To learn how to
do this, see
(notation)Modifying ties and slurs section ‘Modifying ties and slurs’ in Notation Reference.
Here’s a further example. We see that the beams collide with the ties:
{ \time 4/2 << \relative { c'1~ 2. e8 f } \\ \relative { e''8 e e e e e e e f2 g } >> << \relative { c'1~ 2. e8 f } \\ \relative { e''8 e e e e e e e f2 g } >> }
This can be resolved by manually moving both ends of the beam up from their position at 1.81 staff-spaces below the center line to, say, 1:
{ \time 4/2 << \relative { c'1~ 2. e8 f } \\ \relative { \override Beam.positions = #'(-1 . -1) e''8 e e e e e e e f2 g } >> << \relative { c'1~ 2. e8 f } \\ \relative { e''8 e e e e e e e f2 g \revert Beam.positions } >> }
Note that the override continues to apply in the second voice of the second measure of eighth notes, but not to any of the beams in the first voice, even those in the later second measure. As soon as the override should no longer apply it should be reverted, as shown.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
force-hshift propertyWe can now see how to apply the final corrections to the Chopin example introduced at the end of I’m hearing Voices, which was left looking like this:
\new Staff \relative { \key aes \major << { c''2 aes4. bes8 } \\ { <ees, c>2 des } \\ \\ { aes'2 f4 fes } >> | <c ees aes c>1 | }
The inner note of the first chord (i.e. the A-flat in the fourth
Voice) need not be shifted away from the note column of the higher
note, so we use \shiftOff.
In the second chord we prefer the F to line up with the A-flat and
the lowest note to be positioned slightly right to avoid a collision
of stems. We achieve this by setting force-hshift in the
NoteColumn of the low D-flat to move it to the right by half
a staff-space, and setting force-hshift for the F to zero.
Note that we use \once to avoid the settings propagating
beyond the immediate musical moment, although in this small example
the \once and the second \override in Voice four could
be omitted. This would not be good practice.
Here’s the final result:
\new Staff \relative { \key aes \major << { c''2 aes4. bes8 } \\ { <ees, c>2 \once \override NoteColumn.force-hshift = 0.5 des } \\ \\ { \once \shiftOff aes'2 \once \shiftOff f4 fes } >> | <c ees aes c>1 | }
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
We end this section on Tweaks by showing the steps to be taken to deal with a tricky example which needs several tweaks to produce the desired output. The example has been deliberately chosen to illustrate the use of the Notation Reference to resolve unusual problems with notation. It is not representative of the more usual engraving process, so please do not let these difficulties put you off! Fortunately, difficulties like these are not very common!
The example is from Chopin’s Première Ballade, Op. 23, bars 6 to 9, the transition from the opening Lento to Moderato. Here, first, is what we want the output to look like, but to avoid over-complicating the example too much we have left out the dynamics, fingering and pedalling.
We note first that the right hand part in the third bar requires four voices. These are the five beamed eighth notes, the tied C, the half-note D which is merged with the eighth note D, and the dotted quarter note F-sharp, which is also merged with the eighth note at the same pitch. Everything else is in a single voice, so the easiest way is to introduce these extra three voices temporarily at the time they are needed. If you have forgotten how to do this, look at I’m hearing Voices and Explicitly instantiating voices. Here we choose to use explicitly instantiated voices for the polyphonic passage, as LilyPond is better able to avoid collisions if all voices are instantiated explicitly in this way.
So let us begin by entering the notes as two variables, setting up the staff structure in a score block, and seeing what LilyPond produces by default:
rhMusic = \relative { \new Voice { r2 c''4. g8 | bes1~ | \time 6/4 bes2. r8 % Start polyphonic section of four voices << { c,8 d fis bes a } % continuation of main voice \new Voice { \voiceTwo c,8~ 2 } \new Voice { \voiceThree s8 d2 } \new Voice { \voiceFour s4 fis4. } >> | g2. % continuation of main voice } } lhMusic = \relative { r2 <c' g ees>2 | <d g, d>1 | r2. d,,4 r4 r | r4 } \score { \new PianoStaff << \new Staff = "RH" << \key g \minor \rhMusic >> \new Staff = "LH" << \key g \minor \clef "bass" \lhMusic >> >> }
All the notes are right, but the appearance is far from satisfactory. The tie collides with the change in time signature, some notes are not merged together, and several notation elements are missing. Let’s first deal with the easier things. We can easily add the left hand slur and the right hand phrasing slur, since these were all covered in the Tutorial. Doing this gives:
rhMusic = \relative { \new Voice { r2 c''4.\( g8 | bes1~ | \time 6/4 bes2. r8 % Start polyphonic section of four voices << { c,8 d fis bes a } % continuation of main voice \new Voice { \voiceTwo c,8~ 2 } \new Voice { \voiceThree s8 d2 } \new Voice { \voiceFour s4 fis4. } >> | g2.\) % continuation of main voice } } lhMusic = \relative { r2 <c' g ees>2( | <d g, d>1) | r2. d,,4 r4 r | r4 } \score { \new PianoStaff << \new Staff = "RH" << \key g \minor \rhMusic >> \new Staff = "LH" << \key g \minor \clef "bass" \lhMusic >> >> }
The first bar is now correct. The second bar contains an arpeggio and
is terminated by a double bar line. How do we do these, as they have
not been mentioned in this Learning Manual? This is where we need to
turn to the Notation Reference. Looking up ‘arpeggio’ and ‘bar
line’ in the index quickly shows us that an arpeggio is produced by
appending \arpeggio to a chord, and a double bar line is
produced by the \bar "||" command. That’s easily done. We
next need to correct the collision of the tie with the time signature.
This is best done by moving the tie upwards. Moving objects was
covered earlier in Moving objects, which says that objects
positioned relative to the staff can be moved vertically by overriding
their staff-position property, which is specified in half staff
spaces relative to the center line of the staff. So the following
override placed just before the first tied note would move the tie up
to 3.5 half staff spaces above the center line:
\once \override Tie.staff-position = #3.5
This completes bar two, giving:
rhMusic = \relative { \new Voice { r2 c''4.\( g8 | \once \override Tie.staff-position = #3.5 bes1~ | \bar "||" \time 6/4 bes2. r8 % Start polyphonic section of four voices << { c,8 d fis bes a } % continuation of main voice \new Voice { \voiceTwo c,8~ 2 } \new Voice { \voiceThree s8 d2 } \new Voice { \voiceFour s4 fis4. } >> | g2.\) % continuation of main voice } } lhMusic = \relative { r2 <c' g ees>2( | <d g, d>1)\arpeggio | r2. d,,4 r4 r | r4 } \score { \new PianoStaff << \new Staff = "RH" << \key g \minor \rhMusic >> \new Staff = "LH" << \key g \minor \clef "bass" \lhMusic >> >> }
On to bar three and the start of the Moderato section. The tutorial
showed how to add a tempo indication with the \tempo command, so
adding “Moderato” is easy. But how do we merge notes in
different voices together? This is where we need to turn again to
the Notation Reference for help. A search for “merge” in the
Notation Reference index quickly leads us to the commands for merging
differently headed and differently dotted notes in
(notation)Collision resolution section ‘Collision resolution’ in Notation Reference. In our example we need to merge both
types of note for the duration of the polyphonic section in bar 3,
so using the information we find in the Notation Reference we add
\mergeDifferentlyHeadedOn \mergeDifferentlyDottedOn |
to the start of that section and
\mergeDifferentlyHeadedOff \mergeDifferentlyDottedOff |
to the end, giving:
These overrides have merged the two F-sharp notes, but not the two
on D. Why not? The answer is there in the same section in the
Notation Reference – notes being merged must have stems in
opposite directions and two notes cannot be merged successfully if
there is a third note in the same note column. Here the two D’s
both have upward stems and there is a third note – the C. We know
how to change the stem direction using \stemDown, and
the Notation Reference also says how to move the C – apply a shift
using one of the \shift commands. But which one?
The C is in voice two which has shift off, and the two D’s are in
voices one and three, which have shift off and shift on,
respectively. So we have to shift the C a further level still
using \shiftOnn to avoid it interfering with the two D’s.
Applying these changes gives:
rhMusic = \relative { \new Voice { r2 c''4.\( g8 | \once \override Tie.staff-position = #3.5 bes1~ | \bar "||" \time 6/4 bes2.\tempo "Moderato" r8 \mergeDifferentlyHeadedOn \mergeDifferentlyDottedOn % Start polyphonic section of four voices << { c,8 d fis bes a } % continuation of main voice \new Voice { \voiceTwo % Move the c2 out of the main note column % so the merge will work c,8~ \shiftOnn c2 } \new Voice { \voiceThree % Stem on the d2 must be down to permit merging s8 \stemDown d2 } \new Voice { \voiceFour s4 fis4. } >> | \mergeDifferentlyHeadedOff \mergeDifferentlyDottedOff g2.\) % continuation of main voice } } lhMusic = \relative { r2 <c' g ees>2( | <d g, d>1)\arpeggio | r2. d,,4 r4 r | r4 } \score { \new PianoStaff << \new Staff = "RH" << \key g \minor \rhMusic >> \new Staff = "LH" << \key g \minor \clef "bass" \lhMusic >> >> }
Nearly there. Only two problems remain: The downward stem on the
merged D should not be there, and the C would be better positioned
to the right of the D’s. We know how to do both of these from the
earlier tweaks: we make the stem transparent, and move the C with
the force-hshift property. Here’s the final result:
rhMusic = \relative { \new Voice { r2 c''4.\( g8 | \once \override Tie.staff-position = #3.5 bes1~ | \bar "||" \time 6/4 bes2.\tempo "Moderato" r8 \mergeDifferentlyHeadedOn \mergeDifferentlyDottedOn % Start polyphonic section of four voices << { c,8 d fis bes a } % continuation of main voice \new Voice { \voiceTwo c,8~ % Reposition the c2 to the right of the merged note \once \override NoteColumn.force-hshift = #1.0 % Move the c2 out of the main note column % so the merge will work \shiftOnn c2 } \new Voice { \voiceThree s8 % Stem on the d2 must be down to permit merging \stemDown % Stem on the d2 should be invisible \tweak Stem.transparent ##t d2 } \new Voice { \voiceFour s4 fis4. } >> | \mergeDifferentlyHeadedOff \mergeDifferentlyDottedOff g2.\) % continuation of main voice } } lhMusic = \relative { r2 <c' g ees>2( | <d g, d>1)\arpeggio | r2. d,,4 r4 r | r4 } \score { \new PianoStaff << \new Staff = "RH" << \key g \minor \rhMusic >> \new Staff = "LH" << \key g \minor \clef "bass" \lhMusic >> >> }
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated by gub on July 13, 2020 using texi2html 1.82.
Outros idiomas: català, deutsch, español, français, italiano, 日本語, nederlands.
Sobre seleção automática de idioma.