What's new

Changing round robin cycle size

Alejandro

New Member
I'm building an instrument that has various articulations with different amounts of round robins. This is causing me problems because if I have 12 on articulation A and 10 on articulation B, then when I activate B (with a key switch) and play it, it will still count up to 12 and so I will play two notes that don't trigger anything until the cycle resets.

So my question is, is there a way that I could make Kontakts cycle count to one number when I triggered one articulation and a different number when I trigger another? Like setting the cycle max when a MIDI message is received for a specific keyswitch?

Thanks in advance to anyone who can help!
 

EvilDragon

KSP Wizard
Here's how it would work in your illustrated case (assuming articulation A is the first 12 groups then articulation B is the next 10 groups).

Code:
on init
    declare const $NUM_ARTICS := 2

    SET_CONDITION(NO_SYS_SCRIPT_GROUP_START)

    declare %artic_grp_start[$NUM_ARTICS] := (0, 12)
    declare %artic_key_min[$NUM_ARTICS] := (48, 60)    { set keyrange for articulations here, this is lowest key used for all artics }
    declare %artic_key_max[$NUM_ARTICS] := (84, 96)    { set keyrange for articulations here, this is highest key used for all artics }
    declare %KS[$NUM_ARTICS] := (36, 37)
    declare %NUM_RR[$NUM_ARTICS] := (12, 10)
    declare %RR_count[$NUM_ARTICS]

    declare $i
    declare $search_KS
    declare $sel_KS

    make_persistent($sel_KS)
end on


function KeyColor()
    $i := 0
    while ($i < 128)
        set_key_color($i, $KEY_COLOR_INACTIVE)
        set_key_type($i, $NI_KEY_TYPE_NONE)

        if (in_range($i, %artic_key_min[$sel_KS], %artic_key_max[$sel_KS]))
            set_key_color($i, $KEY_COLOR_BLUE)
            set_key_type($i, $NI_KEY_TYPE_DEFAULT)
        end if

        inc($i)
    end while

    $i := 0
    while ($i < $NUM_ARTICS)
        if ($i = $sel_KS)
            set_key_color(%KS[$i], $KEY_COLOR_GREEN)
        else
            set_key_color(%KS[$i], $KEY_COLOR_RED)
        end if

        set_key_type(%KS[$i], $NI_KEY_TYPE_CONTROL)

        inc($i)
    end while
end function


on persistence_changed
    call KeyColor()
end on


on note
    { process keyswitches }
    $search_KS := search(%KS, $EVENT_NOTE)
    if ($search_KS # -1)
        $sel_KS := $search_KS
        call KeyColor()

        exit
    end if

    { process playable keyrange }
    if (in_range($EVENT_NOTE, %artic_key_min[$sel_KS], %artic_key_max[$sel_KS]))
        disallow_group($ALL_GROUPS)
        allow_group(%RR_count[$sel_KS])

        if (%RR_count[$sel_KS] >= %NUM_RR[$sel_KS])
            %RR_count[$sel_KS] := 0
        else
            inc(%RR_count[$sel_KS])
        end if
    end if
end on
 
Top Bottom