Hardware Reference
In-Depth Information
•
| sox -q -t sox - -d
then pipes that output to our local
sox
application,
which we've given a
-q
or
quite mode
argument for cosmetic reasons,
otherwise SoX would show two competing progress displays.
• The two
-t sox
arguments instruct SoX to use its own native, uncompressed
file format, which is especially useful for transporting audio between SoX
pipes like this one.
Let's look at a few additional tricks with SSH and SoX:
• It's useful to be able to store the recording on your machine instead of the SD
card on the Pi. The following command will record from the Pi to
myrec.wav
on your local desktop:
$ ssh pi@[IP address] sox -t alsa plughw:1 -t wav - > ~/Desktop/
myrec.wav
Note the
>
character instead of the pipe, which is used to
redirect the output to a file.
• Of course, you should also know how to simply copy files from your Pi using
the
scp
command. The following command copies
myrec.wav
from the
pi
user's home directory to your local desktop:
$ scp pi@[IP address]:myrec.wav ~/Desktop/myrec.wav
• Just reverse the argument order of the previous command to copy
myrec.
wav
from your local desktop to the
pi
user's home directory:
$ scp ~/Desktop/myrec.wav pi@[IP address]:myrec.wav
• To avoid having to remember those long commands, you could easily create
aliases for them using the same techniques we covered previously in this
chapter. Only on Mac OS X, you need to put your lines in
~/.bash_profile
instead of
~/.bash_aliases
:
$ echo "alias pilisten='ssh pi@[IP address] sox -t alsa plughw:1
-t sox - | sox -q -t sox - -d'" >> ~/.bash_profile
Talking to people from a distance
Instead of listening in on the action, maybe you'd like to be the one creating all the
noise by making the Pi an extension of your own voice. You'll be on a computer with
a microphone, and the Pi can be somewhere else broadcasting your message to the
world through a pair of speakers (or a megaphone). In other words, the roles of the
Pi and your computer from the previous topic will be reversed.