# Kontakt : transform PC to KS? (spitfire)



## studioj (Nov 8, 2014)

Hello-

I'd like to find a way to translate program changes from my DAW into Key switches to switch spitfire instruments. The problem with UACC is that 1) it is still a bit of a moving target, and 2) you basically need a custom controller for every library still as there are just too many articulations to have a global controller. And at the rate they release updates and new libraries (no complaints there!) there is just no way to keep up. 

Currently I'm just using the individual patches with Mind Control in order to switch articulations via PC from my DAW (I have notes in each track as to what each PC can trigger) ... this is working ok... but of course every instrument has its own mixing settings and its a bit cumbersome. I'd love to be able to just load up their stock patch and switch those arts with PC's as they are (that should be a feature anyway!)... program changes are better in my opinion than either CC or keyswitching as they are easier to program specifically, they translate well, and chasing is usually perfect. 

is there a kontakt script that will let me use Program changes to switch spitfire articulations? Thanks!


----------



## Stiltzkin (Nov 8, 2014)

What DAW are you using? Cubase expression maps sort of take care of most of the problems here without using UACC - there's pretty much nothing you can't do with expression maps 

But yeah, that won't help if you're using another daw so it might help to know which you're using!


----------



## studioj (Nov 8, 2014)

ah, srry that would be useful info!!  Pro Tools 11...

and i'm using custom lemur controllers through Osculator to trigger PC's, CC's, etc. 
I use Osculator to get key commands and the MIDI port in Lemur isn't very stable in my experience.


----------



## mk282 (Nov 9, 2014)

Sure, you can use a multiscript to convert program changes to notes. This will do it:


```
on midi_in
	if ($MIDI_COMMAND = $MIDI_COMMAND_PROGRAM_CHANGE)
		ignore_midi
		set_midi($MIDI_CHANNEL,$MIDI_COMMAND_NOTE_ON,$MIDI_BYTE_1,0)
		wait(1000)
		set_midi($MIDI_CHANNEL,$MIDI_COMMAND_NOTE_OFF,$MIDI_BYTE_1,0)
	end if
end on
```


----------



## studioj (Nov 9, 2014)

Rocking! Thank you!! 

Is there a spot where I can add "midi note + X"... x being the number of offset I may want so PC 1 could equal note #25 for instance?

Thank so much for your help!


----------



## mk282 (Nov 9, 2014)

I'm thinking it might be better to just send the relevant Program Change. So if you want to trigger note #25, send PC #25. Makes much more sense to me.


----------



## studioj (Nov 9, 2014)

Good point... but I have a custom iPad controller that I'm trying to constrain to only 15 Program changes. In the spitfire UI it is easy to move the key switches so I would probably just move them to the bottom of the keyboard so the KS's would line up with PC 0-14. But it would be cool to be able to adjust the script if nec for other instruments (like 8dio and project Sam). Thank you!


----------



## mk282 (Nov 9, 2014)

In that case you just need to add or subtract a number from $MIDI_BYTE_1 constant in the code.


----------



## studioj (Nov 9, 2014)

Thank you! so would it read like this? (I have never done any kontakt scripting) :

on midi_in 
if ($MIDI_COMMAND = $MIDI_COMMAND_PROGRAM_CHANGE) 
ignore_midi 
set_midi($MIDI_CHANNEL,$MIDI_COMMAND_NOTE_ON,$MIDI_BYTE_1,0+X) 
wait(1000) 
set_midi($MIDI_CHANNEL,$MIDI_COMMAND_NOTE_OFF,$MIDI_BYTE_1,0+X) 
end if 
end on

? x would be the offset that I require....

thanks!


----------



## mk282 (Nov 10, 2014)

Nope, you're adding it at the wrong place. Needs to go directly after $MIDI_BYTE_1, but before the comma.


----------



## A.G (Nov 10, 2014)

Hi Studioj,
I'm familiar with your requirements, cause there are a few hardware synths (most vintage) which send Program Change (PC) starting from say #64. The PC offset your are talking about is called as *PC Base* in the MIDI standard.
I just created a complex Multi script for you where I added 3 UI knobs:
*1.* PC Base (offset). It offers negative -127 values and positive +127 ones. Zero value is equivalent of no offset.
*2.* Key Switch Velocity (KS Vel). I noted that Mario set this to 0 in his prototype which will not produce any KS Note ON by the way. Some instruments such as the Sample Modeling need dynamic KS for X-fading the articulations. For example velocity 127 is equivalent of 100% X-fading. That's why I added this knob.
*3.* KS Note OFF sending time. Here you can assign the time (in msec) for the KS Note OFF being sent. For example 300-400ms work well with most Instruments.


```
on init
  set_script_title("PC to KS")
  declare ui_knob $PC_base(-127, 127, 1) 
  set_text($PC_base,"PC Base")
  declare ui_knob $KS_Vel(1, 127, 1) 
  set_text($KS_Vel,"KS Vel")
  declare ui_knob $KS_OFF_time(0, 3000, 1) 
  set_text($KS_OFF_time,"OFF time")
  make_persistent($PC_base)
  make_persistent($KS_Vel)
  make_persistent($KS_OFF_time)
  _read_persistent_var($KS_OFF_time)
  move_control($PC_base,1,1)
  move_control($KS_Vel,3,1)
  move_control($KS_OFF_time,5,1)
  set_knob_label($KS_OFF_time,$KS_OFF_time & "ms")
end on

on ui_control($KS_OFF_time)
  set_knob_label($KS_OFF_time,$KS_OFF_time & "ms")
end on

on midi_in
  if ($MIDI_COMMAND=$MIDI_COMMAND_PROGRAM_CHANGE)
    ignore_midi
    set_midi($MIDI_CHANNEL,$MIDI_COMMAND_NOTE_ON,$MIDI_BYTE_1+$PC_base,$KS_Vel)
    wait($KS_OFF_time*1000)
    set_midi($MIDI_CHANNEL,$MIDI_COMMAND_NOTE_OFF,$MIDI_BYTE_1+$PC_base,0)
  end if
end on
```

Copy the code and paste it in the Multi script. Set the KS Vel and KS OFF time as shown in the image below.


----------



## mk282 (Nov 10, 2014)

A.G @ 10.11.2014 said:


> I noted that Mario set this to 0 in his prototype which will not produce any KS Note ON by the way.



Whoops, how careless of me. :oops:


----------



## A.G (Nov 10, 2014)

mk282 @ Mon Nov 10 said:


> Whoops, how careless of me. :oops:


Take easy dude, we know what you can o-[][]-o .


----------



## studioj (Nov 10, 2014)

Holy moly, thank you!! thanks so much for all the help guys, so appreciated. 

So if i set the PC Base to lets say "24" 
then will PC 0 trigger KS C0? (with note 0 = C-2)

The idea here is that I have program changes 0-15 (or maybe 1-16) on my iPad controller ... and I want to use these 16 PC's to switch every instrument I have regardless of where the instruments' keyswitches lie. Thank you so much for helping me out! 

Very cool Products AG! I don't use logic anymore but will certainly turn my Logic using colleagues on to your stuff.


----------



## A.G (Nov 10, 2014)

studioj @ Mon Nov 10 said:


> So if i set the PC Base to lets say "24" then will PC 0 trigger KS C0?


Definitely, PC Base does exactly that!


----------



## studioj (Nov 10, 2014)

this works great, thanks again!


----------

