2

I have a stereo. I like it, because the sound is nice, but it's not quite sophisticated engineered:

enter image description here

It has an internal USB Card soldered on some board, directly outputting audio to the power amp. Well.. both devices, the USB card and the power amp have their own volume control, and they are (how smart) not in sync.

I already hacked the remote, so that it can receive volume commands. Now I want to implement some kind of sync for convenience. Both of my audio sources (shairport-sync and spotifyd) do already support controlling the ALSA volume sliders, so that pressing the volume buttons on my smartphone forwards the signals to the ALSA device (you can verify this with alsamixer).

My best guess is something like this: enter image description here

I've never worked with ALSA before and I just started to get familiar with the architecture, but I haven't found any solution yet that would help me implementing this 'Forward' arrow in the graphics.

I could deal with the sync script myself, but I honestly have no idea where to start with the ALSA part.

dersimn
  • 325
  • 3
  • 8
  • 1) Are you sure you are only using ALSA, and not Pulseaudio? Pulseaudio is the default on most modern distros. 2) After your description, I am still a bit confused what exactly you'd like to sync. The ALSA volume control with your hardware volume control? And the latter is controlled by an ESP8266 hooked up to your PC how? 3) Wouldn't it be simpler to leave the hardware control at a fixed level, and use a single ALSA volume control for overall volume? And possible use LIRC etc. to control this by remote? – dirkt Aug 22 '20 at 12:47
  • 1) Yes it's a headless Raspberry Pi connected to the stereo. 2) Also right the ALSA output has it's own volume slider, I want this to become a "dummy" slider that's just synced to the hardware volume control via MQTT to the ESP8266, while the actual sound card just outputs at 100% all the time. 3) Simpler, yes, but it sounds better if you output always at 100% or 80% and adjust the power amp instead. This way the music is much louder compared to the digital noise of the sound card. – dersimn Aug 22 '20 at 14:10
  • So basically you want to implement a "dummy" slider that's not backed by real hardware, but which synchronizes two-way via the ESP8266. I don't think this can be done without writing an ALSA driver or plugin for it. You could use `amixer` to change it FROM the ESP8266, but I don't know any way to attach to change events that would you allow to sync TO the ESP8266. – dirkt Aug 22 '20 at 14:45
  • I need to solve a very similar problem. Did you ever make any progress on this? – Lincoln Feb 08 '23 at 16:43
  • Not really a "solution" imho, I just configured Shairport Sync and librespot to use 'Mic' as the Mixer for Volume control (I don't use this input otherwise, so these tools control something that doesn't do any difference) and wrote a NodeJS script https://github.com/dersimn/alsa2mqtt that's fetching these changes and send it to MQTT, from there some another script forwards the signal to the actual remote control which is already smart-ed by this: https://github.com/dersimn/DevilRemote – dersimn Feb 25 '23 at 16:47
  • librespot is just started via `librespot -n "Livingroom Stereo" --backend alsa --mixer alsa --volume-ctrl linear --mixer-name Mic --mixer-linear-volume --enable-volume-normalisation` and Shairport Sync has a similar option in the config files `general = { output_backend = "alsa"; } alsa = { mixer_control_name = "Mic"; }` – dersimn Feb 25 '23 at 16:48

0 Answers0