Hello all. I’m getting some weird behaviour with sysex callbacks on long sysex messages. I wanted to code up a way to detect a Push by getting the standard MIDI sysex id request reply, then parsing it to check it matches a pattern.
The problem i am running into is that a message longer than 24 bytes seems to get split in two and the callback fires twice, with the first 24 bytes then the remainder (11 more bytes in the case of Push 1 which sends a 35 byte id reply).
The really annoying thing about Push is that it has two MIDI ports, but when you send an id request to either one, both respond to it! Madness. Anyway, i have it working ok, not perfectly, but it detects that Push has responded. I’m just capturing the 24 byte table and parsing that, but i would love to know whether i’m doing anything wrong.
Code is q ugly, but i just pulled out the function as it was when i discovered what was going on. I have rewritten it now to be a bit nicer.
function Push:findDeviceBySysex()
local id, result, t_input, t_output = {}, {}, {}
for i, device in ipairs(renoise.Midi.available_input_devices()) do
t_input[i] = renoise.Midi.create_input_device(device, nil,
function (reply)
id[device] = reply
print(t_input[i].name, id, os.clock())
rprint(id[i])
-- Close the port after callback gets fired so lose the last 11 bytes.
-- If the close() is commented out, then the reply is set to the last message response only (remaining 11 bytes) as callback is fired twice.
t_input[i]:close()
end
)
end
for _, device in ipairs(renoise.Midi.available_output_devices()) do
t_output = renoise.Midi.create_output_device(device)
t_output:send(Midi.sysex.id_request)
t_output:close()
end
print("hello", id)
rprint(id)
-- parse reply and set stuff here, blah blah blah, etc. nothing to do with the MIDI part.
end
I’m thinking i could just find a way to join the two tables. But maybe there is an answer? I started printing the clock time to see if it was anything to do with sending and receiving MIDI too fast, but it seems it gets buffered so that was not the problem. Thankfully, as i had plans to start using coroutines and all sorts of nonsense to sleep the call to close until the message was definitely sent…!
Edit: still on V3.2.1 as i have an old Mac running osx10.11.6.
Edit 2: electric boogaloo - i also verified that the sysex messages are being transmitted fully by Push using MIDI Monitor software, and they are always the full message including the EOX byte (247/F7).