fixed interpolation in the delay line and switched to nearest for the delays in the dattorro reverb and to cubic inside the modulated all-pass filters.

This commit is contained in:
Weird Constructor 2021-08-08 21:16:40 +02:00
parent 0f344b0fc1
commit c0c0ac7b04
2 changed files with 18 additions and 10 deletions

View file

@ -399,12 +399,12 @@ impl DattorroReverb {
let left = self.left_sum;
let left = self.apf1[0].0.next(left_apf1_delay_ms, self.apf1[0].2, left);
let left_apf_tap = left;
let left = self.delay1[0].0.next_cubic(self.delay1[0].1, left);
let left = self.delay1[0].0.next_nearest(self.delay1[0].1, left);
let left = self.lpf[0].process(left);
let left = self.hpf[0].process(left);
let left = left * decay;
let left = self.apf2[0].0.next(left_apf2_delay_ms, self.apf2[0].2, left);
let left = self.delay2[0].0.next_cubic(self.delay2[0].1, left);
let left = self.delay2[0].0.next_nearest(self.delay2[0].1, left);
// if self.dbg_count % 48 == 0 {
// println!("APFS dcy={:8.6}; {:8.6} {:8.6} {:8.6} {:8.6} | {:8.6} {:8.6} {:8.6} {:8.6}",
@ -428,12 +428,12 @@ impl DattorroReverb {
let right = self.right_sum;
let right = self.apf1[1].0.next(right_apf1_delay_ms, self.apf1[1].2, right);
let right_apf_tap = right;
let right = self.delay1[1].0.next_cubic(self.delay1[1].1, right);
let right = self.delay1[1].0.next_nearest(self.delay1[1].1, right);
let right = self.lpf[1].process(right);
let right = self.hpf[1].process(right);
let right = right * decay;
let right = self.apf2[1].0.next(right_apf2_delay_ms, self.apf2[1].2, right);
let right = self.delay2[1].0.next_cubic(self.delay2[1].1, right);
let right = self.delay2[1].0.next_nearest(self.delay2[1].1, right);
self.right_sum = left * decay;
self.left_sum = right * decay;

View file

@ -777,6 +777,14 @@ impl<F: Flt> DelayBuffer<F> {
res
}
/// Combines [DelayBuffer::nearest_at] and [DelayBuffer::feed]
/// into one convenient function.
#[inline]
pub fn next_nearest(&mut self, delay_time_ms: F, input: F) -> F {
let res = self.nearest_at(delay_time_ms);
self.feed(input);
res
}
/// Shorthand for [DelayBuffer::cubic_interpolate_at].
#[inline]
@ -807,8 +815,8 @@ impl<F: Flt> DelayBuffer<F> {
let fract = s_offs.fract();
let i = (self.wr + len) - offs;
let x0 = data[i % len];
let x1 = data[(i + 1) % len];
let x0 = data[i % len];
let x1 = data[(i - 1) % len];
x0 + fract * (x1 - x0)
}
@ -833,10 +841,10 @@ impl<F: Flt> DelayBuffer<F> {
//
// For the interpolation code:
// MIT License, Copyright (c) 2021 Eric Wood
let xm1 = data[(i - 1) % len];
let xm1 = data[(i + 1) % len];
let x0 = data[i % len];
let x1 = data[(i + 1) % len];
let x2 = data[(i + 2) % len];
let x1 = data[(i - 1) % len];
let x2 = data[(i - 2) % len];
let c = (x1 - xm1) * f(0.5);
let v = x0 - x1;
@ -897,7 +905,7 @@ impl<F: Flt> AllPass<F> {
#[inline]
pub fn next(&mut self, time_ms: F, g: F, v: F) -> F {
let s = self.delay.linear_interpolate_at(time_ms);
let s = self.delay.cubic_interpolate_at(time_ms);
let input = v + -g * s;
self.delay.feed(input);
input * g + s