From 85bc8988309c8df2e4fbb8390d64a10a7888ca3c Mon Sep 17 00:00:00 2001 From: Henrik Friedrichsen Date: Thu, 14 May 2020 21:48:09 +0200 Subject: [PATCH] implement volume normalization setting fixes #195 --- README.md | 2 ++ src/config.rs | 2 ++ src/spotify.rs | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 20b7879..2c47e84 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,8 @@ values are: * `use_nerdfont`: Turn nerdfont glyphs on/off * `theme`: Set a custom color palette (see below) +* `volnorm`: Enable or disable volume normalization, off by default +* `volnorm_pregain`: Normalization pregain to apply (if enabled) Keybindings can be configured in `[keybindings]` section in `config.toml`, e.g. as such: diff --git a/src/config.rs b/src/config.rs index 7e59037..c5c341f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -13,6 +13,8 @@ pub struct Config { pub theme: Option, pub use_nerdfont: Option, pub saved_state: Option, + pub volnorm: Option, + pub volnorm_pregain: Option, } #[derive(Serialize, Deserialize, Debug, Default, Clone)] diff --git a/src/spotify.rs b/src/spotify.rs index 71ad6da..0e13673 100644 --- a/src/spotify.rs +++ b/src/spotify.rs @@ -225,8 +225,8 @@ impl Spotify { pub fn new(events: EventManager, credentials: Credentials, cfg: &config::Config) -> Spotify { let player_config = PlayerConfig { bitrate: Bitrate::Bitrate320, - normalisation: false, - normalisation_pregain: 0.0, + normalisation: cfg.volnorm.unwrap_or(false), + normalisation_pregain: cfg.volnorm_pregain.unwrap_or(0.0), }; let (user_tx, user_rx) = oneshot::channel(); let volume = match &cfg.saved_state {