Plugin to convert existing durations to tuplets

• Jun 9, 2021 - 23:14

I had an issue yesterday where I'd entered a long passage in straight 1/8th notes accidentally then realised they should all be triplets - and couldn't find a way to make them so!
So I figured it must be possible with a plugin, and put one together that basically does the job.
At this stage it's hard-coded to always do triplets (easy to change though), and note that it basically ignores the durations of the existing notes except the first one - it uses that to determine the triplet duration, then all subsequent pitches are converted to the same duration regardless of original duration. It also ignores rests, but that's probably not hard to change, and it applies to all notes in the time period selected even if you've only selected individual notes, which I tried fixing but gave up after a while because I didn't really need it.
It's also not quite polished in the way it pads out the remaining rests but it's good enough what for I want.
Have attached anyway in case anyone's interested.

Attachment Size
convertToTuplets.qml 3.31 KB

Comments

Nice! When I implemented the "paste half duration" and "paste double duration" commands, I also did an undocumented "paste special" command that can multiply durations by other factors. It's not documented because there is no reasonable UI for it, and it doesn't handle triplets. Probably it wouldn't be that hard to get it work this way though, should you wish to make something like this built in. The code happens within the paste, essentially a filter on each chord or rest as we write it to the destination.

In reply to by Marc Sabatella

Having it preserve all the original relative durations would actually be a fair bit more complicated as you'd have to work out when you needed to split notes across tuplets (e.g. if the original durations were 2 1/8 notes followed by a 1/4 note, the 1/4 note would need to be split into two 1/8 notes, the first belonging to one triplet and the 2nd to the next etc.). If there was a genuine need for it I guess it'd be worthwhile.

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