abcjs icon indicating copy to clipboard operation
abcjs copied to clipboard

Equal measures width

Open yoavkadshai opened this issue 5 years ago • 10 comments

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

width

yoavkadshai avatar Dec 08 '19 14:12 yoavkadshai

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.

paulrosen avatar Dec 11 '19 10:12 paulrosen

Thank you Paul. I really appreciate it.

yoavkadshai avatar Dec 11 '19 10:12 yoavkadshai

Hi Paul, is this issue implemented in the coming beta.8 version?

yoavkadshai avatar Mar 17 '20 22:03 yoavkadshai

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.

paulrosen avatar Mar 19 '20 23:03 paulrosen

Great, thank you Paul. I will continue to follow.

yoavkadshai avatar Mar 22 '20 13:03 yoavkadshai

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!

yoavkadshai avatar Feb 23 '21 18:02 yoavkadshai

@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.

sammarks avatar Jan 26 '22 22:01 sammarks

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

paulrosen avatar Jan 27 '22 13:01 paulrosen

Thanks @paulrosen, I appreciate the tips! I'll see what I can get done over the next few weeks.

sammarks avatar Jan 27 '22 14:01 sammarks

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.

paulrosen avatar Jan 28 '22 23:01 paulrosen