Skip to content

Extend the bad-sysex guard to the Continue state (Ref #39) - #40

Open
sauloverissimo wants to merge 1 commit into
midi2-dev:mainfrom
sauloverissimo:fix/sysex-guard-continue-state
Open

Extend the bad-sysex guard to the Continue state (Ref #39)#40
sauloverissimo wants to merge 1 commit into
midi2-dev:mainfrom
sauloverissimo:fix/sysex-guard-continue-state

Conversation

@sauloverissimo

Copy link
Copy Markdown
Contributor

The guard added in 2120c02 tests sysex7State==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.

F0 01 02 03 04 05 06 07 08 90 3C 7F
before: 30160102 03040506
after:  30160102 03040506 + 30220708 00000000 + 20903C7F

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.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant