这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Implement MIDI Input Callback System with UMP Support

This PR implements the missing MIDI input callback system in the C++ MIDI-CI implementation to handle receiving and processing MIDI-CI discovery reply messages. The implementation ports the setupInputEventListener(), processMidi1Input(), and processUmpInput() logic from the Kotlin ktmidi implementation.

Changes Made

New UMP Message Parsing Infrastructure

  • include/midi-ci/ump/Ump.hpp - UMP message structure and constants
  • src/midi-ci/ump/Ump.cpp - UMP message parsing implementation
  • include/midi-ci/ump/UmpRetriever.hpp - SysEx data extraction from UMP packets
  • src/midi-ci/ump/UmpRetriever.cpp - SysEx7/SysEx8 data retrieval implementation

Enhanced CIDeviceManager

  • tools/ci-tool/src/CIDeviceManager.cpp - Complete process_ump_input() implementation with message buffering
  • tools/ci-tool/include/CIDeviceManager.hpp - Added setup_input_event_listener() method
  • Added SysEx7 and SysEx8 message buffers for chunked message handling
  • Connected MIDI input opened callbacks to message processing

Build System Updates

  • src/CMakeLists.txt - Added new UMP source files to build configuration

Key Features

UMP Message Support

  • Ported UMP message types and binary chunk status constants from Kotlin implementation
  • Support for SYSEX7 and SYSEX8_MDS message types
  • Proper handling of chunked messages with START, CONTINUE, END, and COMPLETE_PACKET status

Message Processing

  • MIDI 1.0: Existing SysEx processing for traditional MIDI-CI messages
  • MIDI 2.0: New UMP processing with proper message buffering and chunking
  • Both protocols can handle MIDI-CI discovery replies correctly

Callback System

  • setup_input_event_listener() equivalent ported from Kotlin
  • MIDI input opened callbacks automatically set up message processing
  • Thread-safe implementation using existing mutex patterns

Testing

  • Build: All files compile successfully without errors
  • Runtime: MIDI-CI tool starts and initializes properly
  • Integration: UMP implementation integrates seamlessly with existing codebase
  • Compatibility: Maintains backward compatibility with MIDI 1.0 processing

The implementation follows the existing C++ patterns in the codebase:

  • Uses pimpl idiom for encapsulation
  • Follows existing mutex locking patterns for thread safety
  • Reuses existing callback mechanism patterns
  • Maintains the same error handling and logging approaches

Technical Details

The UMP message parsing is based directly on the Kotlin reference implementation but adapted to C++ idioms and memory management. The message buffering for chunked SysEx messages follows the same logic as the Kotlin version but uses C++ containers.

This enables the C++ MIDI-CI implementation to properly receive and process "Reply to Discovery" MIDI-CI messages from connected devices, completing the bidirectional MIDI-CI communication capability.


Link to Devin run: https://app.devin.ai/sessions/4ede00a17db4407e8b62e93f3961e59c

Requested by: Atsushi Eno (atsushieno@gmail.com)

- Add UMP message parsing infrastructure (Ump.hpp/cpp, UmpRetriever.hpp/cpp)
- Port UMP message types and binary chunk status constants from Kotlin
- Implement proper process_ump_input() with SysEx7/SysEx8 message buffering
- Add setup_input_event_listener() method to CIDeviceManager
- Connect MIDI input opened callbacks to message processing
- Support both MIDI 1.0 and UMP protocols for MIDI-CI discovery replies
- Update CMakeLists.txt to include new UMP source files

This enables receiving and processing MIDI-CI discovery reply messages
by porting the setupInputEventListener() logic from the Kotlin ktmidi
implementation.

Co-Authored-By: Atsushi Eno <atsushieno@gmail.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@atsushieno atsushieno merged commit aa5b137 into main Jun 16, 2025
@atsushieno atsushieno deleted the devin/1750048993-midi-input-callbacks branch June 19, 2025 06:00
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.

2 participants