From fa6af749de3ea9cba9ee3d0dfeaeae30b817c59f Mon Sep 17 00:00:00 2001 From: Weird Constructor Date: Thu, 21 Jul 2022 02:03:16 +0200 Subject: [PATCH] added AllPass::next_linear --- src/dsp/helpers.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/dsp/helpers.rs b/src/dsp/helpers.rs index f24782c..4931e85 100644 --- a/src/dsp/helpers.rs +++ b/src/dsp/helpers.rs @@ -1221,7 +1221,8 @@ impl AllPass { self.delay.tap_n(time_ms) } - /// Retrieve the next sample from the all-pass filter while feeding in the next. + /// Retrieve the next (cubic interpolated) sample from the all-pass + /// filter while feeding in the next. /// /// * `time_ms` - Delay time in milliseconds. /// * `g` - Feedback factor (usually something around 0.7 is common) @@ -1233,6 +1234,20 @@ impl AllPass { self.delay.feed(input); input * g + s } + + /// Retrieve the next (linear interpolated) sample from the all-pass + /// filter while feeding in the next. + /// + /// * `time_ms` - Delay time in milliseconds. + /// * `g` - Feedback factor (usually something around 0.7 is common) + /// * `v` - The new input sample to feed the filter. + #[inline] + pub fn next_linear(&mut self, time_ms: F, g: F, v: F) -> F { + let s = self.delay.linear_interpolate_at(time_ms); + let input = v + -g * s; + self.delay.feed(input); + input * g + s + } } #[derive(Debug, Clone)]