Introduction
Raspberry Pi has a build-in sound card, HDMI and phone jack output to play sound. If you connect to HDMI display or plug-in a headphone to it, you can play sound. The setup of sound feature is easy as described below.
Step 1. Install PiAUISuite sound software
$ sudo apt-get install git-core
$ git clone git://github.com/StevenHickson/PiAUISuite.git
$ ./InstallAUISite.sh
(be aware to answer pop-up question to continue installation)
Step 2. Setup Sound Device
$ modprobe snd_bcm2835
$ amixer controls
numid=3,iface=MIXER,name=’PCM Playback Route’
numid=2,iface=MIXER,name=’PCM Playback Switch’
numid=1,iface=MIXER,name=’PCM Playback Volume’
$ amixer cset numid=3 1
where 0 for auto-select, 1 for headphone, 2 for HDMI.
$ sudo amixer cset numid=1 60%
to set the volume between 0 – 100%, 0 for mute.
$ sudo amixer set PCM – 60%
Step 3. To Play Sound
$ sudo omxplayer voice.mp3
If omxplayer’s auto-detection of the correct audio output device fails, you can force output over hdmi with:
$ sudo omxplayer-o hdmivoice.mp3
or you can force output over the headphone jack with:
$ sudo omxplayer-o localvoice.mp3
Note: you should be able to play sound on VLC connection, too.
Reference Link:
- https://www.raspberrypi.org/documentation/usage/audio/
- https://www.raspberrypi.org/forums/viewtopic.php?f=53&t=42696
- http://raspberrypi.stackexchange.com/questions/22708/is-there-some-trick-to-getting-aplay-audio-output-working
Bonus:
You can install alsa to control sound. Make sure alsa-utils is installed and run alsamixer as below:
$ sudo apt-get install -y alsa-utils
$ alsamixer
Then use the F1-F6 keys and UI to push up the volume.
Use the arrow keys to jack up the volume and quit.
To save what you changed in alsamixer as defaults, do:
sudo alsactl store 0