Disable set of key switches with menu
Hi Guys,
I am trying to have a menu that allows the user to move between a 'simple' and 'advanced' key switch system. The problem is that when I select advanced even though the red 'simple' key switch notes disappear and the magenta 'advanced' ones appear, the blacked out key switch 'simple' notes still work when the 'advanced' dropdown is selected. How do I disable $key_switch_1 to $key_switch_4 when the 'advanced' dropdown is selected?
on ui_control ($simple_advanced_menu) select ($simple_advanced_menu) case 0 {Simple Dropdown} set_key_color($key_switch_1, $KEY_COLOR_RED) set_key_color($key_switch_2, $KEY_COLOR_RED) set_key_color($key_switch_3, $KEY_COLOR_RED) set_key_color($key_switch_4, $KEY_COLOR_RED) set_control_par(get_ui_id($key_switch_1), $CONTROL_PAR_HIDE, $HIDE_PART_NOTHING) set_control_par(get_ui_id($key_switch_2), $CONTROL_PAR_HIDE, $HIDE_PART_NOTHING) set_control_par(get_ui_id($key_switch_3), $CONTROL_PAR_HIDE, $HIDE_PART_NOTHING) set_control_par(get_ui_id($key_switch_4), $CONTROL_PAR_HIDE, $HIDE_PART_NOTHING) set_control_par(get_ui_id($button_1), $CONTROL_PAR_HIDE, $HIDE_PART_NOTHING) set_control_par(get_ui_id($button_2), $CONTROL_PAR_HIDE, $HIDE_PART_NOTHING) set_control_par(get_ui_id($button_3), $CONTROL_PAR_HIDE, $HIDE_PART_NOTHING) set_control_par(get_ui_id($button_4), $CONTROL_PAR_HIDE, $HIDE_PART_NOTHING) set_control_par(get_ui_id($key_switch_1), $CONTROL_PAR_HIDE, $HIDE_PART_BG) set_control_par(get_ui_id($key_switch_2), $CONTROL_PAR_HIDE, $HIDE_PART_BG) set_control_par(get_ui_id($key_switch_3), $CONTROL_PAR_HIDE, $HIDE_PART_BG) set_control_par(get_ui_id($key_switch_4), $CONTROL_PAR_HIDE, $HIDE_PART_BG) set_control_par(get_ui_id($key_switch_5), $CONTROL_PAR_HIDE, $HIDE_WHOLE_CONTROL) set_control_par(get_ui_id($key_switch_6), $CONTROL_PAR_HIDE, $HIDE_WHOLE_CONTROL) set_control_par(get_ui_id($key_switch_7), $CONTROL_PAR_HIDE, $HIDE_WHOLE_CONTROL) set_control_par(get_ui_id($key_switch_8), $CONTROL_PAR_HIDE, $HIDE_WHOLE_CONTROL) set_control_par(get_ui_id($button_5), $CONTROL_PAR_HIDE, $HIDE_WHOLE_CONTROL) set_control_par(get_ui_id($button_6), $CONTROL_PAR_HIDE, $HIDE_WHOLE_CONTROL) set_control_par(get_ui_id($button_7), $CONTROL_PAR_HIDE, $HIDE_WHOLE_CONTROL) set_control_par(get_ui_id($button_8), $CONTROL_PAR_HIDE, $HIDE_WHOLE_CONTROL) case 1 {Advanced Dropdown} set_key_color($key_switch_5, $KEY_COLOR_MAGENTA) set_key_color($key_switch_6, $KEY_COLOR_MAGENTA) set_key_color($key_switch_7, $KEY_COLOR_MAGENTA) set_key_color($key_switch_8, $KEY_COLOR_MAGENTA) set_control_par(get_ui_id($key_switch_1), $CONTROL_PAR_HIDE, $HIDE_WHOLE_CONTROL) set_control_par(get_ui_id($key_switch_2), $CONTROL_PAR_HIDE, $HIDE_WHOLE_CONTROL) set_control_par(get_ui_id($key_switch_3), $CONTROL_PAR_HIDE, $HIDE_WHOLE_CONTROL) set_control_par(get_ui_id($key_switch_4), $CONTROL_PAR_HIDE, $HIDE_WHOLE_CONTROL) set_control_par(get_ui_id($button_1), $CONTROL_PAR_HIDE, $HIDE_WHOLE_CONTROL) set_control_par(get_ui_id($button_2), $CONTROL_PAR_HIDE, $HIDE_WHOLE_CONTROL) set_control_par(get_ui_id($button_3), $CONTROL_PAR_HIDE, $HIDE_WHOLE_CONTROL) set_control_par(get_ui_id($button_4), $CONTROL_PAR_HIDE, $HIDE_WHOLE_CONTROL) set_control_par(get_ui_id($key_switch_5), $CONTROL_PAR_HIDE, $HIDE_PART_NOTHING) set_control_par(get_ui_id($key_switch_6), $CONTROL_PAR_HIDE, $HIDE_PART_NOTHING) set_control_par(get_ui_id($key_switch_7), $CONTROL_PAR_HIDE, $HIDE_PART_NOTHING) set_control_par(get_ui_id($key_switch_8), $CONTROL_PAR_HIDE, $HIDE_PART_NOTHING) set_control_par(get_ui_id($button_5), $CONTROL_PAR_HIDE, $HIDE_PART_NOTHING) set_control_par(get_ui_id($button_6), $CONTROL_PAR_HIDE, $HIDE_PART_NOTHING) set_control_par(get_ui_id($button_7), $CONTROL_PAR_HIDE, $HIDE_PART_NOTHING) set_control_par(get_ui_id($button_8), $CONTROL_PAR_HIDE, $HIDE_PART_NOTHING) set_control_par(get_ui_id($key_switch_5), $CONTROL_PAR_HIDE, $HIDE_PART_BG) set_control_par(get_ui_id($key_switch_6), $CONTROL_PAR_HIDE, $HIDE_PART_BG) set_control_par(get_ui_id($key_switch_7), $CONTROL_PAR_HIDE, $HIDE_PART_BG) set_control_par(get_ui_id($key_switch_8), $CONTROL_PAR_HIDE, $HIDE_PART_BG) end select end on
Answers
-
You would do this in note callback, where you actually handle what incoming notes are supposed to do.
0 -
Ok, so looking at the Kontakt Factory Library the code below is for 4 key switches, how would you integrate buttons 5-8 and key switches 5-8 into that with the menus?
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 incoming note equals one of the six EXISTING keyswitches ignore them} if (search(%actual_keyswitches,$EVENT_NOTE) # -1) ignore_event($EVENT_ID) end if {if incoming note equals one of the six value edits} if ($EVENT_NOTE = $key_switch_1 or... $EVENT_NOTE = $key_switch_2 or... $EVENT_NOTE = $key_switch_3 or... $EVENT_NOTE = $key_switch_4) {set all buttons to zero} $count := 0 while ($count < 4) set_control_par(%articulation_id[$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 end if end on
0 -
I was expecting something like this might work but it doesn't activate the second set of KS, any ideas?:
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) 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) 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
0 -
Your branching is off kilter. You need an
end if
beforeif ($simple_advanced_menu = 1)
so that you close theif ($simple_advanced_menu = 0)
branch first. Then remove oneend if
from the end to match all the openings with closures. Watch out with indentation and all should be clearer.0 -
Ok so applying that I think this is what you mean? The advanced dropdown still isn't working though, is there something obvious missing from on note? It is weird as when I comment out all the = 0 elements key switches 5-8 work. I have attached the rest of the script just in case.
on note if($simple_advanced_menu = 0) 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 (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 end if if($simple_advanced_menu = 1) ignore_event($EVENT_ID) play_note(%actual_keyswitches2[$active_group2],1,0,1000) $played_note_id := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,-1) 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_group2 := 0 play_note(%actual_keyswitches2[0],1,0,1000) end if if($EVENT_NOTE = $key_switch_6) $button_6 := 1 $active_group2 := 1 play_note(%actual_keyswitches2[1],1,0,1000) end if if($EVENT_NOTE = $key_switch_7) $button_7 := 1 $active_group2 := 2 play_note(%actual_keyswitches2[2],1,0,1000) end if if($EVENT_NOTE = $key_switch_8) $button_8 := 1 $active_group2 := 3 play_note(%actual_keyswitches2[3],1,0,1000) end if end if end if end if end on
0 -
So the main thing is if you want the "advanced" to work with all 8 KS, you need to check for all 8 KS, not just 5-8.
But this code can be heavily optimized... you should store all the keyswitches in one single array, then you can search(array, $EVENT_NOTE) instead of doing individual checks for each KS and using
or
...0 -
That has sorted it, thank you very much.
0
Categories
- All Categories
- 19 Welcome
- 1.5K Hangout
- 62 NI News
- 785 Tech Talks
- 4.1K Native Access
- 16.5K Komplete
- 2K Komplete General
- 4.3K Komplete Kontrol
- 5.7K Kontakt
- 1.6K Reaktor
- 379 Battery 4
- 845 Guitar Rig & FX
- 429 Massive X & Synths
- 1.3K Other Software & Hardware
- 5.8K Maschine
- 7.3K Traktor
- 7.3K Traktor Software & Hardware
- Check out everything you can do
- Create an account
- See member benefits
- Answer questions
- Ask the community
- See product news
- Connect with creators