Get access to non exposed classes in plugin

• Dec 13, 2023 - 15:36

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?


Comments

In reply to 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.

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

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

Do you still have an unanswered question? Please log in first to post your question.