How do I change chord durations via a plugin in MS3
This code processes through the score's tracks and attempts to set each chord to a 1/16 duration. However, it only actually applies the 1/16 setting to whichever note happened to be selected when the plugin started. (The pad-dot and voice-1 statements are commented out).
Any suggestions as to what I'm missing would be most welcome.
Comments
Got it working with:
but it's very slow at about 2s per measure so I need to work out what's slowing it down. I have several other plugins and they all run very quickly but they don't involve changing note face value durations.
In reply to Got it working with: [inline… by yonah_ag
If I remove the pad-note-16 then it's instantaneous so this looks like the cause of slowness. Is there a faster way to change note durations?
In reply to Got it working with: [inline… by yonah_ag
I use the same mechanism in Duration Editor. And it isn't so slow. This is the only way I found too.
Question: how many instruments do you have ?
In reply to I use the same mechanism in… by parkingb
A single instrument of up to 4 voices but even with 2 voices it's slow. I checked Duration Editor after failing to set duration directly. It can take many seconds for scores with tens of measures.
The plugin is here:
https://musescore.org/en/project/merge-voices-4-1
and even these two measures cause a noticeable pause when processed.
Reading the score, erasing it, and writing it back out ‘modified’ is faster, as in e.g.
https://musescore.org/en/project/new-retrograde
https://musescore.org/en/project/pitch-and-rhythm-transformer
but New Retrograde does not handle tuplets with uneven notes correctly (e.g. a half note and a quarter note in a quarter note triplet)
and the transformer does not deal with inner voices.
Combining the two would do the trick.
EDIT: + the merge logic...
In reply to Reading the score, erasing… by elsewhere
Thanks for the tip. I'll take a look.
Triplets are not going to be an issue for now.
In reply to Reading the score, erasing… by elsewhere
One must pay attention at the elements that are te-written, such as dynamics, chord symbols, articulations. In order to not loose them in the output score.
How are you managing this?
I have built one system for this in Duration Editor, but it has room for improvement.
In reply to One must pay attention at… by parkingb
Such details are not really an issue for the context in which the plugin is designed to run, although these elements will mainly be preserved if I continue with pad-note commands since I am only shortening durations rather than deleting notes.
(Context: https://musescore.org/en/node/370074 )
In reply to Such details are not really… by yonah_ag
My remark was more targeted to @elswhere approach.
BTW, I wonder if you are forced to work on a note by note basis as you are doing right now:
Wouldn't it be possible (once you have identified the shortest duration) to
1. select all the chords and rests from voice 1 and call on that selection the correct
cmd("pad-note-xx")
2. Process the same for each voice => max 4 calls to
cmd("pad-note-xx")
3. select all the chords and rests from voice 2 and call on that selection the correct
cmd("voice-1")
4. Process the same for each voice => max 3 calls to
cmd("pad-note-xx")
In reply to My remark was more targeted… by parkingb
Nice idea.
I haven't used selection methods much in plugins but I presume, (from your suggestion), that I can programatically build a non-contiguous selection with plugin code. I've just finished v1.2 which deals with ties better and removes unisons so now I can work on optimising.
In reply to My remark was more targeted… by parkingb
I'm thinking of a slight variant. Why not process all voices together?
Is there a reason that I need to process voices separately?
(The note-by-note processing was inherited from the TAB Ring plugin which was initially used to host the voice merge code.)
In reply to One must pay attention at… by parkingb
The Retrograde plugins only remove note elements, so this may not be a problem...
Let me make a premise: I often create scores of classical music, and for this purpose I use (if I find them) midi files with the piece I need, so I save time. Sometimes importing a midi file produces disconcerting results: for this purpose I created a plugin ('Select overlapping tied notes' which I published in the dedicated section of Musescore), which improves the readability of the file. If you export your scores in midi format, and then reload them into the software, following the plugin's instructions you should get the result you need.
In reply to Let me make a premise: I… by ILPEPITO
I'll take a look but my plugin also deals with messy MIDI imported files, removes ties and unisons and squishes the score down to a single voice,
In reply to I'll take a look but my… by yonah_ag
As you wish, my plugin simply selects overlapping notes with ties for their eventual deletion. Almost everything else (reduction to a single voice, elimination of staccato notes, and more) it doesn't do because Musescore can do it for me. This is my philosophy...
In reply to As you wish, my plugin… by ILPEPITO
It's always interesting seeing someone else's approach in plugin code and 'borrowing' better techniques so I'll definitely check out your method.
In reply to As you wish, my plugin… by ILPEPITO
I have found something to 'borrow' from your plugin: a neat way of building a selection to process. 😀
In reply to I have found something to … by yonah_ag
Happy to have been helpful to you. We all (including myself, of course) have learned by copying others, it's a universal law.