small clean up

This commit is contained in:
JasonLG1979 2023-07-06 17:58:42 -05:00
parent 1bc16855c9
commit a331729f0e
2 changed files with 13 additions and 13 deletions

View file

@ -180,17 +180,20 @@ impl SampleRate {
mut coefficients: Vec<f64>,
resample_factor_reciprocal: f64,
) -> Vec<f64> {
let mut coefficient_sum = 0.0;
for (index, coefficient) in coefficients.iter_mut().enumerate() {
*coefficient *= Self::sinc((index as f64 * resample_factor_reciprocal).fract());
coefficient_sum += *coefficient;
}
let mut coefficients_sum = 0.0;
coefficients
.iter_mut()
.for_each(|coefficient| *coefficient /= coefficient_sum);
.enumerate()
.for_each(|(index, coefficient)| {
*coefficient *= Self::sinc((index as f64 * resample_factor_reciprocal).fract());
coefficients_sum += *coefficient;
});
coefficients
.iter_mut()
.for_each(|coefficient| *coefficient /= coefficients_sum);
coefficients
}

View file

@ -296,17 +296,14 @@ impl StereoInterleavedResampler {
// The player increments the player id when it gets it...
let player_id = PLAYER_COUNTER.load(Ordering::SeqCst).saturating_sub(1);
let left_thread_name = format!("resampler:{player_id}:left");
let right_thread_name = format!("resampler:{player_id}:right");
Resampler::Worker {
left_resampler: ResampleWorker::new(
MonoSincResampler::new(sample_rate),
left_thread_name,
format!("resampler:{player_id}:left"),
),
right_resampler: ResampleWorker::new(
MonoSincResampler::new(sample_rate),
right_thread_name,
format!("resampler:{player_id}:right"),
),
}
}