I can't get the audio running. I don't hear anything and can not play anything.
Is there a solution to enable audio?
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It only takes a minute to sign up.Sign up to join this community
This is caused by some computer monitors which select DVI mode even if an HDMI cable is connected. This fix may be necessary even if other HDMI devices work perfectly on the same monitor (or TV)!
/boot/config.txt file (see Raspberry-Pi Configuration File) and add the following line to the configuration file:
Sound is disabled by default because the ALSA sound driver is still "alpha" (not fully tested) on the R-Pi. To try out sound, from the command prompt before "startx", type
sudo apt-get install alsa-utils sudo modprobe snd_bcm2835 sudo aplay /usr/share/sounds/alsa/Front_Center.wav
By default output will be automatic (
hdmi if hdmi supports audio, otherwise
analogue). You can force it with:
sudo amixer -c 0 cset numid=3 <n>
n is one of:
0 = auto,
1 = headphones,
2 = hdmi. (source)
If you are running Debian, try
cd /opt/vc/src/hello_pi make -C libs/ilclient make -C libs/vgfont cd hello_audio make ./hello_audio.bin
to test analogue output. And to test HDMI.
Also note that you may have to add your user to the
audio group to get permission to access the sound card.
gpasswd -a <username> audio
sudo apt-get install alsa-utils is permanent, but
sudo modprobe snd_bcm2835 only initialises the driver for the current session. To ensure the module is initialised on boot, add
I also ran into the same problem with my Raspberry Pi 2. I connected my Pi to my HD TV via an HDMI cable. My solution:
Set the audio output using the following command:
amixer cset numid=3 2
I tested the sound output using the following command, but no sound was heard:
speaker-test -c2 -t wav
To enable HDMI sound, I followed the directions found here
sudo [your favourite editor] /boot/config.txt
Reboot Pi using the following command:
sudo shutdown -r 0
I'm running OSMC, which runs Debian, and I got sound to play through my TV speakers, which is connected by HDMI. https://youtu.be/p2ljmTE67gs
If this is what you're trying to do, try adding
Original solution posted here: https://discourse.osmc.tv/t/alsa-doesnt-work-after-last-update/10600
My current working hypothesis is that, for me at least, the audio depends somehow on the desktop environment. I have a Raspberry Pi 2, running Raspbian, installed from NOOBS. I've wiped it clean and reinstalled Raspbian dozens of times. The sound works when I first install Raspbian. The next thing I habitually do is remove the LXDE desktop environment and replace it with XFCE desktop environment, and sometime after that, I notice that the sound has stopped working. Switching desktop environments must be breaking my audio. I don't know whether it's removing LXDE or installing XFCE that breaks it.
Perhaps the person is correct who suggested that the culprit is PulseAudio, and installing XFCE installs PulseAudio. Right now, "lxde" is installed, "xfce4" is not installed, "pulseaudio" is not installed, and the sound is working.
I ran into a problem where sound did not work or static played instead of my recording. But it was a problem with my approach, not the Pi itself. I'm using Raspbian 3.6.11 (2013-02-09-wheezy-raspbian).
Primarily, I tried to play an MP3 file with
aplay, which only seems to support WAVs. Also, some of the MP3 files I used may not have been created with a compatible codec. To test the sound output on your Pi, I found it best to the sample audio files that come with the Raspbian OS. Also ensure that you use a player appropriate for the audio format. For example:
aplayfor .wav files. For example:
aplay /usr/share/scratch/Media/Sounds/Vocals/Singer2.wav(there are lots of sample audio files in /usr/share/scratch/Media/Sounds).
mpg123for .mp3 files. For example: use
omxplayer /usr/share/scratch/Media/Sounds/Effects/WaterDrop.mp3or alternatively
mpg123 /usr/share/scratch/Media/Sounds/Effects/WaterDrop.mp3(If you don't already have
mpg123, you should be able to install it with the command
sudo apt-get install mpg123).
amixerto control the volume output. For example:
amixer cset numid=1 50%sets the headphone jack volume output to fifty percent.
For more information on audio out commands, I found the following web site useful: http://blog.scphillips.com/2013/01/sound-configuration-on-raspberry-pi-with-alsa
For what it's worth, I was also experiencing a popping sound caused by a voltage jump when the audio starts and stops. That issue is now fixed in the Pi firmware.
I was having problems with the analog audio output myself. Came to this thread among others to try to solve. In the end, it turns out I only needed to right-click on the audio icon in my toolbar and change the selection from HDMI to Analog. This probably doesn't solve your problem, but it might help someone else who isn't hearing audio and who missed that easy solution.
On my Raspberry Pi the "speaker-test" worked without any extra hardware added. Then I added some webcams. The default device had changed and I found this question How to make Alsa pick a preferred sound device automatically? from which solution #1 worked for me.
/etc/asound.confwith following: ...
Replace "card 1" with the number of your card determined above.
My solution came from this page:
And was this:
sudo modprobe snd_bcm2835
I ran into this problem while trying to get Amazon Voice Services working on a Raspberry Pi 3/3+. I made sure that analog audio was selected. Also using aplay worked.
It turns out AVS uses the autoaudiosink element, which in turn was selecting the omxhdmiaudiosink element, which had a higher priority than the alsasink element. In file /etc/xdg/gstomx-rpi.conf there is a section for omxhdmiaudiosink which I simply commented out. After doing so, AVS worked fine (for the most part--the responses were getting cut short by about ~0.25 seconds).
I suppose I could have changed the priority as well.
If you want a simple answer there are 3 options:
omxplayer -o hdmi filename.mp4
omxplayer -o both filename.mp4
omxplayer -o local filename.mp4
If you want it playing though your monitor do
omxplayer -o hdmi
If you want both then do
omxplayer -o both
If you have headphones and you want to plug it in your Raspberry do
omxplayer -o local
and then add your file name and there you go; it's that easy