Pi Musicbox volume control (for Amp hat) not working with Spotify Connect


I am using a Raspberry Pi Zero and Justboom Amp Zero with Pi Musicbox with Spotify Connect and I can not change the output volume ?!

Pi Musicbox volume slider or initial volume has no effect.



The regular pimusicbox volume controls are for the main Mopidy music server and not for Spotify connect which is separate. I think you can only change the volume through the Spotify app running on the control device (e.g your phone). But I’ve not checked that with that particular setup, possibly it doesn’t send those volume changes to the hardware. Can you verify if you have tried that?


Yes, sure I can change the volume from the Spotify Connect app, but is that not only the input volume ?
I have to set it to 2% to avoid blowing the speakers. For that reason I would like to reduce the Amp hat volume.


That volume information should be going to the hardware but it’s very possible it is not. Spotify connect doesn’t stream music from the control app to the playback device. It instructs the playback device to connect to Spotify directly and stream the music from there. I don’t think an “input volume” makes sense in this context.


Hmm … Most Spotify Connect radios has a volume kontrol knob, that has nothing to do with the Spotify Connect app volume. I was hoping that the Amp hat had the same (in SW)


Try changing it through alsamixer.


Ok. How do I do that ?

-------- Oprindelig besked --------


mopidy-alsamixer plugin, docs are here https://github.com/mopidy/mopidy-alsamixer

mopidy-alsamixer allows to control volume through the alsa interface, but the souncard alsa driver must support volume control. I your soundcard does not support volume control then You can use softvol alsa plugin. In both cases, the volume on the speakers will be controlled with mopidy volume bar, and spotify connect volume will be able only to decrese this volume. So if you make volume realy low on mopidy You will be not able to make it louder through spotify connect.


No, login via ssh and run the program alsamixer. See if you can change the volume that way. This issue is entirely outside of Mopidy.


Tried it. Yes, I can change Analogue and Digital succesfully with alsamixer (see picture) Unfortunately changing Analogue (-6db) is not enough, and even though you can also reduce Digital, it only saves the Analogue setting, but not the Digital settings, so the Digital setting goes back to full power after reboot.


Something overrides the stored alsamixer setting for Digital in asound.state, when rebooting, always setting it to -4 db.


That’s at the bottom of /opt/musicbox/setsound.sh. Comment it out, or change to what you prefer.


Thanks. Worked like a charm. Changing Digital volume from 98% to 85% in setsound.sh lowered the amp volume to an acceptable level after reboot.


I’ve just tried that, as the phatdac I’ve just got seemed quite loud and difficult to control, changed the volume down to 80% and although I think it’s better, the setsound.sh file no longer has anything in it apart from a line that says mopidy and lots of @@.

Everything still works fine and I’m not sure how I managed to mess it up, but if you could post a copy of yours that I can put in I would be grateful.





I have the same issue but can’t make it working…

I use this card : https://www.audiophonics.fr/fr/dac-diy/audiophonics-dac-sabre-es9023-v22-i2s-vers-analogique-24bit192khz-p-8396.html

Working as Hifiberry_DAC.

I setted setsound.sh like this :
amixer -c 0 set PCM playback 10% > /dev/null 2>&1 || true &

And setting.ini like this :

output = volume volume=0.1 ! alsasink buffer-time=200000 latency-time=10000

mixer = software

The sound is perfect when I stream from Spotify by MDP or Webserver but when I use Spotify Connect the sound is very LOUD…

When I run alsamixer :


Can you, please, help me ?


EDIT: I’ve gone and rephrased this answer, I think it’s clearer now.

There are two main ways you can adjust volume. You can do it in software or hardware (feel free to look up the difference) but unfortunately since your soundcard has no hardware mixer, you can forget about that.

So with software mixing you can have each piece of software (Mopidy/librespot/shairport) handle the volume themselves or you can get ALSA to handle it for the whole system, or you can have both! The former method is a bit of a mess since you need to provide volume config to each program and they might all do things a bit differently. Furthermore, they may not all allow you to set an initial volume. Mopidy supports specifying a volume and setting the settings.ini output line as you have done is a way to do that. However, I don’t think librespot exposes a way to set an initial volume for it’s software mixer.

So an alternative is to configure an ALSA softvol plugin which will perform software volume mixing globally for everything going to the audio device. And then you can set an initial volume for that using amixer. In an ideal world you would then configure all the individual programs to use this softvol mixer rather than doing their own software mixing. Mopidy supports this but, again, I don’t think librespot does. So I think you are left the “both” option: each program doing it’s own software mixing and then the ALSA softvol plugin doing some more on top of that. This isn’t a great solution but I think it’s your best bet.

I never got around to integrating this with pimusicbox and setsound.sh but I think it should work OK if you don’t mind hacking things up a bit. I’m not 100% sure if this it totally correct but something like the following in /etc/asound.conf maybe?

pcm.!default {
    type plug
    slave.pcm  "softvol"
ctl.!default {
    type hw
    card 0

pcm.softvol {
    type            softvol
    slave {
        pcm         "hw:0,0"
    control {
        name        "PCM"
        card        0

You may need to adjust those card numbers for your hardware. Note that /etc/asound.conf gets overwritten by setsound.sh on every boot so you’ll need to prevent that some how. You may have to experiment a bit with this…


Thank you for your help. :slight_smile:

Is ALSA softvol plugin already installed on the 0.7RC5 ?

Can I simply comment out the setsound.sh line to avoid it run ? I mean, what the impact of that ?


Yes it is.

Yes you can. setsound.sh creates a /etc/asound.conf file and tries to set up some initial volumes. So if you already have an /etc/asound.conf file you want to use, and you are managing the volume in some way, you should be fine. Obviously this will break the ability to change soundcard through settings.ini or websettings.


My card number seems to be 1

Working /etc/asound.conf :

pcm.!default {
    type plug
    slave.pcm  "softvol"
ctl.!default {
    type hw
    card 1

pcm.softvol {
    type            softvol
    slave {
        pcm         "hw:1,0"  
    control {
        name        "PCM"
        card        1

EDIT : Ok,must be hw:1,0 following : https://superuser.com/questions/53957/what-do-alsa-devices-like-hw0-0-mean-how-do-i-figure-out-which-to-use

EDIT2 : ALRIGHT ! The /etc/asound.conf above is working ! Music is playing !

I can lower the volume of Spotify Connect with alsamixer :


Ok, I figure it out ! I’m stupid…

Just use the following command :slightly_smiling_face: :

amixer set PCM 40%

Then put it in script runned at boot.


So it all works? If so, fantastic!