diff --git a/Cargo.lock b/Cargo.lock index 9a7b011..19ac521 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -151,6 +151,46 @@ dependencies = [ "libloading", ] +[[package]] +name = "clap" +version = "4.5.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2797f34da339ce31042b27d23607e051786132987f595b02ba4f6a6dffb7030a" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24a241312cea5059b13574bb9b3861cabf758b879c15190b37b6d6fd63ab6876" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92793da1a46a5f2a02a6f4c46c6496b28c43638adea8306fcb0caa1634f24e5" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831" + [[package]] name = "colorchoice" version = "1.0.4" @@ -161,6 +201,7 @@ checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" name = "composer" version = "0.1.0" dependencies = [ + "clap", "env_logger", "itertools 0.14.0", "midir", @@ -285,6 +326,12 @@ version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "indexmap" version = "2.13.0" @@ -663,6 +710,12 @@ version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "syn" version = "2.0.117" diff --git a/Cargo.toml b/Cargo.toml old mode 100644 new mode 100755 index 535403c..aa438d5 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" edition = "2024" [dependencies] +clap = { version = "4.5.60", features = ["derive"] } env_logger = "0.11.9" itertools = "0.14.0" midir = "0.10.3" diff --git a/src/main.rs b/src/main.rs index 4f18372..0860fa6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,8 @@ use std::sync::Arc; use tinyaudio::prelude::*; fn main() { + let flags = Flags::parse(); + // Load the SoundFont. let mut sf2 = File::open("super_small_font.sf2").unwrap(); let sound_font = Arc::new(SoundFont::new(&mut sf2).unwrap()); @@ -22,8 +24,10 @@ fn main() { let settings = SynthesizerSettings::new(params.sample_rate as i32); let synthesizer = Synthesizer::new(&sound_font, &settings).unwrap(); - let mut syn = Syn::Real(synthesizer); - let mut syn = Syn::Text(std::collections::HashMap::new()); + let mut syn = match &flags.debug{ + false => Syn::Real(synthesizer), + true => Syn::Text(std::collections::HashMap::new()), + }; // Play some notes (middle C, E, G). // 16 channels actually // 60=c 64=e 67=g //up to 128velocity though dont go below 50 tbh // 12 notes per octave syn.note_on(0, 64 + 12, 127); @@ -48,6 +52,14 @@ fn main() { std::thread::sleep(std::time::Duration::from_secs(2)); } +use clap::Parser; +#[derive(Parser, Debug, Clone)] +struct Flags { + #[arg(short, default_value_t = false)] + debug: bool, +} + + enum Syn { Real(Synthesizer), Text(std::collections::HashMap>),