on init
	hide_inst_icon
	make_perfview
	set_ui_width_px(1000)
	set_ui_height_px(750)
	set_script_title("")
	set_skin_offset(0)
	disable_logging($NI_LOG_MESSAGE)
	disable_logging($NI_LOG_WARNING)
	disable_logging($NI_LOG_WATCHING)
   reset_ksp_timer
   SET_CONDITION(NO_SYS_SCRIPT_RLS_TRIG)
   declare $GC:=0
	message("")


	declare $CN:=0
	while ($CN<128)
		set_key_type($CN, $NI_KEY_TYPE_NONE)
		set_key_color($CN, $KEY_COLOR_WHITE)
		remove_keyrange($CN)
		inc($CN)
	end while
	declare $SL_CNT := 0
	declare %SL_ALLOW[16] := (1)
	make_persistent     (%SL_ALLOW)
	read_persistent_var (%SL_ALLOW)

	if (%SL_ALLOW[0] = 1)
		set_keyrange(41, 52, "Sample Layer A")
		$CN:=41
		while ($CN<53)
			set_key_color($CN, $KEY_COLOR_YELLOW)
			inc($CN)
		end while
	else
		$CN:=41
		while ($CN<53)
			remove_keyrange($CN)
			set_key_color($CN, $KEY_COLOR_WHITE)
			inc($CN)
		end while
	end if
	if (%SL_ALLOW[1] = 1)
		set_keyrange(41, 47, "Sample Layer B")
		$CN:=41
		while ($CN<48)
			set_key_color($CN, $KEY_COLOR_RED)
			inc($CN)
		end while
	else
		$CN:=41
		while ($CN<48)
			remove_keyrange($CN)
			set_key_color($CN, $KEY_COLOR_WHITE)
			inc($CN)
		end while
	end if

	declare %KR_ENABLED[16] := (1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
	declare %KR_S[16] := (41,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
	declare %KR_E[16] := (52,47,127,127,127,127,127,127,127,127,127,127,127,127,127,127)
	declare %SL_FNP[16] := (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
	declare $SL_A_NCYCL := 0
	declare $SL_B_NCYCL := 0
	declare $SL_C_NCYCL := 0
	declare $SL_D_NCYCL := 0
	declare $SL_E_NCYCL := 0
	declare $SL_F_NCYCL := 0
	declare $SL_G_NCYCL := 0
	declare $SL_H_NCYCL := 0
	declare $SL_I_NCYCL := 0
	declare $SL_J_NCYCL := 0
	declare $SL_K_NCYCL := 0
	declare $SL_L_NCYCL := 0
	declare $SL_M_NCYCL := 0
	declare $SL_N_NCYCL := 0
	declare $SL_O_NCYCL := 0
	declare $SL_P_NCYCL := 0

	declare %SL_A_NCYCL[128] := (0)
	declare %SL_B_NCYCL[128] := (0)
	declare %SL_C_NCYCL[128] := (0)
	declare %SL_D_NCYCL[128] := (0)
	declare %SL_E_NCYCL[128] := (0)
	declare %SL_F_NCYCL[128] := (0)
	declare %SL_G_NCYCL[128] := (0)
	declare %SL_H_NCYCL[128] := (0)
	declare %SL_I_NCYCL[128] := (0)
	declare %SL_J_NCYCL[128] := (0)
	declare %SL_K_NCYCL[128] := (0)
	declare %SL_L_NCYCL[128] := (0)
	declare %SL_M_NCYCL[128] := (0)
	declare %SL_N_NCYCL[128] := (0)
	declare %SL_O_NCYCL[128] := (0)
	declare %SL_P_NCYCL[128] := (0)

	declare $SL_CHAIN_DEF_CNT := 0
	declare $SL_CHAIN_REL_CNT := 0
	declare $CHPOS_DEF := 0
	declare $CHPOS_REL := 0
	declare %SL_CHAIN_DEF_PB_ARR[16]
	declare %SL_CHAIN_REL_PB_ARR[16]
	declare %SL_CHAIN_DEF_ARR[16]
	declare %SL_CHAIN_REL_ARR[16]
			%SL_CHAIN_DEF_ARR[0] := 1
			%SL_CHAIN_DEF_ARR[1] := 1
			%SL_CHAIN_DEF_ARR[2] := 0
			%SL_CHAIN_DEF_ARR[3] := 0
			%SL_CHAIN_DEF_ARR[4] := 0
			%SL_CHAIN_DEF_ARR[5] := 0
			%SL_CHAIN_DEF_ARR[6] := 0
			%SL_CHAIN_DEF_ARR[7] := 0
			%SL_CHAIN_DEF_ARR[8] := 0
			%SL_CHAIN_DEF_ARR[9] := 0
			%SL_CHAIN_DEF_ARR[10] := 0
			%SL_CHAIN_DEF_ARR[11] := 0
			%SL_CHAIN_DEF_ARR[12] := 0
			%SL_CHAIN_DEF_ARR[13] := 0
			%SL_CHAIN_DEF_ARR[14] := 0
			%SL_CHAIN_DEF_ARR[15] := 0
			%SL_CHAIN_REL_ARR[0] := 0
			%SL_CHAIN_REL_ARR[1] := 0
			%SL_CHAIN_REL_ARR[2] := 0
			%SL_CHAIN_REL_ARR[3] := 0
			%SL_CHAIN_REL_ARR[4] := 0
			%SL_CHAIN_REL_ARR[5] := 0
			%SL_CHAIN_REL_ARR[6] := 0
			%SL_CHAIN_REL_ARR[7] := 0
			%SL_CHAIN_REL_ARR[8] := 0
			%SL_CHAIN_REL_ARR[9] := 0
			%SL_CHAIN_REL_ARR[10] := 0
			%SL_CHAIN_REL_ARR[11] := 0
			%SL_CHAIN_REL_ARR[12] := 0
			%SL_CHAIN_REL_ARR[13] := 0
			%SL_CHAIN_REL_ARR[14] := 0
			%SL_CHAIN_REL_ARR[15] := 0
	declare $SL_CHAIN_DEF_CNT_MAX := 1
	declare $SL_CHAIN_REL_CNT_MAX := 1
	declare polyphonic $SL_A_NOTE_ID := -1
	declare polyphonic $SL_B_NOTE_ID := -1
	declare polyphonic $SL_C_NOTE_ID := -1
	declare polyphonic $SL_D_NOTE_ID := -1
	declare polyphonic $SL_E_NOTE_ID := -1
	declare polyphonic $SL_F_NOTE_ID := -1
	declare polyphonic $SL_G_NOTE_ID := -1
	declare polyphonic $SL_H_NOTE_ID := -1
	declare polyphonic $SL_I_NOTE_ID := -1
	declare polyphonic $SL_J_NOTE_ID := -1
	declare polyphonic $SL_K_NOTE_ID := -1
	declare polyphonic $SL_L_NOTE_ID := -1
	declare polyphonic $SL_M_NOTE_ID := -1
	declare polyphonic $SL_N_NOTE_ID := -1
	declare polyphonic $SL_O_NOTE_ID := -1
	declare polyphonic $SL_P_NOTE_ID := -1
	declare %YOFFSET[16] := (0)
	%YOFFSET[0] := 0
	%YOFFSET[1] := 818
	%YOFFSET[2] := 1636
	%YOFFSET[3] := 2454
	%YOFFSET[4] := 3272
	%YOFFSET[5] := 4090
	%YOFFSET[6] := 4908
	%YOFFSET[7] := 5726
	%YOFFSET[8] := 6544
	%YOFFSET[9] := 7362
	%YOFFSET[10] := 8180
	%YOFFSET[11] := 8998
	%YOFFSET[12] := 9816
	%YOFFSET[13] := 10634
	%YOFFSET[14] := 11452
	%YOFFSET[15] := 12270
	declare $PANELITEMCNT := 0
	declare %PANEL1_UIID[999] := (-1)
	declare %PANEL2_UIID[999] := (-1)
	declare %PANEL3_UIID[999] := (-1)
	declare %PANEL4_UIID[999] := (-1)
	declare %PANEL5_UIID[999] := (-1)
	declare %PANEL6_UIID[999] := (-1)
	declare %PANEL7_UIID[999] := (-1)
	declare %PANEL8_UIID[999] := (-1)
	declare %PANEL9_UIID[999] := (-1)
	declare %PANEL10_UIID[999] := (-1)
	declare %PANEL11_UIID[999] := (-1)
	declare %PANEL12_UIID[999] := (-1)
	declare %PANEL13_UIID[999] := (-1)
	declare %PANEL14_UIID[999] := (-1)
	declare %PANEL15_UIID[999] := (-1)
	declare %PANEL16_UIID[999] := (-1)
	declare %PANELITEMS[16] := (0)
   declare $NEWPANEL := 0

   declare %SLTUN_OCT[16]  := (0)
   declare %SLTUN_SEMI[16] := (0)
   declare %SLTUN_FINE[16] := (0)
	make_persistent (%SLTUN_OCT)
	make_persistent (%SLTUN_SEMI)
	make_persistent (%SLTUN_FINE)
	read_persistent_var (%SLTUN_OCT)
	read_persistent_var (%SLTUN_SEMI)
	read_persistent_var (%SLTUN_FINE)

	declare %INIT_DONE[1]
			%INIT_DONE[0]:=0

	declare %RESET_DONE[1]
			%RESET_DONE[0]:=0

	load_array(%RESET_DONE,1)

	if (%RESET_DONE[0]=1)
	end if

	declare $PREVIEW_NOTE_ID := -1

	declare ui_switch $DEBUG_WP_SWITCH
	set_control_par (get_ui_id($DEBUG_WP_SWITCH),$CONTROL_PAR_HIDE,16)
	declare                        %DEBUG_WP_STATE[1]
	                               %DEBUG_WP_STATE[0]:=1


	if (1=1)
						    { Name: KNOB_KV58TBCT2K1 }
	declare ui_slider              $KNOB_KV58TBCT2K1 (0,127)
	set_control_par_str (get_ui_id($KNOB_KV58TBCT2K1),$CONTROL_PAR_PICTURE,"Sudanes bongoz_bend_slider_hor_left_med_128fKV58TBCT2K1")
	set_control_par_str (get_ui_id($KNOB_KV58TBCT2K1),$CONTROL_PAR_HELP,"")
	set_control_par     (get_ui_id($KNOB_KV58TBCT2K1),$CONTROL_PAR_DEFAULT_VALUE,0)
	set_control_par     (get_ui_id($KNOB_KV58TBCT2K1),$CONTROL_PAR_POS_X,136)
	set_control_par     (get_ui_id($KNOB_KV58TBCT2K1),$CONTROL_PAR_POS_Y,60)
	set_control_par     (get_ui_id($KNOB_KV58TBCT2K1),$CONTROL_PAR_Z_LAYER,1)
	set_control_par     (get_ui_id($KNOB_KV58TBCT2K1),$CONTROL_PAR_MOUSE_BEHAVIOUR,-500)
	set_control_par_str (get_ui_id($KNOB_KV58TBCT2K1),$CONTROL_PAR_AUTOMATION_NAME,"KNOB_KV58TBCT2K1")
	set_control_par     (get_ui_id($KNOB_KV58TBCT2K1),$CONTROL_PAR_AUTOMATION_ID,0)
	set_control_par     (get_ui_id($KNOB_KV58TBCT2K1),$CONTROL_PAR_ALLOW_AUTOMATION,1)
	make_persistent               ($KNOB_KV58TBCT2K1)
	read_persistent_var           ($KNOB_KV58TBCT2K1)
	declare ui_label               $KNOB_KV58TBCT2K1_LABEL (1,1)
	set_control_par_str (get_ui_id($KNOB_KV58TBCT2K1_LABEL),$CONTROL_PAR_TEXT,"REVERB")
	set_control_par     (get_ui_id($KNOB_KV58TBCT2K1_LABEL),$CONTROL_PAR_FONT_TYPE,17)
	set_control_par     (get_ui_id($KNOB_KV58TBCT2K1_LABEL),$CONTROL_PAR_TEXT_ALIGNMENT,1)
	set_control_par     (get_ui_id($KNOB_KV58TBCT2K1_LABEL),$CONTROL_PAR_WIDTH,96)
	set_control_par     (get_ui_id($KNOB_KV58TBCT2K1_LABEL),$CONTROL_PAR_POS_X,112)
	set_control_par     (get_ui_id($KNOB_KV58TBCT2K1_LABEL),$CONTROL_PAR_POS_Y,188)
	set_control_par     (get_ui_id($KNOB_KV58TBCT2K1_LABEL),$CONTROL_PAR_HIDE,$HIDE_PART_BG)

	%PANEL1_UIID[0] :=   get_ui_id($KNOB_KV58TBCT2K1)
	%PANEL1_UIID[1] :=   get_ui_id($KNOB_KV58TBCT2K1_LABEL)
	declare !KNOB_KV58TBCT2K1_IMG[16]
			!KNOB_KV58TBCT2K1_IMG[0]:="Sudanes bongoz_bend_slider_hor_left_med_128fKV58TBCT2K1"
			!KNOB_KV58TBCT2K1_IMG[1]:="Sudanes bongoz_bend_slider_hor_left_med_128fKV58TBCT2K1"
			!KNOB_KV58TBCT2K1_IMG[2]:="Sudanes bongoz_bend_slider_hor_left_med_128fKV58TBCT2K1"
			!KNOB_KV58TBCT2K1_IMG[3]:="Sudanes bongoz_bend_slider_hor_left_med_128fKV58TBCT2K1"
			!KNOB_KV58TBCT2K1_IMG[4]:="Sudanes bongoz_bend_slider_hor_left_med_128fKV58TBCT2K1"
			!KNOB_KV58TBCT2K1_IMG[5]:="Sudanes bongoz_bend_slider_hor_left_med_128fKV58TBCT2K1"
			!KNOB_KV58TBCT2K1_IMG[6]:="Sudanes bongoz_bend_slider_hor_left_med_128fKV58TBCT2K1"
			!KNOB_KV58TBCT2K1_IMG[7]:="Sudanes bongoz_bend_slider_hor_left_med_128fKV58TBCT2K1"
			!KNOB_KV58TBCT2K1_IMG[8]:="Sudanes bongoz_bend_slider_hor_left_med_128fKV58TBCT2K1"
			!KNOB_KV58TBCT2K1_IMG[9]:="Sudanes bongoz_bend_slider_hor_left_med_128fKV58TBCT2K1"
			!KNOB_KV58TBCT2K1_IMG[10]:="Sudanes bongoz_bend_slider_hor_left_med_128fKV58TBCT2K1"
			!KNOB_KV58TBCT2K1_IMG[11]:="Sudanes bongoz_bend_slider_hor_left_med_128fKV58TBCT2K1"
			!KNOB_KV58TBCT2K1_IMG[12]:="Sudanes bongoz_bend_slider_hor_left_med_128fKV58TBCT2K1"
			!KNOB_KV58TBCT2K1_IMG[13]:="Sudanes bongoz_bend_slider_hor_left_med_128fKV58TBCT2K1"
			!KNOB_KV58TBCT2K1_IMG[14]:="Sudanes bongoz_bend_slider_hor_left_med_128fKV58TBCT2K1"
			!KNOB_KV58TBCT2K1_IMG[15]:="Sudanes bongoz_bend_slider_hor_left_med_128fKV58TBCT2K1"
	declare %KNOB_KV58TBCT2K1_XYMS[3*16]:=(136,60,-500,136,60,-500,136,60,-500,136,60,-500,136,60,-500,136,60,-500,136,60,-500,136,60,-500,136,60,-500,136,60,-500,136,60,-500,136,60,-500,136,60,-500,136,60,-500,136,60,-500,136,60,-500)


	end if
	if (1=1)
						    { Name: KNOB_T3F5AME7QS2 }
	declare ui_slider              $KNOB_T3F5AME7QS2 (0,127)
	set_control_par_str (get_ui_id($KNOB_T3F5AME7QS2),$CONTROL_PAR_PICTURE,"Sudanes bongoz_bend_slider_hor_right_med_128fT3F5AME7QS2")
	set_control_par_str (get_ui_id($KNOB_T3F5AME7QS2),$CONTROL_PAR_HELP,"")
	set_control_par     (get_ui_id($KNOB_T3F5AME7QS2),$CONTROL_PAR_DEFAULT_VALUE,0)
	set_control_par     (get_ui_id($KNOB_T3F5AME7QS2),$CONTROL_PAR_POS_X,616)
	set_control_par     (get_ui_id($KNOB_T3F5AME7QS2),$CONTROL_PAR_POS_Y,60)
	set_control_par     (get_ui_id($KNOB_T3F5AME7QS2),$CONTROL_PAR_Z_LAYER,1)
	set_control_par     (get_ui_id($KNOB_T3F5AME7QS2),$CONTROL_PAR_MOUSE_BEHAVIOUR,-500)
	set_control_par_str (get_ui_id($KNOB_T3F5AME7QS2),$CONTROL_PAR_AUTOMATION_NAME,"KNOB_T3F5AME7QS2")
	set_control_par     (get_ui_id($KNOB_T3F5AME7QS2),$CONTROL_PAR_AUTOMATION_ID,1)
	set_control_par     (get_ui_id($KNOB_T3F5AME7QS2),$CONTROL_PAR_ALLOW_AUTOMATION,1)
	make_persistent               ($KNOB_T3F5AME7QS2)
	read_persistent_var           ($KNOB_T3F5AME7QS2)
	declare ui_label               $KNOB_T3F5AME7QS2_LABEL (1,1)
	set_control_par_str (get_ui_id($KNOB_T3F5AME7QS2_LABEL),$CONTROL_PAR_TEXT,"DELAY")
	set_control_par     (get_ui_id($KNOB_T3F5AME7QS2_LABEL),$CONTROL_PAR_FONT_TYPE,17)
	set_control_par     (get_ui_id($KNOB_T3F5AME7QS2_LABEL),$CONTROL_PAR_TEXT_ALIGNMENT,1)
	set_control_par     (get_ui_id($KNOB_T3F5AME7QS2_LABEL),$CONTROL_PAR_WIDTH,96)
	set_control_par     (get_ui_id($KNOB_T3F5AME7QS2_LABEL),$CONTROL_PAR_POS_X,592)
	set_control_par     (get_ui_id($KNOB_T3F5AME7QS2_LABEL),$CONTROL_PAR_POS_Y,188)
	set_control_par     (get_ui_id($KNOB_T3F5AME7QS2_LABEL),$CONTROL_PAR_HIDE,$HIDE_PART_BG)

	%PANEL1_UIID[2] :=   get_ui_id($KNOB_T3F5AME7QS2)
	%PANEL1_UIID[3] :=   get_ui_id($KNOB_T3F5AME7QS2_LABEL)
	declare !KNOB_T3F5AME7QS2_IMG[16]
			!KNOB_T3F5AME7QS2_IMG[0]:="Sudanes bongoz_bend_slider_hor_right_med_128fT3F5AME7QS2"
			!KNOB_T3F5AME7QS2_IMG[1]:="Sudanes bongoz_bend_slider_hor_right_med_128fT3F5AME7QS2"
			!KNOB_T3F5AME7QS2_IMG[2]:="Sudanes bongoz_bend_slider_hor_right_med_128fT3F5AME7QS2"
			!KNOB_T3F5AME7QS2_IMG[3]:="Sudanes bongoz_bend_slider_hor_right_med_128fT3F5AME7QS2"
			!KNOB_T3F5AME7QS2_IMG[4]:="Sudanes bongoz_bend_slider_hor_right_med_128fT3F5AME7QS2"
			!KNOB_T3F5AME7QS2_IMG[5]:="Sudanes bongoz_bend_slider_hor_right_med_128fT3F5AME7QS2"
			!KNOB_T3F5AME7QS2_IMG[6]:="Sudanes bongoz_bend_slider_hor_right_med_128fT3F5AME7QS2"
			!KNOB_T3F5AME7QS2_IMG[7]:="Sudanes bongoz_bend_slider_hor_right_med_128fT3F5AME7QS2"
			!KNOB_T3F5AME7QS2_IMG[8]:="Sudanes bongoz_bend_slider_hor_right_med_128fT3F5AME7QS2"
			!KNOB_T3F5AME7QS2_IMG[9]:="Sudanes bongoz_bend_slider_hor_right_med_128fT3F5AME7QS2"
			!KNOB_T3F5AME7QS2_IMG[10]:="Sudanes bongoz_bend_slider_hor_right_med_128fT3F5AME7QS2"
			!KNOB_T3F5AME7QS2_IMG[11]:="Sudanes bongoz_bend_slider_hor_right_med_128fT3F5AME7QS2"
			!KNOB_T3F5AME7QS2_IMG[12]:="Sudanes bongoz_bend_slider_hor_right_med_128fT3F5AME7QS2"
			!KNOB_T3F5AME7QS2_IMG[13]:="Sudanes bongoz_bend_slider_hor_right_med_128fT3F5AME7QS2"
			!KNOB_T3F5AME7QS2_IMG[14]:="Sudanes bongoz_bend_slider_hor_right_med_128fT3F5AME7QS2"
			!KNOB_T3F5AME7QS2_IMG[15]:="Sudanes bongoz_bend_slider_hor_right_med_128fT3F5AME7QS2"
	declare %KNOB_T3F5AME7QS2_XYMS[3*16]:=(616,60,-500,616,60,-500,616,60,-500,616,60,-500,616,60,-500,616,60,-500,616,60,-500,616,60,-500,616,60,-500,616,60,-500,616,60,-500,616,60,-500,616,60,-500,616,60,-500,616,60,-500,616,60,-500)


	end if

	%PANELITEMS[0]:=4
	%PANELITEMS[1]:=0
	%PANELITEMS[2]:=0
	%PANELITEMS[3]:=0
	%PANELITEMS[4]:=0
	%PANELITEMS[5]:=0
	%PANELITEMS[6]:=0
	%PANELITEMS[7]:=0
	%PANELITEMS[8]:=0
	%PANELITEMS[9]:=0
	%PANELITEMS[10]:=0
	%PANELITEMS[11]:=0
	%PANELITEMS[12]:=0
	%PANELITEMS[13]:=0
	%PANELITEMS[14]:=0
	%PANELITEMS[15]:=0

	$PANELITEMCNT:=0
	while($PANELITEMCNT<4)
		set_control_par(%PANEL1_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL2_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL3_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL4_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL5_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL6_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL7_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL8_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL9_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL10_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL11_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL12_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL13_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL14_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL15_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL16_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while

	$PANELITEMCNT:=0
	while($PANELITEMCNT<4)
		set_control_par(%PANEL1_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,0)
		set_control_par(%PANEL1_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,$HIDE_PART_BG)
		inc($PANELITEMCNT)
	end while

end on
on persistence_changed
	save_array(%INIT_DONE,1)
	%RESET_DONE[0]:=0
	save_array(%RESET_DONE,1)
end on
function UPDATE_PANEL_ITEMS
	set_control_par_str (get_ui_id($KNOB_KV58TBCT2K1),$CONTROL_PAR_PICTURE,!KNOB_KV58TBCT2K1_IMG[$NEWPANEL])
	set_control_par     (get_ui_id($KNOB_KV58TBCT2K1),$CONTROL_PAR_POS_X,%KNOB_KV58TBCT2K1_XYMS[0+($NEWPANEL*3)])
	set_control_par     (get_ui_id($KNOB_KV58TBCT2K1),$CONTROL_PAR_POS_Y,%KNOB_KV58TBCT2K1_XYMS[1+($NEWPANEL*3)])
	set_control_par     (get_ui_id($KNOB_KV58TBCT2K1),$CONTROL_PAR_MOUSE_BEHAVIOUR,%KNOB_KV58TBCT2K1_XYMS[2+($NEWPANEL*3)])
	set_control_par     (get_ui_id($KNOB_KV58TBCT2K1_LABEL),$CONTROL_PAR_POS_X,%KNOB_KV58TBCT2K1_XYMS[0+($NEWPANEL*3)]-24)
	set_control_par     (get_ui_id($KNOB_KV58TBCT2K1_LABEL),$CONTROL_PAR_POS_Y,%KNOB_KV58TBCT2K1_XYMS[1+($NEWPANEL*3)]+128)
	set_control_par_str (get_ui_id($KNOB_T3F5AME7QS2),$CONTROL_PAR_PICTURE,!KNOB_T3F5AME7QS2_IMG[$NEWPANEL])
	set_control_par     (get_ui_id($KNOB_T3F5AME7QS2),$CONTROL_PAR_POS_X,%KNOB_T3F5AME7QS2_XYMS[0+($NEWPANEL*3)])
	set_control_par     (get_ui_id($KNOB_T3F5AME7QS2),$CONTROL_PAR_POS_Y,%KNOB_T3F5AME7QS2_XYMS[1+($NEWPANEL*3)])
	set_control_par     (get_ui_id($KNOB_T3F5AME7QS2),$CONTROL_PAR_MOUSE_BEHAVIOUR,%KNOB_T3F5AME7QS2_XYMS[2+($NEWPANEL*3)])
	set_control_par     (get_ui_id($KNOB_T3F5AME7QS2_LABEL),$CONTROL_PAR_POS_X,%KNOB_T3F5AME7QS2_XYMS[0+($NEWPANEL*3)]-24)
	set_control_par     (get_ui_id($KNOB_T3F5AME7QS2_LABEL),$CONTROL_PAR_POS_Y,%KNOB_T3F5AME7QS2_XYMS[1+($NEWPANEL*3)]+128)
end function

function _FUNC_HIDE_PANELS
	$PANELITEMCNT:=0
	while($PANELITEMCNT<4)
		set_control_par(%PANEL1_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL2_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL3_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL4_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL5_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL6_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL7_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL8_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL9_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL10_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL11_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL12_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL13_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL14_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL15_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while
	$PANELITEMCNT:=0
	while($PANELITEMCNT<0)
		set_control_par(%PANEL16_UIID[$PANELITEMCNT],$CONTROL_PAR_HIDE,16)
		inc($PANELITEMCNT)
	end while

end function

function _DO_KNOB_KV58TBCT2K1
	set_engine_par($ENGINE_PAR_IRC_LENGTH_RATIO_ER,$KNOB_KV58TBCT2K1*7812,-1,0,$NI_SEND_BUS)
	set_engine_par($ENGINE_PAR_SENDLEVEL_1,$KNOB_KV58TBCT2K1*7812,0,7,-1)
end function
function _DO_KNOB_T3F5AME7QS2
	set_engine_par($ENGINE_PAR_RDL_TIME,$KNOB_T3F5AME7QS2*7812,-1,2,$NI_SEND_BUS)
	set_engine_par($ENGINE_PAR_SENDLEVEL_2,$KNOB_T3F5AME7QS2*7812,0,7,-1)
end function
on ui_control ($KNOB_KV58TBCT2K1)
	call _DO_KNOB_KV58TBCT2K1
end on
on ui_control ($KNOB_T3F5AME7QS2)
	call _DO_KNOB_T3F5AME7QS2
end on
on ui_control ($DEBUG_WP_SWITCH)
	%DEBUG_WP_STATE[0] := 0
	save_array(%DEBUG_WP_STATE,1)
end on

on note
	disallow_group($ALL_GROUPS)
	disallow_group($ALL_GROUPS)
	ignore_event($EVENT_ID)
	set_event_par($EVENT_ID, 0, 2)
	$GC:=0
	while ($GC<16)
		if (%SL_CHAIN_REL_ARR[$GC] = 0)
			if (%KR_ENABLED[$GC] = 1)
				if (in_range($EVENT_NOTE, %KR_S[$GC], %KR_E[$GC]))
					if (%SL_FNP[$GC] = 0)
						set_event_par_arr($EVENT_ID, $EVENT_PAR_ALLOW_GROUP, %SL_ALLOW[$GC], $GC)
					end if
				end if
			end if
		end if
		inc($GC)
	end while
	play_note($EVENT_NOTE, $EVENT_VELOCITY, 0, -1)
end on
