This project describes how to convert an old 1930's style radio into a retro-feeling media player. The main tuner knob navigates from playlist to playlist - however the device keeps track of the current time and will navigate to a point in the playlist where it "thinks" it should be. This gives off the illusion that you're actually listening to a radio. You can change the station, but you can't change what song you're listening to!
Source code on GitHub
Physically, the device consists of a network attached linux box hooked up via USB to an Arduino board. The Arduino is used to read sensor values from a series of potentiometers attached to the knobs of the radio. The linux box is used for everything else - driving the Arduino board, storing and playing the music, etc.. For the rest of this article I will be referring to the linux box as the "music server"
The bulk of the logic is a Python script that reads the sensor values from the Arduino and issues commands to Media Player Daemon (MPD), which handles the actual audio playback as well as the management of playlists.
The nice thing about using MPD is that it has a nice API, and can therefore be easily scripted. There are also plenty of MPD clients out there that can be used as backplane controllers to the device. For example, I use Theremin to control MPD if I feel like listening to a specific song or want to create ad-hoc playlists on the fly. I've also got an MPD client on my phone, in case I feel like changing songs from the comfort of my bed :)
Music and playlists are automatically synced from iTunes (running on your laptop or desktop) to the music server using a few simple scripts.
This part is going to be different depending on what kind of radio you're hacking. I picked up an old Philco radio from an antique sale for $20. The idea is the same though: hook up the existing knobs and dials to (working) potentiometers.
The first step is to remove the metal enclosure that houses all the electronics, and remove any unecessary parts. This includes pretty much all stray wires, vacuum tubes, dust, cobwebs.... trust me, it'll make the next steps much easier!
You'll probably want to replace the existing potentiometers. I found that mine were in pretty rough condition. They are also going to be logarithmic pots, and we'll want linear ones. I picked up some standard issue pots from Radio Shack.
On my radio, the main dial is connected to a variable capacitor, basically two sets of interleaving aluminum plates. Turning the main dial rotates the interleaving plates into/out of each other, which changes the capacitance, which then tunes the radio to a different frequency.
I thought I could try measuring the capacitance between the plates to get a sensor value for the main dial by building a little RC circuit, and measuring the first order response time. Turns out that the capacitance is too small to make this feasible on a 16MHz Arduino.
The design I ended up going with utilizes an engineers best friend: duct tape! I hacked apart the main shaft and attached it to a potentiometer mounted on the other side. Turns out duct tape is a pretty good coupling if you have large tolerances and low torsion requirements.
Be careful when cutting the shaft. You'll want to keep the distance between the shaft and the potentiometer small (2 or 3mm), otherwise there's a chance that the duct tape coupling will twist and throw off your sensor values!
The circuit is pretty simple - just a series of voltage dividers connected to the potentiometers and into analog-in pins of the Arduino.
Feel free to contact me if you want more elaboration, but there are plenty of examples online of how to do this.
The Python script that is running on the music server is pretty simple: read the sensor values at some reasonable sample rate (10ms in my case), and make the appropriate API calls to MPD. Currently there are only two sensors being read: one for changing the "station" and one for adjusting the volume.
There is some hysterisis in the software in that it only changes stations or the volume when the sensor values change by a predfined amount. This is so that you can manually change the volume or the song without the Python script immediately switching it back!
I've written some scripts which help with music management. Unfortunately this only really works if you let iTunes mange your music library for you, because the scripts assume that the relative path of your mp3s is going to be the same on your local computer as it will be on the music server. Feel free to improve on this :)
A summary of what the scripts do:
Alright, enough talk... get the source code!
If you have any questions, feel free to drop me a note
kenshi (at sign) recurse (period) ca
And please, fork the project on GitHub!