The ‘Raspberry Pi in a vintage radio’ project is a stalwart of the community. Pi computers the world over have rescued otherwise defunct devices from the rubbish heap and are often cited as a great example of upcycling.

When Raphaël Yancey, a maker from Paris, France, was gifted his grandfather’s Optalix TO100 radio, he decided to take this classic project to the next level.

This project first appeared in The MagPi issue 81. Sign up to our newsletter to get a free digital edition of The MagPi every month. Subscribe in print for 12-months and get a free Raspberry Pi computer.

Raphaël’s love of Grand Theft Auto: San Andreas’s in-game radio stations inspired him: “It’s always a pleasure to steal luxury cars and drive way too fast while listening to good music! The hilarious talk-shows and skits make it even more real.” When the complete set of station recordings was released by Rockstar, some new ideas for a project started to form.

GTA Radio: Fast Facts

There are five stations, from 88.7MHz to 108.0MHz

This radio used costs around £20 on auction sites

The project can run for hours on batteries

The rotary encoders are the popular KY040 type

Raphaël wrote a Python library for the KY040s

Tuning into to GTA Radio

“I thought of a way to listen to the radio stations ‘in context’ without launching the game,” says Raphaël. “A radio set was the perfect choice, because: first, I had a spare one on hand; second, being able to move between the stations would make it real, like it’s taken right out of the game.”

Raphaël’s radio plays five stations from the game in real-time. The radio features a ‘tuning’ knob (a rotary encoder) that switches between each station, complete with cross-fade. When you’re listening to one station, the others continue to play silently, making for a more realistic experience. “I was really looking forward to turning that knob, changing station, and then coming back to the first station to see it has lived its life without me listening to it! That little feature is what makes it real in my opinion.”

Building a GTA radio

The hardware side of the project was straightforward enough: a Raspberry Pi 3, two rotary encoders (tuning and volume), with an amplifier to power the original speaker. The challenges lay in the software. The Pi would have to be playing five channels concurrently, one per station. Would it be able to handle it? “The audio was really glitchy when playing multiple files with the built-in Raspberry Pi DAC,” recalls Raphaël, “so I bought a cheap USB DAC (kind of a sound-card-on-a-stick) to offload this work.”

A further challenge was to be able to elegantly cross-fade between each station, rather than a straight, jarring cut. “I also struggled to find an audio mixer Python library that fitted my needs (controlling volume and position of multiple audio tracks) and benchmarked all of them before choosing swmixer.”

After some maths to work out an elegant ‘fade’, the project was complete. A hit with the community, it was featured on many popular maker sites, including the Raspberry Pi Foundation’s blog.

Are there any further plans for the radio? “A feature that was requested a lot was to add static between stations to make it even more real,” says Raphaël. “I could also optimise the code to not play every track at the same time and rather only play audible stations. In the meantime, every contribution is welcome on the GitHub repository."

See also: