balenaSound: inno amp hat on rpi3 / alsamixer / amixer persistent volume settings / USB Numpad Hotkeys

Hi!

So I’m running a small multiroom balenaSound fleet of RPI3’s and one of them has the supported inno amp hat on it. It behaves like a hifiberry-amp. It’s a 25W PowerAmp and I need to lower the initial volume, which is 75/100 by default. I need to change it to 25/100.

I can use the following commands to do so via Terminal in audio:

//AMP Volume to 25%:
amixer -M -c1 sset Master 25%

//AMP Volume up/down
amixer -M -c1 sset Master 3%+
amixer -M -c1 sset Master 3%-

//AMP Mute toggle
amixer -M -c1 sset Master toggle

//save alsamixer settings
alsactl store

But alsactl store does not store persistently, after rebooting the volume is again set to 75/100. Please note that this is not SOUND_VOLUME as I’m trying to change the AMP Hat’s HW output volume of this particular device.

How do I store this across reboots?

In a second step, I’d like to use an USB Numpad to control volume and play Webradio stations to the fleet. I thought of using triggerhappy to bind keystrokes to the aforementioned amixer commands.

How would I install triggerhappy into the audio docker? Or probably running triggerhappy from the HostOS is a better approach, and binding keys to telling the audio docker to execute the amixer commands? :-)

Many thanks

kls0e

i see the different binds in the audio docker when running balena container inspect audio_... in the HostOS terminal. Do I add a bind there or do I need to approach this in a completely different way?

Hi @kls0e, ALSA stores saved state in /var/lib/alsa/asound.state so you would need to create a volume and map it to that folder. Your docker-compose.yml file would look like this:

version: '2'

volumes:
  spotifycache:
  alsacache:

services:

  # Core services
  # -- Required for a fully featured installation of balenaSound
  # -- Mutiroom services can be removed if not using multiroom mode
  audio:
    build: ./core/audio
    privileged: true
    labels:
      io.balena.features.dbus: 1
      io.balena.features.supervisor-api: 1
    ports:
      - 4317:4317
    volumes:
      - alsacache:/var/lib/alsa

....
# Omitted rest of services for brevity

I haven’t tested but I’m pretty sure ALSA checks that folder and automatically loads the state file if present. So the only other thing you would need to do is to manually run alsactl store whenever you want to save the volume (state). Please do let me know how it goes if you try it out!

Hi Tomas, many thanks, I appreciate your help and will post once I’ve tried to set it up.

Awesome!