mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Remove unnecessary step
Our interpolation_coefficients are already normalized.
This commit is contained in:
parent
d1e4b4464a
commit
841f923549
1 changed files with 2 additions and 14 deletions
|
@ -50,7 +50,6 @@ impl<'a> IntoIterator for &'a DelayLine {
|
||||||
|
|
||||||
struct WindowedSincInterpolator {
|
struct WindowedSincInterpolator {
|
||||||
interpolation_coefficients: Vec<f64>,
|
interpolation_coefficients: Vec<f64>,
|
||||||
interpolation_coefficients_sum: f64,
|
|
||||||
delay_line: DelayLine,
|
delay_line: DelayLine,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,13 +58,10 @@ impl WindowedSincInterpolator {
|
||||||
let interpolation_coefficients =
|
let interpolation_coefficients =
|
||||||
interpolation_quality.get_interpolation_coefficients(resample_factor_reciprocal);
|
interpolation_quality.get_interpolation_coefficients(resample_factor_reciprocal);
|
||||||
|
|
||||||
let interpolation_coefficients_sum = interpolation_coefficients.iter().sum();
|
|
||||||
|
|
||||||
let delay_line = DelayLine::new(interpolation_coefficients.len());
|
let delay_line = DelayLine::new(interpolation_coefficients.len());
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
interpolation_coefficients,
|
interpolation_coefficients,
|
||||||
interpolation_coefficients_sum,
|
|
||||||
delay_line,
|
delay_line,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,20 +72,12 @@ impl WindowedSincInterpolator {
|
||||||
self.delay_line.push(sample);
|
self.delay_line.push(sample);
|
||||||
|
|
||||||
// Temporal convolution
|
// Temporal convolution
|
||||||
let mut output_sample = self
|
self.interpolation_coefficients
|
||||||
.interpolation_coefficients
|
|
||||||
.iter()
|
.iter()
|
||||||
.zip(&self.delay_line)
|
.zip(&self.delay_line)
|
||||||
.fold(0.0, |acc, (coefficient, delay_line_sample)| {
|
.fold(0.0, |acc, (coefficient, delay_line_sample)| {
|
||||||
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) {
|
fn clear(&mut self) {
|
||||||
|
|
Loading…
Reference in a new issue