ibt Posted February 20, 2017 Share Posted February 20, 2017 Basic script that remaps the Novation Launchpad's pads chromatically, and has a slider to transpose by semitones. 'defaultValue' is not working as it should for some reason... Scripted by a novice, so if it is a bit verbose and could to be shortened, let me know. //Pads are mapped chromatically, from C-2 (@ top left) var PluginParameters = [{ name:'Transpose', type:'lin', unit:'semitones', minValue:0, maxValue:64, numberOfSteps:64, defaultValue:24}] function HandleMIDI(e) { //map Launchpad's 64 pads chromatically { if (e.pitch <= 7){ e.pitch += 0;} if (e.pitch >= 16 && e.pitch <= 23) { e.pitch -= 8} if (e.pitch >= 32 && e.pitch <= 39) { e.pitch -= 16} if (e.pitch >= 48 && e.pitch <= 55) { e.pitch -= 24} if (e.pitch >= 64 && e.pitch <= 71) { e.pitch -= 32} if (e.pitch >= 80 && e.pitch <= 87) { e.pitch -= 40} if (e.pitch >= 96 && e.pitch <=103) { e.pitch -= 48} if (e.pitch >=112 && e.pitch <=119) { e.pitch -= 56} } e.pitch = e.pitch + GetParameter(0); { e.trace(); e.send(); } } Quote Link to comment Share on other sites More sharing options...
Unheardofski Posted March 14, 2017 Share Posted March 14, 2017 Thanks for sharing! If you want it to reset to defaults on launch add in the global scope: ResetParameterDefaults = true; Quote Link to comment Share on other sites More sharing options...
ibt Posted March 15, 2017 Author Share Posted March 15, 2017 Hey, thanks for that suggestion. I did run into one other problem though... I had also hoped to add a button to the GUI, to give the user the option to invert the scale (to run from bottom left pad to top right, instead of from top left to bottom right (as in the script above) But, only the lower 6 rows will ascend properly in the inverter script... then, playing from last (right) pad of row 6, to first (left) pad of row 7, instead of increasing one semitone as expected, the pitch drops an octave (sequence goes B1 to C1 instead of B1 to C2). var PluginParameters = [{ name:'Transpose', type:'lin', unit:'semitones', minValue:0, maxValue:64, numberOfSteps:64, defaultValue:24}] function HandleMIDI(e) { //map Launchpad's 64 pads chromatically { if (e.pitch <= 7) { e.pitch += 0} //row 1 if (e.pitch >= 16 && e.pitch <= 23) { e.pitch += 36} //row 2 if (e.pitch >= 32 && e.pitch <= 39) { e.pitch += 8} //row 3 if (e.pitch >= 48 && e.pitch <= 55) { e.pitch -= 16} //row 4 if (e.pitch >= 64 && e.pitch <= 71) { e.pitch -= 40} //row 5 if (e.pitch >= 80 && e.pitch <= 87) { e.pitch -= 64} //row 6 if (e.pitch >= 96 && e.pitch <=103) { e.pitch -= 88} //row 7 if (e.pitch >=112 && e.pitch <=119) { e.pitch -= 112} //row 8 } e.pitch = e.pitch + GetParameter(0); { e.trace(); e.send(); } } Launchpad factory layout: Quote Link to comment Share on other sites More sharing options...
Unheardofski Posted March 15, 2017 Share Posted March 15, 2017 Hi I think I see what's wrong. In the non-inverted script, the way the if statements are ordered only one can evaluate to true and after you apply the -= none of the following can evaluate to true. In the inverted however they will basically all evaluate to true after applying the pitch offset since they are all evaluated sequentially. If you want to use a similar method without going sequentially try "switch", it tests e.pitch just once and then breaks out. Secret ninja pro tip, if instead of testing for e.pitch you test for true you can have a range instead of an absolute value per case: switch(true){ case (e.pitch > somevalue && e.pitch < someothervalue): do something; break; case (e.pitch > somethingelse && e.pitch blablabla): do something different; break; default: //if nothing evaluates to true do nothing } 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.