diff --git a/src/lib.rs b/src/lib.rs index 1a1cf5f..879a01e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -582,6 +582,8 @@ impl Plugin for Del2 { const SAMPLE_ACCURATE_AUTOMATION: bool = true; + const HARD_REALTIME_ONLY: bool = false; + // If the plugin can send or receive SysEx messages, it can define a type to wrap around those // messages here. The type implements the `SysExMessage` trait, which allows conversion to and // from plain byte buffers. @@ -971,11 +973,13 @@ impl Plugin for Del2 { ]); let frame_filtered = *delay_tap.ladders.tick_pivotal(frame).as_array(); - // let frame_out = *delay_tap.ladders.tick_linear(frame).as_array(); + // let frame_filtered = *delay_tap.ladders.tick_linear(frame).as_array(); let frame_out = delay_tap .shelving_eq .highshelf_cheap(frame_filtered.into(), gain_values); + // .lowshelf_cheap(frame.into(), gain_values); // .highshelf(frame_filtered.into(), gain_values); + // .allpass(frame.into()); delay_tap.delayed_audio_l[i] = frame_out[0]; delay_tap.delayed_audio_r[i] = frame_out[1]; diff --git a/src/svf_simper.rs b/src/svf_simper.rs index 672121d..a3046d0 100644 --- a/src/svf_simper.rs +++ b/src/svf_simper.rs @@ -35,7 +35,7 @@ DEALINGS IN THE SOFTWARE. // thanks, andy! use std::f32::consts; -use std::simd::{LaneCount, Simd, SupportedLaneCount}; +use std::simd::{LaneCount, Simd, StdFloat, SupportedLaneCount}; #[derive(Debug, Clone)] pub struct SVFSimper @@ -119,6 +119,11 @@ where v2 } + #[inline] + pub fn bandpass(&mut self, v0: Simd) -> Simd { + let (v1, _) = self.process(v0); + v1 + } #[inline] pub fn highpass(&mut self, v0: Simd) -> Simd { let (v1, v2) = self.process(v0); @@ -129,6 +134,18 @@ where let (_, v2) = self.process(v0); v0 - v2 } + + #[inline] + pub fn notch(&mut self, v0: Simd) -> Simd { + let (v1, _) = self.process(v0); + v0 - self.k * v1 + } + #[inline] + pub fn peak(&mut self, v0: Simd) -> Simd { + let (v1, v2) = self.process(v0); + let two = Simd::splat(2.0); + v0 - self.k * v1 - two * v2 + } #[inline] pub fn allpass(&mut self, v0: Simd) -> Simd { let (v1, _) = self.process(v0); @@ -136,6 +153,24 @@ where v0 - two * self.k * v1 } + #[inline] + pub fn lowshelf( + &mut self, + v0: Simd, + lin_gain: Simd, + ) -> Simd { + let (v1, v2) = self.process(v0); + // lin_gain.mul_add(v2, v0 - self.k * v1 - v2) - self.k * v1 + (lin_gain - Simd::splat(1.0)).mul_add(v2, v0) - (Simd::splat(2.0) * self.k * v1) + } + pub fn lowshelf_cheap( + &mut self, + v0: Simd, + lin_gain: Simd, + ) -> Simd { + let (v1, v2) = self.process(v0); + lin_gain.mul_add(v2, v0 - v2) + } #[inline] pub fn highshelf( &mut self, @@ -143,17 +178,19 @@ where lin_gain: Simd, ) -> Simd { let (v1, v2) = self.process(v0); - v2 + (lin_gain * (v0 - self.k * v1 - v2)) - self.k * v1 + lin_gain.mul_add(v0 - self.k * v1 - v2, v2) - self.k * v1 } + #[inline] pub fn highshelf_cheap( &mut self, v0: Simd, lin_gain: Simd, ) -> Simd { let (_, v2) = self.process(v0); - v2 + (lin_gain * (v0 - v2)) + lin_gain.mul_add(v0 - v2, v2) } } + /* @@ -166,5 +203,10 @@ make set_x4 use wider iiuc, my cpu can do f32x8 and M1 macs can do f32x16 +make lerp that crossfades + +look at olegs impl in faust: +mix is a dot mult +A = pow(10.0, G/40.0); */