# Changing sets of groups with CC, KS or Program Change - Kontakt



## Kevin Smithers (May 23, 2015)

Hi,

So, I'm trying to build an instrument with some percussion samples I recorded and wanted to figure out how to do the following:

I have samples for both soft and hard mallets and would like to have both sets of samples in the same instrument and just be able to switch between them with a KS, CC or program change.
I have 4 RR per sample so I thought I'd need 8 groups: 4 for soft mallets and 4 for hard mallets.

Issue is, I have no idea how to make Kontakt only cycle through the soft mallet groups and when to only cycle through the hard mallet groups when specified.

Any ideas or other ways to program this?
My knowledge about scripting in Kontakt is very limited, so if you know of any script that might help would you mind sharing?

Thanks a lot!


----------



## tomaslobosk (May 23, 2015)

This can be easily done with scripting... I can script it for you, but I'll need some time to do it.  

EDIT: Even without scripting this can be easily done:

Use Group Start Options: Assign all soft mallet groups to start with key C0, next, all hard mallet groups to start with key D0, and then you assign each RR group to the corresponding position in RR chain.

(You can use CC too, in Group Starts menu just select "start on controller"...)

It will look like this:






Greetings, 
Tomás.


----------



## Kevin Smithers (May 23, 2015)

Tomi,

Brilliant, thanks a lot! I'll give this a go.
Thanks.


----------



## Kevin Smithers (May 23, 2015)

Thomas, your solution worked perfectly, thanks a lot!

My only issue now is that the script that I've been using to create a RR reset button now doesn't work. When the script is active no samples get triggered anymore. Any idea? This is the script I'm using:

on init
declare ui_label $text (2,1)
declare ui_switch $Reset
declare $RRpos := 0

set_text($text,"Round-robin Position: " & $RRpos+1)

message("")
end on

on note
disallow_group($ALL_GROUPS)
allow_group($RRpos)
set_text($text,"Round-robin Position: " & $RRpos+1)
if ($RRpos # 7) 
inc($RRpos)
else
$RRpos := 0
end if
end on

on ui_control ($Reset)
if ($Reset = 1)
$RRpos := 0
$Reset := 0
set_text($text,"Round-robin Position: " & $RRpos+1)
end if
end on


----------



## polypx (May 23, 2015)

If you're using Kontakt to Round Robin, don't do it in the script as well... The built in Kontakt method doesn't "know about" the script, so they might be working against each other. Just use one or the other method.

cheers! Dan


----------



## Kevin Smithers (May 23, 2015)

What do you mean Dan? I had my RR setup in Kontakt (no script) and used that script to create a RR reset button. It was working fine before but since now I've added that extra layer of "group starts" it's no longer working.

How would you reset RR if not with a script?

Thanks!


----------



## tomaslobosk (May 23, 2015)

Kevin, as Dan stated before, if you're using Kontakt's own RR functionality, don't use custom RR scripting. If you want a RR reset button, bad news... you must script it :( 
good news... I can help you 

EDIT: This will do the job:


```
on init 
    message("") 
    declare ui_label $text1 (2,1) 
    declare ui_label $text2 (2,1) 
    declare ui_switch $reset 
    set_text ($reset ,"Reset RR")
    declare $RRpos:=1 
    make_persistent($RRpos)
    declare $RRlastvalue:=0
    make_persistent($RRlastvalue)
    read_persistent_var($RRlastvalue)
    set_text($text1,"RR Position: " & $RRlastvalue)
    declare $mallet:=0
    make_persistent($mallet)
    read_persistent_var($mallet)
    if ($mallet=0)
        set_text($text2,"Key Switch: Soft Mallet") 
        set_key_color(0,$KEY_COLOR_RED)
        set_key_color(1,$KEY_COLOR_BLUE)
    else
        set_text($text2,"Key Switch: Hard Mallet") 
        set_key_color(0,$KEY_COLOR_BLUE)
        set_key_color(1,$KEY_COLOR_RED)
    end if
end on 

on note
    select ($EVENT_NOTE)
        case 0
            $mallet:=0
            set_text($text2,"Key Switch: Soft Mallet") 
            set_key_color(0,$KEY_COLOR_RED)
            set_key_color(1,$KEY_COLOR_BLUE)
        case 1 
            $mallet:=1
            set_text($text2,"Key Switch: Hard Mallet") 
            set_key_color(0,$KEY_COLOR_BLUE)
            set_key_color(1,$KEY_COLOR_RED)
        case 2 to 127
            disallow_group($ALL_GROUPS) 
            select ($mallet)
                case 0
                    allow_group($RRpos-1)  
                case 1
                    allow_group($RRpos-1+4)    
            end select
            $RRlastvalue:=$RRpos
            if ($RRpos < 4) 
                inc($RRpos) 
            else 
                $RRpos := 1 
            end if
            set_text($text1,"RR Position: " & $RRlastvalue)
    end select
end on 

on ui_control ($reset) 
    $reset:=0 
    $RRpos:=1 
    set_text($text1,"RR Position: 0")
end on
```

Of course it isn't optimized, but you can study it and make the best of it.

Greetings, 
Tomás


----------



## Kevin Smithers (May 24, 2015)

Thank a lot Thomas! I'm getting a similar result that I had with my previous script where the RR reset, but Kontakt's not triggering the samples anymore. 

I'll have a look at it, good opportunity for me to get more into Kontakt scripting anyways.
Thanks for the help!


----------



## tomaslobosk (May 24, 2015)

You must disable all group start options for all groups if you're using scripting!


----------



## Kevin Smithers (May 24, 2015)

Gotcha, that makes sense. It works great man, thank you so much for the help!


----------



## tomaslobosk (May 24, 2015)

You are quite welcome


----------

