question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Spotify Initial Volume

See original GitHub issue

Spotify connect uses the ‘SYSTEM_OUTPUT_VOLUME’ variable as initial volume.

If this volume is set to 100% it means that when i connect to Spotify-connect, my naeghbours and family members are blown away 😃. (I am using a raspberry pi 3’s with Hifi Berry Amp).

If I set the SYSTEM_OUTPUT_VOLUME to like 25%, the maximum volume for the soundcard is set to 25% but Spotify also drops down to 25%. which means that it now starts at 25% of the 25%. If i turn up the volume to 100% on the spotify connect app, the soundcard will play at 25%.

This volume level is (re)set whenever the Spotify service is restarted.

I have fixed this by adding a new variable called SPOTIFY_INITIAL_VOLUME to the start.sh in the Spotify folder.

This variable is then used when starting the service. I don’t know (yet…) how to make a branch or request of how to implment this, so i’m hoping that a kind soul could help with this.

Here is the code for start.sh in the Spotify folder (balena-sound-master\spotify):

#!/usr/bin/env bash
 
#Check for incompatible multi room and client-only setting
if [[ -n $DISABLE_MULTI_ROOM ]] && [[ $CLIENT_ONLY_MULTI_ROOM == "1" ]]; then
  echo “DISABLE_MULTI_ROOM and CLIENT_ONLY_MULTI_ROOM cannot be set simultaneously. Ignoring client-only mode.”
fi
 
#Exit service if client-only mode is enabled 
if [[ -z $DISABLE_MULTI_ROOM ]] && [[ $CLIENT_ONLY_MULTI_ROOM == "1" ]]; then
  exit 0
fi

# Set the device broadcast name for Spotify
if [[ -z "$DEVICE_NAME" ]]; then
  DEVICE_NAME=$(printf "balenaSound Spotify %s" $(hostname | cut -c -4))
fi

# Set the system volume here
SYSTEM_OUTPUT_VOLUME="${SYSTEM_OUTPUT_VOLUME:-75}"

# Set the Initial volume here
SPOTIFY_INITIAL_VOLUME="${SPOTIFY_INITIAL_VOLUME:-10}"

# Set the Spotify username and password
if [[ ! -z "$SPOTIFY_LOGIN" ]] && [[ ! -z "$SPOTIFY_PASSWORD" ]]; then
  SPOTIFY_CREDENTIALS="--username \"$SPOTIFY_LOGIN\" --password \"$SPOTIFY_PASSWORD\""
  printf "%s\n" "Using Spotify login."
fi

# Use pipe backend if multi room is enabled
# Don't pipe for Pi 1 family devices since snapcast-server is disabled by default
if [[ -z $DISABLE_MULTI_ROOM ]] && [[ $BALENA_DEVICE_TYPE != "raspberry-pi" ]]; then
  SPOTIFY_BACKEND="--backend pipe"
  SPOTIFY_DEVICE="--device /var/cache/snapcast/snapfifo"
fi

# Start raspotify
exec /usr/bin/librespot --name "$DEVICE_NAME" $SPOTIFY_BACKEND --bitrate 320 --cache /var/cache/raspotify --enable-volume-normalisation --linear-volume --initial-volume=$SPOTIFY_INITIAL_VOLUME $SPOTIFY_CREDENTIALS $SPOTIFY_DEVICE

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
AlexProgrammerDEcommented, Jun 5, 2020

I will open a PR and link it with this issue. It closes it automaticly when its merged.

0reactions
tmigonecommented, Jun 15, 2021

This was addressed with the release of 3.0 last year. Volume is now controlled by the audio block, can be edited at runtime visiting http://balena.local or at startup via env var SOUND_VOLUME

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spotify Initial Volume · Issue #208 · balena-labs ... - GitHub
This volume level is (re)set whenever the Spotify service is restarted. I have fixed this by adding a new variable called SPOTIFY_INITIAL_VOLUME ......
Read more >
max volume on startup - The Spotify Community
Everytime it starts up on my desktop it resets to full volume. Tried doing clean reinstall, did not work.
Read more >
Topic: How To Set Starting Volume Spotify Connect - Max2Play
Hi all,. How would I set the initial volume when connecting with spotify please? At the moment every time I connect it is...
Read more >
Spotify Connect Volume - MiniDSP
Change volume in spotify app... ... We did set the initial spotify volume to 75% to have a chance to turn the volume...
Read more >
Spotify Connect: What is it? How can you get it? - What Hi-Fi?
To use Spotify Connect, you'll first need a smartphone, tablet, ... it will always adjust the volume automatically for the chosen audio ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found