Solved: Strange behaviour sending a Sysex Message via lua API


I’m trying to send a sysex message to write to the screen of my MIDI controller. It requires 77 bytes, but if i send a 77 byte message correctly formatted from the midi_device:send(data) method, it loses a byte and won’t write the string. The controller needs to see the correct message length to react. So i have to send an extra byte padding, 78 bytes long total and then 77 bytes hit the controller port (have checked via snoize MIDI monitor snooper prog).

I will look into it further to see what’s being lost exactly, but just wanted to put this up for notice.

Right, i’ve done some more debugging and it’s very strange what’s going on.

What i’m trying to do is place a string into a template array which contains the correct number of bytes. There is a loop which parses a string out into individual characters and places them at the correct points of the array to be sent out via MIDI. When i check the length of the array before and after my loop it has 78 elements, but it will be sent as 77 bytes from Renoise lua API. I filled the array manually with repeating numbers, and the odd thing is that the byte which goes missing is the first one after the string i write into the array.

So if it goes 1, 2, 3, 4, 1, 2, 3, 4 and i overwrite the first 4 with “cool” then the next byte after is 2, not 1 as it should be. The last 5 bytes of the array are 1, 2, 3, 4, 5 and they stay the same. (goes to 5 because it has to be padded with extra number, this is the only instance of 5 in the array).

I can’t see how the loop would be doing this as it is still the same number of elements going out as it is coming in. Might be something to look into on the API side perhaps. Thanks.

Shit, just figured it out. Null character at the end of the string is getting written into the array somehow and deleting a field. Sorry, my fault.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.