# Keyswitch Persistence?



## kurtvanzo (Jun 18, 2016)

I've built an instrument with keyswitches using group start options and it all works great. But when I save the .nki with the sustains selected, then reload the instrument, nothing plays until I hit the sustain keyswitch again. I can see the samples are loading up fine and I have no disallow groups in the script. I have 4 round robins and am using group start for that as well (with "and" statements), but that's it. The script worked fine with just one set of groups (before I added more and keyswitches with group start).

I've checked here, the manual, the ref guide, NI forum... can't find my mistake. Any ideas? Thanks.


----------



## Gerhard Westphalen (Jun 18, 2016)

I don't know the "proper" way to do this but is it not possible for you to make it "play" the keyswitch note when the patch loads?


----------



## INCIRIOS (Jun 18, 2016)

Generally speaking this is done using a variable in the script which keeps track of the active keyswitch, then you reconfirm everything based on the variable during either the "on init" or initial "on listener" callback to ensure everything works as it appears on the UI - but afaik this only works when you are taking care of groups via script rather than the kontakt interface.

As Gerhard mentioned, it could be a possible workaround to have it play the keyswitch you want during the on listener callback (though I haven't tested if it would work) I would personally recommend looking into taking care of the groups within the script itself - if you need any help with how to do that you can always ask


----------



## kurtvanzo (Jun 18, 2016)

Thanks for the ideas. I'm just surprised it wouldn't save the keyswitch state with the .nki. This would mean everyone using the group start without a script always have the instrument load with all keyswitches unselected (nothing plays). Weird. But I can script the keyswitches using disallow/ allow groups if needed, I just wanted to learn how this would work. If anyone knows, I think the post (which I can't find anywhere) would be helpful to others.


----------



## kurtvanzo (Jun 18, 2016)

I've scripted the keyswitches but I'm having issues here too. My allow_group while loop apparently isn't working.

Can anyone share an on_note keyswitch script that is working (just the on_note section would help)? There must be a step I'm missing.


----------



## EvilDragon (Jun 19, 2016)

No need for scripting. If you're using Group Start Options to do keyswitching, then you have to adjust *Instrument Options -> Default keyswitch*. Save NKI afterwards.


----------



## INCIRIOS (Jun 19, 2016)

EvilDragon said:


> No need for scripting. If you're using Group Start Options to do keyswitching, then you have to adjust *Instrument Options -> Default keyswitch*. Save NKI afterwards.



I'm assuming this will only allow for a default keyswitch on loading the instrument - or does this then also set it up to save the active keyswitch for loading each time?


----------



## EvilDragon (Jun 19, 2016)

Only default keyswitch, yeah. Which was what I thought OP wanted to do.


----------



## kurtvanzo (Jun 19, 2016)

EvilDragon said:


> No need for scripting. If you're using Group Start Options to do keyswitching, then you have to adjust *Instrument Options -> Default keyswitch*. Save NKI afterwards.



Yes, this is the missing piece, thanks E.D.! Really appreciate it. So even with a scripted keyswitch this should work for the default upon loading the instrument, yes? So keyswitches don't get saved with the .nki, just this default setting? Or is there another way with scripted keyswitches?


----------



## EvilDragon (Jun 19, 2016)

No, that only works for GSO defined keyswitches, not scripted ones. For scripted ones, you need to do your own KS initializing by having play_note() right after init callback (use persistence_changed callback to have post-init things happening).


----------



## kurtvanzo (Jun 19, 2016)

EvilDragon said:


> No, that only works for GSO defined keyswitches, not scripted ones. For scripted ones, you need to do your own KS initializing by having play_note() right after init callback (use persistence_changed callback to have post-init things happening).



Thanks again. The option setting worked great for the kontakt keyswitch version. I wanted to see if I can build a scripted version to ve able to set up KS arrows for moving the keyswitches (like Orch Tools). i have most of it done besides solving the on_persistence, on_note section. i'll look into your suggestion (play_note on persistence_changed). Thanks!


----------

