I am working on a pi project which uses audio out through HDMI. I am using respeaker mic for audio in. My problem is everytime when I startup the pi, the default audio is analog. I need to change it to HDMI by logging in and running
amixer -c 0 cset numid=3 2
using the terminal. I tried adding this line in a file sound.sh and when i execute the shell script using terminal it executes fine and changes to hdmi audio. My question is how to add this shell script to startup of pi, so that i dont have to run the script manually. i tried adding it to /etc/rc.local file. But doesnt seem to work. I am not sure of the exact command too. i tried:
sudo sh /home/pi/sound.sh & sudo /home/pi/sound.sh & /home/pi/sound.sh & sh /home/pi/sound.sh &
Please help me out.