├── modulationToVelocity.js ├── README.md ├── velocityControlledModulation.js ├── LICENSE └── automaticVelocityBuilds.js /modulationToVelocity.js: -------------------------------------------------------------------------------- 1 | /* Use Modwheel to Set Velocity of Notes 2 | Script by: Daniel Turner 3 | License: MIT */ 4 | 5 | var modValue = 127; // set modValue to default value 6 | 7 | function HandleMIDI(event) 8 | { 9 | if (event instanceof ControlChange && event.number == 1) { 10 | modValue = event.value; // capture modulation changes 11 | } 12 | 13 | event.velocity = modValue; // set note velocity to modulation value 14 | 15 | event.send(); // send result to Logic 16 | } 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Logic Pro X MIDI Scripts 2 | These MIDI scripts run on software instrument tracks in Logic Pro X. 3 | 4 | Click MIDI FX on track -> Scripter -> copy Javascript code into editor 5 | 6 | ##### Scripts by: Daniel Turner (Github - djtech42) 7 | ##### License: MIT 8 | 9 | ## Scripts 10 | 11 | [Set Note Velocity using Modwheel](modulationToVelocity.js) 12 | 13 | [Add Modulation if Key is Pressed Hard](velocityControlledModulation.js) 14 | 15 | [Set Increasing Velocity (Build) for Specified Measure Range](automaticVelocityBuilds.js) 16 | -------------------------------------------------------------------------------- /velocityControlledModulation.js: -------------------------------------------------------------------------------- 1 | /* Add Modulation When Key is Pressed Hard 2 | Script by: Daniel Turner 3 | License: MIT */ 4 | 5 | var velocityValue = 0; // set velocityValue to default value 6 | 7 | function HandleMIDI(event) 8 | { 9 | if (event instanceof NoteOn) { 10 | if (event.velocity >= 80) // capture note velocity 11 | { 12 | velocityValue = event.velocity - 40; // add modulation if high velocity 13 | } 14 | else 15 | { 16 | velocityValue = 0; // no modulation if low to mid velocity 17 | } 18 | } 19 | 20 | var addedMod = new ControlChange; // create modulation change 21 | addedMod.number = 1; // control change number 22 | addedMod.value = velocityValue; // set to calculated value 23 | addedMod.send(); // send added modulation with note 24 | 25 | event.send(); // send note to Logic 26 | } 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Dan Turner 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /automaticVelocityBuilds.js: -------------------------------------------------------------------------------- 1 | /* Automatic Velocity Builds 2 | Script by: Daniel Turner 3 | License: MIT */ 4 | 5 | var NeedsTimingInfo = true; // enables timing info object 6 | 7 | // sliders and menu selection 8 | var PluginParameters = [ 9 | {name:"Build Length", defaultValue:4, minValue:1, maxValue:16, numberOfSteps:15, unit:" measures", type:"lin"}, 10 | {name:"Build Range", defaultValue:127, minValue:1, maxValue:127, numberOfSteps:126, type:"lin"}, 11 | {name:"Peak Velocity", defaultValue:127, minValue:0, maxValue:127, numberOfSteps:127, type:"lin"}, 12 | {name:"Build Mode", type:'menu', valueStrings:["Linear", "Exponential"], defaultValue:0}]; 13 | 14 | function HandleMIDI(event) 15 | { 16 | // load slider and menu parameters 17 | var measures = GetParameter("Build Length"); 18 | var range = GetParameter("Build Range"); 19 | var maxVelocity = GetParameter("Peak Velocity"); 20 | var buildMode = GetParameter("Build Mode"); 21 | 22 | // get current beat and set up number of beats for each build 23 | var logicInfo = GetTimingInfo(); 24 | var beat = logicInfo.blockStartBeat + logicInfo.blockLength; 25 | var buildLength = logicInfo.meterNumerator * measures; 26 | var beatPositionInBuild = (beat-1) % buildLength; 27 | 28 | var newVelocity; 29 | // calculate velocity for linear setting 30 | newVelocity = beatPositionInBuild * (range / buildLength); 31 | // calculate velocity for exponential setting 32 | if (buildMode === 1) { 33 | newVelocity = Math.pow(newVelocity, 2)/range; 34 | } 35 | // compensate for range bottom and set peak velocity offset 36 | newVelocity += (maxVelocity - range); 37 | 38 | // minimum value for velocity is 0 39 | if (newVelocity > 0) { 40 | event.velocity = newVelocity; 41 | } 42 | else { 43 | event.velocity = 0; 44 | } 45 | 46 | // send note to Logic 47 | event.send(); 48 | } --------------------------------------------------------------------------------