PIcast Chest - Open

Raspberry Pi based SHOUTcast internet radio.

Internet radio is something I listen to a lot at work, and have used SHOUTcast as my radio listing since the old winamp days (long before the curse cult of Apple). I’ve seen many Raspberry PI based internet radios, but all the ones I saw seemed to function on the basis of having a small selection of pre-defined radio stations which can be scrolled through. I deicide to make my own, but instead of trying to cram my tastes into only a few stations, I wanted to have an entire directory of hundreds of stations I could browse. The key to this is SHOUTcast.com, a radio directory which claims to have 57,675 live radio stations at time of writing, all organised neatly by genre and sub-genre. To get access to their live API allowing the querying of their library you need to be a partner, which I applied to be under no expectation of them saying yes. Whilst doing this I also looked at other free directories, namely Internet Radio, which has a similar directory but at the moment, they are working on a public API which is not yet available. Much to my surprise, SHOUTcast agreed to give me a developer ID allowing me to incorporate their radio directory.


The software running the radio service is custom written in Java (not my favourite language, but I’ve been using it for work for a while and am most used to it atm). It’s based on the ability to browse the radio directly easily and defaults by giving a listing of genres. Any genre can be selected using the two main navigation knobs (Up/Down and OK/Back) giving a list of sub-genres, which in turn give a listing of radio stations. One of the keys is the ability to set favourites, helping the sorting of the thousands of stations, by pressing the push button incorporated into the up/down knob. A favourite listing shows at the top of the main genre list and I’ve added seperate user accounts allowing each person in the household to have their own favourite list. Once a station is selected, it’s played using mplayer as a console command on the Pi.

The actual API interaction is done by sending an HTTP request to SHOUTcast’s servers, which returns the listing you requested formatted as a nice JSON object. I’ve also included custom stations by saving a JSON describing them in the same way on the PI, allowing me to add the full list of BBC digital stations to the box. The third knob on the display controls volume in software, allowing the hardware knob on the amplifier to be set at a comfortable level and left. In addition to browsing the directory, I got a brilliant idea from the clever man responsible for this video: “Raspberry Pi Internet Radio – Using Evernote to save song names”. He used an email auto-send to add the currently playing song title to a list stored on Evernote for future reference. Working from this idea, when the “Save favourite station” push button is pressed when radio is currently playing, it sends an HTTP request to my web server containing the name of the current track, which is parsed and placed into an SQL database for me to go through later and browse, possibly buy.

The last bit of functionality I’ve added to the software is the ability to browse a specified folder on the PI’s drive and load any found MP3’s into a separate listing. This is very much a secondary feature to the main radio, but I do like having the Skyrim and Blade Runner soundtracks on hand when tinkering in the garage. Also a collection of radio shows by Vincent Price.


The main peice of hardware is the Raspberry Pi itself, using the model 2 B. I looked into low powered amps for quite a while and eventually decided that instead of getting an underpowered 5v amp, I would get a 12v amp and 20w speakers, using a car voltage regulator to lower the 12v supply to 2 5v usb sockets. This allowed me to run everything on one 12v power supply. Due to the low quality of the Pi’s audio out, I also used an active HDMI converter to take audio from the HDMI socket and use that to run the amp. With all the majour components accounted for, the knobs on the front of the radio caused me the most effort to find. The up/down and vol+/- knobs are standard rotary encoders wired to the PI’s GPIO pins, but for the middle ok/back knob I wanted something with two finite states and a nutural rest position. I had decided I needed a momenrary rotary switch, one which I could turn in either direction to make a selection but would be self-centering when released. Eventually, the only place I could find one was Surplus Sales of Nebraska. The box to house the whole radio I bought from ebay and I made the internal mounting panels from a sheet of 3.6mm plywood stained with Ronseal Rosewood Woodstain.


All in all, this has been a brilliantly fun project and I’m thrilled with how it’s turned out. Whenever I’m tinkering in the garage, this is the first thing I turn on, tuned into 20th Century Radio.