use crate::synth::va::dsp::Svf;
use crate::synth::va::engine::param;
use crate::synth::va::fx::{Effect, Params};
use crate::synth::va::m;
const SHELF_HZ: f32 = 90.0;
const SHELF_K: f32 = 1.4;
pub(crate) struct BassBoostFx {
shelf: [Svf; 2],
boost: f32,
}
impl BassBoostFx {
pub(crate) fn new(sample_rate: u32) -> Self {
let mut shelf = [Svf::default(); 2];
for f in &mut shelf {
f.set(SHELF_HZ, SHELF_K, sample_rate as f32);
}
BassBoostFx { shelf, boost: 0.0 }
}
}
impl Effect for BassBoostFx {
fn update(&mut self, p: &Params<'_>, _sample_rate: f32) -> bool {
self.boost = m::powf(10.0, p.get(param::BASS_BOOST) / 20.0) - 1.0;
true
}
fn process(&mut self, x: [f32; 2], _sample_rate: f32) -> [f32; 2] {
let mut out = x;
for (o, f) in out.iter_mut().zip(&mut self.shelf) {
let low = f.process(*o).lp;
*o += low * self.boost;
}
out
}
fn clear(&mut self) {
for f in &mut self.shelf {
f.clear();
}
}
}