Skip to content

Commit a4ad6d4

Browse files
committed
Fix default normalisation threshold [#745]
1 parent 041f084 commit a4ad6d4

3 files changed

Lines changed: 21 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
* [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.
1313

14+
### Fixed
15+
16+
* [librespot-playback] Incorrect `PlayerConfig::default().normalisation_threshold` caused distortion when using dynamic volume normalisation downstream
17+
1418
## [0.2.0] - 2021-05-04
1519

1620
## [0.1.6] - 2021-02-22

playback/src/config.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
use super::player::NormalisationData;
12
use crate::convert::i24;
3+
24
use std::convert::TryFrom;
35
use std::mem;
46
use std::str::FromStr;
@@ -138,7 +140,7 @@ impl Default for PlayerConfig {
138140
normalisation_type: NormalisationType::default(),
139141
normalisation_method: NormalisationMethod::default(),
140142
normalisation_pregain: 0.0,
141-
normalisation_threshold: -1.0,
143+
normalisation_threshold: NormalisationData::db_to_ratio(-1.0),
142144
normalisation_attack: 0.005,
143145
normalisation_release: 0.1,
144146
normalisation_knee: 1.0,

src/main.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -557,26 +557,26 @@ fn get_setup(args: &[String]) -> Setup {
557557
.opt_str("normalisation-pregain")
558558
.map(|pregain| pregain.parse::<f32>().expect("Invalid pregain float value"))
559559
.unwrap_or(PlayerConfig::default().normalisation_pregain),
560-
normalisation_threshold: NormalisationData::db_to_ratio(
561-
matches
562-
.opt_str("normalisation-threshold")
563-
.map(|threshold| {
560+
normalisation_threshold: matches
561+
.opt_str("normalisation-threshold")
562+
.map(|threshold| {
563+
NormalisationData::db_to_ratio(
564564
threshold
565565
.parse::<f32>()
566-
.expect("Invalid threshold float value")
567-
})
568-
.unwrap_or(PlayerConfig::default().normalisation_threshold),
569-
),
566+
.expect("Invalid threshold float value"),
567+
)
568+
})
569+
.unwrap_or(PlayerConfig::default().normalisation_threshold),
570570
normalisation_attack: matches
571571
.opt_str("normalisation-attack")
572-
.map(|attack| attack.parse::<f32>().expect("Invalid attack float value"))
573-
.unwrap_or(PlayerConfig::default().normalisation_attack * MILLIS)
574-
/ MILLIS,
572+
.map(|attack| attack.parse::<f32>().expect("Invalid attack float value") / MILLIS)
573+
.unwrap_or(PlayerConfig::default().normalisation_attack),
575574
normalisation_release: matches
576575
.opt_str("normalisation-release")
577-
.map(|release| release.parse::<f32>().expect("Invalid release float value"))
578-
.unwrap_or(PlayerConfig::default().normalisation_release * MILLIS)
579-
/ MILLIS,
576+
.map(|release| {
577+
release.parse::<f32>().expect("Invalid release float value") / MILLIS
578+
})
579+
.unwrap_or(PlayerConfig::default().normalisation_release),
580580
normalisation_knee: matches
581581
.opt_str("normalisation-knee")
582582
.map(|knee| knee.parse::<f32>().expect("Invalid knee float value"))

0 commit comments

Comments
 (0)