# How to code a "Bypass Round Robin" button?



## peterwilson (Jul 9, 2010)

I have an instrument that uses Kontakt's inbuilt round-robin feature. Does anyone know how to code a button that can disable and enable round robin? Here is an example of what I mean:

*on init 
declare ui_button $BYPASS 
end on 

on ui_control ($BYPASS) 
if ($BYPASS = 1) 
***[set group 1 start option to "always"] ***
***[set group 3 start option to "never"] ***
***[set group 4 start option to "never"] ***
else 
***[set group 1 start option to "rd. robin" with position in round robin chain: 1] ***
***[set group 3 start option to "rd. robin" with position in round robin chain: 2] ***
***[set group 4 start option to "rd. robin" with position in round robin chain: 3] ***
end if 
end on*

The above would make a nice simple "on / off" round robin button. I've starred the code I don't know how to do above. I have done the usual searches, and manual search, but all I could find was a reference to retrieving the status of start group options.

Does anyone know how to do this? 

Thanks


----------



## EvilDragon (Jul 9, 2010)

Unfortunately, you cannot do that directly - KSP can only query the state of the Group Starting options, but you cannot change them at all.

You need to code your own way of round-robin to be able to do this.


----------



## EvilDragon (Jul 10, 2010)

I have noticed that Kontakt becomes sluggish when changing group start option parameters on the fly, especially the keyswitches, etc. I recommend coding your own RR at all times.


----------



## peterwilson (Jul 10, 2010)

Hi Blake,

Wow thanks for that! I've copied and pasted your code in, but it generates an error:

incorrect line: 


```
declare %rr_lastnote[256]
 "ERROR (line 8): constant value(s) expected for variable initializer(s)!"
```

Have you tried the code and it works?

I've tried a few things to fix it, but no go. I don't understand it fully, but once I see it in action think I could figure it out. Do you know what should be corrected in the code to get rid of the error?

Thanks


----------



## peterwilson (Jul 10, 2010)

Thanks so much for your help Blake 

The RR layers are playing as "one-shots", is this normal behaviour for the script? Everything plays as one-shots, the releases also sound on key-release even while the sustain pedal is pressed. Is there a way to fix this? 

[EDIT: I've tried making a few changes to the script, but haven't managed to fix it yet. I think once I see it working, I'll be able to figure out how it works and make changes. I'm a bit stumped on this one]


----------



## gregjazz (Jul 11, 2010)

Yeah, you can change group start criteria and their variables dynamically, but it can become buggy at times, at least in Kontakt 2.


----------

