Retrieving the bar number
Hi,
Is it possible to find the number of a measure accessed via a segment ?
´´´
var segment=...
var measure=segment.parent;
var measureNumber = measure.????
´´´
Whether the global measure number ou the local one (local to the section).
I couldn't find the right property...
Thanks,
Comments
In MuseScore 4.6 it will be possible with the
measure.no
property. You may or may not need to addmeasure.noOffset
to it.In reply to In MuseScore 4.6 it will be… by XiaoMigros
Thanks!
4.6 seems to be a game changer!
To what extent does it improve the API?
In reply to Thanks! 4.6 seems to be a… by parkingb
Here are all the commits I could find adding new features:
https://github.com/musescore/MuseScore/pull/28791
https://github.com/musescore/MuseScore/pull/28539/
https://github.com/musescore/MuseScore/pull/28505/
https://github.com/musescore/MuseScore/pull/28477/
https://github.com/musescore/MuseScore/pull/28386
https://github.com/musescore/MuseScore/pull/28323
https://github.com/musescore/MuseScore/pull/28307
https://github.com/musescore/MuseScore/pull/28729
Possibly we will see the return of readScore/writeScore, I have a working open PR for that. But no guarantees.
In reply to Here are all the commits I… by XiaoMigros
Nice effort!
Waiting for the wonders of version 4.6 (on which I allow myself to be skeptical), I must say that unfortunately there is no property to have the number of measure directly, but it is certainly possible to create a map of the measures through the cursor.nextMeasure() method, but perhaps you already know ...
In reply to Waiting for the wonders of… by ILPEPITO
If you have a segment and you want the number, better to do the following:
In reply to If you have a segment and… by XiaoMigros
There are certainly several ways to find the numbers of the measures, different from the two proposed here. Personally I don't know if there is a better or a worse, but everyone is free to think that their own method is the best in the universe. Always waiting for the magical version 4.6 which will resolve all issues ...
In reply to There are certainly several… by ILPEPITO
Thanks for your suggestions.
I needed a fast way. Because my new plugin (TextSearch) can be really time consuming when searching texts on lines. So I don't want to add that extra time consumption to be able to display the measure nr.
In reply to Thanks for your suggestions… by parkingb
I don't know how structured your plugin is, but a search algorithm of the number of measures, whatever the method you choose (I prefer to always do a complete mapping of the score, but everyone can do what they want), usually does not add appreciable times to the execution of the program. In any case, the best judge of the situation can only be you.