How to set the sound output in Raspberry Pi
Audio Setting
ThisMost shortRaspberry tutorialPis shouldhave bea enough3.5mm audio jack for outputting audio, but you can also output audio via HDMI as well. The below will show you two different ways to beset ablethe tooutput setupdevice.
Method 1: Use Raspberry Pi withConfiguration GUI mode and auto login enabled to disable a web page full screen automatically when it turns on.(GUI)
Copyfull-screen.shintoClick thehomeRaspberryfoldermenuof(top-left corner)- Go to Preferences → Audio Device Settings
- In the
piOutputuser,Deviceanddropdown,runchoose:HDMI
orHDMI 1
(depending on your Pi model) - Click Select Controls if needed to unmute or adjust volume
- Click Close
You may not see the followingexact command:thing on your pi based on the operating system you used.
Method 2: Terminal Command
For example, setting HDMI as default audio output:
amixer cset numid=3 2
The 2
at the end indicates HDMI.
- 0 = Auto
- 1 = Analog (3.5mm jack)
- 2 = HDMI
Method 3: Use raspi-config
-
sudo raspi-config
- Navigate to:
1. System Options → S2 Audio
- Choose:
1 HDMI
(or HDMI 1 if you see multiple) - Press Enter, then Finish
Test the Audio
- You can test it with:
speaker-test -t sine -f 440 -c 2
- Or play a WAV sound file:
aplay /home/pi/
full-screen.shMusic/youOwnSoundFile.wav - Or play a MP3 sound file:
cvlc /home/pi/Music/youOwnSoundFile.mp3
sudo chmod +x full-screen.sh
full-screen.sh
export DISPLAY=:0.0
xset s off
xset -dpms
xset s noblank
chromium-browser --noerrdialogs --kiosk https://google.co.uk --incognito
Create a folder called autorun inside the.configfolder of the home folder of the pi user:/home/pi/.config/autorun/kiosk.desktop
cd /home/pi/.config
mkdir autorun
kiosk.desktop
[Desktop Entry]
Type=Application
Exec=/home/pi/full-screen.sh
Hidden=false
X-GNOME-Autostart-enabled=true
Name=kiosk
Reboot the Raspberry Pi.
sudo reboot now