Sha256: 66b3711859be7a4bcb167a48cb4daa99eda654bbbdecbcccbb61b339d1a51d23

Contents?: true

Size: 852 Bytes

Versions: 2

Compression:

Stored size: 852 Bytes

Contents

use midir::{MidiInput, Ignore};
use tauri::Manager;

pub fn start_midi_listener(app_handle: tauri::AppHandle) {
    let mut input = MidiInput::new("MIDI Input").expect("Failed to create MIDI input");
    input.ignore(Ignore::None);

    let in_ports = input.ports();
    if in_ports.is_empty() {
        println!("No available MIDI input ports.");
        return;
    }

    let in_port = &in_ports[0];
    let in_port_name = input.port_name(in_port).unwrap();

    println!("Opening connection to {}", in_port_name);
    let _conn_in = input.connect(in_port, "midir-read-input", move |_stamp, message, _| {
        println!("Received message: {:?}", message);
        app_handle.emit_all("midi-event", format!("{:?}", message)).unwrap();
    }, ()).expect("Failed to connect to input port");

    // Keep the connection open
    std::thread::park();
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
atome-0.5.7.6.0 vendor/assets/src-tauri/src/midi.rs
atome-0.5.7.5.9 vendor/assets/src-tauri/src/midi.rs