Skip to content

Commit

Permalink
add more filter modes
Browse files Browse the repository at this point in the history
  • Loading branch information
magnetophon committed Dec 22, 2024
1 parent 23b8c4a commit 362be10
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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];
Expand Down
48 changes: 45 additions & 3 deletions src/svf_simper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<const LANES: usize>
Expand Down Expand Up @@ -119,6 +119,11 @@ where
v2
}

#[inline]
pub fn bandpass(&mut self, v0: Simd<f32, LANES>) -> Simd<f32, LANES> {
let (v1, _) = self.process(v0);
v1
}
#[inline]
pub fn highpass(&mut self, v0: Simd<f32, LANES>) -> Simd<f32, LANES> {
let (v1, v2) = self.process(v0);
Expand All @@ -129,31 +134,63 @@ where
let (_, v2) = self.process(v0);
v0 - v2
}

#[inline]
pub fn notch(&mut self, v0: Simd<f32, LANES>) -> Simd<f32, LANES> {
let (v1, _) = self.process(v0);
v0 - self.k * v1
}
#[inline]
pub fn peak(&mut self, v0: Simd<f32, LANES>) -> Simd<f32, LANES> {
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<f32, LANES>) -> Simd<f32, LANES> {
let (v1, _) = self.process(v0);
let two = Simd::splat(2.0);
v0 - two * self.k * v1
}

#[inline]
pub fn lowshelf(
&mut self,
v0: Simd<f32, LANES>,
lin_gain: Simd<f32, LANES>,
) -> Simd<f32, LANES> {
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<f32, LANES>,
lin_gain: Simd<f32, LANES>,
) -> Simd<f32, LANES> {
let (v1, v2) = self.process(v0);
lin_gain.mul_add(v2, v0 - v2)
}
#[inline]
pub fn highshelf(
&mut self,
v0: Simd<f32, LANES>,
lin_gain: Simd<f32, LANES>,
) -> Simd<f32, LANES> {
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<f32, LANES>,
lin_gain: Simd<f32, LANES>,
) -> Simd<f32, LANES> {
let (_, v2) = self.process(v0);
v2 + (lin_gain * (v0 - v2))
lin_gain.mul_add(v0 - v2, v2)
}
}

/*
Expand All @@ -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);
*/

0 comments on commit 362be10

Please sign in to comment.