{When Instrument Loads}
on init
	make_perfview {create performance view}
	set_ui_height_px(300) {set height of performance view}

	{create three buttons to turn on and off each trigger and release trigger group}
	declare ui_button $group_1_button
	declare ui_button $group_2_button
	declare ui_button $group_3_button

	$group_1_button := 1
	$group_2_button := 0
	$group_3_button := 0

	declare $group_1_active := 1
	declare $group_2_active := 0
	declare $group_3_active := 0

	{declaring a integer to store a note event later}
	declare $new_id2

end on

{when group one's button is pressed...}
on ui_control ($group_1_button)
	if ($group_1_button = 0)
		$group_1_active := 0
	else
		$group_1_active := 1
	end if
end on

on ui_control ($group_2_button)
	if ($group_2_button = 0)
		$group_2_active := 0
	else
		$group_2_active := 1
	end if
end on

on ui_control ($group_3_button)
	if ($group_3_button = 0)
		$group_3_active := 0
	else
		$group_3_active := 1
	end if
end on

{When a note on is received...}
on note
	disallow_group($ALL_GROUPS)

	if ($group_1_active = 1)
		allow_group(find_group("T-01"))
	else
		disallow_group(find_group("T-01"))
	end if

	if ($group_2_active = 1)
		allow_group(find_group("T-02"))
	else
		disallow_group(find_group("T-02"))
	end if

	if ($group_3_active = 1)
		allow_group(find_group("T-03"))
	else
		disallow_group(find_group("T-03"))
	end if

end on

{When a note off is received...}
on release
	disallow_group($ALL_GROUPS)

	if ($group_1_active = 1)
		allow_group(find_group("RT-01"))
	else
		disallow_group(find_group("RT-01"))
	end if

	if ($group_2_active = 1)
		allow_group(find_group("RT-02"))
	else
		disallow_group(find_group("RT-02"))
	end if

	if ($group_3_active = 1)
		allow_group(find_group("RT-03"))
	else
		disallow_group(find_group("RT-03"))
	end if

	$new_id2 := play_note($EVENT_NOTE,$EVENT_VELOCITY,0,0)

end on




