Extend the bad-sysex guard to the Continue state (Ref #39) - #40
Open
sauloverissimo wants to merge 1 commit into
Open
Extend the bad-sysex guard to the Continue state (Ref #39)#40sauloverissimo wants to merge 1 commit into
sauloverissimo wants to merge 1 commit into
Conversation
A status byte arriving after a Start or Continue packet has gone out (sysex7State==2) still bypassed the flush, dropping the buffered bytes and the interrupting message. Ref midi2-dev#39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The guard added in
2120c02testssysex7State==1, so a status byte arriving after a Start or Continue packet has already gone out (sysex7State==2) still gets through without a flush: the buffered bytes and the interrupting message are lost.Test 17 covers the case, in the style of Tests 13/15/16. The suite goes from 340 to 346 passing, 0 failures, and the new test fails without the one-character change.
I swept the behaviour exhaustively to confirm nothing else moves: an open SysEx with payloads of 0 to 14 bytes against all 128 possible status bytes. Below 7 bytes of payload there is not a single difference. From 7 up, 119 of the 128 change, and all of them are data-loss cases. The 9 that do not change are
F0 F6 F7 F8 FA FB FC FE FF, exactly the ones that must not flush.An aside, unrelated to this PR. Since midi2 (C99) does the opposite (it flushes the partial packet before emitting the real-time), I got curious and measured both on a Pico, with a 1 KB patch dump. Emitting the real-time first leaves it up to 1.92 ms ahead of wire order, per event; flushing the packet first removes that and costs 1.7% more UMPs at 120 BPM, 6% at 174 BPM. With a real-time every 6 bytes both emit exactly the same number of UMPs; at densities beyond that this side gets more expensive (every 2 bytes, which would be 1500 BPM). So I am coming round to it really not making a difference.