Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support complex formatting #198

Merged
merged 6 commits into from
Jan 6, 2024
Merged

Support complex formatting #198

merged 6 commits into from
Jan 6, 2024

Conversation

jaredjj3
Copy link
Collaborator

@jaredjj3 jaredjj3 commented Jan 5, 2024

This PR fixes #189 by fixing how divisions are tracked when creating voices.

vexml

image

osmd

image

MuseScore 4

image

Guitar Pro 7

image

@jaredjj3 jaredjj3 self-assigned this Jan 5, 2024
@jaredjj3
Copy link
Collaborator Author

jaredjj3 commented Jan 5, 2024

For the second and third staves, if I render only the first or only the second voice of each stave, the formatting is correct. There must be a weird interaction between the voices that I'm not accounting for.

first voice only for staves 2 and 3

image

second voice only for staves 2 and 3

image

@jaredjj3
Copy link
Collaborator Author

jaredjj3 commented Jan 5, 2024

vexflow.Voice.setStrict(true) hints at the problem.

16:59:16.416 (1116px) Error: [RuntimeError] IncompleteVoice: Voice does not have enough notes.

This is what @sschmidTU was talking about in #162 (comment). Right now, I'm ignoring notes with [print-object="no"], but this is yielding the wrong result.

Instead of completely ignoring the notes with [print-object="no"], I'm going to update the voice generation algorithm to use rendering.GhostNote instead, then post the result.

@jaredjj3
Copy link
Collaborator Author

jaredjj3 commented Jan 5, 2024

I still get the incorrect result and vexflow also complains if I set the voice strict mode to true. However, I think I'm moving in the right direction.

image

Ultimately, I'm going to revisit the voice generation algorithm and I'm going to make vexml try its best to fill gaps with GhostNote objects. If there are too many notes, it's infeasible to try to pick which notes to cull out. That's ok, because I want to be able to support measures with invalid beats to be editor friendly, where invalid measures would be a common occurrence.

@jaredjj3
Copy link
Collaborator Author

jaredjj3 commented Jan 5, 2024

Looking at the beats for each voice's entries helps illuminate the problem:

voiceId 1: (start: 0, end: 2),(start: 2, end: 4),(start: 4, end: 5),(start: 5, end: 6)
voiceId 3: (start: 2, end: 3),(start: 3, end: 4),(start: 4, end: 5),(start: 5, end: 6)
voiceId 5: (start: -6, end: -4),(start: -4, end: -2),(start: -2, end: -1),(start: -1, end: 0)
voiceId 7: (start: -4, end: -3),(start: -3, end: -2),(start: -2, end: -1),(start: -1, end: 0)

Voices 1 and 3 seem correct. Voices 5 and 7 are definitely invalid — it looks like they're offset by 6 beats. It might be the way vexml is handling <backup> elements...

@jaredjj3
Copy link
Collaborator Author

jaredjj3 commented Jan 6, 2024

Clamping the voice entry divisions to zero produces the correct result in terms of formatting. The next thing to figure out is if the rest notes are being rendered according to the <display-step> and <display-octave>. They should look like OSMD's rendering.

vexml

image

osmd

image

@jaredjj3 jaredjj3 marked this pull request as ready for review January 6, 2024 03:00
@jaredjj3 jaredjj3 merged commit f5717aa into master Jan 6, 2024
1 check passed
@jaredjj3 jaredjj3 deleted the sarabande branch January 6, 2024 03:02
@jaredjj3
Copy link
Collaborator Author

jaredjj3 commented Jan 6, 2024

Looks like the rests are rendering in the correct place according to <display-step> and <display-octave>.

@rvilarl
Copy link
Collaborator

rvilarl commented Jan 6, 2024

Looks like the rests are rendering in the correct place according to <display-step> and <display-octave>.

@jaredjj3 have you tried alignRests: true as option to format? The second # on the second voice is also not needed.

@jaredjj3
Copy link
Collaborator Author

jaredjj3 commented Jan 6, 2024

I just tried that formatting option, but I get the same result. Any other hints?

@rvilarl
Copy link
Collaborator

rvilarl commented Jan 6, 2024

I will have a look.

@sschmidTU
Copy link

sschmidTU commented Jan 8, 2024

This is what @sschmidTU was talking about in #162 (comment). Right now, I'm ignoring notes with [print-object="no"], but this is yielding the wrong result.

Instead of completely ignoring the notes with [print-object="no"], I'm going to update the voice generation algorithm to use rendering.GhostNote instead, then post the result.

Didn't you want to just render the notes with invisible color, like I recommended? Then they can be made visible instantly via SVG (setting the color), and there will also be no issues with using GhostNotes. Just a question out of curiosity :)

@jaredjj3
Copy link
Collaborator Author

jaredjj3 commented Jan 8, 2024

I experimented with transparent StaveNotes as you suggested first, but then I realized that they are functionally acting the same as the GhostNotes that come from different voices when applying <backup> and <forward> elements. It also seemed that GhostNote objects only need a subset of StaveNote data, so I wanted to keep things slim until something else warrants otherwise. I may end up doing what you originally suggested later on.

@rvilarl
Copy link
Collaborator

rvilarl commented Jan 8, 2024

I missed that.

'note.renderOptions.draw = false should make any note invisible.

@rvilarl
Copy link
Collaborator

rvilarl commented Jan 19, 2024

@jaredjj3 did you see my comment above?

@jaredjj3
Copy link
Collaborator Author

Ah, now I have. Does GhostNote offer any advantage over a StaveNote using note.renderOptions.draw = false?

@rvilarl
Copy link
Collaborator

rvilarl commented Jan 19, 2024

I do not know. @ronyeh can you help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] (v0.0.0): <Sarabande measure 8>
3 participants