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

	declare ui_button $no_tone
	declare ui_button $yes_tone

	declare $rr_t := 0
	declare $rr_rt := 0

	declare $new_id2


end on

on note
	disallow_group($ALL_GROUPS)

	if ($no_tone > 0)
		
		if ($rr_t = 0)
			allow_group(find_group("T-01"))
		end if
		
		if ($rr_t = 1)
			allow_group(find_group("T-02"))
		end if

		if ($rr_t = 2)
			allow_group(find_group("T-03"))
		end if

	end if

	if ($yes_tone > 0)

		if ($rr_t = 0)
			allow_group(find_group("T-01-Tone"))
		end if
		
		if ($rr_t = 1)
			allow_group(find_group("T-02-Tone"))
		end if

		if ($rr_t = 2)
			allow_group(find_group("T-03-Tone"))
		end if

	end if

	if ($rr_t < 2)
		inc($rr)
	else
		$rr_t := 0
	end if

end on

on release
	disallow_group($ALL_GROUPS)

	if ($no_tone > 0)

		if ($rr_rt = 0)
			allow_group(find_group("RT-01"))
		end if
		
		if ($rr_rt = 1)
			allow_group(find_group("RT-02"))
		end if

		if ($rr_rt = 2)
			allow_group(find_group("RT-03"))
		end if

	end if

	if ($yes_tone > 0)
		
		if ($rr_rt = 0)
			allow_group(find_group("RT-01-Tone"))
		end if
		
		if ($rr_rt = 1)
			allow_group(find_group("RT-02-Tone"))
		end if

		if ($rr_rt = 2)
			allow_group(find_group("RT-03-Tone"))
		end if

	end if

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

	if ($rr_rt < 2)
		inc($rr_rt)
	else
		$rr_rt := 0
	end if
end on