Stems and beams for small chords don't align correctly

• Jul 3, 2019 - 10:19
Reported version
3.2
Priority
P1 - High
Type
Functional
Frequency
Once
Severity
S4 - Minor
Reproducibility
Always
Status
closed
Regression
No
Workaround
No
Project

The beam is slightly longer than the distance between the stems at the edge.
批注 2019-07-03 171856.png


Comments

In reply to by Jojo-Schmitz

Oops.
I've been reviewing C++ and I hope to understand at least some code of MuseScore (so that maybe I can do some easy fixes later?). Could you possibly tell me where're the code folders of, for example, note/beam layout; playback; palette; other workspaces? I'm afraid I cannot find them out by myself...
Or is there anything in the developers' handbook that can do the job of tutoring new developers in this way?

Doesn't hurt to go through the developer's handbook, but it doesn't have that level of detail. The important thing to know is that anything having to do with the appearance of elements of your score is in the libmscore folder, where there is generally one cpp file per class, and the classes match up with elements pretty well (eg, beam.cpp, note.cpp). Anything having to do with the UI is in the mscore folder, also at least in part organized by class name in a logical way (palette.cpp, etc). Playback is pretty complicated and spread out as lots of different things are involved. Best advice is join the develoepr chat on Telegram where you can usually get rea-time answers to specific questions.

As an addendum, I would say that beam layout is probably the single most complex part of the entire code, it's not where I'd recommend starting. Although every so often there are aspects that are simple. Like, I wouldn't be surprised to find out this particular issue is just a matter of our not recognizing the thinner stem, and would be fixed with a one-line change where we make that adjustment. But it could turn out to be something much harder to deal with.

Title Beam for grace notes doesn't have 100% accurate length Stems and beams for small chords don't align correctly

Actually, the problem is a rather worse. Look at the when the stem joins the notehead - that's off too, by about the same amount. And the problem isn't just grace notes, it also affects normal chords made small or chords on small staves.

There's several places where we reference the stem width within beam.cpp. Probably all of them need to be adjusted by the "mag" for the stem.

FWIW, I did try making a simple (two-line) change to scale the stem width by the "mag" factor in the beam layout. It works almost perfectly. It fails only in the case where you have chords of mixed sizes on the same beam, and either the start or the end chord is one of the small ones. Then you either get an overhang similar to what we see currently, or else the beam is a little short.

At this point, I'd say the problem is reduced down enough that maybe it's not such a bad place to get started. Not the easiest, but nowhere near the complexity of dealing with beams in a more general sense. Probably there is just one more line that same function that needs to get scaled, or a place where my initial attempts applied the wrong scaling. If you were able to get to Telegram, I could definitely help you through this.

Seems the beams don't take the smaller stems into account. When switching from small to normal notes, I see the beams stay unchanged while the stem with becomes smaller for the small notes.

Status PR created fixed

Fixed in branch master, commit 57d8a1841f

_fix #291699 - Stems and beams for small chords don't align correctly

When calculating the length of the beams the width of the stems was neglected.
To support this calculation, a new method lineWidthMag() is the class Stem was
created, returning the scaled width of the stem._

Fix version
3.5.0