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

View File

@@ -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<i32, std::collections::HashMap<i32, i32>>),