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 2200hrs Stephen Watkins hosts a 2 hour radio show that presents "music and texts that seek to enlighten the path untravelled, the idea unravelled". Following the iconic introduction of Arvo Pärt's 'Cantus in Memoriam Benjamin Britten' Stephen's beautiful and quietly contemplative voice introduces and expands on sacred music for 2 peaceful hours. 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 and the mp3 encoder Lame you can download the live stream of "For the God Who Sings" and then convert it to mp3 format for offline playback on computer, smart phone or in my case: iPOD Classic. A perhaps precarious mix of religious music and modern technology?

All the steps...

Downloading and converting the live stream for "For The God Who Sings" can be easily done from within most modern Linux distros but I will share a few tips and tricks that will hopefully make the whole process a little easier:

MPlayer, Lame & eyeD3...

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 stream. For Ubuntu users there is always my guide for building the latest MPlayer and I would advise following this route rather than using an aged copy from the Ubuntu Repository. There should be no problem getting access to Lame which under Slackware needs to be compiled and installed and perhaps this is best done with a script from Slackbuilds.org. Same with eyeD3 which I maintain for Slackware.

Finding the stream...

ABC ClassicFM have again their streaming method in February 2015 making life a little more difficult! In particular the copies of older broadcasts of "For The God Who Sings", maintained for a month on the website for replay, now use HTTP Live Streaming (HLS) which has its own special challenge to capture for offline use. The ABC ClassicFM station live broadcast itself can still be accessed directly via either of the two links below:

mplayer -playlist "http://abc.net.au/res/streaming/audio/windows/classic_fm.asx"
mplayer -playlist "http://www.abc.net.au/res/streaming/audio/aac/classic_fm.pls"

I am using the first of these streams to script the download but I would not be suprised if this link ceases to work over the next little while!

Scripting the 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 between 2159hrs and 0001hrs (this contains a 1 minute 'sneeze' factor before and after the 2 hour broadcast). 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 live radio broadcast of: #
#             'For the God Who Sings'                           #
#  Tested with the svn Mplayer, Lame 3.99.5 & eyeD3 0.7.5       #
#---------------------------------------------------------------#

# Most of the variables:

DATE=$(date +"%Y-%m-%d")
STREAM=http://abc.net.au/res/streaming/audio/windows/classic_fm.asx
DURATION=122m
MUSIC_DIR=$HOME/media/ftgws

#---------------------------------------------------------------#
cd $MUSIC_DIR

# Download the stream and convert it to wave format:

mplayer -cache 16384 -cache-min 80 -playlist $STREAM \
        -vc null -vo null -ao pcm:fast:waveheader:file=ftgws_$DATE.wav &

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

# Convert to mp3 format, place the appropriate tags and add some album art.
# I use the following image of Stephen Watkins: 
#       http://www.andrews-corner.org/images/ftgws_album.jpg
         
lame -V 2 ftgws_$DATE.wav ftgws_$DATE.mp3 
          
eyeD3 --artist "Stephen Watkins" \
      --album-artist "Various" \
      --album "For the God Who Sings" \
      --title "$DATE" \
      --genre "Classical" \
      --recording-date "$DATE" \
      --add-image "ftgws_album.jpg:FRONT_COVER" \
      --add-comment "Thanks to ABC Classic FM & Stephen Watkins..." \
      --text-frame TENC:"Andrew Strong" \
      --url-frame WORS:"http\\://www.abc.net.au/classic/program/forthegodwhosings/" \
      ftgws_$DATE.mp3     

#---------------------------------------------------------------#
# Automatically delete the big wav file:

rm ftgws_$DATE.wav

# Now enjoy the music :)
#---------------------------------------------------------------#

The script is run from cron as follows (after running crontab -e as an ordinary user):

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

Running lame with -V 2 is actually using the following parameters which I invite you to look up if you are interested:

-m j -V 2 -q 0 -lowpass 18.5 --vbr-new -b 32

and this is a little overkill for my purposes but the sound is very, very nice! So all that remains is for you to open up your favourite command line player mpg123, 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 if this fails...

If for whatever reason the capture of the live stream fails it is still possible to catch the archived copy which is available as an HLS stream for several weeks. I am still working on a more robust method of accomplishing this but something like the following works at the moment:

mplayer \
ffmpeg://http://abcradiomodhls.abc-cdn.net.au/i/classic/audio/fgs-YYYY-MM-DD.m4a/index_0_a.m3u8 \
        -vc null -vo null -ao pcm:fast:waveheader:file=ftgws_YYYY-MM-DD.wav && \
lame -V 2 ftgws_YYYY-MM-DD.wav ftgws_YYYY-MM-DD.mp3 && \
eyeD3 --artist "Stephen Watkins" \
      --album-artist "Various" \
      --album "For the God Who Sings" \
      --title "YYYY-MM-DD" \
      --genre "Classical" \
      --recording-date "YYYY-MM-DD" \
      --add-image "ftgws_album.jpg:FRONT_COVER" \
      --add-comment "Thanks to ABC Classic FM & Stephen Watkins..." \
      --text-frame TENC:"Andrew Strong" \
      --url-frame WORS:"http\\://www.abc.net.au/classic/program/forthegodwhosings/" \
      ftgws_YYYY-MM-DD.mp3 && \
rm ftgws_YYYY-MM-DD.wav

My thanks again to Wireshark for revealing the location of the archived file and generated playlist (which usually has about 720 segents!). Of course you will need to transform YYYY-MM-DD to the appropriate dates for the stored broadcast. Some work still to do on this method but this is the sort of work and research I enjoy!

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?