From 0fc6e0a0a39018554be67284107c98dec4199b5d Mon Sep 17 00:00:00 2001 From: Bart Brouns Date: Fri, 1 Nov 2024 14:03:10 +0100 Subject: [PATCH] add dry/wet --- src/lib.rs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 5ef64a1..e842ab0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -821,10 +821,6 @@ impl Plugin for Del2 { } } - // We'll start with silence, and then add the output from the active delay taps - output[0][block_start..block_end].fill(0.0); - output[1][block_start..block_end].fill(0.0); - self.set_mute_for_all_delay_taps(sample_rate); let block_len = block_end - block_start; @@ -839,6 +835,12 @@ impl Plugin for Del2 { self.params.gain.smoothed.next_block(&mut gain, block_len); // not poly: + let mut dry_wet = [0.0; MAX_BLOCK_SIZE]; + self.params + .global + .dry_wet + .smoothed + .next_block(&mut dry_wet, block_len); let mut output_gain = [0.0; MAX_BLOCK_SIZE]; self.params .global @@ -851,9 +853,16 @@ impl Plugin for Del2 { .global_drive .smoothed .next_block(&mut global_drive, block_len); + let mut delay_tap_gain = [0.0; MAX_BLOCK_SIZE]; let mut delay_tap_amp_envelope = [0.0; MAX_BLOCK_SIZE]; + for sample_idx in block_start..block_end { + let dry = 1.0 - dry_wet[sample_idx]; + output[0][sample_idx] *= dry; + output[1][sample_idx] *= dry; + } + // TODO: Some form of band limiting // TODO: Filter for delay_tap in self.delay_taps.iter_mut().filter_map(|v| v.as_mut()) { @@ -916,9 +925,9 @@ impl Plugin for Del2 { } } - for (_value_idx, sample_idx) in (block_start..block_end).enumerate() { - let post_filter_gain = - output_gain[sample_idx] / (drive * global_drive[sample_idx]); + for sample_idx in block_start..block_end { + let post_filter_gain = dry_wet[sample_idx] * output_gain[sample_idx] + / (drive * global_drive[sample_idx]); output[0][sample_idx] += delay_tap.delayed_audio_l[sample_idx] * post_filter_gain;