Working on a test script with midi clock and seeing some weird behavior.
I get inconsistent looking timing while simply trying to make a graphic blink on the norns display in time with midi clock. I’m testing with midi clock being sent from a TR-09 drum machine over USB-midi.
In the following, the on screen box blinks OK, but sometimes stays on for more than a beat. The print output to maiden for my blink flag seems super inconsistent watching it go by in the REPL. I feel like it should be printing right on the beat, but it stutters.
issue is more apparent at slower tempos like 40-80
Am i doing something stupid/wrong here or is this some deeper issue?
test script:
local blinker = false
function init()
midi.connect()
params:set("clock_source", 2)
clock.run(blink)
end
function blink()
while true do
clock.sync(1/2)
blinker = true
redraw()
clock.sync(1/2)
blinker = false
redraw()
end
end
function redraw()
screen.clear()
if blinker then
screen.level(12)
screen.rect(52, 20, 24, 24)
screen.fill()
-- screen.pixel(112, 6)
else
screen.level(1)
screen.rect(52, 20, 24, 24)
screen.fill()
end
print(blinker)
screen.stroke()
screen.update()
end