From 40db21277e6c64c51cfdabbc1eeb26cee7524a4b Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Wed, 5 Apr 2023 16:15:09 +0200 Subject: [PATCH] Fix debug assertions in oversampling These were leftover from before the addition of delays. --- plugins/aw_soft_vacuum/src/oversampling.rs | 41 ++++++++++------------ 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/plugins/aw_soft_vacuum/src/oversampling.rs b/plugins/aw_soft_vacuum/src/oversampling.rs index 0910197a..84b1ddbb 100644 --- a/plugins/aw_soft_vacuum/src/oversampling.rs +++ b/plugins/aw_soft_vacuum/src/oversampling.rs @@ -347,29 +347,26 @@ impl Lanzcos3Stage { // NOTE: 'Even samples' is considered from the perspective of a zero latency filter. In // this case the evenness of the filter's latency also needs to be considered. If // it's odd then the direct reading should also happen for odd indexed samples. - self.scratch_buffer[output_sample_idx] = if output_sample_idx % 2 - == (LANZCOS3_KERNEL_LATENCY % 2) - { - nih_debug_assert!( - self.upsampling_rb[(direct_read_pos + LANCZOS3_UPSAMPLING_KERNEL.len() - 1) - % LANCZOS3_UPSAMPLING_KERNEL.len()] - .abs() - == 0.0 - ); - nih_debug_assert!( - self.upsampling_rb[(direct_read_pos + 1) % LANCZOS3_UPSAMPLING_KERNEL.len()] - .abs() - == 0.0 - ); + self.scratch_buffer[output_sample_idx] = + if output_sample_idx % 2 == (LANZCOS3_KERNEL_LATENCY % 2) { + nih_debug_assert_eq!( + self.upsampling_rb[(direct_read_pos + self.upsampling_rb.len() - 1) + % self.upsampling_rb.len()], + 0.0 + ); + nih_debug_assert_eq!( + self.upsampling_rb[(direct_read_pos + 1) % self.upsampling_rb.len()], + 0.0 + ); - self.upsampling_rb[direct_read_pos] - } else { - convolve_rb( - &self.upsampling_rb, - &LANCZOS3_UPSAMPLING_KERNEL, - self.upsampling_write_pos, - ) - }; + self.upsampling_rb[direct_read_pos] + } else { + convolve_rb( + &self.upsampling_rb, + &LANCZOS3_UPSAMPLING_KERNEL, + self.upsampling_write_pos, + ) + }; } }