Implement MIDI I/O device opening functionality #15
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.
Implement MIDI I/O Device Opening Functionality
This PR implements actual MIDI device port opening functionality in the C++
MidiDeviceManagerto achieve feature parity with the Kotlin implementation. Previously, the C++ version only stored device names without actually opening MIDI ports.Changes Made
Core Implementation
std::unique_ptr<libremidi::midi_in>andstd::unique_ptr<libremidi::midi_out>toMidiDeviceManager::Implset_input_device()andset_output_device()methods to use libremidi API for opening MIDI portsmidi_input_opened_andmidi_output_opened_callback lists matching the Kotlin patternadd_input_opened_callback()andadd_output_opened_callback()public methodsMIDI Input Handling
libremidi::input_configurationwith.on_messagecallback to process incoming MIDI messagesprocess_incoming_sysex()method for message dispatch.ignore_sysex = falseto ensure SysEx messages are receivedMIDI Output Enhancement
stdx::errorsystemResource Management
shutdown()method to close MIDI ports before shutdownBuild System
Technical Details
libremidi API Integration
libremidi::observerto enumerate available MIDI portslibremidi::midi_inwith configuration-based callback setuplibremidi::midi_outfor sending MIDI messagesstdx::errorandstdx::string_refconversionCallback Pattern Matching
The implementation follows the exact pattern from the Kotlin version:
midiInputOpenedandmidiOutputOpenedcallback listsmidi_input_opened_andmidi_output_opened_callback vectorsError Handling
stdx::string_reftostd::stringfor error messagesTesting
Compatibility
This change is backward compatible:
Link to Devin run
https://app.devin.ai/sessions/ad9744cfe3c64558ae6f5adb9fadf986
Requested by: Atsushi Eno (atsushieno@gmail.com)