Fix default normalisation threshold [#745]

This commit is contained in:
Roderick van Domburg 2021-05-16 22:30:35 +02:00
parent 041f084d7f
commit a4ad6d4aa8
No known key found for this signature in database
GPG key ID: FE2585E713F9F30A
3 changed files with 21 additions and 15 deletions

View file

@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [librespot-audio] Removed `VorbisDecoder`, `VorbisError`, `AudioPacket`, `PassthroughDecoder`, `PassthroughError`, `AudioError`, `AudioDecoder` and the `convert` module from `librespot_audio`. The underlying crates `vorbis`, `librespot-tremor`, `lewton` and `ogg` should be used directly.
### Fixed
* [librespot-playback] Incorrect `PlayerConfig::default().normalisation_threshold` caused distortion when using dynamic volume normalisation downstream
## [0.2.0] - 2021-05-04
## [0.1.6] - 2021-02-22

View file

@ -1,4 +1,6 @@
use super::player::NormalisationData;
use crate::convert::i24;
use std::convert::TryFrom;
use std::mem;
use std::str::FromStr;
@ -138,7 +140,7 @@ impl Default for PlayerConfig {
normalisation_type: NormalisationType::default(),
normalisation_method: NormalisationMethod::default(),
normalisation_pregain: 0.0,
normalisation_threshold: -1.0,
normalisation_threshold: NormalisationData::db_to_ratio(-1.0),
normalisation_attack: 0.005,
normalisation_release: 0.1,
normalisation_knee: 1.0,

View file

@ -557,26 +557,26 @@ fn get_setup(args: &[String]) -> Setup {
.opt_str("normalisation-pregain")
.map(|pregain| pregain.parse::<f32>().expect("Invalid pregain float value"))
.unwrap_or(PlayerConfig::default().normalisation_pregain),
normalisation_threshold: NormalisationData::db_to_ratio(
matches
.opt_str("normalisation-threshold")
.map(|threshold| {
normalisation_threshold: matches
.opt_str("normalisation-threshold")
.map(|threshold| {
NormalisationData::db_to_ratio(
threshold
.parse::<f32>()
.expect("Invalid threshold float value")
})
.unwrap_or(PlayerConfig::default().normalisation_threshold),
),
.expect("Invalid threshold float value"),
)
})
.unwrap_or(PlayerConfig::default().normalisation_threshold),
normalisation_attack: matches
.opt_str("normalisation-attack")
.map(|attack| attack.parse::<f32>().expect("Invalid attack float value"))
.unwrap_or(PlayerConfig::default().normalisation_attack * MILLIS)
/ MILLIS,
.map(|attack| attack.parse::<f32>().expect("Invalid attack float value") / MILLIS)
.unwrap_or(PlayerConfig::default().normalisation_attack),
normalisation_release: matches
.opt_str("normalisation-release")
.map(|release| release.parse::<f32>().expect("Invalid release float value"))
.unwrap_or(PlayerConfig::default().normalisation_release * MILLIS)
/ MILLIS,
.map(|release| {
release.parse::<f32>().expect("Invalid release float value") / MILLIS
})
.unwrap_or(PlayerConfig::default().normalisation_release),
normalisation_knee: matches
.opt_str("normalisation-knee")
.map(|knee| knee.parse::<f32>().expect("Invalid knee float value"))