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

Enforce minimum stem length for notes within beamed groups #23197

Merged
merged 2 commits into from
Jun 21, 2024

Conversation

miiizen
Copy link
Contributor

@miiizen miiizen commented Jun 11, 2024

Resolves: #18280

@oktophonie oktophonie added the vtests This PR produces approved changes to vtest results label Jun 19, 2024

double startY = (isStartDictator ? dictator : pointer) * ldata->spatium / 4 + tolerance;
double endY = (isStartDictator ? pointer : dictator) * ldata->spatium / 4 + tolerance;
// min stem lengths according to how many beams there are (starting with 1)
static const int minStemLengths[] = { 11, 13, 15, 18, 21, 24, 27, 30 };
Copy link
Contributor

Choose a reason for hiding this comment

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

Couple of things about this.
a) It is unclear at first sight in which units these values are represented. I'm guessing, from the way that you are using it later, that these are quarter-spaces? I think it would be clearer if you expressed these numbers in units of spatium (also good to write a comment that says so). This will also save you from doing that strange * 4 multiplication in desiredLen.
b) Please make this into a function, so its meaning and use are more transparent. Something like
double BeamTremoloLayout::minStemLength(int beamsCount) { ... }. Then define this array inside the funtion itself and that way you can also safe guard against out-of-range access by checking that beamsCount is within range.
c) You can make it not just const but constexpr, that way it will be evaluated at compile time.

Copy link
Contributor

Choose a reason for hiding this comment

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

By the way, I know that this thing of using quarter-spaces is done a lot in the beam layout code (and it's totally fine given that beams adjust in quarter-space increments) so I wasn't critizing you for that. I just want to avoid perpetuating the bad practice of doing * 4 and / 4 all the time, which is obscure and prone to mistakes :)

This comment was marked as outdated.

|| (!ldata->up && muse::RealIsEqualOrMore(desiredY, anchor.y() - reduction));
if (beamClearsAnchor) {
// avoid division by zero for zero-length beams (can exist as a pre-layout state used
// for horizontal spacing computations)
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is about the if condition, so better move it out of the while loop

if (beamClearsAnchor) {
// avoid division by zero for zero-length beams (can exist as a pre-layout state used
// for horizontal spacing computations)
const double proportionAlongX = (anchor.x() - startX) / (endX - startX);
Copy link
Contributor

Choose a reason for hiding this comment

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

If this variable doesn't change within the loop it should be moved out, so we save having to recalculate it each time.

@mike-spa mike-spa merged commit 8afba75 into musescore:master Jun 21, 2024
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vtests This PR produces approved changes to vtest results
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Minimum stem length not respected for all inside notes in beams
3 participants