dasan90 Posted August 24, 2017 Share Posted August 24, 2017 Hey guys, I want to be able to scale midi cc values, for instance mod wheel values 0-127, to grow exponentially by a specified constant (see picture). Any idea how you could do this in logic pro x scripter? When input is 0, i want output to be 0, and when input is 127 i want output to be 127 etc, but everything in between is scaled accordingly. Thanks in advance, David Quote Link to comment Share on other sites More sharing options...
Dewdman42 Posted August 24, 2017 Share Posted August 24, 2017 var GAMMA = 2.2; // gamma function HandleMIDI(event) { if (event instanceof ControlChange) { event.value = 127 * Math.pow((event.value/127),GAMMA); } event.send(); } Try the above. Gamma values between 0-1 will result in a curve above the diagonal line and values above 1 will result in curves below the diagonal line. Quote Link to comment Share on other sites More sharing options...
dasan90 Posted August 25, 2017 Author Share Posted August 25, 2017 It works! Thanks a lot! Quote Link to comment Share on other sites More sharing options...
Dewdman42 Posted March 17, 2021 Share Posted March 17, 2021 Here's a version with a GUI that is made specifically for velocity: var scaled = []; function calculateCurve(gamma) { for(let i=0; i<=127; i++) { scaled[i] = 127 * Math.pow((i/127), gamma ); } } function HandleMIDI(event) { if (event instanceof NoteOn) { event.velocity = scaled[event.velocity]; } event.send(); } //------- // GUI //------- var PluginParameters = []; PluginParameters.push({ name: "Gamma", type: "lin", defaultValue: 2.2, minValue: 0, maxValue: 10, numberOfSteps: 100 }); var GuiParameters = { data: [], set: function(id, val) { if(typeof id != "string") id = PluginParameters[id].name; this.data[id] = val; }, get: function(id) { if(typeof id != "string") id = PluginParameters[id].name; if(this.data[id] == undefined) { this.data[id] = GetParameter(id); } return this.data[id]; } }; function ParameterChanged(id, val) { GuiParameters.set(id, val); calculateCurve(val); } 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.