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.
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.
_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._
Comments
Can reproduce in the latest nightly.
first report though was with 3.2
In reply to first report though was with… 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.
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.
In reply to Actually, the problem is a… by Marc Sabatella
Thanks for the elaboration! I'll try to start from easy things.
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.
Ah! Looking back into this issue now, I can almost imagine what will the problematic code be like :D
https://github.com/musescore/MuseScore/pull/5669
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._
Fixed in branch master, commit 9d17cc8127
_Merge pull request #5669 from njvdberg/issue-291669-wrong-beams
fix #291699 - Stems and beams for small chords don't align correctly_
Automatically closed -- issue fixed for 2 weeks with no activity.