-
-
Save xuanvu/4672e014db42804cca8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NeedsTimingInfo = true; | |
var start = Date.now(), | |
triggered = false, | |
prev; | |
var PluginParameters = [ | |
{ | |
name: "Window Length", | |
defaultValue: 80, | |
minValue: 0, | |
maxValue: 500, | |
numberOfSteps: 500, | |
unit: "ms", | |
type: "lin" | |
}, | |
{ | |
name: "Added Velocity", | |
defaultValue: 30, | |
minValue: 0, | |
maxValue: 127, | |
numberOfSteps: 128, | |
type: "lin" | |
}, | |
{ | |
name: "Transpose", | |
defaultValue: 12, | |
minValue: -24, | |
maxValue: 24, | |
numberOfSteps: 4, | |
type: "lin" | |
}, | |
{ | |
name: "Note Choice", | |
type: "menu", | |
defaultValue: 1, | |
valueStrings: ["Bottom", "Top"] | |
} | |
]; | |
function HandleMIDI(event) { | |
event.send(); | |
if (event instanceof NoteOn) { | |
if (prev === undefined) { | |
prev = event; | |
} else { | |
if (GetParameter("Note Choice") === 1) { | |
if (event.pitch > prev.pitch) { | |
prev = event; | |
} | |
} else { | |
if (event.pitch < prev.pitch) { | |
prev = event; | |
} | |
} | |
} | |
if (!triggered) { | |
triggered = true; | |
start = Date.now(); | |
} | |
} | |
} | |
function ProcessMIDI () { | |
var info = GetTimingInfo(), | |
now = Date.now(), | |
dur = GetParameter("Window Length"), | |
pitch = GetParameter("Transpose"), | |
vel = GetParameter("Added Velocity"); | |
if (triggered && (start + dur) <= now) { | |
prev.pitch += pitch; | |
prev.velocity += vel; | |
prev.send(); | |
triggered = false; | |
prev = undefined; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment