1
0
Fork 0
mirror of https://github.com/librespot-org/librespot.git synced 2025-10-03 09:49:31 +02:00

Improve sample rounding and clean up noise shaping leftovers (#771)

This commit is contained in:
Roderick van Domburg 2021-05-29 22:53:19 +02:00 committed by GitHub
parent a2fde0a1d6
commit 8062bd2518
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 89 additions and 24 deletions

View file

@ -32,7 +32,7 @@ pub trait Ditherer {
where
Self: Sized;
fn name(&self) -> &'static str;
fn noise(&mut self, sample: f32) -> f32;
fn noise(&mut self) -> f32;
}
impl fmt::Display for dyn Ditherer {
@ -64,7 +64,7 @@ impl Ditherer for TriangularDitherer {
"Triangular"
}
fn noise(&mut self, _sample: f32) -> f32 {
fn noise(&mut self) -> f32 {
self.distribution.sample(&mut self.cached_rng)
}
}
@ -87,7 +87,7 @@ impl Ditherer for GaussianDitherer {
"Gaussian"
}
fn noise(&mut self, _sample: f32) -> f32 {
fn noise(&mut self) -> f32 {
self.distribution.sample(&mut self.cached_rng)
}
}
@ -113,7 +113,7 @@ impl Ditherer for HighPassDitherer {
"Triangular, High Passed"
}
fn noise(&mut self, _sample: f32) -> f32 {
fn noise(&mut self) -> f32 {
let new_noise = self.distribution.sample(&mut self.cached_rng);
let high_passed_noise = new_noise - self.previous_noises[self.active_channel];
self.previous_noises[self.active_channel] = new_noise;