Skip to content

Commit

Permalink
small clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLG1979 committed Jul 6, 2023
1 parent 1bc1685 commit a331729
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
15 changes: 9 additions & 6 deletions playback/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,20 @@ impl SampleRate {
mut coefficients: Vec<f64>,
resample_factor_reciprocal: f64,
) -> Vec<f64> {
let mut coefficient_sum = 0.0;
let mut coefficients_sum = 0.0;

for (index, coefficient) in coefficients.iter_mut().enumerate() {
*coefficient *= Self::sinc((index as f64 * resample_factor_reciprocal).fract());
coefficients
.iter_mut()
.enumerate()
.for_each(|(index, coefficient)| {
*coefficient *= Self::sinc((index as f64 * resample_factor_reciprocal).fract());

coefficient_sum += *coefficient;
}
coefficients_sum += *coefficient;
});

coefficients
.iter_mut()
.for_each(|coefficient| *coefficient /= coefficient_sum);
.for_each(|coefficient| *coefficient /= coefficients_sum);

coefficients
}
Expand Down
7 changes: 2 additions & 5 deletions playback/src/resampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
}
}
Expand Down

0 comments on commit a331729

Please sign in to comment.