Interface of an audio device
In this task, we will work on installing MP3
and WAV
file audio player tools on the Raspbian operating system.
Prepare for lift off
The Raspberry Pi is equipped with a 3.5mm audio jack and the speakers can be connected to that output. In order to get started, we install the ALSA utilities package and a command-line mp3 player:
sudo apt-get install alsa-utils sudo apt-get install mpg321
Engage thrusters
In order to use the alsa-utils
or mpg321
players, we have to activate the BCM2835's sound drivers and this can be done using the modprobe
command:
sudo modprobe snd_bcm2835
After activating the drivers, it is possible to play the WAV
files using the aplay
command (aplay
is a command-line player available as part of the alsa-utils
package) :
aplay testfile.wav
An MP3
file can be played using the mpg321
command (a command-line MP3 player) :
mpg321 testfile.mp3
Note
In the preceding examples, the commands were executed in the directory where the WAV
file or the MP3...