Can you us a note to change a menu item?

DaDrumBum1
DaDrumBum1 Member Posts: 8 Sine
edited July 2022 in Kontakt

First of all thank you so much to anyone who takes their time to help me with this question.

I am super new to scripting just started about 2 weeks ago, and I have menu items that allow different groups just like my key switches do. However I would like to be able to have the menu item change when the key switch is pressed.

Basically when I hit note 0 I want kontakt to select item 1 in my menu. I tried with the select command but that seems to not work or I did it wrong.

This way the user can either use a keyswitch or dropdown menu and still get visual feedback.

Is this possible in Kontakt? This is what I have so far.



on init

declare const $keyswitch1 := 0
declare const $keyswitch2 := 1
set_key_color($keyswitch1, $KEY_COLOR_RED)
set_key_color($keyswitch2, $KEY_COLOR_RED)
declare $current_state

  declare $count
    declare ui_menu $menu
    $menu := 1
    $count := 1
    while ($count < 14)
        add_menu_item ($menu, "Ethereal " & $count,$count)
        inc ($count)
    end while
end on

on note
disallow_group($ALL_GROUPS)

if ($current_state = 0)
    allow_group(0)
end if

if($current_state = 1)
    allow_group(1)
  end if

if ($EVENT_NOTE = $keyswitch1 or $menu = 1)
$current_state := 0

   select ($menu)
case 1
end select
    
end if

if ($EVENT_NOTE = $keyswitch2 or $menu = 2)
    $current_state := 1
select ($menu
case 2
end select
    
end if

end on



Best Answer

  • EvilDragon
    EvilDragon CroatiaModerator Posts: 811 mod
    Answer ✓

    This can be much simpler.


    on init
        declare const $NUM_KS := 2
        declare const $FIRST_KS := 0
    
        declare $i
    
        declare ui_menu $menu
    
        while ($i < $NUM_KS)
            add_menu_item($i, "Ethereal " & $i, $i)
            inc($i)
        end while
    
        make_persistent($menu)
    end on
    
    on note
        if (in_range($EVENT_NOTE, $FIRST_KS, $FIRST_KS + $NUM_KS - 1))
            $menu := $EVENT_NOTE - $FIRST_KS { this assumes the first menu entry value is always 0! }
            exit
        end if
    
        disallow_group($ALL_GROUPS)
        allow_group($menu)
    end on
    

Answers

  • Kaiwan_NI
    Kaiwan_NI BerlinAdministrator Posts: 1,702 admin

    @EvilDragon Can you help DaDrumBum1 with the scripting? 🙂

  • EvilDragon
    EvilDragon CroatiaModerator Posts: 811 mod
    Answer ✓

    This can be much simpler.


    on init
        declare const $NUM_KS := 2
        declare const $FIRST_KS := 0
    
        declare $i
    
        declare ui_menu $menu
    
        while ($i < $NUM_KS)
            add_menu_item($i, "Ethereal " & $i, $i)
            inc($i)
        end while
    
        make_persistent($menu)
    end on
    
    on note
        if (in_range($EVENT_NOTE, $FIRST_KS, $FIRST_KS + $NUM_KS - 1))
            $menu := $EVENT_NOTE - $FIRST_KS { this assumes the first menu entry value is always 0! }
            exit
        end if
    
        disallow_group($ALL_GROUPS)
        allow_group($menu)
    end on
    
  • DaDrumBum1
    DaDrumBum1 Member Posts: 8 Sine
    edited August 2022

    Thank you so much @EvilDragon!

Back To Top