This commit is contained in:
2026-01-20 02:11:51 +01:00
parent 4391995eae
commit ce0014020f
16 changed files with 941 additions and 595 deletions

View File

@@ -32,7 +32,9 @@ use orbit::{EffectParams, Orbit};
use sample::{FileSource, SampleEntry, SampleInfo, SamplePool, WebSampleSource};
use schedule::Schedule;
#[cfg(feature = "native")]
use telemetry::EngineMetrics;
use std::sync::Arc;
#[cfg(feature = "native")]
pub use telemetry::EngineMetrics;
use types::{DelayType, Source, BLOCK_SIZE, CHANNELS, MAX_ORBITS, MAX_VOICES};
use voice::{Voice, VoiceParams};
@@ -55,7 +57,7 @@ pub struct Engine {
pub effect_params: EffectParams,
// Telemetry (native only)
#[cfg(feature = "native")]
pub metrics: EngineMetrics,
pub metrics: Arc<EngineMetrics>,
}
impl Engine {
@@ -96,7 +98,48 @@ impl Engine {
comb_damp: 0.1,
},
#[cfg(feature = "native")]
metrics: EngineMetrics::default(),
metrics: Arc::new(EngineMetrics::default()),
}
}
#[cfg(feature = "native")]
pub fn new_with_metrics(
sample_rate: f32,
output_channels: usize,
metrics: Arc<EngineMetrics>,
) -> Self {
let mut orbits = Vec::with_capacity(MAX_ORBITS);
for _ in 0..MAX_ORBITS {
orbits.push(Orbit::new(sample_rate));
}
Self {
sr: sample_rate,
isr: 1.0 / sample_rate,
voices: vec![Voice::default(); MAX_VOICES],
active_voices: 0,
orbits,
schedule: Schedule::new(),
time: 0.0,
tick: 0,
output_channels,
output: vec![0.0; BLOCK_SIZE * output_channels],
sample_pool: SamplePool::new(),
samples: Vec::with_capacity(256),
sample_index: Vec::new(),
effect_params: EffectParams {
delay_time: 0.333,
delay_feedback: 0.6,
delay_type: DelayType::Standard,
verb_decay: 0.75,
verb_damp: 0.95,
verb_predelay: 0.1,
verb_diff: 0.7,
comb_freq: 220.0,
comb_feedback: 0.9,
comb_damp: 0.1,
},
metrics,
}
}