Vexflow: Poor horizontal spacing - Basic combinations of durations are very uneven

Created on 14 Aug 2016  路  12Comments  路  Source: 0xfe/vexflow

Examples:

image

image

image

bug

Most helpful comment

Latest update is even better, and I have a pretty good idea for dealing with the fine tuning. But there are some cases where the formatter makes things worse, and I'm looking into that.

screen shot 2016-08-15 at 4 20 44 pm

screen shot 2016-08-15 at 4 38 11 pm

All 12 comments

Worth looking at this:

"Algorithms and Data Structures for a Music Notation System based on GUIDO Music Notation"
Specifically the section starting on page 85: "Spacing, Line Breaking, and Page Filling'
http://tuprints.ulb.tu-darmstadt.de/epda/000265/kai_renz_diss.pdf

Ugh... not sure why that's happening. I'll look into it.

Okay, I think I know what's going on.

I've got a better formatter coming -- doesn't fix this specific issue, but does fix a lot of other ones. Also, it's much simpler.

I pushed a new formatter that works much better, but there's still a fundamental issue with symmetry when you have to align voices that have overlapping odd rhythms. I have two ideas for algorithms to deal with this -- one is a simple iterative technique, but slow, and the other is quite complex, but fast. :-/

I need to think this through a bit.

It's quite a hard problem.

I think lilypond uses a constraint solver for horizontal spacing.

Some PDF's are available that describe algorithms:

"An Improved Algorithm for Spacing a Line of Music"
http://quod.lib.umich.edu/cgi/p/pod/dod-idx/improved-algorithm-for-spacing-a-line-of-music.pdf?c=icmc;idno=bbp2372.2002.097

"A New Algorithm for Horizontal Spacing of Printed Music"
http://quod.lib.umich.edu/cgi/p/pod/dod-idx/new-algorithm-for-horizontal-spacing-of-printed-music.pdf?c=icmc;idno=bbp2372.1995.032

Taken from earlier, same author as previous link:
"Algorithms and Data Structures for a Music Notation System based on GUIDO Music Notation"
Specifically the section starting on page 85: "Spacing, Line Breaking, and Page Filling'
http://tuprints.ulb.tu-darmstadt.de/epda/000265/kai_renz_diss.pdf

Thanks, I was just reading the section from the first PDF you sent (thanks!) I noticed that the current spacing algorithm performs a little like the Sibelius example (which isn't great.)

Sibelius

screen shot 2016-08-14 at 7 51 20 pm

Vexflow

screen shot 2016-08-14 at 7 57 07 pm

I added some code to export and plot formatter decisions, in particular the gaps between ticks, which I'm going to use this to build the iterative algorithm. This specific test has about 82 pixels of freedom in aggregate, and we should be able to redistribute those pixels to format the notation more evenly.

screen shot 2016-08-15 at 9 46 55 am

Also note that this is a particularly complex case -- typical cases should have more pixels of freedom.

I got the iterative formatter working. It's not perfect, but it's much better:

Before

screen shot 2016-08-15 at 2 23 41 pm

After

screen shot 2016-08-15 at 2 23 19 pm

Progression

Here you can see how the loss is reduced through each iteration. (Higher loss = uglier.)

screen shot 2016-08-15 at 2 24 14 pm

Awesome! That's way better!

Latest update is even better, and I have a pretty good idea for dealing with the fine tuning. But there are some cases where the formatter makes things worse, and I'm looking into that.

screen shot 2016-08-15 at 4 20 44 pm

screen shot 2016-08-15 at 4 38 11 pm

This looks very good from my perspective. Congrats!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

graciano picture graciano  路  4Comments

devboell picture devboell  路  6Comments

jeroenlammerts picture jeroenlammerts  路  3Comments

gristow picture gristow  路  5Comments

gciluffo picture gciluffo  路  4Comments