Sounding Off
Part 3
Building an MP3 Sound-Making Robot by Gordon McComb
Ever notice how the robots in movies like to make noise? Sound helps them to connect with their human counterparts — cheery advise, warnings, whatever. Audible feedback makes them more interesting. Who can forget the tweeps and braaps of R2-D2, the incessant warnings to Will Robinson by the robot in Lost in Space, or the nasal-sounding jabberings of those countless Daleks?
F
or the last several months, we’ve been talking about ways to add sound to your robot creations. Simple sounds can be made using just a microcontroller and small speaker; songs and sound effects are easy using a low cost
Discuss this article in the SERVO Magazine forums at http://forum.servomagazine.com.
MIDI synthesizer board. This month, you’ll learn how to add recorded effects to your robot using MP3 digital audio files. In this installment, I’ll show you how to build the Musicbot shown in Figure 1. It uses an Arduino and SparkFun MP3 player shield to play MP3 digital audio files. The shield contains an MP3 decoder, plus a micro-SD card slot for storing all your tunes and effects. There are numerous digital audio formats; I chose MP3 because it’s well-known and easy to work with. MP3 audio files are compressed, so not only do they take up less space on the storage medium, they reduce the amount of data the Arduino must shuttle every second. That means the Arduino has more time for robotic tasks, like motivating motors or sensing sensors.
A Quick Overview of MP3 First, some basics: MP3 is an audio compression standard originally created for the MPEG-1 format of low resolution video. The technical name for the standard is MPEG-1 Audio Layer III. MP3 was later expanded for use in MPEG-2 video which supports higher resolution images. Though meant to be paired with video, MP3 audio is perfectly happy living on its own; it’s this variation most people are familiar with. The MP3 format gained popularity in the mid 1990s as a way to save and play sound and music; compared to compact disc audio tracks, it drastically reduces the size of the stored audio file. Whereas an hour long CD might consume 600+ megabytes of disk space, the equivalent file encoded using MP3 could be just a tenth of that. Processing a sound file as MP3 is a two-step procedure: encoding and decoding. • Encoding transforms the original digital sound to a highly compressed form. A number of methods are used to achieve this compression, including something referred to as perceptual coding. The technique leverages a science known as psychoacoustics which deals with the way the human ear receives and processes sound. For example, certain frequencies of sound cannot (normally) be discerned when accompanied by FIGURE 1. The Musicbot uses an ArdBotII robot chassis, Arduino Uno (or compatible) development board, and SparkFun MP3 player shield.
38
SERVO 05.2012