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:
parent
a2fde0a1d6
commit
8062bd2518
4 changed files with 89 additions and 24 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue