3 unstable releases

Uses new Rust 2024

new 0.2.1 May 21, 2025
0.2.0 May 21, 2025
0.1.0 May 20, 2025

#234 in Audio

45 downloads per month

GPL-3.0-or-later

105KB
2.5K SLoC

rtpmidi

Crates.io Version Crates.io License Codecov

This provides functions for working with RTP-MIDI in Rust.

Usage

let session = RtpMidiSession::new("My Session".to_string(), 54321, 5004).await.unwrap();

// Wait for midi commands
session
    .add_listener(RtpMidiEventType::MidiPacket, move |data| {
        for command in data.commands() {
            info!("Received command: {:?}", command);
        }
    })
    .await;

// start listening for packets - this can be accept_all_invitations, reject_all_invitations, or a function
// that takes the form my_function(packet: &SessionInitiationPacket, socket: &SocketAddr) -> bool
let _ = server.start(RtpMidiSession::accept_all_invitations).await;

// invite another participant to the session
let addr = std::net::SocketAddr::new("192.168.0.1".parse().unwrap(), 5006);
let _ = invite_server.invite_participant(addr).await.unwrap();

// send MIDI commands
let command = MidiCommand::NoteOn {
    channel: *channel,
    key: key.saturating_sub(12), // Transpose down by 1 octave
    velocity: *velocity,
};

session.send_midi(command).await.unwrap();

See the Examples directory for more examples.

Installation

cargo add rtpmidi

Status

Supported:

  • Responding to invitations (currently auto-accepts all invitations)
  • Inviting others
  • Advertising via MDNS / Bonjour (optional - enable the 'mdns' feature for this)
  • SysEx

Not supported:

  • Recovery journal

Dependencies

~3–12MB
~122K SLoC