Controller Value To Note On Velocity
-
A simple little script to convert a selected controller's value to note on velocity. Handy if you want to control staccato sample dynamics with a CC instead of velocity for example. Or you could bypass the script to switch back to the default velocity based control.
/** * Title: Controller Value To Note On Velocity v1.0.1 * Author: David Healey * Date: 30/06/2017 * Modified: 30/06/2017 * License: Public Domain */ Content.setHeight(50); const var knbCC = Content.addKnob("CC Number", 0, 0); knbCC.setRange(1, 127, 1); reg lastCCValue = 1; function onNoteOn() { Message.setVelocity(lastCCValue); } function onNoteOff() { } function onController() { if (Message.getControllerNumber() == knbCC.getValue()) { lastCCValue = Math.max(1, Message.getControllerValue()); } } function onTimer() { } function onControl(number, value) { }
-
I'd recommend using a
reg
variable for thelastCCValue
. Also you can uselastCCValue = Math.max(1, Message.getControllerValue();
to remove the if branch (shorter and slightly faster).
-
Oh I'd completely forgotten Math.max(). Good idea! I'll update my original post