From 0fb4185ecf2bcbd7b594862d5f53fbd61ad68d1d Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Thu, 20 Apr 2023 18:22:02 +0200 Subject: [PATCH] More refactoring --- Cargo.toml | 3 ++- src/main.rs | 7 +++++-- src/midi.rs | 7 ++++--- src/utils.rs | 1 + 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 42e6fa8..79ad998 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ actix-web = "4.3.1" reqwest = { version = "0.11.16", features = ["blocking"] } base64 = "0.21.0" lazy_static = "1.4.0" +toml = "0.7.3" [[bin]] name = "rusty_midicommander" @@ -19,4 +20,4 @@ path = "src/main.rs" [[bin]] name = "webtest" -path = "src/webtest.rs" \ No newline at end of file +path = "src/webtest.rs" diff --git a/src/main.rs b/src/main.rs index 6db78d0..02cc913 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,8 +18,6 @@ use midir::MidiOutputConnection; pub mod midi; mod projector; - -#[macro_use] mod utils; /// Simple program to greet a person @@ -29,6 +27,7 @@ struct Args { /// The midi interface to select midi_input: Option, midi_output: Option, + config: Option, } fn main() { @@ -38,6 +37,7 @@ fn main() { Args { midi_input: None, midi_output: None, + config: _, } => { midi::print_midi_interfaces(&"No interface selected, please select one:".into()); return; @@ -45,10 +45,12 @@ fn main() { Args { midi_input: Some(_), midi_output: Some(_), + config: _, } => {} Args { midi_input: _, midi_output: None, + config: _, } => { midi::print_midi_interfaces(&"No interface selected, please select one:".into()); return; @@ -56,6 +58,7 @@ fn main() { _ => {} } + // let config_text = &args.config; println!("[INFO] Connecting with args: {:?}", args); let proj = Arc::new(Mutex::new(projector::Projector::new( "127.0.0.1:8080", diff --git a/src/midi.rs b/src/midi.rs index ff8f96d..1935b7d 100644 --- a/src/midi.rs +++ b/src/midi.rs @@ -127,9 +127,7 @@ pub fn create_output_interface( } let output_port = &output_interface.ports()[port.unwrap()]; Arc::new(Mutex::new( - output_interface - .connect(output_port, "Rusty MIDI Commander Output") - .unwrap(), + output_interface.connect(output_port, name).unwrap(), )) } @@ -139,6 +137,9 @@ pub fn cleanup( // for message in messages.iter() { // co.send(message).unwrap(); // } + // out_port + // .send(&[0xF0, 0x47, 0x7F, 0x29, 0x60, 0x00, 0x40, 0x08, 0x00, 0xF7]) + // .unwrap(); for n in 0..=71 { send_note_on(out_port, n, 0); } diff --git a/src/utils.rs b/src/utils.rs index 9db0dfa..624c83b 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,6 +1,7 @@ // 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_export] macro_rules! list_actions { ($proj:ident, $($id:literal, $action:ident),+ ) => { {