I want to build a plugin which would spread selected notes evenly in duration keeping their original pitches.
If I select 4 notes this plugin should spread selected notes on 4 parts of equal duration (regardless of their original durations). For example if I select the following four notes: eighth-note (A) + eighth-note (B) + quarter-note (C) + half-note (D). They together have duration of 4 quarter-notes and this should be divided by plugin into 4 quarter-notes keeping original note's pitches (A,B,C,D). Ok, this is very simple example.
If I select 3 notes (sincope in this case) this plugin should spread selected notes on 3 parts of equal duration (that's triplet now). For example if I select there three notes: eighth-note (A) + quarter-note (B) + eighth-note (C). They together have duration of 2 quarter-notes and this should be divided into 3 quarter-notes keeping original note's pitches (A,B,C). This i still simple example.
However, if one makes a selection of 5 notes with duration of 7-eighth-notes this is more complex but not needed so much in praxis and it is not important if this plugin does not support these complex cases. Similar thing is if selection includes rests.
So general rule is: split selected duration evenly on number of selected notes:
I started to build such a plugin but I'm newbie in MuseScore plugin programming and need help with this:
Here is my starting code targeting selected notes:
import QtQuick 2.0
import MuseScore 1.0
MuseScore
{
menuPath: "Plugins.pluginName"
onRun:
{
var c=curScore.newCursor();
c.rewind(2);//gotoSelectionEnd
var endTick=c.tick;
c.rewind(1);//gotoSelectionStart
var startTick=c.tick;
var selDuration=endTick-startTick;
console.log("selection duration="+selDuration);
var e=0;
while(c.tick