New Pi OS sound trouble shooting

Jump to: navigation, search

Raspberry Pi 4 8GB Sound / Audio Troubleshooting

The latest Raspbian OS (as of May 27, 2020) uses different sub-devices for each output (HDMI and headphone jack). This is aligned with other Linux distro but is different than older Raspbian OS versions. The troubleshooting is then a little different.

Problem 1. There is no sound at all.

The installation of Raspbian OS is smooth on my Pi 4 (8GB) board. Only thing is I found there is no sound when I try Sonic-pi. Then I tried to play youtube in Chromium browser, still no luck. It is a surprise as everything else works as expected. So the easy way to troubleshoot seems to be:

Double check sound device is running. This is easy as it usually is all right:

lsmod | grep snd

You should see this in the output:


Next step is to try play some sound:

aplay /usr/share/sounds/alsa/Front_Center.wav
aplay -l
aplay -d <dev> /usr/share/sounds/alsa/Front_Center.wav

If the first line doesn't work (very likely), the aplay -l command list the ALSA sound devices. Copy the one for headphone jack, use it in the third command. Hopefully you will be able to hear the sound.

Another easy way is to compile the hello_audio demo tool and play the sound. With recent firmware, you can build hello_audio with:

cd /opt/vc/src/hello_pi/
cd hello_audio

With older firmware

cd /opt/vc/src/hello_pi/hello_audio

To test headphone jack analogue output:


and to test HDMI output:

./hello_audio.bin 1

Hopefully by now you should hear the sound played in one of the ways tried above.

Problem 2. How to switch output to headphone jack?

By default the audio output goes to HDMI port. This makes sense if the display is connected to a TV or monitor with speaker by HDMI. However my monitor is not HDMI and I use a separate computer speaker. So I need to change audio output to headphone jack.

<a href="">The official document</a> lists several ways to switch audio output: use desktop volume control, command line, or raspi-config. But it looks based on old Raspbian OS. Neither of those works for me. I can change the output in desktop volume control and raspi-config but it doesn't make any difference. The command listed there:

amixer cset numid=3 2

Simply doesn't work because there is no control with numid=3 (which is output select) now. There are only two control items: numid=1 and numid=2, for mute/unmute, and volume level.

The solution I find by searching on Internet is to create a /etc/asound.conf:

<code>pcm.!default {
    type hw
    card 1

ctl.!default {
    type hw
    card 1

Then the output goes to headphone jack right away or after a reboot.

Problem 3. Sonic-pi still doesn't play any sound.

The problem turns out to be that Sonic-pi (up to v3.1.0) uses hard-coded sound device that works in old version of Raspbian but not the latest. Luckily they have a new version of Sonic-pi now:

Following the instruction there I installed it. I found it worked after a reboot. Not sure why I didn't hear it work immediately after restart the app.

This deb package is not in Raspbian depository because now source deb package is required by Raspbian. The Sonic-pi deb is binary only. Its building instruction has some steps to build other packages from source code. Those dependent packages need to be built as deb source package first. So it is not ready to build Sonic-pi source deb packages right now.

Problem 4. HDMI audio is not working

This has been addressed in the sound section in R-Pi_Troubleshooting.