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

Posted: 5/27/2018 3:30:33 PM

From: Northern NJ, USA

Joined: 2/17/2012

Axis Processing Update

Yesterday I thought I'd take a more or less final look at the assembly code that processes the axis information.  The main thing that was bugging me was the borderline OK behavior of the volume side when set to non-inverting mode sense, or what most people think of as "normal" where farther = louder response.  The sensitivity and offset controls were working fine for the "abnormal" mode where closer = louder.  Here is what I have in there now for both the pitch and volume axes:

The number comes from the down-sampling, acquisition, & filtering section (CIC & 4th order IIR) to get nulled via K0.  The minimum is limited to 1 so as to fix inverse overflow downstream.  This is converted to a fractional float, LOG2 is taken, K1 is fractionally multiplied and negated, and then EXP2 is taken to complete the linearization.  The new thing here is K2, which pulls the result center down to the x axis to make it +/-.  After this it is multiplied by K3 (sensitivity) and offset via K4, after which it is converted to an unsigned integer and fed to the rest of the logic.

K2 is a semi-constant in the range 3 to 12.  The value is chosen to place zero roughly in the middle of the range, so as to "pivot" the result via multiplication with K3.  It's a different value for the pitch vs the volume side, it is strongly influenced by the oscillator parameters and K1, and it has a lot of control over the normal vs. abnormal mode of the volume side, so I'm thinking it should be a system parameter rather than a hard-coded constant in the assembly.  I don't like adding variable parameters to things as just one more increases the complexity of adjustment geometrically, but what do you do?  It will largely be a set & forget thing like linearity.

The sign of K3 is used to control the sense of the axis (negative for the pitch side and "abnormal" volume side).  Note that K3 and K4 have switched positions from the old way I was doing things here.  You really want to bring the thing to the axis (-K2), tilt (*K3), then offset (+K4) and in that order.  There's no need to restore K2 after doing K3, as K4 will swamp K2 in this scenario.

Posted: 6/4/2018 1:07:10 PM

From: Northern NJ, USA

Joined: 2/17/2012


Thanks for the interest folks!  It's been a week or so of heavy volunteering, then the muffler on the car fell off, etc.  Hopefully back to some prototype improvements soon.  I've got some ideas about alias reduction that I need to explore via spreadsheet.

Posted: 6/4/2018 5:10:13 PM

From: 60 Miles North of San Diego, CA

Joined: 10/1/2014

Congratulations dewster (Eric), I have followed your research from the very beginning. It has been an interesting journey, are we there yet? I gotta go pee.

Posted: 6/4/2018 5:56:32 PM

Joined: 11/25/2017


Thank you Eric for sharing your project and your knowledge. I haven't followed the complete thread but, your work is a great inspiration for my own theremin project. And maybe for some further theremins.


Posted: 6/4/2018 7:55:45 PM

From: Theremin Motherland

Joined: 11/13/2005

dewster I beleive in you!

Posted: 6/4/2018 9:26:14 PM

From: germany, kiel

Joined: 5/10/2007

Dewster - undoubtedly your project is interesting. 

Posted: 6/8/2018 11:02:58 PM

From: Northern NJ, USA

Joined: 2/17/2012

Gerd, ILYA, DOMINIK, thanks so much for the encouragement!  

I post mainly as an engineering diary - to document what I'm doing, and to keep something of a mental focus.  The camaraderie is definitetly a plus!


Patent US6806413B1 (Oscillator providing waveform having dynamically continuously variable waveshape)

Ran across this patent (link) while reading a paper on anti-aliasing oscillators.  Did an Excel simulation of it (link). 

The basic idea is extremely similar to my exponential phase distortion glottal oscillator that I'm using in the prototype, but it uses the distorted phase directly rather than running it through a sine function.

Both forms in the paper suffer from amplitude variation with n and have significant aliasing for higher frequencies and higher harmonic settings.  For the lowest harmonic settings both give diminished even harmonics, though the 2nd form is worse here.  And both forms devolve to a second order polynomial approximation of cosine for the minimal harmonic setting, hence the residual odd harmonics.  Neither control the harmonics in an ideal non-pole type way (where the harmonic roll-off dB is a straight line regardless of setting) though neither does my PD method.

1st form: n less than 1.5 or so gives diminished even harmonics.  The harmonic roll-off is fairly linear between 1.5 and 2, and above this the harmonic envelope is fairly linear up to 5 or so with diminished fundamental, and above 5 the envelope is a downward inflected arc which diminishes the lower harmonics as well.

2nd form: n less than 0.65 or so gives diminished even harmonics.  The harmonic roll-off is fairly linear between 0.65 and 0, but above 0.65 the fundamental is accentuated, and there is a general accentuation of higher harmonics overall upward inflected arc.

The patent was issued 2004 and presumably expires in 2024, which I'm OK with as I can't really use the ideas in it.  It's nice and all but IMO it's so generic that what it describes shouldn't be patentable (~ham sandwich).  Patents like this impede progress.


Not a real productive couple of days.  Tried restricting harmonic content to limit aliasing via the power input, which works to some degree but I'm not super happy with it.  Tried using slew limiting and low pass filtering on the phase signal, which was pretty much a bust.  This alias stuff is really tough.

Posted: 6/10/2018 9:51:42 PM

From: Northern NJ, USA

Joined: 2/17/2012

Noodling With The Best

Spent the afternoon noodling around to Amethyste & Doug Hammer's excellent CD "Secret World" (link).  Lush piano, and Amethyste has such amazing pitch, volume control, and nicely seasoned vibrato.

I set the prototype to female vocal and lowered the harmonic content to give it a more ethereal sound.  Wish I had a reverb pedal to spook it up even more. I'm not that great but I can sound semi-OK now and then when "virtually jamming" with the masters! ;-)  "Crystal Water" is particularly fun to play along with.

The tuner patterns reveal the various keys they're playing in, and I'm getting better at straying from the C/Am pattern.

Posted: 6/10/2018 11:28:14 PM

From: Germany

Joined: 8/30/2014

"Wish I had a reverb pedal"

Hehe. I connected, as one of the first things after it basically worked, my Etherwave "sorta clone" to my cheap guitar tube amp with spring verb and some amount of preamp saturation. That did produce some interesting sounds. "Tortured cat from outerspace", is about my playing level.

Not pedals, but anyway, doesn't cost an arm or leg:

Such nice and clean UI. Scroll below the video, there's a box with a bunch of audio examples.
M100 fx processor

Posted: 6/11/2018 2:12:09 AM

From: Northern NJ, USA

Joined: 2/17/2012

The M100 looks and sounds nice, and is certainly priced right!  I dig the smaller form factor rather than rack mount.  And I'm not a fan of bending over to adjust knobs on footpedals, so who knows what I'm looking for.  Had a Lexicon MPX100 I kind of wish I'd held onto but it had input level issues.

You must be logged in to post a reply. Please log in or register for a new account.