- cronjob - schedules the recordings. UNIX only, but other platforms have equivalents.
- Tcl - Needed for Snack. Available for all platforms.
- Snack - Extension to Tcl. Controls the audio card mixer and reads the Line-in and writes to WAV format. Available for all platforms.
- lame - An mp3 encoder that converts the WAV output from Snack to mp3 format. Available for all platforms.
#!/usr/bin/env tclsh package require sound set ::left 90 set ::right 90 snack::mixer volume IGain left right snack::sound ss -channel stdout -rate 16000 -channels Mono ss record -input Line1 -fileformat WAV after [expr [lindex $argv 0] * 1000] exit vwait foreverThe output from this program is piped through lame to write the final output to an mp3 file. One hour of recording generates a ~10 MB file.Here is an example shell script that gets run from a crontab entry. It creates a 1 hour time-stamped recording, storing it on a network accessible drive
#!/bin/sh DEST=/mnt/bilbo/windows/MP3/Radio/DougMcIntyre TOD=`date +%d%b%Y_%H%M%S` exec /usr/local/bin/tclsh $HOME/radio/radiorecorder.tcl 3600 | /usr/local/bin/lame - $DEST/DougMcIntyre$TOD.mp3That's it. I have various cronjobs that make hours of recordings of my favorite programs. I use Snackamp [1] to play back the radio shows on any of my Windows or UNIX machines. My next step will be to get an AM/FM tuner card that I can install in the server (anyone know of a good one?).Marty Backe 07 Aug 2002
I've updated the program to take pairs of command line arguments, specifying start and stop times (in seconds). This was done because some of the radio programs I record are syndicated and therefore have precise, dependable commercial breaks. I can have the recording start and stop, thus avoiding the recording of commercials (and helping to reduce file size - a typical 1 hour talk show only requires ~35 minutes of disk space). Marty Backe - 31 Dec 2003
#!/usr/bin/env tclsh package require sound proc Exit {} { ::ss stop exit } # # Parse input parameters. Each parameter consists of a start time, colon, and # stop time. All times are in seconds, referenced to the program start time. # if {$argc == 0} { puts "ERROR: At least one start/stop time must be provided." exit 255 } foreach parameter $argv { set splitList [split $parameter :] lappend recordTimesList $splitList } set ::left 90 set ::right 90 snack::mixer volume IGain left right snack::sound ss -channel stdout -rate 16000 -channels Mono ss record -input Line1 -fileformat WAV ss pause # # Create a series of events to start and stop the recording # foreach times $recordTimesList { set startTime [expr {[lindex $times 0] * 1000}] set stopTime [expr {[lindex $times 1] * 1000}] after $startTime {ss pause} after $stopTime {ss pause} } # # Setup for program exit after the last stop # set lastTimeIndex [expr {$argc - 1}] set exitTime [lindex [lindex $recordTimesList $lastTimeIndex] 1] set exitTime [expr {$exitTime * 1000}] incr exitTime 10 after $exitTime Exit vwait foreverAnd here's the driver shell (UNIX) script, run from a cronjob.
#!/bin/sh DEST=/mnt/bilbo_extra/MP3/Radio/DennisPrager TOD=`date +%d%b%Y_%H%M%S` exec /usr/local/bin/tclsh $HOME/radio/radiorecorder.tcl 330:1025 1265:1805 2060:2405 2645:3125 3320:3530 | /usr/local/bin/lame - $DEST/DennisPrager$TOD.mp3 > /dev/nullFor Windows, I use the Task Manager to schedule a batch file to run. Here's an example batch file:
for /f %%i in ('c:\tcl\bin\tclsh84.exe c:\radio\getDate.tcl') do set DATESTRING=%%i c:\Tcl\bin\tclsh84.exe c:\radio\radiorecorder.tcl 360:1005 1230:17845 2085:2450 2640:3035 3195:3575 | c:\lame\lame.exe - c:\mp3\radio\TammyBruce\TammyBruce%DATESTRING%.mp3The first line is a convoluted (but necessary) approach to setting a batch variable (DATESTRING) to the results of another program (a Tcl program that creates the needed date/time string).Here's the getDate.tcl program:
puts [clock format [clock -seconds] -format %d%h%Y_%H%M%S]Marty Backe - 07 Nov 2004Marty Backe - 27 May 2005 - incorporated a couple of updates suggested by Geoffrey CoramVPT - 8 June 2005 - If you're using Linux then vsound (http://www.zorg.org/vsound/index.shtml


