Let's Design and Build a (mostly) Digital Theremin!

I've been beavering away on this project for more than three months and it's finally bearing solid fruit. It's an extension of various projects and investigations I've worked on in the past: capacitance sensing, digital phase locked loops, averaging to trade response time for reduced noise and increased precision, etc.

The Analog Front End (AFE) is simple enough that anyone with basic electronic skills could build it. In fact mine is currently on a small plastic breadboard mounted in an alumimum project box. The LC resonance point is around 700kHz with drive and quadrature maintained by the FPGA. Antenna construction incorporates the "linearizing" coil within, and is quite a bit better IMO than the various "plumbing" solutions on professinal Theremin products. As for the digital circuitry in the FPGA: The pitch section is working almost as well as I could hope - it is smooth, responsive, reasonably stable, and surprisingly linear without correction (except for right at the antenna where it becomes a bit crampt - still thinking about this but it's less urgent than I initially thought it would be). It "sees me" out to more than a meter, and I'm getting around 10 octaves out of it with 8 of them fairly linear. I also have the LED "tuner" section up and running (though without the full complement of LEDs) - quite fun to see it work, it's also quite responsive, and after using it for an hour or so it strikes me as an essential element for the Theremin.

The FPGA demo board I'm using is an old Xilinx Spartan 3 model and I think this is where most will run into trouble. I'll need to segue over to board with more availability if this project gets to the commercial stage. I've been avoiding hardware multipliers in hopes of targeting something small and inexpensive like the Lattice MachXO for which inexpensive demo boards exist.

There is of course quite a bit more work to be done:- Timbres other than the current simple square wave output.- Left hand control over volume and perhaps one or more other parameters.- Ergonomics and user interface.- Prototype on stand with built-in amp(s) and speaker(s).

Famous last words as you never know when a design will blow up in your face, but with the AFE, pitch, and LED tuner sections operating on my bench I feel I'm over the major hump of this feasibility study.

I think that I will rather not jump in. Words like digital, FPGA, etc., are rather contradictory when it comes to my imagination of theremin technology. But that is my personal thing.

A pitch range of 10 octaves sounds interesting — but only for engineers. Linearity is only one half of the work, tone spacing is the other half, at least for the precision player. Consider an octave spacing of 4" as the minimum and you will end up with a 40" wide pitch field. I'm not sure if you will find a player who can handle that with ease. When it comes to play higher tones, the player will have to move his body at least partly into the field and then good bye linearity...

You should consider cooperating with one ore more professional theremin players of all techniques and styles and meet them often with your prototypes during theremin workshops and conventions. Only after the majority of them approved your circuit, you could present it to the grand public in order to prevent deception on both sides, yours and your future clients'.

"I think that I will rather not jump in. Words like digital, FPGA, etc., are rather contradictory when it comes to my imagination of theremin technology. But that is my personal thing."

It's just applied DSP techniques. Rather than heterodyning two oscillators, the operational point of the DPLL (a number) is subtracted from a fixed number close to it, producing the difference numerically and with a single oscillator. The NCO in the DPLL is phase dithered to make it behave like a continuous oscillator, even though it is clocked by a 50MHz crystal oscillator. Works like a champ.

"A pitch range of 10 octaves sounds interesting — but only for engineers. Linearity is only one half of the work, tone spacing is the other half, at least for the precision player. Consider an octave spacing of 4" as the minimum and you will end up with a 40" wide pitch field. I'm not sure if you will find a player who can handle that with ease. When it comes to play higher tones, the player will have to move his body at least partly into the field and then good bye linearity..."

I agree that linearity is a slippery subject, and that the position of one's body has a large effect on it. My circuit provides an approximate octave pitch change between an open hand pointed at the center of the antenna and a closed fist. I have to move my body back some to get similar octave spacing farther out. The pitches within the octaves are continuous and evenly spaced (I can see this with the tuner). Indeed, there is no reason for them to be oddly spaced as I am not currently applying any correction to the pitch in the digital section. [EDIT] Oh, I see you are talking about tone spacing in terms of how wide the octaves per hand movement are. No provision for changing that yet, though the zero calibration can be performed closer or farther from the antenna, but this profoundly affects linearity (as it does on a conventional analog Theremin).

"You should consider cooperating with one ore more professional theremin players of all techniques and styles and meet them often with your prototypes during theremin workshops and conventions. Only after the majority of them approved your circuit, you could present it to the grand public in order to prevent deception on both sides, yours and your future clients'."

Yes I have been considering this, but for now am relying on my own musical instincts.

For the left hand I'm thinking up/down for volume, and in/out (closer/farther from the player's body) for timbre of some sort. For that I'd need a double sensor for the left hand and capacitance mixing antennas. And I know I shouldn't, but I still want to have the left hand physically anchored somehow, it would make the playing of the pitch side so much easier and more intuitive.

Christopher, I agree that voice selection is critical, am aiming for something like human, at least at first. I must say that your enthusiasm is infectious and your insights most inspiring - why are you winding your building efforts down?

I am replying to your post from your YAEWSBM thread - this seems like a more appropriate place..

You say:"The waveform could be changed on a per-sampling clock period or even faster (the beauty of doing this in logic rather than software)."

Yes, doing this in software would be a problem... However, I do not really understand how doing this is possible, even with logic..

Discussing the issue of quantizing, you stated (on the YAEWSBM thread) “Any resolution is possible if the low pass filter can be set low enough, but response time suffers if it is set too low, so there is a tradeoff” And from this, it would seem impossible to update the audio waveform on a “per-sampling clock period” – It seems to me that any latency inherent in computing / filtering the input capacitance value must be the minimum possible update time.

The above probably doesn’t matter one iota if the (reading) update rate (or filter TC) is not too long, and if this latency is constant – a couple (IMO, up to a maximum of 10ms) of ms latency IF this latency is constant – and if one then updates the audio wave-shape at a frequency >> 20kHz you should, I think, be able to emulate a mixed signal theremin adequately.

If you get the sensing accurate enough and fast enough, you should theoretically be able to emulate any theremin and create theremins which have not existed before – You have a numeric value which you can do whatever you want with – control digital oscillators and filters, cause the harmonic content to vary with pitch in a way which can emulate oscillator syncing – whatever you want…

One day, someone will achieve this – I wish you all the best!

If I was investing time / money into a FPGA /CPLD / DSP based theremin, I think I would be looking at producing a unit which concentrated on rapid acquisition of position, and which, from this, computed the log of the acquired data to give an adjustable linearity correction and output this as a 1V/octave CV..

It is easy to make any theremin voltage controlled! (yes – it is! ;-) and it is easy to set registers, change the range (number of octaves spanned)

I am not trying to persuade you to change direction (Don’t! I have been switching direction continuously in my theremin developments, and this is probably the main reason Im broke!) – But, if while playing with your FPGA you see an easy way to provide a linearized CV, let me know!I believe the future is a hybrid : Front-end which deals with the linearity and stability issues and allows control of range etc, and this to be followed by conventional (or unconventional) heterodyning analogue / mixed signal theremin which is ‘liberated’ from the constraints imposed by the antenna and its circuitry.

Thank you for your thoughtful comments Fred, and thank you also for addressing them here where it is more germane.

"If I was investing time / money into a FPGA /CPLD / DSP based theremin, I think I would be looking at producing a unit which concentrated on rapid acquisition of position, and which, from this, computed the log of the acquired data to give an adjustable linearity correction and output this as a 1V/octave CV.."

I agree entirely with the rapid acquisition part. This is why I spent about a month doing math and spreadsheet sims, to see if I could acquire a number with enough precision quickly enough. My current prototype uses a single pole low pass digital filter and is right on the edge in terms of resolution and response time. I will probably try a higher order filter soon to see if that improves things. One could also do adaptive or tracking filtering here, as lower frequencies don't need to change as quickly, and you could get some added precision in this region where the SNR is tanking.

The current operating point is roughly exponential with hand distance (see video above) so I'm using this directly for pitch. It would be nice to be able to offset this and fine tune the linearity and such, but for now I'm pretty happy with it.

The "tuner" has a module that converts the current operating point to the log2 of that number (using the al Kashi method) after which it is multiplied by 12 or 24 to get the individual note LEDs (with pulse width modulation for the decimal portion). One could tap into this for other purposes I suppose, but the the natural dithering from the noise and jitter would become non-linear and therefore less useful downstream.

"I believe the future is a hybrid : Front-end which deals with the linearity and stability issues and allows control of range etc..."

The AFE seems pretty darn stable to me, certainly more stable than my EWS, though that is a subjective statement. It is a quadrature locked DPLL and so is only a single oscillator, not two drifting apart or together. When I was researching LC oscillators I came to the conclusion that a single transistor was just too simple to demand very much of, the resonance point could possibly be more a matter of gain than of phase. So I abandoned that route.

Every increase of 1V causes the 'slave' devices to increase their frequency by one octave (I will use the term 'slave' for any 1V/octave voltage controlled 'module' - these are mainly oscillators and filters - VCO's and VCF's - but it is possible to adapt any theremin pitch circuit to accept a 1V/Octave CV, giving one voltage control without losing anything from the theremin)

Each module can have any voltage added (or subtracted) so can be independently tuned - their respective frequencies will be the exponential of the sum of all their CV inputs.. If you have 2 oscillators, both being driven from the same CV, and you add 1V to one of these, the oscillators will track the CV and maintain their pitch seperation at 1 octave, regardless of their pitch.

Ok - to theremins... If one has a "front end" (antenna and circuitry) which provides a voltage which linearly tracks the players hand position (capacitance) from the antenna, and one produces from this a voltage of 10V when the hand is closest to the antenna, and 0V when the hand is (say) 1m from the antenna, and the voltage is linear (decreases by 1V for every 10cm from the antenna) one has what I am seeking - and here's why:

You have 10V over your playing area - feed this to a VCO and you have 10 octaves... Devide this 10V (simple potential divider) by half, and you have 5 octaves over your playing area - You can divide by whatever quantity you want, cover however many octaves you want, and linearity is maintained.

Now, we want 3 octaves, and we dont want to go below E1 (low string bass - 41 Hz) We set the divider for a span of 3 octaves (output voltage is 3V close to the antenna, and 0V at 1m) and we add a voltage to this which raises this voltage so that 3 octaves are covered, starting at E1 (at 1m) and extending to E4 closest to the antenna.

And thats it, really - With such a system, one could adjust "to taste" - Even reducing the field length would be easy - one only wants to play from the antenna to 0.5m? simply clamp the output voltage when it gets to 5V, add whatever offset one wants, and away you go...

One thing I should mention - For any adapted theremin, issues such as its linearity are no longer relevant - the pitch of such a modified theremin will be absolutely determined by the CV - the EQ coil would be removed, and pitch control passed to an electronically variable capacitance controlled in a closed loop... But I am not going to divulge all right now (I may yet get back up and relaunch my business) - The principle can be derived from some prior posting of mine related to pitch-CV.

While linearized analog outputs might provide for some interesting interfacing to analog synth modules, I think I'd prefer to keep the values digital and confined to the Theremin. Theremins seem shaky enough on their own. MIDI is also possible, though I kind of loath it for various reasons I shan't go into. I feel instruments should be as self contained as possible.