Skip to main content

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.

a

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)

  1. Copy full-screen.sh intoClick the homeRaspberry foldermenu of(top-left corner)
  2. Go to Preferences → Audio Device Settings
  3. In the piOutput user,Device anddropdown, runchoose: HDMI or HDMI 1 (depending on your Pi model)
  4. Click Select Controls if needed to unmute or adjust volume
  5. 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

  1. sudo raspi-config
  2. Navigate to: 1. System Options → S2 Audio
  3. Choose: 1 HDMI (or HDMI 1 if you see multiple)
  4. Press Enter, then Finish

Test the Audio

  1. You can test it with: speaker-test -t sine -f 440 -c 2
  2. Or play a WAV sound file: aplay /home/pi/full-screen.shMusic/youOwnSoundFile.wav
  3. 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
  1. Create a folder called autorun inside the .config folder 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
  1. Reboot the Raspberry Pi.

sudo reboot now