MS3 Use plugin API to remove a note's element
I can see in the plugin API documentation that there is a remove() note element function:
https://musescore.github.io/MuseScore_PluginAPI_Docs/plugins/html/class…
Can anyone point me to an example of this in practise? I want to delete play event data from selected notes. It is possible by editing the MSCX file but would be much more convenient in a plugin.
Comments
Found an alternative: note.playEvents = []
FWIW: the New Retrograde plugin has code with removeElement:
// clear selection
for(var trackNum in tracks) {
cursor.track = tracks[trackNum];
while(cursor.segment && cursor.tick < endTick) {
var e = cursor.element;
if(e.tuplet) {
removeElement(e.tuplet); // you have to specifically remove tuplets
} else {
removeElement(e);
}
cursor.next(); // advance cursor
}
In reply to FWIW: the New Retrograde… by elsewhere
Thanks. I'll try this syntax with remove(note.PlayEvents[0]) since it may work better than my solution above which requires closing and re-opening the score to regenerate default note durations at all. (It may, of course, prove no different).
The need to remove user defined ontime and duration can arise with swung rhythm. After making changes to these values in PRE the swing ratio can no longer be changed so I am looking for a solution. Setting ontime=0 and duration=1000 does not fix the issue, presumably because Musescore has flagged that the score has user durations.