Volume control independent from the system (alsamixer)

Hi,

Is there anyway to control the volume of the rhasspy by software instead of getting the volume level from alsamixer?
I wanted to have this independently because I have other sound components running on the same raspberry pi each with its own volume settings and I want to leave the alsamixer on the top volume.
But since I cannot control the volume level on rhasspy it is just too loud.

Current audio components on the rpi:

  • shairport-sync which uses the asound/alsamixer direct volume level but controllable on the physical volume button on iOS devices
  • mopidy which has a “wrapper” in which I can set a different volume level than the asound/alsamixer volume level (up to its maximum)
  • rhasspy which uses the asound/alsamixer direct volume level. It is here that I would like to have something similar to mopidy where I could set a lower volume than the one defined on the sound/alsamixer direct volume level.

Thanks!

Haven’t done it but presuming you could use a softvol.

https://alsa.opensrc.org/Softvol for a specific pcm maybe

2 Likes

Thanks for the tip!

I was able to create the new softvol device (named rhasspysnd as you can see below) and mixer but Rhasspy doesn’t see that device:

pi@livingroom:~ $ aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
jack
JACK Audio Connection Kit
pulse
PulseAudio Sound Server
playback
ac108
default
output
rhasspysnd
sysdefault:CARD=Headphones
bcm2835 Headphones, bcm2835 Headphones
Default Audio Device
dmix:CARD=Headphones,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Direct sample mixing device
dsnoop:CARD=Headphones,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Direct sample snooping device
hw:CARD=Headphones,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Direct hardware device without any conversions
plughw:CARD=Headphones,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Hardware device with all software conversions
usbstream:CARD=Headphones
bcm2835 Headphones
USB Stream Output
usbstream:CARD=seeed4micvoicec
seeed-4mic-voicecard
USB Stream Output

And on Rhasspy:

If I try to use it through aplay on the rpi it works ok:
aplay --device rhasspysnd a.wav

Maybe Rhasspy isn’t loading the softvol type cards right? Can we make it load those?

Dunno but softvols can be really confusing as they don’t exist until after you play that pcm chain.
I am not sure on the setup as haven’t done much with them but presumed you could have a pcm chain with the softvol in it for rhasspy that just has the initial alsa device as a slave.

I think on boot in the start-up script you need to aplay the pcm with the softvol once and then it should be there from then aplay -d for duration is it just have a second burst of some wav before rhasspy loads.

Also with asla pcms you have to add the description tag to that pcm. Have a look through the forum as there is an example somewhere.

Think its hint.description

hint.description "Mic1 loopback 0,1,0"

or this format in the ever confusing alsa formatting

hint {
                description "Mic2 loopback 0,1,1"
        }

As sometimes without they don’t list for some reason without, just change the description to what you need.

Hi,
Sorry I missed posting my config. Making the change you mentioned still doesn’t work:

pi@livingroom:~ $ cat ~/.asoundrc
pcm.rhasspysnd {
type softvol
slave.pcm “sysdefault”
control.name “rhasspysndctrl”
control.card 0
hint.description “Rhasspy”
}

It already shows the description:
pi@livingroom:~ $ aplay -L
rhasspysnd
Rhasspy

But on the rhasspy interface it still isn’t available. (I have already added an aplay command to my rpi /etc/profile so that on boot it runs it):
pi@livingroom:~ $ cat /etc/profile
aplay --device rhasspysnd output.wav

I always refer to this article when fiddling with alsa.

The softvol is a control so like the article create an end PCM where the chain continues and the softvol is a slave.

Otherwise dunno but maybe someone else will post as remember something mentioned in the forum about PCMs needing a description or tag line to turn up in Rhasspy and just plain forget what and where.

Finally solved. Was missing passing the -v “/etc/asound.conf:/etc/asound.conf” on the docker run

1 Like