Hardware Reference
In-Depth Information
Notice that I have also extended the control codes. Instead of a simple 0 and 1, I now have B and E to begin and
end the recording, P to play back the sounds, and D to delete them all. You can then adapt the PC-based C code as you
did for the doormat to run one of three scripts you've written on the PC to control the sound card:
if (v == 'B') {
system("vox_record.sh start");
} else if (v == 'E') {
system("vox_record.sh stop");
} else if (v == 'P') {
system("vox_play.sh");
} else if (v == 'D') {
system("vox_delete.sh");
... as before ...
This might be to record the sound with vox_record.sh :
#!/bin/bash
LOGFILE=/var/log/voxrecordpid
DIR_INCOMING=/usr/local/media/voxrecord
if [ "$1" == "start" ]; then
FILENAME=`mktemp -p $DIR_INCOMING`.wav
arecord -f cd -t wav $FILENAME >/dev/null >/dev/null 2>&1 &
PID=$!
echo $PID >$LOGFILE
fi
if [ "$1" == "stop" ]; then
PID=`cat $LOGFILE`
kill $PID
rm $LOGFILE
fi
or play back each sound in the directory with vox_play.sh :
#!/bin/bash
DIR_INCOMING=/usr/local/media/voxrecord
for F in "$DIR_INCOMING"/*.wav
do
play $F
done
or even delete them all through vox_delete.sh :
#!/bin/bash
DIR_INCOMING=/usr/local/media/voxrecord
rm -f $DIR_INCOMING/*
Search WWH ::




Custom Search