In the post about horizontal spacing in Fried Songs edition I have complained about a nasty bug in LilyPond horizontal spacing (issue 3304), which was causing us a lot of trouble in pieces that contained a lot of triplets. I am extremely happy to announce that the bug has been fixed by Keith OHara!
A little background
When calculating distances between notes, LilyPond uses a metaphor of springs and “compressing force”. First, virtual spring objects are inserted between consecutive notes in the score; the stiffness of these springs (as well as their minimal and optimal lengths) is related to the duration of the notes. After the line-breaking is decided (i.e. after it’s known what measures will be in which system), LilyPond stretches the music until all springs are fully extended and then loosens them until the desired line width is reached.
Now, when different voices contain unequal subdivisions (for example one instrument plays quavers, and another plays quaver triplets) some springs are split (i.e. one longer spring is replaced with two shorter ones). The problem was that these smaller springs didn’t behave the same during compressing as the bigger springs they replaced, which resulted in uneven spacing of some notes (it was especially visible when the music was compressed or stretched a lot):
It was possible to noticeably improve the results by enabling
uniform-stretching option, but it had some unwanted side-effects (so it couldn’t be enabled by default).
Fortunately, Keith managed to change this behaviour, so now this example is rendered as follows (by default!):
Also, the triplet-intense opus 7-1 from Fried Edition, which was giving me some headaches before, has improved dramatically:
Keith’s fix not only makes the spacing more pleasing to the eye – it also significantly improves legibility of polyphonic rhythms in situations like this:
And an extreme example – the music here is compressed so much that before Keith’s adjustments the spacing was completely wrong (notes that aren’t simultaneous had the same horizontal position, ugh!):
Now note placement is quite acceptable (given how extremely limited the available space is):
I have to say that I am very happy to see this change – this was probably the most serious horizontal spacing bug LilyPond had. There are a few other things that should still be improved, but generally speaking horizontal spacing in LilyPond is now in a quite good condition 🙂
Since the fix was applied already after we released stable 2.18 version, it is now available only in the development branch (2.19) – however, it is possible that it will be backported to the 2.18.2 stable version, which should be released in the next few weeks.
I’d like to end this post with a big THANK YOU to Keith 🙂 This is really awesome!