From 777debb9aef6f4ac7e112a546890076885b0d949 Mon Sep 17 00:00:00 2001 From: Tim Hudson Date: Mon, 17 Apr 2023 18:44:18 -0700 Subject: [PATCH] spotify: Add volume control option This commit introduces the option to choose the volume control method for Spotify playback by adding a new environment variable `SOUND_SPOTIFY_VOLUME_CTRL`. Users can now set the volume control method to `cubic`, `fixed`, `linear`, or `log`. The default value is set to `linear` to maintain backwards compatibility with the currently set value. Additionally, the default value for `SOUND_SPOTIFY_BITRATE` has been updated to be wrapped in backticks for better readability. Change-type: minor --- docs/03-customization.md | 3 ++- plugins/spotify/start.sh | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/03-customization.md b/docs/03-customization.md index c7235ef1..0f6e8fb5 100644 --- a/docs/03-customization.md +++ b/docs/03-customization.md @@ -50,4 +50,5 @@ The following variables control various aspects of each plugin behavior: | SOUND_SPOTIFY_PASSWORD | Your Spotify login password. Note: most Spotify clients on phones will authenticate via zeroconf so this is not usually required. | --- | --- | | SOUND_SPOTIFY_DISABLE_NORMALISATION | Disable volume normalization in Spotify. | Disabled if the variable exists regardless of its value. | --- | | SOUND_SPOTIFY_ENABLE_CACHE | Enable the audio cache in Spotify. Note that over time the cache can take up large amounts of disk space. | Enabled if the variable exists regardless of its value. | --- | -| SOUND_SPOTIFY_BITRATE | Spotify playback bitrate. | Bitrate in kbps: `96`, `160` or `320` | 160 | +| SOUND_SPOTIFY_BITRATE | Spotify playback bitrate. | Bitrate in kbps: `96`, `160` or `320` | `160` | +| SOUND_SPOTIFY_VOLUME_CTRL | Spotify volume control method. | `cubic`, `fixed`, `linear`, or `log` | `linear` | diff --git a/plugins/spotify/start.sh b/plugins/spotify/start.sh index 1e34a6b2..75672f13 100644 --- a/plugins/spotify/start.sh +++ b/plugins/spotify/start.sh @@ -8,8 +8,10 @@ fi # --- ENV VARS --- # SOUND_DEVICE_NAME: Set the device broadcast name for Spotify # SOUND_SPOTIFY_BITRATE: Set the playback bitrate +# SOUND_SPOTIFY_VOLUME_CTRL: Set the volume control method SOUND_DEVICE_NAME=${SOUND_DEVICE_NAME:-"balenaSound Spotify $(echo "$BALENA_DEVICE_UUID" | cut -c -4)"} SOUND_SPOTIFY_BITRATE=${SOUND_SPOTIFY_BITRATE:-160} +SOUND_SPOTIFY_VOLUME_CTRL=${SOUND_SPOTIFY_VOLUME_CTRL:-linear} # SOUND_SPOTIFY_DISABLE_NORMALISATION: Disable volume normalization if [[ -z ${SOUND_SPOTIFY_DISABLE_NORMALISATION+x} ]]; then @@ -44,7 +46,7 @@ set -- /usr/bin/librespot \ --name "$SOUND_DEVICE_NAME" \ --bitrate "$SOUND_SPOTIFY_BITRATE" \ --cache /var/cache/raspotify \ - --volume-ctrl linear \ + --volume-ctrl "$SOUND_SPOTIFY_VOLUME_CTRL" \ "$@" exec "$@"