Musescore code design
Hi,
Perhaps I will have the possibility to help with development.
First I'm trying to undertand the basic of the code organization.
I wonder if someody can explain the choice to organize in segments then divided in voices instead of voices divided in segments?
Or is there any document I could read explaining the rationale behind the current organization?
Thanks
Fred
Comments
Here is a document that explains soe of the basics of how a score is structured:
https://musescore.org/en/developers-handbook/references/musescore-inter…
You can find more information in the Developers Handbook (see Development link in menu at right of this page).
In reply to Here is a document that by Marc Sabatella
Thanks I will read that carefully. Note that as you say it explains how a score is structured, not why this specific choice was made.
In reply to Thanks I will read that by frfancha
Seems a pretty natural way of structuring things to me. Is there a reason you might think another way could/should have been chosen?
In reply to Seems a pretty natural way of by Marc Sabatella
No, not for the moment, it is just that sometimes explanation about the choices of datastructures can also help to understand the code in general.
Right now I'm learning Qt, it seems to be the first step before I can jump in the code ;-)
In reply to No, not for the moment, it is by frfancha
In that case, let me guess at a reasonable answer:
It's very often necessary to know the complete list of things that happen at a given time slice, and also, ranges are defined in terms of a start and end time slice, plus the range of staves covered. Since the number of staves in a score is fixed (or at least, it changes only rarely), and usually very small in comparison to the number of time slices in a score, it seems most efficient to have a *list* of segments, each having an *array* of staves (or voices). Clearly, an array of segments wouldn't make sense - we are way too often adding and deleting segments from the middle of the score for that to be efficient. Whereas an array of staves/voices allows us to very quickly find what content a given voice has in a given segment.
Now, if we had an array of voices, each having a list of segments, certain operations might be easier - like finding the next note in a given voice - but that's hardly difficult or inefficient now. Whereas finding the list of all elements that occur at a given segment would be extremely inefficient in such an arrangement - we'd need to do full list traversals for each voice.
In reply to In that case, let me guess at by Marc Sabatella
Ok, makes sense. Thanks for your time!