Recording audio on the FreeRunner
The FreeRunner can record audio. It is nice to record audio: for example I can
run the recording in background while I keep tangogps in the screen, and take
audio notes about where I am while I am doing mapping for OpenStreetMap.
Here is the script that I put together to create geocoded audio notes:
#!/bin/sh
BASENAME=~/rec/rec-$(date +%Y-%m-%d-%H-%M-%S)
alsactl -f /usr/share/openmoko/scenarios/voip-handset.state restore
echo "Getting GPS info..."
getgps > $BASENAME.info
arecord -D hw -f cd -r 8000 -v -t wav $BASENAME.wav
echo "Setting wav timestamp to GPS start of recording"
TS=$(cat $BASENAME.info grep time_tstamp cut -f2 -d' ')
touch -d "@$TS" $BASENAME.wav
echo "Done"
It works like this:
- It loads mixer settings to record from the handset, but the same could in
theory be done for the headset.
- It gets all sort of information from the GPS and stores them into a file.
- It records audio until it gets interrupted.
- It retrieves the GPS timestamp from the beginning of the audio recording,
and uses it to set the file timestamp
And the following is the
getgps script, adapted from
a mailing list post: it can be generally useful to save information about a fix from the GPS.
#!/usr/bin/env python
import dbus
from time import gmtime, strftime
obj = dbus.SystemBus().get_object('org.freesmartphone.ogpsd', '/org/freedesktop/Gypsy')
constatus = obj.GetConnectionStatus(dbus_interface='org.freedesktop.Gypsy.Device')
print "connection_status:", constatus
print "connection_status_name:", (constatus and 'TRUE' or 'FALSE')
fixstatus = obj.GetFixStatus(dbus_interface='org.freedesktop.Gypsy.Device')
print "fix_status:", fixstatus
names = ["INVALID", "NONE", "2D", "3D"]
if fixstatus < 0 or fixstatus > len(names):
print "fix_status_name:", names[0]
else:
print "fix_status_name:", names[fixstatus]
def yesno(val):
return val and "yes" or "no"
(fields, tstamp, lat, lon, alt) = obj.GetPosition(dbus_interface='org.freedesktop.Gypsy.Position')
print "pos_fields:", fields,
print "pos_tstamp:", tstamp
print "pos_time:", strftime('%F %T', gmtime(tstamp))
print "pos_lat: %f" % lat
print "pos_lat_valid:", yesno(fields & (1 << 0))
print "pos_lon: %f" % lon
print "pos_lon_valid:", yesno(fields & (1 << 1))
print "pos_alt: %f" % alt
print "pos_alt_valid:", yesno(fields & (1 << 2))
(fields, pdop, hdop, vdop) = obj.GetAccuracy(dbus_interface='org.freedesktop.Gypsy.Accuracy')
print "accuracy_fields: %d", fields
print "accuracy_pdop: %f" % pdop
print "accuracy_pdop_valid:", yesno(fields & (1 << 0))
print "accuracy_hdop: %f" % hdop
print "accuracy_hdop_valid:", yesno(fields & (1 << 1))
print "accuracy_vdop: %f" % vdop
print "accuracy_vdop_valid:", yesno(fields & (1 << 2))
(fields, tstamp, speed, heading, climb) = obj.GetCourse(dbus_interface='org.freedesktop.Gypsy.Course')
print "course_fields:", fields
print "course_tstamp:", tstamp
print "course_time:", strftime('%F %T', gmtime(tstamp))
print "course_speed: %f" % speed
print "course_speed_valid:", yesno(fields & (1 << 0))
print "course_heading: %f" % heading
print "course_heading_valid:", yesno(fields & (1 << 1))
print "course_climb: %f" % climb
print "course_climb_valid:", yesno(fields & (1 << 2))
time = obj.GetTime(dbus_interface='org.freedesktop.Gypsy.Time')
print "time_tstamp:", time
print "time_time:", strftime('%F %T', gmtime(time))
satellites = obj.GetSatellites(dbus_interface='org.freedesktop.Gypsy.Satellite')
for satIndex, sat in enumerate(satellites):
print "sat%d_prn: %u" % (satIndex, sat[0])
print "sat%d_used: %s" % (satIndex, yesno(sat[1]))
print "sat%d_used_value: %u" % (satIndex, sat[1])
print "sat%d_elevation: %u" % (satIndex, sat[2])
print "sat%d_azimuth: %u" % (satIndex, sat[3])
print "sat%d_snr: %u" % (satIndex, sat[4])