Okay, here's my issue. I have this script (below) that calculates every half beat and adds "swing" to any notes falling there. The trouble is, the beat position isn't always accurate. I found a partial solution in this thread (viewtopic.php?t=128908), which seemed to work at first, but the values are all thrown off when a different track is selected. Help! What's the best way to find the current position so I can detect notes falling on half beats?
PluginParameters = [{name: 'Swing %', minValue: 0, maxValue: 30, numberOfSteps: 60, defaultValue: 20},];
NeedsTimingInfo = true;
var beat = 0;
function HandleMIDI (e) {
if (e instanceof NoteOn) {
var delay = GetParameter('Swing %')/100;
processNoteOn(e, delay);
} else {
e.send();
}
}
function processNoteOn(e, delay) {
if (isSwingPosition() && delay > 0) {
e.sendAfterBeats(delay);
} else {
e.send();
}
}
function isSwingPosition() {
Trace('BEAT: ' + beat);
return beat.toString().slice(-2) == '.5';
}
function ProcessMIDI () {
var info = GetTimingInfo();
var curr = Math.ceil(info.blockStartBeat * 24) / 24;
if (info.playing && beat !== curr) beat = curr;
}