Fix MIDI 2.0 SysEx handling and add comprehensive test suite #22
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.
Fix MIDI 2.0 SysEx Handling and Add Comprehensive Test Suite
Problem
The
Messenger::process_input()method in PR #21 introduced a regression where it expected all MIDI-CI messages to start with theF0SysEx prefix. However, MIDI 2.0 Universal MIDI Packets (UMP) SysEx messages start directly with the Universal SysEx ID (0x7E) without theF0prefix, causing MIDI 2.0 input processing to fail.Solution
Messenger::process_input()to handle both MIDI 1.0 and MIDI 2.0 SysEx message formatsF0prefixlibremidi::midi_intransportF0prefix when receiving input from MIDI 1.0 sourcesTechnical Details
The fix introduces an
offsetvariable that detects the transport format:F0 7E ...(offset = 1)7E ...(offset = 0)All array access throughout the method now uses
data[index + offset]to correctly parse both formats.Comprehensive Test Suite
Ported extensive test coverage from the
ktmidi-ciKotlin module to prevent future regressions:New Test Files Added:
test_ci_factory.cpp- Discovery messages, profile configuration, MIDI CI 32-to-28 bit conversiontest_midi_ci_device_extended.cpp- Device initialization, connection establishment, MUID handlingtest_midi_ci_converter.cpp- String encoding/decoding to/from ASCII formattest_property_facades.cpp- Property exchange workflows and operationstest_profile_facades.cpp- Profile configuration and managementEnhanced Existing Tests:
test_messenger.cpp- Added specific tests for MIDI 1.0 vs MIDI 2.0 message processing validationTest Results
The 7 failing tests are pre-existing issues unrelated to this fix (property JSON serialization and device connection setup problems that existed before these changes).
Verification
Link to Devin run
https://app.devin.ai/sessions/2821c23715c043b8b7fa33f5da15b773
Requested by: Atsushi Eno (atsushieno@gmail.com)