hacktribe icon indicating copy to clipboard operation
hacktribe copied to clipboard

Fix long sysex messages

Open bangcorrupt opened this issue 2 years ago • 6 comments

Chunk long messages to reduce chance of failure.

Current workaround is Linux specific and generally bad.

bangcorrupt avatar Dec 30 '21 11:12 bangcorrupt

The solution I outlined in bangcorrupt/e2-scripts#9 should fix this.

maks avatar Feb 21 '22 08:02 maks

I had no issues sending SysEx in 512B chunks with no explicit delay, but probably best to stick to spec. It may be better to add this to mido, but I realise now it's been discussed a few times.

https://github.com/mido/mido/pull/60 https://github.com/mido/mido/issues/66 https://github.com/mido/mido/issues/207 https://github.com/mido/mido/issues/313

bangcorrupt avatar Feb 24 '22 11:02 bangcorrupt

@bangcorrupt sorry I may have got this confused, I thought this may have been why you had in your python code shelling out to amidi to send long sysex's: https://github.com/bangcorrupt/e2-scripts/blob/master/e2sysex.py#L224

But I can confirm that adding the delay got it working in my Flutter app, where the Dart code does call ALSA directly when running on Linux, whereas sending it all in one go doesn't work.

maks avatar Feb 24 '22 11:02 maks

No confusion, you are correct.

bangcorrupt avatar Feb 24 '22 11:02 bangcorrupt

I've just had a read of those mido issues and they do sound like exactly the problem thats involved here: keeping under the 31250b/s limit thats in the MIDI spec.

And it made me realise I should have mentioned that the library I'm using is calling the "rawmidi" interface from ALSA, so I'm not sure why he mido devs chose to create a backend based on amidi, but I guess it doesn't really matter as long as it works to keep the sending rate low enough.

maks avatar Feb 24 '22 11:02 maks

I forked mido and added a fix based on https://github.com/mido/mido/pull/60/commits/4e48566c614b8a2333b505b82613d153eb677689. This caused an exception in python-rtmidi so I forked that and removed the ValueError exception.

Pattern files now send without issue. There is still an issue with sending ifx presets (which are shorter), solved by splitting ifx preset into two chunks. This is likely a separate issue with the hacked code on the receiving end. The data is sent correctly by the OS, but a data format error (0x26) is received in response.

Sending note messages and CC while chunked sysex is transmitting will also cause errors. It's less bad than it was and removes Linux dependency.

bangcorrupt avatar Sep 28 '22 01:09 bangcorrupt