Using menu to change key switch sets

Andrew Finch
Andrew Finch Member Posts: 17 Newcomer
edited March 2022 in Scripting Workshop

I have asked about this before but I am trying something a little different now and am stuck. I have tried to adapt the code from the Kontakt factory library so I can have two different sets of key switches (a 'simple' set and an 'advanced' set). The idea is that there is a menu with a dropdown for each set and when one is selected the other set is deactivated. However, I am struggling to disable the set of key switches that I am not using. Below is the 'on note' section of what I have so far but it isn't quite working. Any ideas? At the moment KS 1-4 work on the 'Simple' dropdown and then don't work on 'Advanced' (how I want it) but KS 5-8 don't work when the 'Advanced' dropdown (not how I want it!).

on note 
    
    ignore_event($EVENT_ID)
    play_note(%actual_keyswitches[$active_group],1,0,1000)
    $played_note_id := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,-1)
    
    
    if($simple_advanced_menu = 0) {Simple Dropdown}
        if (search(%actual_keyswitches,$EVENT_NOTE) # -1)
            ignore_event($EVENT_ID)
        end if
        if ($EVENT_NOTE = $key_switch_1 or...
            $EVENT_NOTE = $key_switch_2 or...
            $EVENT_NOTE = $key_switch_3 or...
            $EVENT_NOTE = $key_switch_4)
            
            
            $count := 0
            while ($count < 4)
                set_control_par(%articulation_id[$count],$CONTROL_PAR_VALUE,0)
                inc($count)
            end while
            
            $count := 0
            while ($count < 4)
                set_control_par(%articulation_id2[$count],$CONTROL_PAR_VALUE,0)
                inc($count)
            end while
            
            ignore_event($EVENT_ID)
            
            if($EVENT_NOTE = $key_switch_1)
                $button_1 := 1
                $active_group := 0
                play_note(%actual_keyswitches[0],1,0,1000)
            end if
            
            if($EVENT_NOTE = $key_switch_2)
                $button_2 := 1
                $active_group := 1
                play_note(%actual_keyswitches[1],1,0,1000)
            end if
            
            if($EVENT_NOTE = $key_switch_3)
                $button_3 := 1
                $active_group := 2
                play_note(%actual_keyswitches[2],1,0,1000)
            end if
            
            if($EVENT_NOTE = $key_switch_4)
                $button_4 := 1
                $active_group := 3
                play_note(%actual_keyswitches[3],1,0,1000)
            end if
            
            if($simple_advanced_menu = 1) {Advanced Dropdown}
                
                if (search(%actual_keyswitches2,$EVENT_NOTE) # -1)
                    ignore_event($EVENT_ID)
                end if
                
                if ($EVENT_NOTE = $key_switch_5 or...
                    $EVENT_NOTE = $key_switch_6 or...
                    $EVENT_NOTE = $key_switch_7 or...
                    $EVENT_NOTE = $key_switch_8)
                    
                    $count := 0
                    while ($count < 4)
                        set_control_par(%articulation_id[$count],$CONTROL_PAR_VALUE,0)
                        inc($count)
                    end while
                    
                    $count := 0
                    while ($count < 4)
                        set_control_par(%articulation_id2[$count],$CONTROL_PAR_VALUE,0)
                        inc($count)
                    end while
                    
                    if($EVENT_NOTE = $key_switch_5)
                        $button_5 := 1
                        $active_group := 4
                        play_note(%actual_keyswitches2[0],1,0,1000)
                    end if
                    
                    if($EVENT_NOTE = $key_switch_6)
                        $button_6 := 1
                        $active_group := 5
                        play_note(%actual_keyswitches2[1],1,0,1000)
                    end if
                    
                    if($EVENT_NOTE = $key_switch_7)
                        $button_7 := 1
                        $active_group := 6
                        play_note(%actual_keyswitches2[2],1,0,1000)
                    end if
                    
                    if($EVENT_NOTE = $key_switch_8)
                        $button_8 := 1
                        $active_group := 7
                        play_note(%actual_keyswitches2[3],1,0,1000)
                    end if
                end if
            end if
        end if
    end if
end on

Answers

  • EvilDragon
    EvilDragon Moderator Posts: 1,017 mod

    There was no need for a new thread, let's keep it in the original thread please.

This discussion has been closed.
Back To Top