mirror of
https://codeberg.org/uzu/strudel
synced 2026-07-23 21:47:16 -04:00
various fixes
This commit is contained in:
Generated
+31
-122
@@ -17,6 +17,18 @@ version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||
|
||||
[[package]]
|
||||
name = "ahash"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"getrandom 0.2.10",
|
||||
"once_cell",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.20"
|
||||
@@ -98,7 +110,7 @@ name = "app"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"midir",
|
||||
"mini-moka",
|
||||
"quick_cache",
|
||||
"reqwest",
|
||||
"rosc",
|
||||
"serde",
|
||||
@@ -268,12 +280,6 @@ version = "1.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c"
|
||||
|
||||
[[package]]
|
||||
name = "bytecount"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c"
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.13.1"
|
||||
@@ -322,37 +328,6 @@ dependencies = [
|
||||
"system-deps 6.1.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "camino"
|
||||
version = "1.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cargo-platform"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2cfa25e60aea747ec7e1124f238816749faa93759c6ff5b31f1ccdda137f4479"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cargo_metadata"
|
||||
version = "0.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa"
|
||||
dependencies = [
|
||||
"camino",
|
||||
"cargo-platform",
|
||||
"semver",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cargo_toml"
|
||||
version = "0.15.3"
|
||||
@@ -771,19 +746,6 @@ dependencies = [
|
||||
"syn 2.0.18",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dashmap"
|
||||
version = "5.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"hashbrown 0.14.0",
|
||||
"lock_api",
|
||||
"once_cell",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dasp_sample"
|
||||
version = "0.11.0"
|
||||
@@ -889,6 +851,12 @@ dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.1"
|
||||
@@ -910,15 +878,6 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "error-chain"
|
||||
version = "0.12.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc"
|
||||
dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "1.9.0"
|
||||
@@ -1971,21 +1930,6 @@ version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
|
||||
|
||||
[[package]]
|
||||
name = "mini-moka"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23e0b72e7c9042467008b10279fc732326bd605459ae03bda88825909dd19b56"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"crossbeam-utils",
|
||||
"dashmap",
|
||||
"skeptic",
|
||||
"smallvec",
|
||||
"tagptr",
|
||||
"triomphe",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
@@ -2601,17 +2545,6 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pulldown-cmark"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"memchr",
|
||||
"unicase",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quick-xml"
|
||||
version = "0.28.2"
|
||||
@@ -2621,6 +2554,18 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quick_cache"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f69f8d22fa3f34f3083d9a4375c038732c7a7e964de1beb81c544da92dfc40b8"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"equivalent",
|
||||
"hashbrown 0.14.0",
|
||||
"parking_lot",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.28"
|
||||
@@ -3197,21 +3142,6 @@ version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de"
|
||||
|
||||
[[package]]
|
||||
name = "skeptic"
|
||||
version = "0.13.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "16d23b015676c90a0f01c197bfdc786c20342c73a0afdda9025adb0bc42940a8"
|
||||
dependencies = [
|
||||
"bytecount",
|
||||
"cargo_metadata",
|
||||
"error-chain",
|
||||
"glob",
|
||||
"pulldown-cmark",
|
||||
"tempfile",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.8"
|
||||
@@ -3559,12 +3489,6 @@ dependencies = [
|
||||
"version-compare 0.1.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tagptr"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417"
|
||||
|
||||
[[package]]
|
||||
name = "tao"
|
||||
version = "0.16.2"
|
||||
@@ -4108,12 +4032,6 @@ dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "triomphe"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee8098afad3fb0c54a9007aab6804558410503ad676d4633f9c2559a00ac0f"
|
||||
|
||||
[[package]]
|
||||
name = "try-lock"
|
||||
version = "0.2.4"
|
||||
@@ -4126,15 +4044,6 @@ version = "1.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
|
||||
|
||||
[[package]]
|
||||
name = "unicase"
|
||||
version = "2.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89"
|
||||
dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.13"
|
||||
|
||||
@@ -22,8 +22,8 @@ midir = "0.9.1"
|
||||
tokio = { version = "1.29.0", features = ["full"] }
|
||||
rosc = "0.10.1"
|
||||
web-audio-api = { git = "https://github.com/orottier/web-audio-api-rs.git", branch = "main" }
|
||||
mini-moka = "0.10.2"
|
||||
reqwest = "0.11.20"
|
||||
quick_cache = "0.4.0"
|
||||
|
||||
[features]
|
||||
# this feature is used for production builds or when `devPath` points to the filesystem and the built-in dev server is disabled.
|
||||
|
||||
+12
-10
@@ -54,19 +54,18 @@ pub struct FilterADSR {
|
||||
pub env: f64,
|
||||
}
|
||||
|
||||
|
||||
pub fn superdough_sample(message: &WebAudioMessage, context: &mut AudioContext, audio_buffer: AudioBuffer) {
|
||||
pub fn superdough_sample(
|
||||
message: &WebAudioMessage,
|
||||
context: &mut AudioContext,
|
||||
audio_buffer: AudioBuffer,
|
||||
) {
|
||||
let now = context.current_time();
|
||||
let mut chain: Vec<&dyn AudioNode> = Vec::new();
|
||||
let compressor = context.create_dynamics_compressor();
|
||||
compressor.connect(&context.destination());
|
||||
compressor.threshold().set_value(-50.0);
|
||||
let delay = context.create_delay(1.);
|
||||
// Play synth or sample
|
||||
|
||||
|
||||
// Create nodes for sample playback
|
||||
// let audio_buffer = context.decode_audio_data_sync(file).unwrap();
|
||||
let audio_buffer_duration = audio_buffer.duration();
|
||||
let mut src = context.create_buffer_source();
|
||||
src.set_buffer(audio_buffer);
|
||||
@@ -92,7 +91,11 @@ pub fn superdough_sample(message: &WebAudioMessage, context: &mut AudioContext,
|
||||
}
|
||||
|
||||
|
||||
pub fn superdough_synth(message: &WebAudioMessage, context: &mut AudioContext) {
|
||||
pub fn superdough_synth(
|
||||
message: &WebAudioMessage,
|
||||
context: &mut AudioContext,
|
||||
|
||||
) {
|
||||
let now = context.current_time();
|
||||
let mut chain: Vec<&dyn AudioNode> = Vec::new();
|
||||
let compressor = context.create_dynamics_compressor();
|
||||
@@ -100,7 +103,6 @@ pub fn superdough_synth(message: &WebAudioMessage, context: &mut AudioContext) {
|
||||
compressor.threshold().set_value(-50.0);
|
||||
let env = context.create_gain();
|
||||
let delay = context.create_delay(1.);
|
||||
// Play synth or sample
|
||||
|
||||
let osc = context.create_oscillator();
|
||||
// Create nodes for synth playback
|
||||
@@ -139,7 +141,6 @@ fn create_delay(message: &WebAudioMessage, context: &mut AudioContext, env: &Gai
|
||||
delay.connect(&feedback);
|
||||
|
||||
let pre_gain = context.create_gain();
|
||||
// pre_gain.gain().set_value_at_time(0.0, now);
|
||||
pre_gain.gain().set_value_at_time(message.delay.wet, now + message.delay.delay_time as f64);
|
||||
pre_gain.connect(&feedback);
|
||||
|
||||
@@ -170,6 +171,7 @@ fn create_osc_type(message: &WebAudioMessage) -> OscillatorType {
|
||||
"square" => OscillatorType::Square,
|
||||
"triangle" => OscillatorType::Triangle,
|
||||
"saw" => OscillatorType::Sawtooth,
|
||||
"sawtooth" => OscillatorType::Sawtooth,
|
||||
_ => panic!("Invalid oscillator type"),
|
||||
}
|
||||
}
|
||||
@@ -295,7 +297,7 @@ fn apply_adsr(
|
||||
.set_value_at_time(0.0, now)
|
||||
.linear_ramp_to_value_at_time(message.velocity, now + attack)
|
||||
.exponential_ramp_to_value_at_time(
|
||||
sustain * message.velocity,
|
||||
(sustain + 0.00001) * message.velocity,
|
||||
now + attack + decay,
|
||||
)
|
||||
.set_value_at_time(sustain * message.velocity, now + message.duration)
|
||||
|
||||
@@ -4,7 +4,8 @@ use std::{
|
||||
};
|
||||
use std::fs::File;
|
||||
use std::path::Path;
|
||||
use mini_moka::sync::Cache;
|
||||
use quick_cache::sync::Cache;
|
||||
// use mini_moka::sync::Cache;
|
||||
use reqwest::Url;
|
||||
|
||||
use tokio::{fs, sync::{mpsc, Mutex}, time::Instant};
|
||||
@@ -70,9 +71,9 @@ pub fn init(
|
||||
|
||||
let message_queue_clone = Arc::clone(&message_queue);
|
||||
|
||||
/* ...........................................................
|
||||
Prepare audio context
|
||||
............................................................*/
|
||||
/* ...........................................................
|
||||
Prepare audio context
|
||||
............................................................*/
|
||||
let latency_hint = match std::env::var("WEB_AUDIO_LATENCY").as_deref() {
|
||||
Ok("playback") => AudioContextLatencyCategory::Playback,
|
||||
_ => AudioContextLatencyCategory::default(),
|
||||
@@ -81,7 +82,6 @@ pub fn init(
|
||||
latency_hint,
|
||||
..AudioContextOptions::default()
|
||||
});
|
||||
|
||||
tauri::async_runtime::spawn(async move {
|
||||
let cache: Cache<String, AudioBuffer> = Cache::new(10_000);
|
||||
/* ...........................................................
|
||||
@@ -97,7 +97,7 @@ pub fn init(
|
||||
};
|
||||
|
||||
match message.waveform.as_str() {
|
||||
"sine" | "square" | "triangle" | "saw" => {
|
||||
"sine" | "square" | "triangle" | "saw" | "sawtooth" => {
|
||||
superdough_synth(message.clone(), &mut audio_context);
|
||||
}
|
||||
_ => {
|
||||
@@ -109,7 +109,11 @@ pub fn init(
|
||||
let file_path = format!("samples/{}{}", message.dirname, filename);
|
||||
|
||||
if let Some(audio_buffer) = cache.get(&file_path) {
|
||||
superdough_sample(message.clone(), &mut audio_context, audio_buffer.clone());
|
||||
superdough_sample(
|
||||
message.clone(),
|
||||
&mut audio_context,
|
||||
audio_buffer.clone(),
|
||||
);
|
||||
} else if let Ok(file) = File::open(&file_path) {
|
||||
let audio_buffer = audio_context.decode_audio_data_sync(file)
|
||||
.unwrap_or_else(|_| panic!("Failed to decode audio data"));
|
||||
@@ -125,10 +129,6 @@ pub fn init(
|
||||
let bytes = response.bytes().await.unwrap();
|
||||
let path = Path::new(&file_path);
|
||||
let mut file = create_file_and_dirs(path).await;
|
||||
// let mut file = tokio::fs::File::create(&file_path)
|
||||
// .await
|
||||
// .unwrap_or_else(|_| panic!("Failed to create file"));
|
||||
|
||||
file.write_all(&bytes)
|
||||
.await
|
||||
.unwrap_or_else(|_| panic!("Failed to write to file"));
|
||||
|
||||
Reference in New Issue
Block a user