Fixed some more bugs in the reverb

This commit is contained in:
Weird Constructor 2021-08-08 12:51:31 +02:00
parent 14bf59bfac
commit 79c11cd45b
4 changed files with 49 additions and 29 deletions

View file

@ -50,13 +50,20 @@ const DAT_LEFT_TAPS_TIME_MS : [f64; 7] = [
]; ];
const DAT_RIGHT_TAPS_TIME_MS : [f64; 7] = [ const DAT_RIGHT_TAPS_TIME_MS : [f64; 7] = [
353.0 / DAT_SAMPLES_PER_MS, 266.0 / DAT_SAMPLES_PER_MS,
3627.0 / DAT_SAMPLES_PER_MS, 2974.0 / DAT_SAMPLES_PER_MS,
1228.0 / DAT_SAMPLES_PER_MS, 1913.0 / DAT_SAMPLES_PER_MS,
2673.0 / DAT_SAMPLES_PER_MS, 1996.0 / DAT_SAMPLES_PER_MS,
2111.0 / DAT_SAMPLES_PER_MS, 1990.0 / DAT_SAMPLES_PER_MS,
335.0 / DAT_SAMPLES_PER_MS, 187.0 / DAT_SAMPLES_PER_MS,
121.0 / DAT_SAMPLES_PER_MS, 1066.0 / DAT_SAMPLES_PER_MS,
// 353.0 / DAT_SAMPLES_PER_MS,
// 3627.0 / DAT_SAMPLES_PER_MS,
// 1228.0 / DAT_SAMPLES_PER_MS,
// 2673.0 / DAT_SAMPLES_PER_MS,
// 2111.0 / DAT_SAMPLES_PER_MS,
// 335.0 / DAT_SAMPLES_PER_MS,
// 121.0 / DAT_SAMPLES_PER_MS,
]; ];
const DAT_LFO_FREQS_HZ : [f64; 4] = [ 0.1, 0.15, 0.12, 0.18 ]; const DAT_LFO_FREQS_HZ : [f64; 4] = [ 0.1, 0.15, 0.12, 0.18 ];
@ -296,25 +303,25 @@ impl DattorroReverb {
{ {
let left_apf1_delay_ms = let left_apf1_delay_ms =
self.apf1[0].1 self.apf1[0].1
+ (self.lfos[0].next_unipolar() as f64 + (self.lfos[0].next_bipolar() as f64
* DAT_LFO_EXCURSION_MS * DAT_LFO_EXCURSION_MS
* DAT_LFO_EXCURSION_MOD_MAX * DAT_LFO_EXCURSION_MOD_MAX
* params.mod_depth()); * params.mod_depth());
let right_apf1_delay_ms = let right_apf1_delay_ms =
self.apf1[1].1 self.apf1[1].1
+ (self.lfos[1].next_unipolar() as f64 + (self.lfos[1].next_bipolar() as f64
* DAT_LFO_EXCURSION_MS * DAT_LFO_EXCURSION_MS
* DAT_LFO_EXCURSION_MOD_MAX * DAT_LFO_EXCURSION_MOD_MAX
* params.mod_depth()); * params.mod_depth());
let left_apf2_delay_ms = let left_apf2_delay_ms =
self.apf2[0].1 self.apf2[0].1
+ (self.lfos[2].next_unipolar() as f64 + (self.lfos[2].next_bipolar() as f64
* DAT_LFO_EXCURSION_MS * DAT_LFO_EXCURSION_MS
* DAT_LFO_EXCURSION_MOD_MAX * DAT_LFO_EXCURSION_MOD_MAX
* params.mod_depth()); * params.mod_depth());
let right_apf2_delay_ms = let right_apf2_delay_ms =
self.apf2[1].1 self.apf2[1].1
+ (self.lfos[3].next_unipolar() as f64 + (self.lfos[3].next_bipolar() as f64
* DAT_LFO_EXCURSION_MS * DAT_LFO_EXCURSION_MS
* DAT_LFO_EXCURSION_MOD_MAX * DAT_LFO_EXCURSION_MOD_MAX
* params.mod_depth()); * params.mod_depth());
@ -373,9 +380,9 @@ impl DattorroReverb {
let out_hpf = self.input_hpf.process(out_lpf); let out_hpf = self.input_hpf.process(out_lpf);
// HPF => Pre-Delay // HPF => Pre-Delay
let out_pre_delay = out_hpf; // let out_pre_delay = out_hpf;
// self.pre_delay.cubic_interpolate_at(params.pre_delay_time_ms()); let out_pre_delay =
// self.pre_delay.feed(out_hpf); self.pre_delay.next_cubic(params.pre_delay_time_ms(), out_hpf);
// Pre-Delay => 4 All-Pass filters // Pre-Delay => 4 All-Pass filters
let mut diffused = out_pre_delay; let mut diffused = out_pre_delay;
@ -384,8 +391,8 @@ impl DattorroReverb {
} }
// Mix between diffused and pre-delayed intput for further processing // Mix between diffused and pre-delayed intput for further processing
let tank_feed = out_pre_delay; let tank_feed =
// crossfade(out_pre_delay, diffused, params.input_diffusion_mix()); crossfade(out_pre_delay, diffused, params.input_diffusion_mix());
// First tap for the output // First tap for the output
self.left_sum += tank_feed; self.left_sum += tank_feed;
@ -408,8 +415,12 @@ impl DattorroReverb {
let left = self.delay2[0].0.next_cubic(self.delay2[0].1, left); let left = self.delay2[0].0.next_cubic(self.delay2[0].1, left);
if self.dbg_count % 48 == 0 { if self.dbg_count % 48 == 0 {
println!("APFS dcy={:8.6}; {:8.6} {:8.6} {:8.6} {:8.6}", println!("APFS dcy={:8.6}; {:8.6} {:8.6} {:8.6} {:8.6} | {:8.6} {:8.6} {:8.6} {:8.6}",
decay, decay,
self.apf1[0].2,
self.apf1[1].2,
self.apf2[0].2,
self.apf2[1].2,
left_apf1_delay_ms, right_apf1_delay_ms, left_apf1_delay_ms, right_apf1_delay_ms,
left_apf2_delay_ms, right_apf2_delay_ms); left_apf2_delay_ms, right_apf2_delay_ms);
println!("DELY1/2 {:8.6} / {:8.6} | {:8.6} / {:8.6}", println!("DELY1/2 {:8.6} / {:8.6} | {:8.6} / {:8.6}",
@ -458,7 +469,6 @@ impl DattorroReverb {
self.dbg_count += 1; self.dbg_count += 1;
// (left_out * 0.5, right_out * 0.5)
(left_out * 0.5, right_out * 0.5) (left_out * 0.5, right_out * 0.5)
} }
} }

View file

@ -265,8 +265,8 @@ impl SplitMix64 {
/// * `v2` - signal 2, range -1.0 to 1.0 /// * `v2` - signal 2, range -1.0 to 1.0
/// * `mix` - mix position, range 0.0 to 1.0, mid is at 0.5 /// * `mix` - mix position, range 0.0 to 1.0, mid is at 0.5
#[inline] #[inline]
pub fn crossfade(v1: f32, v2: f32, mix: f32) -> f32 { pub fn crossfade<F: Flt>(v1: F, v2: F, mix: F) -> F {
v1 * (1.0 - mix) + v2 * mix v1 * (f::<F>(1.0) - mix) + v2 * mix
} }
/// Constant power crossfade. /// Constant power crossfade.
@ -768,6 +768,16 @@ impl<F: Flt> DelayBuffer<F> {
res res
} }
/// Combines [DelayBuffer::linear_interpolate_at] and [DelayBuffer::feed]
/// into one convenient function.
#[inline]
pub fn next_linear(&mut self, delay_time_ms: F, input: F) -> F {
let res = self.linear_interpolate_at(delay_time_ms);
self.feed(input);
res
}
/// Shorthand for [DelayBuffer::cubic_interpolate_at]. /// Shorthand for [DelayBuffer::cubic_interpolate_at].
#[inline] #[inline]
pub fn tap_c(&self, delay_time_ms: F) -> F { pub fn tap_c(&self, delay_time_ms: F) -> F {
@ -888,10 +898,10 @@ impl<F: Flt> AllPass<F> {
#[inline] #[inline]
pub fn next(&mut self, time_ms: F, g: F, v: F) -> F { pub fn next(&mut self, time_ms: F, g: F, v: F) -> F {
let s = self.delay.nearest_at(time_ms); let s = self.delay.linear_interpolate_at(time_ms);
let input = v + -g * s; let input = v + g * s;
self.delay.feed(input); self.delay.feed(input);
input * g + s input * -g + s
} }
} }

View file

@ -781,7 +781,7 @@ macro_rules! node_list {
( 4 dcy n_id d_id r_id f_def stp_d 0.0, 1.0, 0.25) ( 4 dcy n_id d_id r_id f_def stp_d 0.0, 1.0, 0.25)
( 5 ilpf n_pit d_pit r_fq f_freq stp_d -1.0, 0.5647131, 22050.0) ( 5 ilpf n_pit d_pit r_fq f_freq stp_d -1.0, 0.5647131, 22050.0)
( 6 ihpf n_pit d_pit r_fq f_freq stp_d -1.0, 0.5647131, 0.0) ( 6 ihpf n_pit d_pit r_fq f_freq stp_d -1.0, 0.5647131, 0.0)
( 7 idif n_id d_id r_id f_def stp_d 0.0, 1.0, 1.0) ( 7 dif n_id d_id r_id f_def stp_d 0.0, 1.0, 1.0)
( 8 dmix n_id d_id r_id f_def stp_d 0.0, 1.0, 1.0) ( 8 dmix n_id d_id r_id f_def stp_d 0.0, 1.0, 1.0)
( 9 mspeed n_id d_id r_id f_def stp_d 0.0, 1.0, 0.0) ( 9 mspeed n_id d_id r_id f_def stp_d 0.0, 1.0, 0.0)
(10 mshp n_id d_id r_id f_def stp_d 0.0, 1.0, 1.0) (10 mshp n_id d_id r_id f_def stp_d 0.0, 1.0, 1.0)

View file

@ -19,7 +19,7 @@ pub struct DatParams {
dcy: ProcBuf, dcy: ProcBuf,
ilpf: ProcBuf, ilpf: ProcBuf,
ihpf: ProcBuf, ihpf: ProcBuf,
idif: ProcBuf, dif: ProcBuf,
dmix: ProcBuf, dmix: ProcBuf,
mspeed: ProcBuf, mspeed: ProcBuf,
mshp: ProcBuf, mshp: ProcBuf,
@ -50,7 +50,7 @@ impl DattorroReverbParams for DatParams {
denorm::PVerb::ihpf(&self.ihpf, self.frame) as f64 denorm::PVerb::ihpf(&self.ihpf, self.frame) as f64
} }
fn diffusion(&self) -> f64 { fn diffusion(&self) -> f64 {
denorm::PVerb::idif(&self.idif, self.frame) as f64 denorm::PVerb::dif(&self.dif, self.frame) as f64
} }
fn input_diffusion_mix(&self) -> f64 { fn input_diffusion_mix(&self) -> f64 {
denorm::PVerb::dmix(&self.dmix, self.frame) as f64 denorm::PVerb::dmix(&self.dmix, self.frame) as f64
@ -102,8 +102,8 @@ impl PVerb {
"PVerb ilpf\n\nRange: (0..1)"; "PVerb ilpf\n\nRange: (0..1)";
pub const ihpf : &'static str = pub const ihpf : &'static str =
"PVerb ihpf\n\nRange: (0..1)"; "PVerb ihpf\n\nRange: (0..1)";
pub const idif : &'static str = pub const dif : &'static str =
"PVerb idif\n\nRange: (0..1)"; "PVerb dif\n\nRange: (0..1)";
pub const dmix : &'static str = pub const dmix : &'static str =
"PVerb dmix\n\nRange: (0..1)"; "PVerb dmix\n\nRange: (0..1)";
pub const mspeed : &'static str = pub const mspeed : &'static str =
@ -171,7 +171,7 @@ impl DspNode for PVerb {
dcy: *inp::PVerb::dcy(inputs), dcy: *inp::PVerb::dcy(inputs),
ilpf: *inp::PVerb::ilpf(inputs), ilpf: *inp::PVerb::ilpf(inputs),
ihpf: *inp::PVerb::ihpf(inputs), ihpf: *inp::PVerb::ihpf(inputs),
idif: *inp::PVerb::idif(inputs), dif: *inp::PVerb::dif(inputs),
dmix: *inp::PVerb::dmix(inputs), dmix: *inp::PVerb::dmix(inputs),
mspeed: *inp::PVerb::mspeed(inputs), mspeed: *inp::PVerb::mspeed(inputs),
mshp: *inp::PVerb::mshp(inputs), mshp: *inp::PVerb::mshp(inputs),