1. Andrew's Corner :

Slackware and "For The God Who Sings"

In this page I have attempted to combine my love of an amazing radio broadcast called "For the God Who Sings" with my passion for Linux. Perhaps an uneasy mix in the eyes of many but humour me, Gentle Reader, and read the entire page and perhaps you will follow me down this same path? Every Sunday night at 10.30 pm Stephen Watkins hosts a 2 hour radio show that presents "music and texts that seek to enlighten the path untravelled, the idea unravelled". Stephen has a beautiful and quietly contemplative voice that complements perfectly the sacred music that he introduces. And yes, the music echoes the title of the radio presentation as it speaks of God in an exultation of song:

Sing aloud, O daughter Zion; shout, O Israel! Rejoice and exult with all your heart, O daughter Jerusalem! The LORD has taken away the judgements against you, he has turned away your enemies. The king of Israel, the LORD, is in your midst; you shall fear disaster no more. On that day it shall be said to Jerusalem: Do not fear O Zion; do not let your hands grow weak. The LORD, your God, is in your midst, a warrior who gives you victory; he will rejoice over you with gladness, he will renew you in his love; he will exult over you with loud singing as on a day of festival.

But can I say for all this it is often way past my bedtime!! So on this page I will demonstrate how with the svn MPlayer and oggenc you can download the Real Audio stream of "For the God Who Sings" and then convert it to the free Ogg Vorbis format for offline playback on the music device of your choice. (In my own case this device is an HTC Legend smartphone.) A perhaps precarious mix of religious music and modern technology?

Slackware & MPlayer

Times have changed a little for Slackware and perhaps you will no longer need to compile the newest version of MPlayer, as I have advocated before, because as of release 13.0 there is now a quite capable version of the svn MPlayer available in the Slackware xap series. Certainly you would be well advised to run the Slackbuild script again and pass USE_PATENTS=YES to the script, if this is legally allowable in your country, and perhaps also add the MPlayer codecs to your system but otherwise the default copy of MPlayer is more than ready to tackle this Real Audio stream.

Saving the Real Audio Stream Manually

I usually save the broadcast live, as I detail below, but sometimes network vagaries intervene and I must download the program the next day from the ABC website where it is available for a week or so. Go to the ABC Classic FM web site and find the address of the required Real Audio broadcast of "For the God Who Sings", copy it and paste it into the command below, substituting the actual address for <address.ram>:

$ mplayer -cache 2048 -bandwidth 1000000 -playlist <address.ram> \
          -vc null -vo null -ao pcm:fast:waveheader:file=ftgws.wav

The 2 hour stream will then be saved to your computer in about 30 minutes, courtesy of the -bandwidth option, to a file named ftgws.wav. It will be a file of about 1.2 gig but don't worry, transcoding to Ogg Vorbis will drop it down to about 130 megabytes. And now to do just that:

Converting to Ogg Vorbis

As a passionate advocate of Open Source I transcode the stream to Ogg Vorbis and my HTC Legend features native Ogg Vorbis playback, one of the reasons I bought this device. To transcode to Ogg and tag at the same time simply issue the following command:

$ oggenc -q 6 ftgws.wav \
         -t "$(date +"%d-%m-%Y")" \
         -l "For the God Who Sings" \
         -a "Stephen Watkins" \
         -o ftgws_$(date +"%d%m%Y").ogg 

The filename and title tag given here of course represents the date and time of encoding rather than the date of broadcast so perhaps you might like to pop the actual broadcast date in here? The tagging options I have given will give you tags for Title, Album and Artist and while they they might look a little odd they are designed to show up best on my HTC Legend, your choice of tags might be completely different. A little tip here: find the album art of your choice and place it in the same directory as your ogg files and the HTC Legend will display this when playing the files. However there is a better way to do all this, which is to record the broadcast live with the use of a script and below is my "work in progress", a script to automatically download and convert the live audio stream every Sunday night:

Scripting the Live Stream

The real magic of course lies in actually capturing the stream live as it is broadcast and I have developed a small script to do this for me automatically every Sunday night. In a recent development the ABC has altered their live streams from Real Audio to Flash but have also provided a few alternative streams for those such as myself who are not keen on Flash. For the moment I am experimenting with the asx stream but this may change as the new ABC streams system matures and as I experiment with some of the other available live streams. I have named the following script ftgws_download.sh and it lives in /home/andrew/bin:

#!/bin/sh
#-------------------------------------------------------------
#  A very simple script to capture the Real Audio stream of:
#             'For the God Who Sings'
#  Tested with the svn Mplayer and oggenc 1.2.0
#-------------------------------------------------------------

# Most of the variables:

DATE1=$(date +"%d%m%Y")
DATE2=$(date +"%d-%m-%Y")
STREAM=http://abc.net.au/res/streaming/audio/windows/classic_fm.asx
DURATION=2.2h
MUSIC_DIR=$HOME/music/ftgws

#-------------------------------------------------------------

cd $MUSIC_DIR

# Download the stream and convert it to wave format:

mplayer -cache 2048 -playlist $STREAM \
        -vc null -vo null -ao pcm:fast:waveheader:file=ftgws.wav &

sleep $DURATION # Length of the program being recorded as background. 
kill $!         # End the most recently backgrounded job = mplayer

# Convert to ogg format and place the appropriate tags:

oggenc -q 6 ftgws.wav \
         -t "$DATE2" \
         -l "For the God Who Sings" \
         -a "Stephen Watkins" \
         -o ftgws_$DATE1.ogg 

#-------------------------------------------------------------
# Clean up:

rm ftgws.wav

The script is run from cron as follows:

# Runs the ftgws_download.sh script every Sunday:                               
25 22 * * sun /home/andrew/bin/ftgws_download.sh

This little script is still in its infancy and I will return to this page in the near future to develop it a little more. But in the meantime has the file finished encoding? Well, open up your command line player ogg123, mplayer or whatever you choose, sit back and prepare to be enchanted for 2 beautiful hours as you listen to "For the God Who Sings" with Stephen Watkins.

And in conclusion ...

I have found immense enjoyment in writing this page and my pleasure will be redoubled if you have profited by any of the material on this page. Send me an email and let me know! Importantly I am still having a great and productive time in the world of Linux and I feel as if I have joined a community and am contributing to it. What about you?