Open manajoe opened 3 years ago
Thanks! I’m wondering, if we should add this to the wiki or if this could integrated in the code base with a PR?
is it really working ???
I modified the script a bit. I cleared out the steps for saving the volume and named the devices to my likings. And the toggle is working just fine.
I am currently trying to get the command bash RPi-Jukebox-RFID/scripts/userscripts/switch_audio_output.sh
, which toggles the output devices, onto a button. (see discussion-1638
how can activate this script ? bash RPi-Jukebox-RFID/scripts/userscripts/switch_audio_output.sh is not working my usb speaker are on Card 2 so i only change the settings at /etc/asound.conf ? i disconnect the hdmi so my usb speaker are on card 1
@ddbkva I'm not sure, in my setup, exactly this command works
Additionally, i did a chmod +x RPi-Jukebox-RFID/scripts/userscripts/switch_audio_output.sh
.
Did you also read https://github.com/MiczFlor/RPi-Jukebox-RFID/discussions/1638, maybe this helps?
Hack: Switchable Audio Interface with 2 different sound cards
a little different to https://github.com/MiczFlor/RPi-Jukebox-RFID/pull/1213 as I didn't have one soundcard with two outputs, I tried to use my USB sound card for speakers and onboard sound card for headphones In the beginning it was a lot of trial and error to figure out, how both sound cards, names and IDs have to be used. But eventually I found a working setup for me, being able to store the separate volumes for each audio output
Maybe it's a too specific setup, but maybe someone can use this:
Prerequisites
/etc/asound.conf
pcm.headphone { type hw card 0 }
ctl.headphone { type hw card 0 }
hw:CARD=Headphones,DEV=0 bcm2835 Headphones, bcm2835 Headphones Direct hardware device without any conversions
hw:CARD=Device,DEV=0 USB PnP Sound Device, USB Audio Direct hardware device without any conversions
audio_output { type "alsa" name "Headphone" # name as in output of "amixer -c 0 scontents"
device "hw:0,0" # optional # Device = output of aplay -L from above mixer_device "default" # mixer_device = "hw:" + Devicename after CARD= mixer_control "Headphone" # name as in output of "amixer -c 1 scontents" mixer_index "0" # optional }
audio_output { type "alsa" name "PCM" # name as in output of "amixer -c 1 scontents" device "hw:CARD=Device,DEV=0" # Device = output of aplay -L from above mixer_device "hw:Device" # mixer_device = "hw:" + Devicename after CARD= mixer_control "PCM" # name as in output of "amixer -c 1 scontents" mixer_index "0" # optional }
Audio_Volume_Level_Headphone Audio_Volume_Level_PCM Max_Volume_Limit_Headphone Max_Volume_Limit_PCM
!/bin/bash
PATHDATA="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
Get active MPC Output
ACTIVE_OUTPUT=
mpc outputs | awk '/enabled/ { print $2 }'
echo $ACTIVE_OUTPUT "is active" #############################################################Define variables for Output Names and IDs according to the IDs from output of "mpc outputs"
MPC_OUTPUT1="PCM" ALSA_OUTPUT1="1" MPC_OUTPUT2="Headphone" ALSA_OUTPUT2="0" ############################################################## if [ $ACTIVE_OUTPUT -eq 2 ] then echo "Activate PCM"
Save Volume and Max Volume settings for previous output
elif [ $ACTIVE_OUTPUT -eq 1 ] then if [[ $1 == "default" ]] # I try to call the script with a parameter "default" within the startup-scripts.sh, to set the desired "default" audio output then echo "Nothing to do"
fi