pub(crate) fn mix(dry: f32, wet: f32, amount: f32) -> f32 {
dry + (wet - dry) * amount
}
pub(crate) fn mix_stereo(dry: (f32, f32), wet: (f32, f32), amount: f32) -> (f32, f32) {
(mix(dry.0, wet.0, amount), mix(dry.1, wet.1, amount))
}
pub(crate) struct Outgoing<T> {
pub(crate) inner: T,
weight: f32,
step: f32,
}
impl<T> Outgoing<T> {
pub(crate) fn start(inner: T, fade_samples: f32) -> Self {
Self {
inner,
weight: 1.0,
step: 1.0 / fade_samples.max(1.0),
}
}
pub(crate) fn advance(&mut self) -> f32 {
let weight = self.weight;
self.weight -= self.step;
weight
}
pub(crate) fn is_done(&self) -> bool {
self.weight <= 0.0
}
}