You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a small midir based programme to read events from a MIDI pedal.
I compare the performance of this to aseqdump, which is working.
When I run this midir programme, and press the pedal buttons, I see nothing. Then I shut the programme down, and restart it, and I see the events. None more are detected.
Using aseqdump I see the events as they occur.
The little midir programme. I cannot see anything I have done incorrectly.
use midir::MidiIO;use midir::MidiInput;use std::env::args;use std::error::Error;use std::io::stdin;use std::iter::zip;fnmain(){let port_name_in:String = args().nth(1).unwrap();run(port_name_in).unwrap();}fnrun(name_of_port_in:String) -> Result<(),Box<dynError>>{handle_input(name_of_port_in.as_str()).unwrap();letmut input = String::new();println!("Running....");stdin().read_line(&mut input)?;// wait for next enter key press println!("Closing connection");Ok(())}fnfind_port<T:MidiIO>(name:&str,midi_io:&T) -> Result<T::Port,Box<dynError>>{let ports = midi_io.ports();let port_names:Vec<String> = ports
.iter().map(|p| midi_io.port_name(p).unwrap()).collect();letmut names_ports = zip(ports, port_names);let port_name = names_ports
.find(|x| &x.1 == name).expect(format!("{} not found", name).as_str());Ok(port_name.0)}fnhandle_input(port_name:&str) -> Result<(),Box<dynError>>{let midi_input = MidiInput::new("120Proof-midi-pedal-driver")?;let input_port = matchfind_port(port_name,&midi_input){Ok(p) => p,Err(err) => panic!("Failed to bet port {port_name}: {err}"),};let _ = midi_input.connect(&input_port,"midir-read-input",move |stamp, message, _| {println!("{}: {:?} (len = {})", stamp, message, message.len());},(),)?;Ok(())}
The text was updated successfully, but these errors were encountered:
I have a small
midir
based programme to read events from a MIDI pedal.I compare the performance of this to
aseqdump
, which is working.When I run this
midir
programme, and press the pedal buttons, I see nothing. Then I shut the programme down, and restart it, and I see the events. None more are detected.Using
aseqdump
I see the events as they occur.The little
midir
programme. I cannot see anything I have done incorrectly.The text was updated successfully, but these errors were encountered: