Raspberry PI – getting audio working
How to get the audio working on your Raspberry PI?
You have to install three packages:
- The ALSA utilities:
sudo apt-get install alsa-utils
- MP3 tools:
sudo apt-get install mpg321 - WAV to MP3 conversion tool:
sudo apt-get install lame
Load the sound driver:
- sudo modprobe snd-bcm2835
To check if the driver is loaded you can type:
- sudo lsmod | grep 2835
Select the output device for sound (0=auto, 1=analog, 2=HDMI):
- sudo amixer cset numid=2
Test the installation:
- aplay /usr/share/sounds/alsa/Front_Center.wav
- speaker-test -t sine -f 440 -c 2 -s 1
- mpg321 “Mannish Boy.mp3”
It you get the following error message:
- ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
Edit the file /usr/share/alsa/alsa.conf:
- sudo nano /usr/share/alsa/alsa.conf
- change the line “pcm.front cards.pcm.front” to “pcm.front cards.pcm.default”
If you are using HDMI and cannot hear any audio at all change the following PI configuration setting:
- edit the RasPI configuration file:
sudo nano /boot/config.txt - uncomment the line:
hdmi_drive=2 - save the file and reboot the PI
Resources: