Fixed more bugs in the Dattorro reverb (delay time interpretation in DelayBuffer)

This commit is contained in:
Weird Constructor 2021-08-08 00:12:02 +02:00
parent c57274bfe4
commit 525c8d8c1b
2 changed files with 29 additions and 10 deletions

View file

@ -102,6 +102,8 @@ pub struct DattorroReverb {
left_sum: f32,
right_sum: f32,
dbg_count: usize,
}
pub trait DattorroReverbParams {
@ -158,6 +160,8 @@ impl DattorroReverb {
left_sum: 0.0,
right_sum: 0.0,
dbg_count: 0,
};
this.reset();
@ -403,6 +407,19 @@ impl DattorroReverb {
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);
if self.dbg_count % 48 == 0 {
println!("APFS dcy={:8.6}; {:8.6} {:8.6} {:8.6} {:8.6}",
decay,
left_apf1_delay_ms, right_apf1_delay_ms,
left_apf2_delay_ms, right_apf2_delay_ms);
println!("DELY1/2 {:8.6} / {:8.6} | {:8.6} / {:8.6}",
self.delay1[0].1,
self.delay2[0].1,
self.delay1[1].1,
self.delay2[1].1);
}
// Right Sum => APF1 => Delay1 => LPF => HPF => APF2 => Delay2
// And then send this over to the left sum.
let right = self.right_sum;
@ -439,6 +456,8 @@ impl DattorroReverb {
let left_out = self.out_dc_block[0].next(left_accum);
let right_out = self.out_dc_block[1].next(right_accum);
self.dbg_count += 1;
// (left_out * 0.5, right_out * 0.5)
(left_out * 0.5, right_out * 0.5)
}

View file

@ -821,9 +821,9 @@ impl DelayBuffer {
}
#[inline]
pub fn nearest_at(&self, delay_time: f32) -> f32 {
pub fn nearest_at(&self, delay_time_ms: f32) -> f32 {
let len = self.data.len();
let offs = (delay_time * self.srate).floor() as usize % len;
let offs = ((delay_time_ms * self.srate) / 1000.0).floor() as usize % len;
let idx = ((self.wr + len) - offs) % len;
self.data[idx]
}
@ -860,13 +860,13 @@ impl AllPass {
}
#[inline]
pub fn delay_tap_n(&self, time: f32) -> f32 {
self.delay.tap_n(time)
pub fn delay_tap_n(&self, time_ms: f32) -> f32 {
self.delay.tap_n(time_ms)
}
#[inline]
pub fn next(&mut self, time: f32, g: f32, v: f32) -> f32 {
let s = self.delay.cubic_interpolate_at(time);
pub fn next(&mut self, time_ms: f32, g: f32, v: f32) -> f32 {
let s = self.delay.linear_interpolate_at(time_ms);
let input = v + -g * s;
self.delay.feed(input);
input * g + s
@ -894,13 +894,13 @@ impl Comb {
}
#[inline]
pub fn delay_tap_c(&self, time: f32) -> f32 {
self.delay.tap_c(time)
pub fn delay_tap_c(&self, time_ms: f32) -> f32 {
self.delay.tap_c(time_ms)
}
#[inline]
pub fn delay_tap_n(&self, time: f32) -> f32 {
self.delay.tap_n(time)
pub fn delay_tap_n(&self, time_ms: f32) -> f32 {
self.delay.tap_n(time_ms)
}
#[inline]