I’m working on a norns sequencer that sends MIDI, but I’d also like to have it respond to external gear se ding start/stop commands.
In the “clocks” doc on line I see the functions for
… but I’m not sure how to implement them.
What is a basic way that I can manage this?
I think you should be able to handle the raw MIDI event with
You have to parse through the byte array, but it’s not too bad. The start and stop events don’t have a channel and it looks like they’re 1 byte each:
So just check
for those I think.
No - you don’t need to do that now.
m = midi.connect()
-- too send start/stop you can use these
-- to receive you can use this
m.event = function(data)
local d = midi.to_msg(data)
-- print something for various data types
-- ignore clock for the moment but look at other types
if d.type = "start" then
-- do stuff
if d.type = "stop" then
-- do stuff
otherwise use the clocks module like:
msg = midi.to_msg(data)
if msg.type == "start" then
elseif msg.type == "continue" then
if running then
if msg.type == "stop" then
see my MIDI Monitor script for more of that example
midi.to_msg looks a lot cleaner than bit-juggling. Just to make sure I’m following, it’s just abstracting these:
data == 250
data == 252
so you can instead use these (which are more descriptive and nicer):
d.type == "start"
d.type == "stop"
Is that right?
yeah, pretty much (it’s looking at the hex values instead of decimal) - see midi.lua for full details
Perfect! I’ll give that a shot and see how it goes.
Works perfectly! Thank you.