A Rust application for MIDI patch mapping that listens on RTP MIDI ports and routes MIDI Program Change and clock events to different destinations (RTP MIDI or OSC).
- RTP MIDI Support: Listen and send MIDI over network using RTP MIDI protocol
- OSC Support: Send OSC messages to audio equipment (e.g., Behringer X32)
- Device Management: Configure devices with programs and associated commands
- Flexible Routing: Map input channels to different output destinations
- Program Change Handling: Respond to MIDI Program Change events
- MIDI Clock Support: Handle MIDI timing clock events
Devices represent conceptual MIDI or OSC equipment with defined programs. Each device can be:
- MIDI Device: Sends MIDI commands (Program Change, Control Change)
- OSC Device: Sends OSC messages
Example device configuration (config/devices.json):
{
"devices": {
"mooer_m2": {
"id": "mooer_m2",
"name": "Mooer M2",
"device_type": "midi",
"programs": [
{
"number": 0,
"name": "Clean",
"commands": [
{
"type": "program_change",
"channel": 1,
"program": 0
}
]
}
]
}
}
}The map configuration specifies:
- RTP MIDI sessions to create and listen on
- Device mappings (which device listens on which channel)
- Routing destinations for each device
Example map configuration (config/map.json):
{
"rtp_midi_sessions": [
{
"name": "MainInput",
"port": 5004,
"listen": true,
"connect_to": []
}
],
"device_mappings": [
{
"device_id": "mooer_m2",
"listen_channel": 1,
"destination": {
"type": "rtp_midi",
"session_name": "Output1"
}
}
]
}- midi: Device that sends MIDI commands
- osc: Device that sends OSC commands
program_change: Send MIDI Program Changecontrol_change: Send MIDI Control Change
osc: Send OSC message with specified address and arguments
- rtp_midi: Route to RTP MIDI session
- osc: Route to OSC destination (host:port)
- Configure Devices: Edit
config/devices.jsonto define your MIDI/OSC devices and their programs - Configure Mapping: Edit
config/map.jsonto set up RTP MIDI sessions and device routing - Run the Application:
cargo run
- MIDI controller sends Program Change message on channel 1
- Application receives message on configured RTP MIDI session
- Looks up device mapped to channel 1 (e.g., "mooer_m2")
- Finds program definition for the received program number
- Executes all commands defined for that program
- Sends commands to the configured destination (RTP MIDI or OSC)
- rtpmidi: RTP MIDI protocol support
- rosc: OSC (Open Sound Control) support
- serde: Configuration serialization
- tokio: Async runtime
- tracing: Logging
cargo build --releaseThe application is structured with these main modules:
device.rs: Device and command definitionsmapping.rs: RTP MIDI session and routing configurationprocessor.rs: MIDI event processing and command executionrouter.rs: RTP MIDI session managementconfig.rs: Configuration loading and savingmain.rs: Application entry point
This project is licensed under the MIT License - see the LICENSE file for details.