From 841f9235497d8c65fbf7a56070ee3f99a340f8f5 Mon Sep 17 00:00:00 2001 From: JasonLG1979 Date: Tue, 27 Jun 2023 16:13:31 -0500 Subject: [PATCH] Remove unnecessary step Our interpolation_coefficients are already normalized. --- playback/src/resampler.rs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/playback/src/resampler.rs b/playback/src/resampler.rs index 3e66791c..58cda2d6 100644 --- a/playback/src/resampler.rs +++ b/playback/src/resampler.rs @@ -50,7 +50,6 @@ impl<'a> IntoIterator for &'a DelayLine { struct WindowedSincInterpolator { interpolation_coefficients: Vec, - interpolation_coefficients_sum: f64, delay_line: DelayLine, } @@ -59,13 +58,10 @@ impl WindowedSincInterpolator { let interpolation_coefficients = interpolation_quality.get_interpolation_coefficients(resample_factor_reciprocal); - let interpolation_coefficients_sum = interpolation_coefficients.iter().sum(); - let delay_line = DelayLine::new(interpolation_coefficients.len()); Self { interpolation_coefficients, - interpolation_coefficients_sum, delay_line, } } @@ -76,20 +72,12 @@ impl WindowedSincInterpolator { self.delay_line.push(sample); // Temporal convolution - let mut output_sample = self - .interpolation_coefficients + self.interpolation_coefficients .iter() .zip(&self.delay_line) .fold(0.0, |acc, (coefficient, delay_line_sample)| { acc + coefficient * delay_line_sample - }); - - if output_sample.is_normal() { - // Make sure that interpolation does not add any gain. - output_sample /= self.interpolation_coefficients_sum; - } - - output_sample + }) } fn clear(&mut self) {