Feat: clean the codebase as much as possible
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
use cpal::traits::{DeviceTrait, StreamTrait};
|
||||
use cpal::Stream;
|
||||
use crossbeam_channel::Receiver;
|
||||
use doux::{Engine, EngineMetrics};
|
||||
use ringbuf::{traits::*, HeapRb};
|
||||
use rustfft::{num_complex::Complex, FftPlanner};
|
||||
use std::sync::atomic::{AtomicBool, AtomicU32, AtomicU64, Ordering};
|
||||
use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::thread::{self, JoinHandle};
|
||||
|
||||
use super::AudioCommand;
|
||||
#[cfg(feature = "cli")]
|
||||
use std::sync::atomic::AtomicU64;
|
||||
|
||||
pub struct ScopeBuffer {
|
||||
pub samples: [AtomicU32; 256],
|
||||
@@ -230,6 +227,36 @@ fn analysis_loop(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn preload_sample_heads(
|
||||
entries: Vec<(String, std::path::PathBuf)>,
|
||||
target_sr: f32,
|
||||
registry: &doux::SampleRegistry,
|
||||
) {
|
||||
let mut batch = Vec::with_capacity(entries.len());
|
||||
for (name, path) in &entries {
|
||||
match doux::sampling::decode_sample_head(path, target_sr) {
|
||||
Ok(data) => batch.push((name.clone(), Arc::new(data))),
|
||||
Err(e) => eprintln!("preload {name}: {e}"),
|
||||
}
|
||||
}
|
||||
if !batch.is_empty() {
|
||||
registry.insert_batch(batch);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "cli")]
|
||||
use cpal::traits::{DeviceTrait, StreamTrait};
|
||||
#[cfg(feature = "cli")]
|
||||
use cpal::Stream;
|
||||
#[cfg(feature = "cli")]
|
||||
use crossbeam_channel::Receiver;
|
||||
#[cfg(feature = "cli")]
|
||||
use doux::{Engine, EngineMetrics};
|
||||
|
||||
#[cfg(feature = "cli")]
|
||||
use super::AudioCommand;
|
||||
|
||||
#[cfg(feature = "cli")]
|
||||
pub struct AudioStreamConfig {
|
||||
pub output_device: Option<String>,
|
||||
pub channels: u16,
|
||||
@@ -237,12 +264,14 @@ pub struct AudioStreamConfig {
|
||||
pub max_voices: usize,
|
||||
}
|
||||
|
||||
#[cfg(feature = "cli")]
|
||||
pub struct AudioStreamInfo {
|
||||
pub sample_rate: f32,
|
||||
pub host_name: String,
|
||||
pub channels: u16,
|
||||
}
|
||||
|
||||
#[cfg(feature = "cli")]
|
||||
pub fn build_stream(
|
||||
config: &AudioStreamConfig,
|
||||
audio_rx: Receiver<AudioCommand>,
|
||||
|
||||
Reference in New Issue
Block a user