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

**URL:** <https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840>\
**Category:** Pi MusicBox (archive)\
**Created:** [August 22, 2017, 6:43am UTC](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840 "2017-08-22T06:43:56Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![OXL](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/oxl/32/673_2.png) [@OXL](https://discourse.mopidy.com/u/OXL)\
**Post date:** [August 22, 2017, 6:43am UTC](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840/1 "2017-08-22T06:43:56Z")

</div>

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.

Cheers  
Ole

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [August 22, 2017, 7:24am UTC](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840/2 "2017-08-22T07:24:50Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![OXL](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/oxl/32/673_2.png) [@OXL](https://discourse.mopidy.com/u/OXL)\
**Post date:** [August 22, 2017, 7:56am UTC](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840/3 "2017-08-22T07:56:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [August 22, 2017, 11:11am UTC](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840/4 "2017-08-22T11:11:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![OXL](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/oxl/32/673_2.png) [@OXL](https://discourse.mopidy.com/u/OXL)\
**Post date:** [August 22, 2017, 12:54pm UTC](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840/5 "2017-08-22T12:54:17Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [August 22, 2017, 1:25pm UTC](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840/6 "2017-08-22T13:25:18Z")

</div>

Try changing it through `alsamixer`.

---

<div class="post-metadata">

**Author:** ![OXL](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/oxl/32/673_2.png) [@OXL](https://discourse.mopidy.com/u/OXL)\
**Post date:** [August 22, 2017, 1:46pm UTC](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840/7 "2017-08-22T13:46:22Z")

</div>

Ok. How do I do that ?

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

---

<div class="post-metadata">

**Author:** ![mczerski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/mczerski/32/742_2.png) [@mczerski](https://discourse.mopidy.com/u/mczerski)\
**Post date:** [August 22, 2017, 2:43pm UTC](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840/8 "2017-08-22T14:43:21Z")

</div>

mopidy-alsamixer plugin, docs are here [https://github.com/mopidy/mopidy-alsamixer](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.

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [August 22, 2017, 3:03pm UTC](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840/9 "2017-08-22T15:03:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![OXL](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/oxl/32/673_2.png) [@OXL](https://discourse.mopidy.com/u/OXL)\
**Post date:** [August 24, 2017, 9:42pm UTC](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840/10 "2017-08-24T21:42:51Z")

</div>

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.

 ![alsamixer](https://yyz2.discourse-cdn.com/flex036/uploads/mopidy/original/1X/5f6cc9fae156166243429e2307256e030880c6d0.jpg)

---

<div class="post-metadata">

**Author:** ![OXL](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/oxl/32/673_2.png) [@OXL](https://discourse.mopidy.com/u/OXL)\
**Post date:** [August 26, 2017, 10:21pm UTC](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840/11 "2017-08-26T22:21:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [August 27, 2017, 6:59am UTC](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840/12 "2017-08-27T06:59:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![OXL](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/oxl/32/673_2.png) [@OXL](https://discourse.mopidy.com/u/OXL)\
**Post date:** [August 27, 2017, 12:44pm UTC](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840/13 "2017-08-27T12:44:56Z")

</div>

Thanks. Worked like a charm. Changing Digital volume from 98% to 85% in [setsound.sh](http://setsound.sh) lowered the amp volume to an acceptable level after reboot.

---

<div class="post-metadata">

**Author:** ![Steve\_Lambert](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/steve_lambert/32/1149_2.png) [@Steve\_Lambert](https://discourse.mopidy.com/u/Steve_Lambert)\
**Post date:** [September 1, 2017, 7:13am UTC](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840/14 "2017-09-01T07:13:43Z")

</div>

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](http://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.

Thanks

Steve

---

<div class="post-metadata">

**Author:** ![ClementAbadie](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/clementabadie/32/743_2.png) [@ClementAbadie](https://discourse.mopidy.com/u/ClementAbadie)\
**Post date:** [October 17, 2017, 10:13am UTC](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840/15 "2017-10-17T10:13:37Z")

</div>

Hi,

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](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 :

![image](https://canada1.discourse-cdn.com/flex036/uploads/mopidy/original/1X/c47ccb6077f57e37dabe4c3435d4fef13fc09e24.png)

Can you, please, help me ?

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [October 17, 2017, 1:02pm UTC](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840/16 "2017-10-17T13:02:34Z")

</div>

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](http://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?

```auto
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](http://setsound.sh) on every boot so you’ll need to prevent that some how. You may have to experiment a bit with this…

---

<div class="post-metadata">

**Author:** ![ClementAbadie](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/clementabadie/32/743_2.png) [@ClementAbadie](https://discourse.mopidy.com/u/ClementAbadie)\
**Post date:** [October 17, 2017, 1:24pm UTC](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840/17 "2017-10-17T13:24:20Z")

</div>

Thank you for your help. 🙂

Is ALSA softvol plugin already installed on the 0.7RC5 ?

Can I simply comment out the [setsound.sh](http://setsound.sh) line to avoid it run ? I mean, what the impact of that ?

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [October 17, 2017, 1:27pm UTC](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840/18 "2017-10-17T13:27:25Z")

</div>

Yes it is.

Yes you can. [setsound.sh](http://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.

---

<div class="post-metadata">

**Author:** ![ClementAbadie](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/clementabadie/32/743_2.png) [@ClementAbadie](https://discourse.mopidy.com/u/ClementAbadie)\
**Post date:** [October 17, 2017, 1:34pm UTC](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840/19 "2017-10-17T13:34:58Z")

</div>

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](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 :

![image](https://canada1.discourse-cdn.com/flex036/uploads/mopidy/original/1X/0f32d35d62df2d50fc9b9bfa1d3c01da6ddd604a.png)

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

Just use the following command 🙂 :

`amixer set PCM 40%`

Then put it in script runned at boot.

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [October 17, 2017, 2:22pm UTC](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840/20 "2017-10-17T14:22:55Z")

</div>

So it all works? If so, fantastic!

[Next page](https://discourse.mopidy.com/t/pi-musicbox-volume-control-for-amp-hat-not-working-with-spotify-connect/1840.md?page=2)
