Pitch and Volume Tracking MIDI interface for the Theremin

After I published some of my earlier videos I get asked on a regular basis if I can create a MIDI interface that would work with any Theremin. So after completing the vacuum tube Theremin, I thought it was about time I put something together.

The hardware tracks threshold crossings of the audio output and uses a fairly comprehensive look-up table to match the fundamental frequency detected with a corresponding MIDI note value (assuming a concert pitch of A= 440Hz).

Volume information is also integrated over time to produce and envelope function that is mapped to MIDI volume data.

(Click the diagram above for a larger version. This covers the basic audio input system.)

Since I was using the LM324 opamp I wanted the whole system to operate with just a Gnd / +5v supply. The first phase is just a biasing network to get the AC input signal up into the active range for the opamp. Then a fairly standard design envelope follower. Finally a differential amp to scale the output back down to positive 0 to +5v, a buffer, a low pass filter and straight into the Analog input of the ATMEGA328.

Pitch preview is even simpler – a threshold comparator generates a square wave, and then the ATMEGA processes this on a positive going interrupt pin.

The real work takes place inside the ATMEGA328 – I used a MIDI synth and the above circuits to generate a look-up table of values. This lookup table (takes up a lot of RAM – hence the 328 and not 168) handles the non-linearity of the system, and since the values were derived on the system being used to track pitch, it takes into account any discrepancies in timing.

There are currently four modes of operation:

PITCH – tracking the frequency and output a corresponding MIDI note.CNTRL – output MIDI controller data (currently set as #55 – general control #1)ARP 1 – read input from a MIDI keyboard and ‘arpeggiate’ the chord described using the same chord “shorthand” used by the Casio MT-65/70 keyboards (Maj / Min / b7 / Min7)ARP 2 – Construct an arpeggio around any chord combination held on the keyboard – up to 12 notes.

Volume data is transmitted in each of the modes. Switching modes can be accomplished via a footswitch, or panel switches.

So far I’ve been able to test it successfully with a PAIA Theremax, a Moog Etherwave, and the Keppinger Vacuum Tube Theremin – in all cases it performs very well.

It’s proven to be a very good training tool – as it shows you exactly where the notes are. With the addition of simple software to render the note on a computer screen you can test how linear the response of the Theremin is (I’ve even been able to plot the response on paper and use this as a playing guide.)

One of the criticisms of trying to interpret Theremin data using MIDI is the discrete nature of the digital form. Since the Theremin is a naturally continuous instrument a great deal of the expression can be lost when remapping the output into note data. Therefore a possible improvement would be to use the pitch detune information (currently driving the LED ladder) to operate the pitch bend function of the synthesizer – depending on how good the implementation of the synth engine is it should be possible to get a seamless transition of pitch from one note to the other. This would allow for the vibrato effect to be mapped out, with the 14 bits resolution operating over 1-2 tones. Hopefully this should prevent aliasing.

In the past I’ve just tried to use the pitch bend over a 2 octave range, but this is far from musical

There are software solutions out there, but they do involve having to take a laptop along to the gig.

I have designed a PCB that holds all the system components and power supply – if there is enough interest I might start selling these as a kit.

UPDATE : I made a slight change to the firmware so that the pitchbend is used to track pitch changes “in-between” whole semitones. Now the MIDI instrument tracks the Theremin pitch almost identically – with the same level of control and expression you get with the regular Theremin tone.

Now I have to quit making cool sound effects and do something musical with it

UPDATE UPDATE : I put together a complete set of plans available here, and uploaded a board you can buy from BatchPCB.

one year ago I built my own laserharp after downloading your documents. It was a really great pleasure. Your explanations and schematics were perfect.
So I’m more interested in (a).
But If you sell (b) or (c), it will be great too.
P.A

I’m trying to figure out a schematic for a theremin-like device that provides control voltage for electrical instruments – used to control the resistance like a pot, to affect the brightness of a light, to be picked up by a microcontroller and translated into digital messages – whatever. Can you point me in the right direction? It sounds like your fantastic project here is mostly for people who already have the theremin antenna hardware.

At the moment BatchPCB wants something like $65 + shipping for single boards. If I can get an order of 15 together then I can place the order somewhere else at a substantially lower cost. I can also redesign the board to be smaller – which will help with costs.

This is interesting…
” Therefore a possible improvement would be to use the pitch detune information (currently driving the LED ladder) to operate the pitch bend function of the synthesizer – depending on how good the implementation of the synth engine is it should be possible to get a seamless transition of pitch from one note to the other. ”

It seems like a huge opening for glitches, depending upon how happy the synth takes to that much midi data in a short time slot. Its been 20 years since I wrote midi code… but what if you were to anticipate what was coming next a few pitch bend updates before the transition (monitoring 1st and 2nd derivative)… and then send a new note on volume 0. The transition from old to new would then seemingly be possible with fewer commands, just pitch bend/volume… and you could shut down the old note in between additional pitch bend commands.

Again, its been many many years…came across your post as I was building a long wave theremin for a contest, and thought hey, making this midi would be cool… and after 10 minutes thought egads, what a rabbit hole, so I went looking to see whats changed since way back when.

When I first attempted it – I was only really looking to emulate the MidiVox – made by Moog and no longer available.

Once I had everything running I wondered how far I could go with the MIDI implementation and was quite pleasantly surprised to see how well modern synthesizers could handle the rapid stream of MIDI data (not sure how well an earlier hardware synth could cope)

OSC is actually a better protocol for Theremin connectivity – 32 bit values throughout and connectivity via USB 2.0, TCP/IP, or whatever high speed transport you want to use.

I have been designing my own synths using “SynthMaker” – and these are created from the ground-up to implement supplemental Theremin patches. In these synths note-on/off is ignored and the pitch is governed by the full width (14-bit) of the pitch bend message. Still discrete notes, but lots of microtonality.

I’m confused by something — does this only take CV as the input or does it take the audio signal? I have a regular Moog Etherwave (not the Plus that has the CV outputs). Would I be able to use it with this?

I have just finished assembly of your theremin interface to midi and trying
to start it.
I have two questions:

1. What should be the range of voltage outbound changes on 14 socket of
lm324 IC2D circuit?
2. How to set fuse bits by programming atmega circuit with external
programmer while having the file THEREMIN_MIDI_2011.cpp.hex generated in
arduino (programmer STK500 – Parallel High Voltage Programming, environment
AVR studio 4)

Hi Steve,
I’d be really interested in
(b) a PCB and preprogrammed chip,
OR Ideally…
(c) a complete kit with all parts,
As I’m just about to build a Jaycar MKII Theremin in a more sensible sized box than the original design. Hopefully with proper sized and spaced antenna it should make it a reasonably playable instrument.

So your design for pitch and volume to MIDI would be a great addition to it. Controlling my Novation Supernova II from the theremin would be fantastic.

Hi Stephan. I don’t have the programming environment for this processor. For me it would be really helpfull to have a programmed processor. Is that possible? The rest I’ll figure out myself. I’m building the Forbes theremin now. Would be nice to have the midi in it, and not inventing the wheel twice… (I use PICs at work and Philips LPC before, but your processor is not supported by MPLAB…

I have built both the Midi Camera and the Volume and Pitch MIDI Interface. The Camera works fine but I am having problems with the Tracker. There is no input through the Vol In JP5 connection, but the PP JP7 input works – except that as soon as there is any signal strong enough to register, the volume readout on the LCD & LED’s go to max. The MIDI Output doesn’t work either but the MIDI In does. I used the BatchPCB and the LCD117.

I am using an EtherWave Plus and have tried every combination of Audio output and Pitch Preview. I have adjusted the trimpots mentioned below as well as the controls on the EtherWave Plus.

The build passed all the tests and successfully uploaded the Theremin_MIDI_2011 sketch with the AFSoftSerial library imported (I did this a second time to be sure). There are a few notes that may or may not matter.

1) I used 10K trim pots from Radio Shack rather than Cermet. They seem to work correctly.
2) The connections for the switches on the BatchPCB did not work using pin 2 of JP 10 and pins 1&2 of JP11 but do with pins 1&2 of JP10 and pin 2 of JP11. (Pin 2 of JP10 is ground.)
3) The LCD serial lead has to be to pin 2 on JP 8 with power from JP12. The instructions were a little vague as to where to hook the LCD 117 but this looks like pin 10 of Atmega 168 shown on the schematic rather than pin 9 as described on page 21 of the assembly instructions. I did use a Boarduino with an Atmega 328, so might there be a difference in the chip?

I have traced Vol In JP5 as far as the LM124N socket and the components are of the right value and installed correctly. I changed the LM124N with the same results. I did recheck all the solder connections with a loop but did not start resoldering since everything seemed to check up to the LM124N socket.

Except for the Vol maxing immediately at 756 or so, the pitch readout and LED’s seem to work correctly when using PP in. The switches change the LCD display line from Pitch to Cont and Arp 1&2. The LCD registers MIDI in signals. but there is no MIDI output and Vol In is dead.

Your work is very well done and I appreciate all the effort it took. Thanks for your help with this and Merry Christmas. Professor Hall

Hi Stephen,
(or anyone else who has built one of these successfully, I guess)
I’m a total electronics novice and I’m about to purchase parts to assemble my pitch to midi board.. I was wondering whether part R3 should be a 3.3K resistor like it says in the parts list and on the batch PCB board itself, or a 3.9K resistor like it says in the step by step instructions? Thanks!
Casey

You are correct, the Pitch input should be a signal that just contains pitch data, and the volume should be one that contains both pitch and volume. For the different Theremin types there are different places in the circuit where you can tap this.

1) Can you elaborate on the difference between the PITCH and CNTRL mode? Currently I am learning the MIDI protocols, so I am novice when it comes to this stuff. From my understanding, when you set the MIDI channel as control change, does that mean that you change parameter of other MIDI devices (similar to the Roland FC-300 MIDI Footswitch) via Pitch-to-MIDI converter? Whereas in PITCH mode, it basically acts like a MIDI instrument, sending NOTE ON, Velocity, etc?

2)In the code you provided, I am having hard time locating the part where the button_state declares mode ARP2; I’ve only figured out that in ProcessButton is where you use the toggle switches to pick the mode operation. Can you help me pinpoint where you can choose ARP2?

3) As for the 3rd pin analog, have you thought of any extra feature that you may have thought of? I may twinkle little bit on that extra pin…

Now that BatchPCB appears to have gone the way of many businesses in this economy, is there any other source for the PCBs for this project? If not and I want to send it out to be fabricated, do you have any suggested vendors, or am I on my own?

Who is this guy?

Steve Hobley works for a software company, but in his spare time likes to deconstruct all the lovely consumer goods with a goal to make unique and interesting things.

A few years ago he posted a short clip of the laser harp he developed, solely to show friends back in the UK.

Automagically that one clip got picked up by Gizmodo, Engadget and a bunch of other tech journals. The end result (apart from a ton of views on Youtube) was to get hired as a consultant for Little Boots – creating a laser harp for her 2010 US tour.