Hardware Reference
In-Depth Information
Recording conversations for later
retrieval
So we have our audio gear all configured and ready to record—let's get sneaky
with it!
Picture the following scenario: you know that something fishy is about to go down
and you'd like to record whatever sound that fishy thing makes. Your first challenge
will be to hide the Pi out of sight with as few cables running to it as possible. Unless
you're working with a battery, the Pi will have to be hidden somewhere within a few
meters of a power outlet.
Next, you'll want to connect your USB microphone and keep it hidden, yet
uncovered if possible, to avoid a muffled recording. Unless you expect the action to
take place right in front of the microphone, you should set the capture signal to the
max with alsamixer for the microphone to be able to pick up as much of the room
as possible.
Now, all we need to worry about is how to trigger the recording.
Writing to a WAV file
The Waveform Audio File ( WAV ) is the most common file format used for
recording audio.
• To save a recording to a file named myrec.wav on the SD card, type in the
following command:
pi@raspberrypi ~ $ sox -t alsa plughw:1 myrec.wav
• Play back the recording using the following command:
pi@raspberrypi ~ $ sox myrec.wav -d
• If your USB gadget happens to have speakers, like a headset, you could listen
to the recording in the headphones with the following command:
pi@raspberrypi ~ $ sox myrec.wav -t alsa plughw:1
Writing to an MP3 or OGG file
So far we've been storing our audio as uncompressed WAV files. This is fine for
shorter recordings, but it'll eat up the free space of your SD card rather quickly if
you want to record several hours of audio data. One hour of uncompressed 16-bit,
48 kHz, stereo sound will take up about 660 MB of space.
 
Search WWH ::




Custom Search