Skip to content

Commit

Permalink
fix audio interface name in setup (MiczFlor#2276)
Browse files Browse the repository at this point in the history
* read out scontrol for audio iface names.
set first as default or PCM

* update Readme for amixer (sudo)

* improve readability
  • Loading branch information
AlvinSchiller authored Feb 23, 2024
1 parent c89b6fc commit 8f47e61
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions components/bluetooth-sink-switch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ CMDBLUETOOTHTOGGLE="1364237231134"

Speakers and Headphones can have very different maximum volume levels. This sometimes leads to very strong volume level changes when switching between speakers and headphones. Restricting the maximum volume with the Phoniebox-integrated max-volume setting does no yield the desired effect, as this is a single setting and does not differentiate between different audio sinks.

The solution is adding a `softvol` component to the /etc/asound.conf. You may already have one set up, if your soundcard does not have a hardware volume control. Then it is easy! The `softvol` copmonent adds a systemwide ALSA-based volume control for a hardware soundcard. You will need to give it a name, that does **not** exist! Check with `$ amixer scontrols` first, which names are already taken. Here, I have choosen *Master*. This will work even if your soundcard has a hardware volume control.
The solution is adding a `softvol` component to the /etc/asound.conf. You may already have one set up, if your soundcard does not have a hardware volume control. Then it is easy! The `softvol` copmonent adds a systemwide ALSA-based volume control for a hardware soundcard. You will need to give it a name, that does **not** exist! Check with `$ sudo amixer scontrols` first, which names are already taken. Here, I have choosen *Master*. This will work even if your soundcard has a hardware volume control.

The `softvol` component has a feature called *max_db* to limit the maximum volume, which we are going to utilize here. With that we are limiting the maximum volume of the speakers systemwide and independent of MPD or other Phoniebox settings.

Expand Down Expand Up @@ -204,7 +204,7 @@ $ speaker-test -D hifiberry
and changing the default volume control in another console

~~~bash
$ alsamixer
$ sudo alsamixer
~~~

If you are experimenting with a softvol and want to get rid of it again - that is not an easy task. Most promising approach is to insert the SD-Card into a different Linux machine delete the file `/var/lib/alsa/asound.state`. This must be done from a different computer, as this file gets written during shutdown. More infos about the softvol may be found [here](https://alsa.opensrc.org/Softvol)
Expand Down
19 changes: 13 additions & 6 deletions scripts/installscripts/install-jukebox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -535,23 +535,30 @@ config_audio_interface() {

clear

local amixer_scontrols=$(sudo amixer scontrols)
local audio_interfaces=$(echo "${amixer_scontrols}" | sed "s|.*'\(.*\)'.*|\1|g")
local first_audio_interface=$(echo "${audio_interfaces}" | head -1)
local default_audio_interface="${first_audio_interface:-PCM}"

echo "#####################################################
#
# CONFIGURE AUDIO INTERFACE (iFace)
#
# The default RPi audio interface is 'Headphone'.
# But this does not work for every setup. Here a list of
# available iFace names:
# The default RPi audio interface is '${default_audio_interface}'.
# But this does not work for every setup.
# Here a list of available iFace names:
${audio_interfaces}
"
amixer scontrols

echo " "
read -rp "Use Headphone as iFace? [Y/n] " response
read -rp "Use '${default_audio_interface}' as iFace? [Y/n] " response
case "$response" in
[nN][oO]|[nN])
read -rp "Type the iFace name you want to use:" AUDIOiFace
;;
*)
AUDIOiFace="Headphone"
AUDIOiFace="${default_audio_interface}"
;;
esac
# append variables to config file
Expand Down
2 changes: 1 addition & 1 deletion scripts/installscripts/tests/run_installation_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selecti
# n dont configure wifi
# y configure autohotspot
# y use autohotspot default config
# y Headphone as iface
# y use default audio iface
# n no spotify
# y configure mpd
# y audio default location
Expand Down
2 changes: 1 addition & 1 deletion scripts/installscripts/tests/run_installation_tests2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selecti
# y confirm interactive
# n dont configure wifi
# n dont configure autohotspot
# y PCM as iface
# y use default audio iface
# n no spotify
# y configure mpd
# y audio default location
Expand Down
2 changes: 1 addition & 1 deletion scripts/installscripts/tests/run_installation_tests3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selecti
# y confirm interactive
# n dont configure wifi
# n dont configure autohotspot
# y Headphone as iface
# y use default audio iface
# y spotify with myuser, mypassword, myclient_id, myclient_secret
# y configure mpd
# y audio default location
Expand Down

0 comments on commit 8f47e61

Please sign in to comment.