# Help! Script needed to change instrument banks via Novation Launchkey 49



## jerry (Sep 2, 2015)

Hi im very new to this. i would like scripts for changing kontakt 5 instrument banks using the buttons 1-8 on my Novation Launchkey 49. i want to use kontakt for live performances. any help will be highly appreciated!!


----------



## tomaslobosk (Sep 2, 2015)

May I ask if you are hiring a scripter?, or do you want to script them by yourself?


----------



## jerry (Sep 2, 2015)

i would like to hire a scripter to be honest i have no clue about scripting


----------



## polypx (Sep 3, 2015)

You might be able to do what you need with Orange Tree's Mind Control?
https://www.orangetreesamples.com/products/mind-control


----------



## Reegs (Sep 3, 2015)

If Mind Control doesn't work for you, here's a rudimentary script that might. I think I've got it set up to respond to the buttons from a Launchpad correctly.

Copy and paste it into the multiscript area (that's the little scroll icon on the multi-rack level). Load your banks in and assign them to MIDI channels 1-8. 


```
{Instrument Bank Switching Script}
on init
  declare %ctl_array[8] := (51,52,53,54,55,56,57,58)  {CC#s of Buttons 1-8 from Launchpad}
  declare %banknum[8] := (0,1,2,3,4,5,6,7) {MIDI Channels according to Kontakt internals}
  declare $current_bank
  $current_bank := 1
  declare $arval
  declare ui_label $ui_curbank (1,1)
  set_text($ui_curbank,"Bank: " & $arval)
  declare ui_button $all_off_on_switch
  set_text($all_off_on_switch,"Send Note offs on switch")
  declare $x
  $x := 0
  declare $prevbank
  $prevbank := 1
end on
 
on midi_in
  if ($MIDI_COMMAND = $MIDI_COMMAND_CC)
  $arval := search(%ctl_array,$MIDI_BYTE_1)
  if ($arval = -1)
  {Passthrough}
  set_event_par($EVENT_ID,$EVENT_PAR_MIDI_CHANNEL,$current_bank)   
  else
  if ($MIDI_BYTE_2 >64)   
  ignore_midi
  $current_bank := %banknum[$arval]
  if ($all_off_on_switch = 1 and $prevbank # $current_bank)
  while ($x < 128)
  set_midi($prevbank,$MIDI_COMMAND_NOTE_OFF,$x,0)
  inc($x)
  end while
  $x := 0
  $prevbank := $current_bank
  end if
  set_text($ui_curbank,"Bank: " & $current_bank+1)
  end if
  end if
  else
  set_event_par($EVENT_ID,$EVENT_PAR_MIDI_CHANNEL,$current_bank)
  end if
end on
```


----------



## jerry (Sep 4, 2015)

Reegs said:


> If Mind Control doesn't work for you, here's a rudimentary script that might. I think I've got it set up to respond to the buttons from a Launchpad correctly.
> 
> Copy and paste it into the multiscript area (that's the little scroll icon on the multi-rack level). Load your banks in and assign them to MIDI channels 1-8.
> 
> ...



Thanks alot for the script it worked! thought not exactly the way i wanted. i do live performances. so i needed a script that will allow me to change the instruments in the different slots (Instrument bank) using bottons 1-8 on my launchkey. for example if i assign electric piano on 001, strings 002, flute 003, brass 003 etc then i should be able to use the buttons (1-8) 1 for piano, 2 for strings, 3 for flute etc that way on a touch of a button on my controller i can change instrument! using a mouse is soooooo cumbersome

thanks for your help tho i really appreciate it


----------



## jerry (Sep 4, 2015)

i did stumble on this script which worked only on the knobs! turning knob 1 left to write would change the instruments. i believe it was written for a Behringer umx610 controller 

on init
set_script_title("CC To PC Marcelo Duarte")
message("")
declare ui_menu $Channel1
declare $count 
declare !port[4]
!port[0] := "[A]"
!port[1] := "*"
!port[2] := "[C]"
!port[3] := "[D]"

while ($count <= 63)
add_menu_item($Channel1,"Port: " & !port[$count / 16] & " Ch: " & $count mod 16 + 1,$count)
inc($count)
end while
make_persistent($Channel1)
end on
on midi_in
message($MIDI_BYTE_2)
if ($MIDI_COMMAND = 176 and $MIDI_CHANNEL = $Channel1 and (($MIDI_BYTE_1 >= 20 and $MIDI_BYTE_1 <= 23) or ($MIDI_BYTE_1 >= 32 and $MIDI_BYTE_1 <= 35))) ignore_midi
if ($MIDI_BYTE_2 < 42)
set_midi(0,192,$MIDI_BYTE_1 - 20,0)
end if
if (($MIDI_BYTE_2 > 42) and ($MIDI_BYTE_2 < 84))
set_midi(0,192,$MIDI_BYTE_1 - 12,0)
end if
if ($MIDI_BYTE_2 > 84)
set_midi(0,192,$MIDI_BYTE_1,0)
end if
end if
if ($MIDI_COMMAND = 176 and $MIDI_CHANNEL = $Channel1 and ($MIDI_BYTE_1 >= 24 and $MIDI_BYTE_1 <= 31))
ignore_midi
set_midi($Channel1,192,$MIDI_BYTE_1,0)
end if
end on
*


----------



## gpax (Sep 4, 2015)

Jerry, 

As I recall, the pads on the Launchkey 49 are essentially fixed to send only MIDI Ch. 10 drum and percussion values, or for pairing up with Ableton Live use. It was frustrating for me to get one of these and discover the pads are not editable on the hardware itself (I ended up donating to a charity). 

I’m not sure if that helps in terms of creating a script that does what you want in Kontakt, but thought I’d mention it, nevertheless. 

Greg


----------



## jerry (Sep 4, 2015)

Thanks greg but the launchkey also has 8 buttons in addition to the pads. The buttons are on cc 51 - 58 i believe. for interest sake the launchkey also has 8 sliders on each of the buttons and also 8 knobs. Thats why i bought it!!


----------



## Reegs (Sep 5, 2015)

jerry said:


> Thanks alot for the script it worked! thought not exactly the way i wanted. i do live performances. so i needed a script that will allow me to change the instruments in the different slots (Instrument bank) using bottons 1-8 on my launchkey. for example if i assign electric piano on 001, strings 002, flute 003, brass 003 etc then i should be able to use the buttons (1-8) 1 for piano, 2 for strings, 3 for flute etc that way on a touch of a button on my controller i can change instrument! using a mouse is soooooo cumbersome


Oh, okay. I misunderstood how you were wishing to use the banks (I thought you needed a layer on top of that). I've updated the script (no Kontakt available at the moment, so I haven't tested it for errors, but I think it is functional). 

The Mind Control product will provide also this functionality, with a lot more robustness and extensibility, if you're looking for a clean solution.


```
{Instrument Bank Switching Script}
on init
  declare %ctl_array[8] := (51,52,53,54,55,56,57,58)  {CC#s of Buttons 1-8 from Launchpad}
  declare %banknum[8] := (0,1,2,3,4,5,6,7) {MIDI Channels according to Kontakt internals}
  declare $current_bank
  $current_bank := 1
  declare $arval
  declare ui_label $ui_curbank (1,1)
  set_text($ui_curbank,"Bank: " & $arval)
  declare ui_button $all_off_on_switch
  set_text($all_off_on_switch,"Send Note offs on switch")
  declare $x
  $x := 0
  declare $prevbank
  $prevbank := 1
end on

on midi_in
  if ($MIDI_COMMAND = $MIDI_COMMAND_CC)
  $arval := search(%ctl_array,$MIDI_BYTE_1)
  if ($arval = -1)
  {Passthrough}
  else
  if ($MIDI_BYTE_2 >64)
  ignore_midi
  $current_bank := %banknum[$arval]
  set_midi($EVENT_PAR_MIDI_CHANNEL,$MIDI_COMMAND_PROGRAM_CHANGE,$current_bank,0)
  if ($all_off_on_switch = 1 and $prevbank # $current_bank)
  while ($x < 128)
  set_midi($prevbank,$MIDI_COMMAND_NOTE_OFF,$x,0)
  inc($x)
  end while
  $x := 0
  $prevbank := $current_bank
  end if
  set_text($ui_curbank,"Bank: " & $current_bank+1)
  end if
  end if
  else
  set_event_par($EVENT_ID,$EVENT_PAR_MIDI_CHANNEL,$current_bank)
  end if
end on
```


----------



## jerry (Sep 6, 2015)

hello Reegs always nice to hear from you. Thanks for your assistance once more.You are very kind. i did try the script. it does change the banks but doesnt navigate the instruments when i press the buttons on the launchkey. i have attached a screenshot for clarity. basically i want to be able to toggle between the instruments loaded in the slots. From the screenshot pic attached, botton 1 will select full grand, then when i press botton 2 on launchkey it should switch to marimba etc etc Thanks again n cheers!!


----------



## Reegs (Sep 7, 2015)

jerry said:


> it does change the banks but doesnt navigate the instruments when i press the buttons on the launchkey


Yeah, that's what happens when I try something without making sure it works in Kontakt, which I didn't have access to over the weekend. A quick fix later, and you'll notice the knob of the channel for the bank --just make sure that matches the Bank's channel assignment. It's a workaround since I wasn't sure what channel the Novation's buttons transmit their CC message on and if it matches the channel for the keyboard. Hope this is helpful! 


```
on init
  declare %ctl_array[8] := (51, 52, 53, 54, 55, 56, 57, 58)
  declare %banknum[8] := (0, 1, 2, 3, 4, 5, 6, 7)
  declare $current_bank
  declare ui_knob $bank_channel(1, 16, 1)
  $current_bank := 0
  declare $arval
  declare ui_label $ui_curbank(1, 1)
  set_text($ui_curbank,"Bank: " & $arval)
  declare ui_button $all_off_on_switch
  set_text($all_off_on_switch,"Send Note offs on switch")
  declare $x
  $x := 0
  declare $prevbank
  $prevbank := 0
end on

on midi_in
  if ($MIDI_COMMAND=$MIDI_COMMAND_CC)
  $arval := search(%ctl_array,$MIDI_BYTE_1)
  if ($arval=-1)
  else
  if ($MIDI_BYTE_2>64)
  $current_bank := %banknum[$arval]
  set_midi($bank_channel-1,$MIDI_COMMAND_PROGRAM_CHANGE,$current_bank,0)
  if ($all_off_on_switch=1 and ($prevbank # $current_bank))
  while ($x<128)
  set_midi($prevbank,$MIDI_COMMAND_NOTE_OFF,$x,0)
  inc($x)
  end while
  $x := 0
  $prevbank := $current_bank
  end if
  set_text($ui_curbank,"Bank: " & ($current_bank+1))
  end if
  ignore_midi
  end if
  else
  end if
end on
```


----------



## jerry (Sep 7, 2015)

Hey Reegs! You are the boss! it works like a charm. thanks mate i really appreciate it. You know i was wondering if it were possible to make the sliders control the individual volumes of the instruments. for example slider one will control volume on instrument on botton 1etc cheers!


----------

