The idea for this project was to build a home-brew, Debian GNU/Linux-based WLAN radio that is able to play Internet radio streams as well as Podcasts and MP3 files. The chassis is from an old portable radio (ITT Schaub-Lorenz Tiny 3) that was produced and sold in the early 70ties.
This page would like to provide some useful tips for the guys of you who want to try to build up their own home-brew WLAN radio.
As a hardware platform for the radio, I chose the NSLU2 ("Network storage link for USB devices"). This device is a little box used to connect USB disks and share them via a Network, but you can patch the ROM and install a Debian GNU/Linux on an attached pen drive or a USB hard disc. It was produced until 2008 (originally by Linksys, later by Cisco). The basic facts:
The NSLU2 nowadays is not the ideal platform for the project, as it is very slow and not in production any more - I used it simply because I had one left. If you want to build a WLAN radio from scratch, you might take a look at other low-budget platforms such as:www.nslu2-linux.org, which provides tons of useful information for running Linux on the NSLU or extending it with additional hardware. My NSLU uses a Debian GNU/Linux "Squeeze" as operating system which I installed on a 8GB USB Mini pen drive. A 4-port USB-HUB is needed to connect all the devices you need (a hub with passive power supply over USB was enough for my radio).
The NSLU has a 100 MBit Ethernet interface, but certainly, I wanted something without a cable. So I used a Mini WLAN USB Stick by Hama, which is based on the Realtek 8192CE chipset. Luckily, Realtek provides a driver for Linux for this chipset. Unluckily, this driver does not work out of the box on the NSLU, so I had to make some modifications on the source code to make it run:
For sound, I used a VIGO USB Soundcard, which worked out-of-the box together with the NSLU. The sound quality is not high-end, but absoluetly ok for a Wlan radio.
The display is a 16x2 LCD module from Bernd Walter Computer Technology, which comes right out of the box with a USB interface. The display should work together with LCD4Linux and LCDProc, but I used a modified version of the Libusb-based software for the display that can be downloaded at the BWCT homepage.
I thought of different ways to control the radio (select Podcast, Radio stream or MP3 file, change volume, Play/Pause/Stop, Forward, Rewind,...). I finally came up with the idea to keep some of the feel of the original radio: As it had two wheels to tune in in the station and change volume, I now use a scrollwheel from a USB mouse to switch through different podcasts /streams / files when the radio is not playing anything, to change the volume if the radio currently plays something and to forward/rewind if the playback was set to pause. I soldered four cables to the mouse board that are connected to two buttons at the chassis that replace the left and right mouse button. With these 3 controls, you are able to fully control the radio. You can see the whole thing at the picture to the left - I am not the kind of a "do-it-yourself" guy, so it doesn't look very descent, but I think you get the idea.
Certainly, you can also try to use other input methods, like a (modified) keyboard or an infrared remote control (via LIRC)
There are many different audio players for Linux (VLC, MPlayer, MPD, madplay,...). For my project, I chose the Music Player Daemon (MPD) together with its console client (mpc), for the following reasons:
The MPD performs pretty well when playing the MP3 files, web radio streams and podcasts I tested. Unfortunatley, on the NSLU the audio playback can be choppy if the audio data has to be converted to another frequency that was configured as default (in my case, from 48KHZ to 44KHZ): The down- and upsampling algorithm MPD normally uses makes heavy usage of floating point arithemetics, so the missing FPU causes a heavy CPU load. To avoid such problems, you can enable and set the option "samplerate_converter" in /etc/mpd.conf to "internal" (and restart MPD). This will result in a slightly lower quality when playing audio files with the "wrong" sample rate - but for me, that was absolutely tolerable. For more details on this issue, see this page about tuning the MPD.
My radio has only one speaker (I kept the speaker from the original radio), so I wanted the audio to be converted to mono. This can easily done by setting the option "format" in the block "audio_output" in /etc/mpd.conf to "44100:16:1" (44khz, 16bit, 1 channel).
I chose to program my own application for controlling the radio and display stuff on the display. As programming language, I chose Perl, because it comes along with most of the features (like text parsing, file processing, network stuff,...) you'll need. If you want you can download the Perl code below, but I warn you: This code was not tested for robustness, performance or fault tolerance, and may be very buggy. It just should give you an idea how some of the stuff you'll need could be done. So beware!
The software can access Internet radio streams and podcast feeds that are stored in two seperate CSV files. (You can change the path in the file "WlanRadio.pm", see below). Also it is possible to browse a directory with MP3 files. As MPD cannot parse playlist files (*.m3u) out of the box, there is also a little piece of code that will download and parse streams ending with ".m3u" and pass the contents to MPD. This works fine for me, a more elegant way is described here.
If everything is set up correctly (you will need to change some parameters in WlanRadio.pm), you should be able to initialize the application with a simple Perl script:
#!/usr/bin/perl use WlanRadio; my $radio = new WLAN::Radio::Application(); $radio->init();