Strange message in midi.onSysex

I am using the following code in LUA.

I get a strange message like this when sending a sysex dump (650 bytes) to Electra.

What does that mean, does Electra lose midi bytes?

I tested a much shorter (40 bytes) midi sysex message and then I didn’t get any error.

UPDATE:

I asked ChatGPT. If you have a large SysEx message (for example, hundreds of bytes), your for loop will print a huge amount of text.
Some environments (such as REAPER ReaScript, MIDI monitors, or embedded Lua) may truncate or corrupt the log output when there’s too much printed data.

Is this the correct answer Martin?

I have seen that it calculates correctly when it comes to the length of the sysex message so maybe this is not a problem…

A sysEx message of a few hundred bytes is nothing special…

Do check there is no MIDI clock running, incoming in the E1. There was an issue with the first version V4 beta release that the MIDI clock got intercepted as part of the sysEx leading to strange results.
Not sure that’s the reason but better first exclude it , I’d say.

1 Like

However, if you’re printing out those kinds of debug statements in a timer loop or in some other high volume routine, it will definitely glitch.

Note that the logic didn’t break, it’s just the output that messes up

Does it occur at the same byte every time?

I have a similar problem using lua midi.onSysex, but in my case the sysex message is always corrupted from byte 49 onwards regardless of the sysex message type. For sysex messages that I know are longer than 50 bytes (usually ~250 bytes), the length of the sysex block is also wrongly reported as 50 when I use sysexBlock:getLength. So instead of getting the full block, it gets 50 bytes of which the first 48 are correct, and then I get several other shorter nonsense messages. I’ve checked the sysex data block in MidiOx and it looks fine. There are no bytes greater than 7F that might break reading the sysex block. Any suggestions what could cause this? I have the synth’s MIDI clock turned off and the electra firmware is 4.1.1.

p.s. The problem persists if I use midi.onMessage rather than onSysex.

I have a similar problem using lua midi.onSysex, but in my case the sysex message is always corrupted from byte 49 onwards regardless of the sysex message type. For sysex messages that I know are longer than 50 bytes (usually ~250 bytes), the length of the sysex block is also wrongly reported as 50 when I use sysexBlock:getLength. So instead of getting the full block, it gets 50 bytes of which the first 48 are correct, and then I get several other shorter nonsense messages. I’ve checked the sysex data block in MidiOx and it looks fine. There are no bytes greater than 7F that might break reading the sysex block. Any suggestions what could cause this? I have the synth’s MIDI clock turned off and the electra firmware is 4.1.1.

p.s. The problem persists if I use midi.onMessage rather than onSysex.

Later: This problem arose when I had the synth connected to the electra mk II USB host port. If I connect them using a pair of DIN cables it works as it should. So maybe there’s a response/latency problem with the host port for longer messages? The synth is a Teensy 4.1 based device.

what type of synth do you run on the teensy board?

richardvanhoesel.com/gnd1t

I have not been able to reproduce that yet :frowning: I keep looking at it.

Do you have a Teensy 4.1? If so, I can see if I can write some short code for it that will allow you to replicate the problem.

only 3.2 and 3.6 here. Just ordered 4.1. I will let you know when it arrives.

teensy arrived. If you were able to make a firmware for it that I could use to replicate the problem, it would really save my time. Let me know. Thanks.

Hi Martin, sorry about the late reply, I didn’t see your message until today. I’ve created a small ino file (txt file attached) that waits for a Midi note-on event and then sends out from the T4.1 USB port a sysex block of 400 bytes containing 4 repeats of the values 0-100. If I connect the T4.1 to MIDI OX to trigger and look at the sysex output it all works just fine.

But when I connect the T4.1 to the electra host port, and use a button to send a note-on event, I can’t get the online lua editor to show any sysex response from the Teensy at all. There’s a led on the T4.1 to show that the sysex has been sent, and that lights up correctly. I’ve included the T4.1 ino src code and simplistic lua script I’m using in the attached txt file, as well as the compiled hex file for your t4.1.
If I hook up the T4.1 based synth that I tested a few weeks ago, and press a manual sysex dump from it, there is a response from the same lua script, but it gets corrupted after ~50 bytes as I mentioned previously.

In either case the host port sysex on my electra seems to not be behaving. Can you please let me know if you get the same result in case I have a hardware problem. Thanks.

lua and t4.1 ino.txt (1.8 KB)

T41_E1_sysex.ino.hex (73.2 KB)

Actually, I recall now that I asked another electra user who also has the same T4.1 based synth as I’m referring to here, and he saw the same corrupted data when reading sysex into the electra host port (and printing the data via lua). So it’s not a hardware issue specific to my electra unit.

I quite sure it is not a hardware thing. The USB protocol and the USB MIDI are quite complex, it is very unlikely that it would be caused by the hardware on a particular device. A hardware issue would most likely result in completely broken communication…

I will flash your firmware to my teensy and will use it to trace the communication / firmware with the hardware debugger. If the issue is reproducible as you describe it should be fairly easy to identify it.

I am currently almost fully occupied with finishing works on the E1 mini, but I will look at that as soon as I can. Both, OG E1 and E1 Mini share the same firmware.

1 Like

Hi Martin, did you get a chance to look at this?

it was so hectic here that I did not find a moment for that yet. It is still on my todo.