I’ve Switched
January 19th, 2008
I have recently made the switch to Ubuntu. Ubuntu, for those who may not be aware, is a word from the Bantu language which refers to a philosophy of life. The word also has been chosen as the name for a popular distribution of linux.
Though I find the philosophy of Ubuntu something to strive towards and am working to incorporate it into my life, it is the distribution of linux I refer to specifically when I say I have switched to it and in the remainder of this post that is what I am referring to when I use the word Ubuntu.
I live near St. Louis Missouri and am thus blessed to be within the listening radius of what many consider to be one of the best radio stations in the country and perhaps the world- the public radio station KDHX 88.1. This is both a blessing and a frustration. It is a blessing in that there is a great variety of diverse programming every day of every week. It is a frustration in that I just can’t listen to everything I want to hear.
I can’t get KDHX in my cube at work and being not only married, but the father of three children, it is just not feasible to sit down and listen to the radio whenever a good show is on. This means, that though I am familiar with the broadcast schedule of KDHX, this familiarity is largely a knowledge of what I might be listening to if I happen to be not at work and in the car when it’s on. This means I am frequently aware that something very cool is currently on the air and I’m not listening to it.
It’s also frustrating in that there is a ton of great stuff on KDHX I know my dad would love, but he lives in Arizona and although KDHX is streamed to the web, he still has dialup.
He has the perfect setup for listening to good music. His house has a nice courtyard area with an outdoor fireplace and even a small indoor bar (His place is seriously like a very small resort- ask anybody who’se been there). In fact, he often talks about sitting out in the courtyard in front of a fire with good music playing on the outdoor speakers. Everytime he mentions such an activity I wish I could get some of the good stuff KDHX broadcasts to him.
Well, thanks to my switch to Ubuntu, a good link by my friend Jay, and a bit of investigation and figuring out on my own, I have now solved both problems.
I now have mp3 files of radio programs broadcast on the Internet automatically saved to my hard drive. As long as my computer is turned on and booted into Ubuntu the shows I want will automatically be captured and saved for later listening.
I suppose I am setting myself up for hasselation and dire oppression by the RIAA making such proclamations, but to them I say you can’t get blood from a stone. Go sue some granny on a fixed income or a suburbanite mallternateen. You’ll have a better chance actually collecting a judgement from either of them than you will from me because if there were a debtor’s prison in the USA in 2008 I’d probably already be there.
Anyway, back to the cool tech stuff.
The Instructables link above that Jay sent me worked perfectly- it was flawless right off the bat. For one of the stations I wanted to record. The one that isn’t KDHX. The one that broadcasts the shows that I frequently am actually able to listen to.
The directions in the link did not work for KDHX. The reason was that the other station offers an mp3 stream which was fine with mplayer, the program instructables used. KDHX provides a stream in RealPlayer .ram format that mplayer could not handle. This was a bit of a stumper to me for a while (I am a command line old-timer, but new to the intricacies of linux audio) until I found the second link listed above which recommended the use of a program called vsound along with a program called totem that can play .ram streams. Vsound can take the audio signal that is going to the speakers and direct it to a file so that once totem is running, vsound can write the audio directly to the hard drive.
I copied the script that worked for the streaming mp3 station and changed the mplayer command to the vsound command. After a little bit of head scratching and syntax double-checking, I had it working. I could run the script, watch totem start, hear the sound, and watch the .wav file grow in my /tmp directory. Once I killed totem, I could even watch the script convert the .wav in /tmp to an mp3 in a directory on my storage drive and then delete the .wav file from /tmp.
It was a beautiful thing and I was very happy. I was happy until today when I noticed that, though running the script from the command line produced perfect results, and clicking “run now” on the etnry for the script in Kcron, a graphical user interface for cron (the linux daemon that make things happen on a schedule) produced perfect results, actually relying on cron to run the script at a set time produced no results.
The reason turned out to be that when cron ran the script, it was failing because it didn’t know where to display totem. Totem wants to pop up on the screen so you can see it while it’s playing and if it doesn’t know where to show up it dies. When I ran the script explicitly either from the command line or via kcron, totem knew to just show up on the screen since the user told it to run.
My difficulties were alleviated when I simply entered the variable DISPLAY=:0.0 at the beginning of the crontab (the text file cron uses to schedule things).
Now everything is absolutely perfect. All I have to do is remember to periodically burn some of the resultant mp3s to CDs so that I can actually send them to Arizona and so that my storage drive doesn’t fill up. Of course, my one extravagant expenditure of 2007 was $140 (you can see why I’m not afraid of the RIAA) for a 500 G hard drive so it will be a while before I run out of storage space for mp3s at 20 M / hour but once they’ve been burned to CD there’s not point keeping them around.
So I feel pretty good. Since I switched to linux I am finally able to harness the power of my computer to make it actually do something for me and I have learned a great deal about audio for linux and cron. I am now also free from the frustration of missing my favorite radio shows and able to improve the quality of my father’s life (if only in a small way) by sharing great audio entertainment with him to which he would otherwise have no access.
Open source rules, even for wannabe feebs like me.
Jan 20, 08 at 9:29 am
COOL I appreciate you effort.
Jan 20, 08 at 10:29 am
1003 Sunday, 20 January 2008
More solutions to non-existent problems:
“As long as my computer is turned on and booted into Ubuntu the shows I want will automatically be captured and saved for later listening.”
If you use a program like Parallels Desktop or QEMU or another of the virtualization programs, you can run a Linux system without rebooting your computer and picking the operating system at run-time.
If you do this, you will suffer a performance hit for CPU-intensive tasks, such as audio and video transcoding.
“The Instructables link above that Jay sent me worked perfectly”
Did you comment on the Instructable? The original author would probably appreciate it. You’d also help people who haven’t yet solved the problem by publishing your method on Instructables.
“KDHX provides a stream in RealPlayer .ram format that mplayer could not handle.”
You might recompile mplayer to maniuplate Real Audio streams. On Gentoo Linux, this happens by changing the USE environment variable to include the correct USE flags, “mplayer” and “real”, resourcing certain configuration files (whose name escape me), and giving “emerge mplayer.” Under Ubuntu, you could compile a private copy of mplayer, but i don’t know how that would affect the system’s package management.
“Vsound can take the audio signal that is going to the speakers and direct it to a file so that once totem is running, vsound can write the audio directly to the hard drive.”
The vsound workaround might have one disadvantage. I suspect it resamples the audio stream. I don’t know if it does that, but if it does you get a higher-beneration copy of the original stream. You get sampling errors in the final file. If this affects the audio quality, you might compare the totem-vsound results with mplayer.
“My difficulties were alleviated when I simply entered the variable DISPLAY=:0.0 at the beginning of the crontab (the text file cron uses to schedule things)”
You can also change the script such that its calls totem with “–display=:0.0”. Check the man page for more options, and test the flag for the right syntax.
If you don’t have X-Windows up, running, and with the user account logged in, does the script still run?
If you also run a VNC server, you can set DISPLAY=:1.0, or to whatever display number matches VNC’s display number. You can do other fun things with VNC.
“All I have to do is remember to periodically burn some of the resultant mp3s to CDs”
Why remember? You have kcron and cdrecord, right? Let the machine do that work for you.
“500 G hard drive so it will be a while before I run out of storage space for mp3s at 20 M / hour but once they’ve been burned to CD there’s not point keeping them around.”
You get about 50 hours of audio per gigabyte of disk space. CD-Rs will decay over a few years.