Compare commits

..

2 Commits

Author SHA1 Message Date
breel
85fd604b7f channel sample rate confirmed page size 2026-03-10 21:33:06 -06:00
breel
75460c0859 optional --debug for text 2026-03-10 21:03:31 -06:00
3 changed files with 76 additions and 4 deletions

53
Cargo.lock generated
View File

@@ -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"

1
Cargo.toml Normal file → Executable file
View File

@@ -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"

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());
@@ -14,16 +16,18 @@ fn main() {
// Setup the audio output.
let params = OutputDeviceParameters {
channels_count: 2,
sample_rate: 44100,
channel_sample_count: 4410,
sample_rate: flags.sample_rate,
channel_sample_count: flags.sample_rate / flags.smallest_note,
};
// Create the synthesizer.
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,20 @@ fn main() {
std::thread::sleep(std::time::Duration::from_secs(2));
}
use clap::Parser;
#[derive(Parser, Debug, Clone)]
struct Flags {
#[arg(short, long, default_value_t = false)]
debug: bool,
#[arg(long, default_value_t = 4)]
smallest_note: usize,
#[arg(long, default_value_t = 44100)]
sample_rate: usize,
}
enum Syn {
Real(Synthesizer),
Text(std::collections::HashMap<i32, std::collections::HashMap<i32, i32>>),