# Script Functions vs Kontakt Built-In Functions



## Hans Adamson (Apr 16, 2006)

Can scripting be used to affect Kontakt's built-in functions such as Round Robin?

If round robin is used in an instrument, can a script conditionally nullify the round robin?

If not, I assume a round robin function has to be written into the script to be possible to affect by script conditions?


----------



## Tod (Apr 16, 2006)

Hi Hans,

If you go here 

http://www.theokrueger.com/kontakt2.htm

and download Big Bob's TKT script it works great. Especialy if the samples are only a half step apart but also work well with whole steps.


----------



## kotori (Apr 16, 2006)

I agree with Thonex. I don't think scripts can cause a group to be used that has a false group start condition. But they can turn off groups that have true start conditions (the conditions I'm talking about is those set in the Kontakt user interface).

In additions to the benefits mentioned in the previous post I could add that scripts have the ability to handle polyphonic playing much nicer. With normal round robin (RR) if you press notes A and B at the same time and then after a while notes C and D simultaneously the latter pair of notes may use the exact same groups as the first causing the machine gun effect. If you just have two groups to alternate between playing A+B will cause the RR to toggle twice, so C+D will use the same groups.
Scripts can be smarter. By calculating the interval between notes they can determine whether the interval is small enough for the notes to be considered been played polyphonically. In that case the RR state should not be changed. Thus A and B will use group 1 and C and D will use group 2. This technique is used in the VSL 1+2 alternation patches bundled with Kontakt.

Here's a minimal round-robin script (without the note interval detection).


```
on init
  declare $i
end on

on note
  { allow only the group having index $i }
  disallow_group($ALL_GROUPS)
  allow_group($i)  
  
  { toggle between 0 and 1 }
  $i := ($i + 1) mod 2  
end on
```


----------



## Thonex (Apr 17, 2006)

kotori @ Sun Apr 16 said:


> ```
> $i := ($i + 1) mod 2
> ```



oooohhh.... what a clever 1 line toggle!!!!

I love little gems like that. :smile: 

T


----------



## Big Bob (Apr 19, 2006)

Or since everyone has recently discovered the .and. operator you could do it as:

```
$i := ($i + 1) .and. 1
```

:razz:


----------

