IR Theremin – Using distance sensors with Pure Data and Max/MSP

IR Theremin is a simple application that uses x-OSC and a pair of infrared proximity sensors from sparkfun to recreate a basic Theremin. The demo patches are available in the project repository and provide simple starting points for connecting x-OSC to Pure Data (Pd-extended) or Max/MSP.

The Theremin was developed in the 1920s by the Russian scientist Léon Theremin. The instrument is notable as it does not require any physical contact to be played: pitch and volume are controlled by the proximity of the players hands to a pair of antennas (or IR distance sensors in our version). The resulting tones can be quite eerie and have featured in the soundtrack for the film Death Wish II and the opening sequence of the TV show Midsomer Murders.

IR-Theremin-Leon

The IR sensors have three connections: power (red), ground (black) and signal (yellow), which were connected to x-OSC’s VOUT, GND and analogue inputs as shown in the wiring diagram below. We secured all the electronics to a wooden tile using sugru. x-OSC was used in ad hock mode to create a WiFi network for us to join; in the video the SSID had been set to “x-OSC – IR Theremin”, via the settings web page (http://169.254.1.1). x-OSC was configured with an analogue sample rate set to 100 Hz and with inputs 1 and 2 set to analogue.

IR-Theremin-Wiring-Diagram

To decode the OSC messages we used the mrpeach objects which came packaged with Pd (extended). Our example patch maps the first analogue input onto the note range C1 to G9 which is synthesised using a single sine wave oscillator. The second analogue input is used to control the amplitude of the oscillator before the resulting tone is fed through a reverb object to add a creepy cavernous effect.

And finally, a treat for your ears and eyes. This video shows a complete walkthrough for connecting and setting up x-OSC to talk to the IR theremin Pd patch followed by a virtuosic performance that is guaranteed to disappoint.

IR-Theremin-Photo-512x288

Open-source resources are released under the Creative Commons Share-alike 3.0 unless an alternative licence is specified in source files.