Ultrasonic Theremin

By Russell Barnes. Posted

An inventive use of the Raspberry Pi that makes use of the kind of components you might have lying around the workshop

Thinking outside the box is what we like here at The MagPi. The Raspberry Pi is so versatile and so open that you can do so much with it that perhaps other people wouldn’t have dreamt of before. So here’s a good question: with a Raspberry Pi, some speakers, and an ultrasonic distance sensor used for robotics, what would you make? Linus Forslid decided to build a type of theremin.

The full article can be found in The MagPi 38

 A compact device with one purpose - this is Linus' complete Theremin

“A theremin is a device that measures distances to objects nearby and turns that into sound, so that when you move your hands around it, you can generate music,” Linus explains. It’s not exactly like a normal theremin, though. “Unlike a classic theremin, my project uses an ultrasound sensor rather than measuring electrical fields with antennas, and currently my project only has a single sensor, so you can only control the tone it produces. Eventually, I plan to add another so that the beat can also be manually controlled.”

Theremins were used to create the eerie, creepy music for classic sci‑fi films. Due to this and its unusual method of operation, the theremin has become intriguing to many musicians and techies, including Linus:

“I’ve always wanted a theremin, from the first day I heard of it. It’s just such a cool thing. As it turns out, though, an actual theremin is not cheap or easy to build, but this project was easily doable and I had almost all of the components at home already, so the cost was minimal as well. I decided to use a PC speaker instead of the Pi’s own audio jack and an external speaker, mostly because I could, in addition to it not requiring an additional power source.”

 The set up is quite simple, but works very well

The hardware is one thing, but actually translating it to sound, surely that takes a bit more work on the code to get it operational?

“Not really, I think.” Linus adapted some pre-existing code for the project. “The script that controls the theremin is coded in C using wiringPi, and it took maybe an hour to get it working. I’ve spent a couple of hours beyond that just tweaking the numbers to try out different sounds and find one I like. I wouldn’t say it was complex, even if the tuning took a while.”

 Wave your hand like you just don't care to get your spooky on

The whole process is deceptively simple then, even though it’s hardly your typical Pi-based project. There are a few caveats, however, and Linus’s Pi-powered theremin could do with a few improvements, as he explains:

“It’s surprisingly hard to operate well, as you need a very steady hand and good aim to get the exact tone you are after… I plan to add another sensor to control the beat of the sound. Right now, it is set entirely by the script, which means it’s basically static. By allowing the user to control the beat, my hope is that it will actually be useful as a musical instrument.”

From The MagPi store

Subscribe

Subscribe to the newsletter

Get every issue delivered directly to your inbox and keep up to date with the latest news, offers, events, and more.