optional --debug for text

This commit is contained in:
breel
2026-03-10 21:03:31 -06:00
parent e907fd0ada
commit 75460c0859
3 changed files with 68 additions and 2 deletions

53
Cargo.lock generated
View File

@@ -151,6 +151,46 @@ dependencies = [
"libloading", "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]] [[package]]
name = "colorchoice" name = "colorchoice"
version = "1.0.4" version = "1.0.4"
@@ -161,6 +201,7 @@ checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
name = "composer" name = "composer"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"clap",
"env_logger", "env_logger",
"itertools 0.14.0", "itertools 0.14.0",
"midir", "midir",
@@ -285,6 +326,12 @@ version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "2.13.0" version = "2.13.0"
@@ -663,6 +710,12 @@ version = "1.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.117" version = "2.0.117"

1
Cargo.toml Normal file → Executable file
View File

@@ -4,6 +4,7 @@ version = "0.1.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
clap = { version = "4.5.60", features = ["derive"] }
env_logger = "0.11.9" env_logger = "0.11.9"
itertools = "0.14.0" itertools = "0.14.0"
midir = "0.10.3" midir = "0.10.3"

View File

@@ -7,6 +7,8 @@ use std::sync::Arc;
use tinyaudio::prelude::*; use tinyaudio::prelude::*;
fn main() { fn main() {
let flags = Flags::parse();
// Load the SoundFont. // Load the SoundFont.
let mut sf2 = File::open("super_small_font.sf2").unwrap(); let mut sf2 = File::open("super_small_font.sf2").unwrap();
let sound_font = Arc::new(SoundFont::new(&mut 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 settings = SynthesizerSettings::new(params.sample_rate as i32);
let synthesizer = Synthesizer::new(&sound_font, &settings).unwrap(); let synthesizer = Synthesizer::new(&sound_font, &settings).unwrap();
let mut syn = Syn::Real(synthesizer); let mut syn = match &flags.debug{
let mut syn = Syn::Text(std::collections::HashMap::new()); 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 // 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); syn.note_on(0, 64 + 12, 127);
@@ -48,6 +52,14 @@ fn main() {
std::thread::sleep(std::time::Duration::from_secs(2)); 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 { enum Syn {
Real(Synthesizer), Real(Synthesizer),
Text(std::collections::HashMap<i32, std::collections::HashMap<i32, i32>>), Text(std::collections::HashMap<i32, std::collections::HashMap<i32, i32>>),