"explode" measure by measure
Love the explode tool in MuseScore. Is there a way to use this in a plugin?
I noticed that I am manually exploding chords measure by measure and it's getting quite tedious. Would love to find a way to explode measure one, then explode measure two, then three, etc.
In the ideal world, would love to be able to explode note-by-note, but I would be quite satisfied with measure-by-measure for now.
Example:
Explode measure by measure:
[Don't want] to explode whole line:
Pipe dream: explode note by note:
Comments
Hi! I'm not sure I understand what you are doing here. Why are you going measure by measure instead of just selecting the whole passage? Is the idea that you don't want single notes to get copied to multiple staves? Can you explain more about that use case? I am not understanding how that would ever come up, but if there is something we are missing, we could conceivably enhance the tool to handle that special case better.
You can control how many staves a line gets exploded onto by selecting the staves you want affected. If you select just one staff, it explodes each chord across however many staves are needed. If you select multiple staves, it explodes only across those staves. Maybe somehow this can help.
Meanwhile, in a plugin, you can involve any command by its internal name using the "cmd" function, something like that. Sorry, I know more about the internals than about the plugin interface.
In reply to Hi! I'm not sure I… by Marc Sabatella
Appreciate the thoughts! With my orchestra being on hiatus until the world normalize, I am trying to rescore some performances for a solo ensemble.
For instance, explode is a great tool to allow me to play piano pieces on a violin (separate out the notes, record myself playing each line, and layer the recordings together). However, if the right piano hand is mostly playing single notes with interspersed chords, exploding the whole line means a lot of redundancy between the exploded parts.
I did not know about the "cmd" function. Cheers!
In reply to Appreciate the thoughts! … by syncopassionfruit
I'd argue that you are better off including the doubled notes. It's probably true to the intent of the original, and it will prevent those notes from sounding softer than the others, which probably was not the intent (a pianist would naturally likely adjust naturally in performance). Plus it will just be more natural then having weird "holes" in the lines. Although there might be weird interval leaps.
Anyhow, if I did want to solve this programmatically, I'd be more likely to do the full explode then write a plugin to detect and delete the doubled notes.
In reply to I'd argue that you are… by Marc Sabatella
Appreciate the insight!
I hadn't even considered that approach. Thank you!
You can invoke the "explode" command by calling
cmd("explode");
in your plugin. However you would need to establish a selection on a measure first. The best way to do so will be available in MuseScore 3.5 (which is now in a release candidate stage) which would addselectRange()
method to Selection object. However a similar thing can be achieved in earlier versions with something like this:Doing so in a loop will allow running explode tool on every measure separately, although the code above seems to break for me if it encounters a full-measure rest.
The command names suitable for use with
cmd()
can be found here and correspond to actions available to users via keyboard shortcuts.In reply to You can invoke the "explode"… by dmitrio95
This is really great! I've been playing around with your code and trying to throw in a while look with a try/catch block but not quite sure how to make it work in musescore. I will keep playing around with it. If I find a solution that doesn't require human attention, I will post it in a reply here.
In reply to You can invoke the "explode"… by dmitrio95
I wasn't quite able to figure out how to run a try/catch block in musescore.
However, as I started using, noticed this interesting behavior from the code: https://www.youtube.com/watch?v=-evZin1E8AQ&feature=youtu.be
Running on a blank measure moves the cursor right one measure and up one staff
Still incredibly useful!
In reply to I wasn't quite able to… by syncopassionfruit
This is a result of selection behavior of "explode" command: if you select an empty measure and run Tools→Explode then the two staves including the upper one is selected. I don't think this is how selection is intended to work with this command, probably that just didn't come to attention of anyone since using Explode on empty measure does not usually make much sense. Maybe for plugin it would make sense to check if current measure is empty before executing "explode" command and just move to the next measure in this case.
In reply to This is a result of… by dmitrio95
I can see the "else" statement being cmd("next-measure")
Looking through the docs, I can see REST is an element type. Does whole rest have a special element type?
I appreciate the time you have taken to help me out with such a bizarre project!