abcjs
abcjs copied to clipboard
Equal measures width
Great work Paul. Is there a way to display all measures, regardless of their musical content, the same width?

I had another request for this. I haven't implemented it yet.
I'll see if I can get this in the next maintenance release, but I'm not sure.
Thank you Paul. I really appreciate it.
Hi Paul, is this issue implemented in the coming beta.8 version?
No, not yet. Let me look at it when I'm doing the final push. It might not be too hard. So maybe beta.9 or beta.10.
Great, thank you Paul. I will continue to follow.
Hi Paul, Well done for the ongoing work of this project in such a challenging time. I wanted to ask - is the 'equal measure width' feature has been implemented in one of the releases? (last time I checked it was beta.8). Thanks!
@paulrosen any high-level on the steps required for this? I would love to contribute a PR if you don't currently have the time to tackle this.
Thanks! I'll write up some more detailed info on this soon but the overview is: look for the function engraveTune() in abc_engraver_controller.js. You will see a call to layout(). If you compare the contents of abcTune before and after that call you will see what the layout adds. All of the work will likely be in the folder src/write/layout. Note that if you try to do stringify on the object there is a circular reference. This helps:
function replacer(key, value) {
// Filtering out properties
if (key === 'abselem') {
return 'abselem';
}
return value;
}
JSON.stringify(abcTune, replacer);
Two caveats: the layout is complicated because it needs to take multiple staves and multiple voices on a staff into consideration.
Second, I keep wanting to do some refactoring here so some of the code may change (but not any time soon - I've got a couple other things ahead of it.)
I'm willing to work with you - I can create tests because I think I can come up with some weird edge cases. If you'd like to connect on Slack I'll send you an invitation. Email me here if so: https://paulrosen.net/contact
Thanks @paulrosen, I appreciate the tips! I'll see what I can get done over the next few weeks.
It occurs to me that the complexity is figuring out where to place each item so that they line up and have the right spacing. This feature takes all the calculations out. It might make sense to leave the layout function alone and do a much simpler alternate function. The way I'd approach it is to take a short but sufficiently complex tune and see what the layout function adds, they tweak it by hand to what it should look like (probably just changing the x coordinates) then there is a unit test.
There's also one more step in supporting the directive that triggers this - what I do is a global search for a similar directive and duplicate it. I can also do that part since I can do it in a few minutes.