diff --git a/src/main.rs b/src/main.rs index a184f05..6db78d0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ // This file should set up the MIDI input and output devices, and then // start a loop to receive and process MIDI messages. // It should also use the commands module to send commands asynchronously. -// use crate::midi::print_midi_interfaces; + use crate::midi::cleanup; use crate::midi::connect_loop_with_callback; use crate::midi::create_output_interface; @@ -16,9 +16,12 @@ use midir::MidiInput; use midir::MidiOutput; use midir::MidiOutputConnection; -// use midir::MidiOutput; pub mod midi; mod projector; + +#[macro_use] +mod utils; + /// Simple program to greet a person #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] @@ -28,33 +31,6 @@ struct Args { midi_output: Option, } -macro_rules! list_actions { - ($proj:ident, $($id:literal, $action:ident),+ ) => { - { - let mut temp_vec:Vec<(u8, Box<(dyn Fn() + Send + 'static)>)> = Vec::new(); - $( - let proj = Arc::clone(&$proj); - temp_vec.push(( - $id, - Box::new(move || { - match proj.lock().unwrap().$action() { - Ok(_) => {} - Err(e) => { - println!( - "[ERROR] An error occurend while sending a ({}) message", - stringify!($action) - ); - println!(" {}", e) - } - }; - }), - )); - )+ - temp_vec - } - }; -} - fn main() { // Parse Arguments let args = Args::parse(); diff --git a/src/projector.rs b/src/projector.rs index c293d52..768c77b 100644 --- a/src/projector.rs +++ b/src/projector.rs @@ -6,7 +6,7 @@ use std::error::Error; use std::time::Duration; -static WAIT_TIME: f64 = 0.7; +static WAIT_TIME: f64 = 0.5; pub struct Projector { ip: String, diff --git a/src/utils.rs b/src/utils.rs index 54f6aa7..9db0dfa 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,2 +1,29 @@ // The utils module should provide utility functions that are used throughout the program. // These functions could include functions to convert MIDI messages to and from human-readable formats, or to handle errors. + +macro_rules! list_actions { + ($proj:ident, $($id:literal, $action:ident),+ ) => { + { + let mut temp_vec:Vec<(u8, Box<(dyn Fn() + Send + 'static)>)> = Vec::new(); + $( + let proj = Arc::clone(&$proj); + temp_vec.push(( + $id, + Box::new(move || { + match proj.lock().unwrap().$action() { + Ok(_) => {} + Err(e) => { + println!( + "[ERROR] An error occurend while sending a ({}) message", + stringify!($action) + ); + println!(" {}", e) + } + }; + }), + )); + )+ + temp_vec + } + }; +}