Jump to content

LaunchpadTransposer


ibt

Recommended Posts

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();
}
}

Link to comment
Share on other sites

  • 4 weeks later...

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).

 

LPTransposerInv.jpg.406daa3c0718d3a25c05775ace1b61b5.jpg

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:

launchpad_XY.PNG.37f878712bb852e13b47bdb713ec970f.PNG

Link to comment
Share on other sites

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
}

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...