Iām trying to stop a MIDI loop with a keypress and restart the loop with the same keypress. The following function does stop the loop, but each successive keypress simply advances one note at a time from the point where it stopped.
k_pos = 0
function key(n,z)
if n == 3 then
if k_pos == 0 then
clk:start()
k_pos= 1
elseif k_pos == 1 then
clk:stop()
k_pos = 0
end
end
end
How should this be handled? Thanks.