From c989909b078767c594eca41a91b0715034d78eab Mon Sep 17 00:00:00 2001 From: Ronak Buch Date: Thu, 13 May 2021 21:01:04 -0400 Subject: [PATCH] Explicitly set default normalisation threshold for librespot The normalisation threshold should be in ratio space, but the default value is specified in dB space, so using it as the default implicitly without passing it through the db_to_ratio function causes distortion and clipping when normalisation is enabled. --- src/spotify.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/spotify.rs b/src/spotify.rs index 559d666..b545dbf 100644 --- a/src/spotify.rs +++ b/src/spotify.rs @@ -4,6 +4,7 @@ use librespot_core::config::SessionConfig; use librespot_core::session::Session; use librespot_core::session::SessionError; use librespot_playback::config::PlayerConfig; +use librespot_playback::player::NormalisationData; use log::{debug, error, info}; use librespot_playback::audio_backend; @@ -190,6 +191,9 @@ impl Spotify { bitrate: bitrate.unwrap_or(Bitrate::Bitrate320), normalisation: cfg.values().volnorm.unwrap_or(false), normalisation_pregain: cfg.values().volnorm_pregain.unwrap_or(0.0), + normalisation_threshold: NormalisationData::db_to_ratio( + PlayerConfig::default().normalisation_threshold, + ), ..Default::default() };