LilyPond Beginnershandleiding
LilyPond Beginnershandleiding
LilyPond Beginnershandleiding
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Hoofdstuk 4: Tweaking output 117<br />
<br />
<br />
8 9<br />
f ff<br />
mf<br />
<br />
However, if the notes and attached dynamics are close together the automatic placement will<br />
avoid collisions by displacing later dynamic markings further away, but this may not be the<br />
optimum placement, as this rather artificial example shows:<br />
\dynamicUp<br />
a4\f b\mf c\mp b\p<br />
<br />
mp<br />
p<br />
<br />
f<br />
mf<br />
Should a similar situation arise in ‘real’ music, it may be preferable to space out the notes a<br />
little further, so the dynamic markings can all fit at the same vertical distance from the staff.<br />
We were able to do this for markup text by using the \textLengthOn command, but there is<br />
no equivalent command for dynamic marks. So we shall have to work out how to do this using<br />
\override commands.<br />
Grob sizing<br />
First we must learn how grobs are sized. All grobs have a reference point defined within them<br />
which is used to position them relative to their parent object. This point in the grob is then<br />
positioned at a horizontal distance, X-offset, and at a vertical distance, Y-offset, from its<br />
parent. The horizontal extent of the object is given by a pair of numbers, X-extent, which say<br />
where the left and right edges are relative to the reference point. The vertical extent is similarly<br />
defined by a pair of numbers, Y-extent. These are properties of all grobs which support the<br />
grob-interface.<br />
By default, outside-staff objects are given a width of zero so that they may overlap in the<br />
horizontal direction. This is done by the trick of adding infinity to the leftmost extent and minus<br />
infinity to the rightmost extent by setting the extra-spacing-width to '(+inf.0 . -inf.0).<br />
So to ensure they do not overlap in the horizontal direction we must override this value of<br />
extra-spacing-width to '(0 . 0) so the true width shines through. This is the command to<br />
do this for dynamic text:<br />
\override DynamicText.extra-spacing-width = #'(0 . 0)<br />
Let’s see if this works in our previous example:<br />
\dynamicUp<br />
\override DynamicText.extra-spacing-width = #'(0 . 0)<br />
a4\f b\mf c\mp b\p |<br />
<br />
mp<br />
<br />
f<br />
mf<br />
p<br />
<br />
Well, it has certainly stopped the dynamic marks being displaced, but two problems remain.<br />
The marks should be spaced a little further apart and it would be better if they were all the<br />
same distance from the staff. We can solve the first problem easily. Instead of making the<br />
extra-spacing-width zero we could add a little more to it. The units are the space between<br />
two staff lines, so moving the left edge half a unit to the left and the right edge half a unit to<br />
the right should do it: