Difference between revisions of "New Pi OS sound trouble shooting"

From eLinux.org
Jump to: navigation, search
(Created page with "== Raspberry Pi 4 8GB Sound / Audio Troubleshooting == The latest Raspbian OS (as of today June 20, 2020) uses different sub-devices for each output (HDMI and headphone jack)...")
 
(Raspberry Pi 4 8GB Sound / Audio Troubleshooting)
 
Line 1: Line 1:
 
== Raspberry Pi 4 8GB Sound / Audio Troubleshooting ==
 
== Raspberry Pi 4 8GB Sound / Audio Troubleshooting ==
  
The latest Raspbian OS (as of today June 20, 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.
+
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.
  
 
<h3>Problem 1. There is no sound at all.
 
<h3>Problem 1. There is no sound at all.
Line 79: Line 79:
 
<p>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:</p>
 
<p>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:</p>
  
<p><a href="https://in-thread.sonic-pi.net/t/v3-2-2-for-raspberry-pi-os-now-available/3976">https://in-thread.sonic-pi.net/t/v3-2-2-for-raspberry-pi-os-now-available/3976</a></p>
+
https://in-thread.sonic-pi.net/t/v3-2-2-for-raspberry-pi-os-now-available/3976
  
 
<p>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.</p>
 
<p>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.</p>
Line 87: Line 87:
 
<h3>Problem 4. HDMI audio is not working</h3>
 
<h3>Problem 4. HDMI audio is not working</h3>
  
<p>This has been addressed in <a href="http://eLinux RPi-hub wiki">eLinux RPI-hub wiki.</a></p>
+
<p>This has been addressed in the sound section in [[R-Pi_Troubleshooting]].</p>

Latest revision as of 21:19, 22 June 2020

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:

snd_bcm2835

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/
./rebuild.sh
cd hello_audio

With older firmware

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

To test headphone jack analogue output:

./hello_audio.bin

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="https://www.raspberrypi.org/documentation/configuration/audio-config.md">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
}</code>

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:

https://in-thread.sonic-pi.net/t/v3-2-2-for-raspberry-pi-os-now-available/3976

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.