Replies: 1 comment 6 replies
-
I think the tricky bit is balancing how SysEx messages can be supported by something like a stream parser whilst also retaining the existing mechanisms for other MIDI messages. The callback mechanism works really well for example, but how would that work alongside a MIDI.read() that is returning single SysEx bytes? I guess I'm struggling to think about the threading that will be required to balance a loop() doing MIDI.read()s with callbacks whilst still allowing some piecemeal building up of a SysEx message. We might need a diagram! Or an attempt to write some code against the proposed API to work out how it might fit together :) I'll chew it over and think a little more! Kevin |
Beta Was this translation helpful? Give feedback.
-
After having a discussion with DIYElectroMusic on Mastodon, it appears that the unreleased feature that allows chunking SysEx messages that are larger than the input buffer is confusing, and hard to work with.
Context
@lathoub contributed a change to allow large SysEx messages (larger than the input buffer) to still be received, but in a chunked manner, with special markers on the first and last byte to indicate what part of the message is being handled (beginning, middle, end).
I do agree that gracefully handling large messages is desirable (we can't always predict the largest SysEx length, or we may not have enough RAM to allocate such a buffer). Large messages are valid according to the spec, and so should be handled no matter what.
The issue of using the first and last data bytes as markers is that it makes parsing difficult, and may cause problems with Thru, by injecting made-up data that did not originate from the input.
The burden of parsing
Whether the SysEx message is sent complete, chunked, or even byte-streamed to the application, it remains the responsibility of application code to parse and interpret the SysEx data, a tasks which is usually repetitive, unsatisfying and prone to error.
We should probably provide ways to further parse a SysEx byte stream, allowing applications to give constraints for which messages to accept, and observe some relevant bytes in the message to ease the extraction of values.
This would essentially make the whole chunking system irrelevant, as SysEx data could be streamed to those parsers one byte at a time (when using OneByteParsing), or by chunks (when parsing as much data as available).
@lathoub, what do you think?
Beta Was this translation helpful? Give feedback.
All reactions