Hardware Reference
In-Depth Information
Interface of an audio device
In this task, we will work on installing MP3 and WAV file audio player tools on the Raspbian
operaing 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 uiliies 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 acivate the BCM2835's
sound drivers and this can be done using the modprobe command:
sudo modprobe snd_bcm2835
Ater acivaing 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
In the preceding examples, the commands were executed in the directory
where the WAV file or the MP3 file was located. In the Linux environment,
it is possible to stop playing a file by pressing CTRL + C .
Objective complete - mini debriefing
We were able to install sound uiliies in this secion. Later, we will use the installed uiliies
to play audio from a web page.
It is possible to play the sound files on the Raspberry Pi using the module available in Python.
Some examples include: Snack sound tool kit, Pygame, and so on.
 
Search WWH ::




Custom Search