Get access to non exposed classes in plugin
Not all classes are part of the Plugin API like the Beam class for example. Is it possible to access these still from the Plugin? Can a plugin get access to the underlying objects not exposed to it?
Not all classes are part of the Plugin API like the Beam class for example. Is it possible to access these still from the Plugin? Can a plugin get access to the underlying objects not exposed to it?
Do you still have an unanswered question? Please log in first to post your question.
Comments
Beam does seem to be available in the plugin API. Are there particular properties which you can't read or write?
https://musescore.github.io/MuseScore_PluginAPI_Docs/plugins/html/class…
In reply to Beam does seem to be… by yonah_ag
Yes, elements. I need to know if the Beam starts at a chord. PagePos is accessible. The Beam class is listed outside of the PluginAPI so I don't really know what this means in terms of accessability
In reply to Yes, elements. I need to… by harmony8
The chordrest element has a beam property which may help.
https://musescore.github.io/MuseScore_PluginAPI_Docs/plugins/html/class…
Have you tried and encountered a problem? I don't think that you need the beam class to be able to achieve your requirement.
In reply to The chordrest element has a… by yonah_ag
Using this, one can see if a chordRest is beamed but not if the Beam starts/ends/continues on that chordRest
In reply to Using this, one can see if a… by harmony8
There may be an easier way but you could process thru the score segments and build a map of chords and beams so that you can detect the beam status.
In reply to There may be an easier way… by yonah_ag
Still would not work. Beams can end and start on the next note. If you just check whether notes have a beam there is no way to differentiate these beams
In reply to Still would not work. Beams… by harmony8
I suggested processing beams AND chords, NOT beams alone.
You say that you need to detect whether a beam starts on a chord. So, process the score tick-by-tick looking for new chords and new beams. When these coincide you have found a beam starting on a chord. You can now process continuing beams until they come to an end. Then you're ready to look for the next starting chord/beam.
In reply to I suggested processing beams… by yonah_ag
This should be possible. [Chord].beam properties are null (except for
[Chord].beamMode
) when there is no beam present on a noteIn reply to I suggested processing beams… by yonah_ag
The problem with that is that one does not detect the beam end
In reply to The problem with that is… by harmony8
Once you have found a beam, when you subsequently find a chordrest in the same voice without a beam then you know that the beam ended on the previous chordrest.
You can access all objects of a score by saving it in mscx format, (writeScore), loading the resulting file into a variable, (using FileIO), then parsing the xml. I have a simple instance of this which uses regex to process the mscx but I consider this the option of last resort.
I also made a plugout framework for exploring and processing mscx files in Microsoft Excel using VBA:
https://github.com/yonah-ag/musescore-mscx-explorer
In reply to You can access all objects… by yonah_ag
I particularly avoid analyzing the XML because I want the symbols as they are rendered to create data for optical music recognition. Not all objects that are rendered are "real, in XML declared" objects like redeclared clefs at each system start
In reply to Ok. On an unrelated note: is… by harmony8
As I said, "it's a last restort". Anyway, it looks as though there is sufficient info in the PluginAPI.
I eventually solved it by using the beams bounding box and checking whether it aligns with the stem or not:
var stemX = e.stem.pagePos.x + (e.stem.bbox.width)/2;
if (Math.abs(e.beam.pagePos.x + e.beam.bbox.x - stemX) < 1) //BEAM STARTS
else if (Math.abs(e.beam.pagePos.x + e.beam.bbox.x + e.beam.bbox.width - stemX) < 1) //BEAM ENDS
else //BEAM CONTINUES
In reply to I eventually solved it by… by harmony8
Neat!