Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spotify: Add volume control option #638

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/03-customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
4 changes: 3 additions & 1 deletion plugins/spotify/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -44,7 +46,7 @@ set -- /usr/bin/librespot \
--name "$SOUND_DEVICE_NAME" \
--bitrate "$SOUND_SPOTIFY_BITRATE" \
--cache /var/cache/raspotify \
--volume-ctrl linear \
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My subjective experience: I've found linear to be quite difficult to accurately control. I've been using cubic which provides a lot more control in lower volumes.

--volume-ctrl "$SOUND_SPOTIFY_VOLUME_CTRL" \
"$@"

exec "$@"
Loading