Hardware Reference
In-Depth Information
Another nifty trick is to specify a shell script to be executed instead of entering the
commands manually:
pi@raspberrypi ~ $ at now + 30 minutes -f ~/autorun.sh
The Raspberry Pi board lacks a Real-time Clock ( RTC ), which computers use to
keep track of the current time. Instead, the Pi has to ask other computers over the
network what time it is when it boots up. Alternatively, it can obtain the correct time
from a GPS module as described in the Using GPS as a time source section of Chapter 5 ,
Taking your Pi Off-road . The Pi is equally unable to keep track of the time that passes
while it's powered off.
If we need to time something but know we won't have network access, we can
combine the technique discussed in the Start on power up section with the at command.
This allows us to implement the idea Start the playback 1 hour after I plug in the Pi.
All we have to do is modify one line in our /etc/rc.local script to add an at timer:
if [ -x /home/pi/autorun.sh ]; then
sudo -u pi at now + 1 hour -f /home/pi/autorun.sh
fi
Controlling recording length
An automated SoX recording will continue to run until the Pi runs out of SD card
space. We can use the trim effect to stop the recording (or playback) after a certain
amount of time has elapsed:
pi@raspberrypi ~ $ sox -t alsa plughw:1 myrec.wav trim 0 00:30:00
The previous command will record thirty minutes of audio to myrec.wav and
then stop. The first zero tells the trim effect to start measuring from the beginning
of the file. The position where you want to cut the recording is then specified as
hours:minutes:seconds .
Another function useful for long recordings is to be able to split it into multiple files,
each file with certain duration. The following command will produce multiple WAV
files, each file being one hour in length:
pi@raspberrypi ~ $ sox -t alsa plughw:1 myrec.wav trim 0 01:00:00 :
newfile : restart
 
Search WWH ::




Custom Search