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

fix #304353: melisma line overlaps next syllable | collect_artifacts #6081

Merged
merged 1 commit into from
Jun 2, 2020

Conversation

MarcSabatella
Copy link
Contributor

Resolves: https://musescore.org/en/node/304353

Melisma lines are spanners and therefore not laid out until
well after note spacing and measure widths have been settled.
This means there is no way for the melisma line to influence spacing.
And yet, it needs to, if we want to avoid potential collisions.

Because we cannot use the melisma line itself to affect spacing,
this code borrows the approach used for lyrics themselves:
calling addHorizontalSpacing() to reserve space for the melisma line
when calculating the shape of the ChordRest.

In order to do this, we need to know if a ChordRestr ends a melisma.
So I have added a helper function, isMelismaEnd(), to check this.
I also fixed a couple of issues in the calculation
of the length of the melisma line.
One was that we used the width of the start rather than end note
(in cases where the next note also has a lyric, which is common).
Another is that we were deliberately overshooting
the right edge of the end note,
whereas Gould says to end at the note.

Currently a WIP. Functionally it is what I expect.
But I left TODO's in the code for clean up,
which I will do once there is buy-in on the results.

@MarcSabatella MarcSabatella added the work in progress not finished work or not addressed review label May 12, 2020
@@ -851,8 +857,10 @@ QPointF SLine::linePos(Grip grip, System** sys) const
extendToEnd = false;
}
}
ChordRest* right = extendToEnd ? cr : toChordRest(startElement());
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe better #else ... #endif?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will keep that in mind if I keep this code at all.

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented May 13, 2020

Looking at the vtests, lyrics-8 before:
lyrics-8-ref
and after:
lyrics-8-1
Melisma now ends with the right edge of the note head, but actually here should end at the right edge of the augmentation dot IMHO. Itz didn't do that before, but ended between notehead and dot, but that does look better already I think?

The lyrics-2 diff:
lyrics-2-diff
shows quite a lot of offsets, into either direction so they level out at the end

@MarcSabatella
Copy link
Contributor Author

For the dots, I guess the only reason the melisma appeared to (partially) cover them before was that extra overshoot. Probably I can extend the melisma line to cover the dots completely, but I note Gould does not do this in her examples (she doesn't discuss it explicitly), and doing so could possibly make differences like we see in lyrics-2 bigger / more common. So I am inclined not to cover the dot without a really good reason to.

The difference in spacing in lyrics-2 is the sort of thing that is to be expected based on how this algorithm works - the whole point is to alter spacing. I wish it didn't affect cases where there was no overlap, but it does for pretty much the same reason that, for example, adding an accidental affects spacing even when it doesn't seem like it should.

That said, I do think I can reduce the effect of this by not reserving quite so much horizontal space. I only need a thin barrier at the right edge, not the entire width of the note.

I will be very interesting to know if you can try the artifact on one of your collections to see if you notice issues with spacing changes causing measure not to fit on a system, etc. Some amount of that may be unavoidable - there is no way to fix the overlap without adding space - but I am curious how big a difference it makes in practice.

@Jojo-Schmitz
Copy link
Contributor

Fair enough. Now I'd just need to find a score of mine that does have this problem to check whether your PR solves it ;-)

return false;
}
}
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this line unreachable? The only way the above while loop ends is by returning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes :-). This code is just temporary, I hope to replace it with code that doesn’t need to loop in this way at all, using the approach mentioned in the TODO

@MarcSabatella MarcSabatella removed the work in progress not finished work or not addressed review label May 13, 2020
@MarcSabatella
Copy link
Contributor Author

I have updated the code and removed the WIP label.

The basic approach hasn't changed, but the way I identify whether a note ends a melisma or not has. Originally it was just a brute force search backwards for the previous lyric and seeing if it had a melisma that ends here. It got the job done but it's terribly expensive to do this each time we needed a chordrest shape. So I knew all along I'd need to replace it.

Current version uses a flag _melismaEnd we set while laying out a lyric - find the end note, mark it. Then when we need to check if a note is melisma end, we can just check that flag. Only complication is clearing the flag when necessary. This can happen if we remove a melisma line or change its length. So I have code to do both.

Along the way I fixed a couple other glitches that got in my way. In addition to the ones already mentioned in calculating the length of the melisma line, it turns out we weren't resetting the alignment of a lyric to centered when removing the melisma line (by editing the lyric and pressing space). Same for hyphenated melismas. This would fix itself on reload of the score.

More testing and review definitely welcome, but as far as I know right now, this code works and is in the shape I would want it to be in.

@MarcSabatella
Copy link
Contributor Author

MarcSabatella commented May 13, 2020

I'm still not understanding the process for tests. Last time I was able to see for myself which had diffs. Somehow I'm not seeing that info this time?

But, I do see other test failures I need to investigate...

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented May 14, 2020

The Travis CI mtest failures are due to crashes, not die to differences in output
For the Gihub vtests you can see the diffs in that artifact

@MarcSabatella
Copy link
Contributor Author

vtest "failures" are to be expected, the direct result of my improvements.

@Jojo-Schmitz
Copy link
Contributor

Shouldn't these commits get squashed?

@MarcSabatella
Copy link
Contributor Author

Maybe, at some point it seems like we stopped doing that?

@anatoly-os
Copy link
Contributor

@MarcSabatella we leave the commits separated if they solve different issues, or they are semantically separated. In your case, all commits relate to fixing one issue. So, please squash them.

Resolves: https://musescore.org/en/node/304353

Melisma lines are spanners and therefore not laid out until
well after note spacing and measure widths have been settled.
This means there is no way for the melisma line to influence spacing.
And yet, it needs to, if we want to avoid potential collisions.

Because we cannot use the melisma line itself to affect spacing,
this code borrows the approach used for lyrics themselves:
calling addHorizontalSpacing() to reserve space for the melisma line
when calculating the shape of the ChordRest.

In order to do this, we need to know if a ChordRestr ends a melisma.
So I have added a helper function, isMelismaEnd(), to check this.
I also fixed a couple of issues in the calculation
of the length of the melisma line.
One was that we used the width of the start rather than end note
(in cases where the next note also has a lyric, which is common).
Another is that we were deliberately overshooting
the right edge of the end note,
whereas Gould says to end at the note.
@MarcSabatella
Copy link
Contributor Author

Done. FWIW, I know that was always the policy in the past, but it seems lately sometimes I've seen comments indicating otherwise.

@anatoly-os anatoly-os merged commit d0003b1 into musescore:3.x Jun 2, 2020
anatoly-os added a commit that referenced this pull request Aug 7, 2020
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.

None yet

4 participants