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

Posted: 7/11/2013 3:21:46 PM
FredM

From: Eastleigh, Hampshire, U.K. ................................... Fred Mundell. ................................... Electronics Engineer. (Primarily Analogue) .. CV Synths 1974-1980 .. Theremin developer 2007 to present .. soon to be Developing / Trading as WaveCrafter.com . ...................................

Joined: 12/7/2007

"And Fred, you are a patenting fiend (with excellent ideas to back them up)!"

Lol ;-) .. A few years ago filing the initial patent application in the UK became on-line and free, but prior to that, each application + recorded postage etc cost me about £15.. Then there is the time drafting the patent specification to comply with the requirements - Calculating all the factors (including my time at the wages I was on) I recon each application cost me at least £100.

Revenue return has been in the order of about £30k - could bump this up to about £100k if I factor in the fact that I got a mortgage based on a letter from one of my clients (back in the '80s) to the effect that I would get substantial royalty payments from them (these payments never materialized)..

If I had personally progressed any of my patents through the whole process, I recon that rather than being in credit, I would probably be a few hundred k more in debt than I am.

I think that the way I do it is probably the only way a solo inventor can get any return - use the patent system to establish the basis of a claim, then pass the idea (and any potential rights) to a prospective developer for an agreed fixed non-returnable sum, and (less important) royalties, with them owning your application and being entirely and exclusively responsible for how they proceed.

The probability that a patent will make any money is extremely small - the costs for worth-while filing and protection are extremely high.. and the chance that some unknown entity filed a similar application a week before yours, and is progressing this in parrallel with yours is a surprisingly major and undetectable risk... Its a killer!

One can go through all the searches, have your patent inspector pass everything, have paid your £100k+ for the processes leading to  publication and granting of the patent - and a week after your patent is granted have this retracted because someone else with an earlier filing date has just completed their patent process and published. There is no way of knowing what other people are patenting until they publish.. so there is a window of uncertainty that can extend for a year or even sometimes more..

Let someone else with money to spare take that risk! - The crumbs that sometimes fall from the table of these people can be enough. One thing about these "crumbs" is that you never know when or if they will fall - in my case its almost been miraculous - every time that I have my back utterly against the wall with no hope in sight, an unexpected morsel drops in front of me and allows me to continue this stupid game for a little longer!

;-)

"as could higher resolution and faster capacitance measurement (timing two threshold like they do in MIDI keyboards)" - Dewster

Hey!  - thats one of the things I am (experimenting with) doing on my volume loop (almost) - Well, im actually looking at rate of change with the thresholds following a median determined by integrating the hands Z position - so movement of the hand which is more rapid than this integration TC can cross either the threshold below the median, or the threshold above it, and return a value (velocity if you like)... I did have a volume loop which only output the change - thought about using this for a 'bowing' action... But I dont think its any good for a theremin - perhaps ok for a theremin cello..

Fred.

Posted: 7/16/2013 2:26:04 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"I did have a volume loop which only output the change - thought about using this for a 'bowing' action... But I dont think its any good for a theremin - perhaps ok for a theremin cello.."  - FredM

Clever idea!  I'll have to investigate that when the prototype is up and running.

===============

Looking at linearity again - linearity is a total bear!  I've likely spent months on this alone.

I've come up empty in my efforts to find a clean, simple, easy to compute function that can compensate for note crowding at the antenna, which is driving me to piecewise solutions (as well as slowly insane).  Ideally this function would have few inputs, could be computed quickly with adds, multiplies, and shifts only, and would give variable inter-note spacing over the entire range as well.

I realized yesterday that my piecewise linearly interpolated octave gain approach is actually simple linear interpolation, which is non-linear in the pitch domain.  The fix is to either make the line segments shorter, or to make them higher order (curves).  I watched a couple of quadratic spline videos on YouTube yesterday (solved via gobs of simultaneous linear equations) which got me thinking of a simpler approach.  You don't want discontinuous slope at the connected points, so the first derivatives of the previous and this curve have to match here.  If you take the very first two points in the spline as slope only, then use this as input to fit a curve to the next point, then the math is really simple.  If delta x (x is the input pitch number, y is the output pitch number) is restricted to powers of 2 then the division necessary is just a shift.  I'm playing with a spreadsheet of this and it seems fairly promising:

http://www.mediafire.com/download/nh3h53sdumvoxmu/trivial_splines_2013-07-15.xls

 

Posted: 7/16/2013 4:47:41 PM
FredM

From: Eastleigh, Hampshire, U.K. ................................... Fred Mundell. ................................... Electronics Engineer. (Primarily Analogue) .. CV Synths 1974-1980 .. Theremin developer 2007 to present .. soon to be Developing / Trading as WaveCrafter.com . ...................................

Joined: 12/7/2007

"Clever idea!" - Dewster

Not my idea! - Many years ago I read a report from a school / college inspector who was examining a theremin some students had put together.. He commented that on his first inspection, there was a fault with the volume loop - the students had AC coupled the output of its detector to the VCA, resulting in one having to move ones volume hand in order to hear the theremin.. He thought this "error" was a good idea, and advised the students to have a switch to allow this mode and the conventional mode.. The next time he saw the theremin it was working normally without the 'bowing' mode - the students had been advised by their tutor to "correct" the theremin and not add this "feature".

I have never been able to find this report again.

"trivial" splines - LOL ;-) ... It looks like a good idea!

" linearity is a total bear!  I've spent likely months on this alone " - Dewster

It is a total bear - I share your frustration, and likewise, I have spent many months on this aspect - and even more months on prototypes which have been abandoned because I never got the linearity I wanted... I had put the "problem" down to my lack of maths ability always thought that if I was better at maths, I would be able to find an easy way to obtain linearity - so its almost comforting to know that you are also having difficulty in this area!

I THINK that I have, at last, cracked the "problem" (at least to a degree where errors in linearity are not noticable or bothersome when playing) - but I could not present the maths for whats going on.. Its all done with analogue 'computation' and requires the AFE to generate a voltage proportional to a selected 'segment' of the antenna capacitance - this is then fed to some damn wierd circuitry (based on analogue multiplication) which produces two output voltages proportional (but 'shaped') to the input voltage - these 'shaped' voltages are curved opposingly - so that when summed equally (knob in mid position), the response is usually close to linear - but the mixing can be adjusted by the player, one can 'bend' the curve either towards "antenna close" compression or "far antenna" compression....

There are some costs though - I have not found any way to get linearity to continue close to the antenna and maintain linearity far from the antenna (the bass end) - so about 10cm closest to the antenna is lost - this requires seperate tuning of two "null" points.. I set the antenna voltage so it is 10V at 10cm, and 0V at the "true" null point (ideally tuned to between about 60-70 cm) - LED's display these "null" points.

Being voltage controlled, the pitch span and actual musical tuning is seperately adjustable - as it would be with a digital system using this kind of front end.

I do, however, suspect that "dual nulling" will be difficult for theremin "old timers" to get used to.. I really do wish there was another way - AFAICS your scheme would have a single tuning control, and if you can achieve linearity through 'splines' should be a lot more familiar to thereminists and a lot easier to implement (my shaping is not easy to implement - in addition to the front end stuff and the care needed to compensate for thermal drift, the analogue multipliers and shaping circuits need to have ovened transistors, and to be stable to less than 2mV if the instrument is set for 5 octaves coverage).. Yeah, I cracked the "problem" - But was there really a massive "problem" worthy of the effort to "crack" it, there in the first place ?

The following is blasphemy!

And I end up coming back again and again to the question, "How important is linearity REALLY ?" - I now suspect that its not nearly as important as us engineering perfectionists think it is - Just look at the instruments people are playing, and the instruments which have been produced recently, and the claims and endorsements given to instruments which cannot be anywhere near the degree of linearity we would even look at...

Is it perhaps that there are two groups of people - those who have the inate ability (and enough will and motivation) to play most theremins, despite them having linearity us engineers would (or do) despise.. And those without ability or will / determination, who delude themselves into believing they can play, and who make unfounded declarations regarding the linearity of their theremin?

I suspect that at least some of the above is true - its certainly true for me.. I have hated every EW I have played, have found them impossible to play - I even found the Enkelaar a more playable / likable instrument... If I did not know better, I would, based on my expierience, vehemently declare that the Enkelaar was MUCH more linear that the EW.. I would declare that the TVox was the most linear theremin, that the E-Pro on its bass setting (which is telling - because the E-Pro has identical linearity on all settings) was ok, but not so good on other settings.... I think my "head state" and perhaps the sound has as much influence on my perception of linearity as anything else..... I could play the TVox Tour better than I could play any other theremin - was this because I liked the sound, and had seen that it was Lydia's choice instrument?

My "conviction" about the importance of linearity is quite subdued now - Yeah, after the months ive spent, I dont intend to change direction.. If nothing else, having the ability to present a real specification showing a chart of the instruments linearity should go some way, when combined with sound samples and videos, to impress potential customers..

But I think that for the few truly 'pro' thereminists in the world, some deviation from 'perfect' linearity is fine - they wont even notice - they play as part of a 'closed loop' system and each time they are in the theremins field they become one with the instrument.

And those who do not become 'one' with the instrument, or do not have an accurate internal pitch 'reference' will probably gain little even if the theremin is perfectly linear..

I personally think that as long as a theremin is not grossly non-linear - as long as it has a few playable octaves with reasonably spaced intervals, the majority of Theremin Wanna-be's will have other factors influencing their playing (and their "feeling" about their theremin) far more than the non-linearity will.

As I say - Blasphemy! .... I may be wrong about all the above - In many ways I hope I am wrong - its entirely contrary to almost everything I believed and said before, and if true invalidates most of my "purpose" and "direction" of the last 5 years!

Fred.

 

Posted: 7/16/2013 6:06:44 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

I was hoping once I had a reasonable formula for the antenna / hand capacitance that linearity corrections would directly (or indirectly) follow.  But an "inverse" formula is perhaps too complicated for a simple processor as it would have to use transcendental functions.  However, precalculating spline points is entirely reasonable if the resulting fit is sufficiently good.

As I believe you have found Fred, it seems near field and far field note crowding must be dealt with separately.  And it would be really nice to incorporate continuous adjustment to overall note spacing as well.

So the ideal linearizing stage would perhaps have three non-interacting controls:  one for the near field, one for the far field, and one to change overall note spacing.  I'm hoping that setting the null point will function as the third here.  And I'm really hoping to find a method that drift won't throw all out of whack.

From "playing" my prototype I see there is really only one null point that gives decent linearity in the mid field - and this rigidly ties one to a fixed note spacing (unless a square root function or similar fractional power function is employed).  Veteran players may be able to compensate for non-linearity, but I believe it is something that stymies players who are new to the instrument.  The ability to change the overall note spacing to suit one's most comfortable playing style seems almost as important as linearity.

Posted: 7/16/2013 10:35:43 PM
FredM

From: Eastleigh, Hampshire, U.K. ................................... Fred Mundell. ................................... Electronics Engineer. (Primarily Analogue) .. CV Synths 1974-1980 .. Theremin developer 2007 to present .. soon to be Developing / Trading as WaveCrafter.com . ...................................

Joined: 12/7/2007

"From "playing" my prototype I see there is really only one null point that gives decent linearity in the mid field - and this rigidly ties one to a fixed note spacing (unless a square root function or similar fractional power function is employed)" ...  "The ability to change the overall note spacing to suit one's most comfortable playing style seems almost as important as linearity." - Dewster

It seems that we have arrived at essentially the same conclusions.. in particular "The ability to change the overall note spacing to suit one's most comfortable playing style seems almost as important as linearity."  is I think absolutely spot on, with the exception that I think it could be of much more importance - that the ability to 'stretch' the note spacing, even if this spacing's linearity is not great, could be of greatest benefit to newcomers to the theremin.

I think that the seperation of the "controller front end" from the "sound engine" (whether the sound engine is digital or analogue) enables the above.. And that this "seperation" is what will give our theremins the "edge"... I also think that future theremins will be built this way, and that it is a natural topological evolution - One which Bob Moog was probably the first to explore.

In my case, I generate a voltage from the front end which is as close to linearly proportional to distance as possible (and when I say linear here, I am talking linear - not musically "linear") - having a voltage from 0 to 7 volts driving 1V / Octave voice modules, and feeding this CV into a potentiometer, allows the playing field to cover any number of octaves from 0 to 7.. In fact I allow adjustment from 3 to 7 octaves.. the less octaves, the greater the distance between semitones - a beginner should, I think, start with 3 octaves.... But add the ability to shift the register in octave steps by adding or subtracting 1V per octave, and 3 or 4 octaves in the field will probably be fine for all thereminists - I doubt that more than 5 octaves crammed into 60cm is really usable for precision playing even if linearity was perfect... 1cm per semitone is I think about as tight as one can really go for all but the most able players, and I think that if the note spacing reduces below this anywhere in the playing field, such a zone becomes unplayable - or at least unplayable for most, and completely unplayable for me - oh, one can get close to the key, close enough to perhaps produce a sequence someone can identify a tune from - but each semitone is off and wandering by a truly horrible degree .. For me 1.5cm is a really comfortable semitone spacing, notes are far enough apart to allow easy playing with reasonable accuracy.

At present I have 4 user controls related to "controller" tuning (each voice has a seperate independent pitch tuning knob - and all voices track the controller, so can be independently detuned from each other)  - One is the "near field null" that sets the position close to the antenna beyond which change is ignored - this is optimally set for beween 20 and 10 cm. The next is far field or "normal" null, optimally set at 60 to 70cm this sets the position corresponding to 0V output - going further away than this point nulls the theremin. The next is a linearity control - In mid position, this should give the best linearity - CCW rotation compresses at the near side and stretches the far side, CW compresses the far side and stretches the near side. Finally there is a "gain" or "span" control - this simply determines the number of octaves covered in the field from the "near field null" point to the  "far field null" point - It effectively sets the voltage at the "near field null" point - this can be set to anything from 3V to 7V (giving a span of anything from 3 to 7 octaves) The voltage output at the "far field" null is always zero.

The near and far field null controls are a bit interactive at present, not too much of a pain, but something I want to fix or at least reduce if possible.. I have managed to get rid of any interaction from other controls. 

As for "unless a square root function or similar fractional power function is employed", I think this is where analogue processing of raw capacitance derived voltage has perhaps an advantage over digital - Effectively, this is what I am doing... Deriving square / square root and other fractional power functions is quite easy to achieve with precision multipliers etc - and there are some really good quad multipliers available from ICHaus... Not cheap, but simple and precise - add a BJT based exponential converter or two and lots of presets ;-) and one can get a good adjustable linearity curve... I am now trying to simplify it - by perhaps sacrificing a little bit of the linearity... Lots of the stuff was included to try to squeeze linearity from the 10cm closest to the antenna - but it never gave a worthwhile improvement, so I have decided to write off the nearest 10cm..

I think that with your Hive processor you will probably be able to match my analogue processor, particularly if you sacrifice one end of the field as I have done.. I believe that the antenna side is the side which is of least importance - Mid and far fields are the critical ones, I think - And I think that some compression as pitch gets higher is acceptable - but that any compression as the pitch gets lower is far less acceptable.

I do fear that saying the above is tempting the theremin demons and thereminists to prove me wrong! ;-)

Fred.

Posted: 7/19/2013 10:57:36 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

I was really hoping just a couple of trivial quadratic splines would suffice to arbitrarily adjust the response, but after a lot of spreadsheeting it looks like one spline per octave is around the minimum needed to keep the result from being too "lumpy" (one spline per two octaves isn't good enough).  I haven't tried to linearize this way yet, but this approach is able to shift the note spacing around in a way that is fairly indistinguishable from the fractional power method, so it should be up to it.  Implementing trivial splines isn't entirely trivial, and they tend to form huge ripples unless you get the starting slope just right.

"Lots of the stuff was included to try to squeeze linearity from the 10cm closest to the antenna - but it never gave a worthwhile improvement, so I have decided to write off the nearest 10cm.."  - FredM

Not surprising, I haven't yet found a mathematically simple fix for this region.  If I could exponentiate quickly I'd entertain a brute force approach (log2, do some linear stuff, then 2^n) and dispense with all of this other nonsense.  Maybe I should shelf this for now, build a coil winder, and try out the capless oscillator topology (need some fresh hell).

Posted: 7/19/2013 11:39:04 PM
FredM

From: Eastleigh, Hampshire, U.K. ................................... Fred Mundell. ................................... Electronics Engineer. (Primarily Analogue) .. CV Synths 1974-1980 .. Theremin developer 2007 to present .. soon to be Developing / Trading as WaveCrafter.com . ...................................

Joined: 12/7/2007

"Not surprising, I haven't yet found a mathematically simple fix for this region.  If I could exponentiate quickly I'd entertain a brute force approach (log2, do some linear stuff, then 2^n) and dispense with all of this other nonsense.  Maybe I should shelf this for now, build a coil winder, and try out the capless oscillator topology (need some fresh hell)."
- Dewster

LOL ;-) .... That's almost (I think*) exactly what I am doing with analogue computation - *I ended up just messing with exponentiation and multipliers - squaring the inverted voltage and putting this into an exponentiator -  started by trying to work out the math's and build the blocks to perform the math's - but it sort of degenerated into a bread-boarded mess which worked, but certainly isnt what I started out to do..

- I haven't reverse engineered it yet to determine what functions I am actually implementing - Not sure im going to bother though - the starting point (the slope of the antenna resonant circuit, and the operating point on this slope) is so critical that unless I get this spot-on in the simulation or mathematical analysis, everything which follows is just garbage..


Like you, my admiration for Lev increases the more I get into the theory - Seeing how every minor change to anything impacts critically on everything else, I believe Lev must have had a theoretical understanding way ahead of anything I could ever hope to attain - To me, it is obvious that he could not have developed the theremin by trial and error - he simply got it too quickly!

Nothing I have ever worked on in my life has been as humbling as the damn theremin - And even walking away from the challenge of combined sensor and sound engine, it still brings up unpleasant shocks now and then.. LOL - The theremin is the first device I have ever worked on that's got me to question whether I was ever fit to be an engineer!


"I haven't yet found a mathematically simple fix for this region" is really comforting to me! ;-) .. I have this continual self doubt which goes along the lines: "If I understood the math's better, I could crack this in minutes.." and often resort to frantically piling my desk full of my old engineering math's books, going back to basics to try to see what I am missing..


"(need some fresh hell)." - LOL ;-)  ... Masochism!

Perhaps thats the common personality disorder everyone here suffers from - players and developers and constructors.. the one thing we all have in common...

Fred.

Posted: 7/21/2013 2:15:08 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

I'm rethinking the digital Theremin pitch path.  My original cunning plan (which I hung on to like a pitbull on a fresh steak) was to take the PLL operating point number (equivalent to the heterodyned pitch), low pass filter it, linearize it somehow (a miracle occurs here), and use the result to directly generate pitch.  Log base 2 of this final number then feeds the LED "tuner".

The new improved plan is to low pass filter, log2, then linearize / tilt / offset (the result of which gets fed to the tuner) then do 2^n for the final pitch number. 

Log2 is a simple square shift loop for each decimal bit of the mantissa.  Exponentiation (2^n) where n is a real fixed point number isn't too difficult either because binary numbers are constructed of powers of 2. 

For example:

  5.5 = 101.1 = (1*2^2)+(0*2^1)+(1*2^0)+(1*2^-1). 

So:

  2^5.5 = 2^[(1*2^2)+(0*2^1)+(1*2^0)+(1*2^-1)]

  = (2^2^2)*(2^2^0)*(2^2^-1) = 16*2*1.414... = 45.254... 

So we need to find (and selectively multiply together) successive roots of 2 (difficult), or start at some 2^2^-m and square our way up (much easier but prone to error due to repeated squaring of the limited resolution base number).

In the log2 domain a simple quadratic (scaled square) term can simultaneously linearize both the near and far fields fairly well.  A very simple global multiplication adjusts inter-note spacing, and a very simple global addition adjusts the basic pitch operating point.

I added a worksheet to the Theremin simulation spreadsheet called "Linearization" to play around with this:

Above, you can see the original ~10 or so octaves of response (of which ~4 in the mid field are roughly linear) are linearized at the ends by subtracting a scaled square term, the inter-note spacing is reduced to a total of ~3 octaves via a simple multiplication, and the pitch offset is unchanged about the center point. 

The center point and square scale have to be readjusted somewhat when the null point is changed (or changes with temperature - doh!) but otherwise there isn't any interaction between the adjustments.  The linearization isn't perfect, but if it isn't too twitchy (which remains to be seen) it is likely good enough.  The continuous inter-note spacing adjustment alone is probably worth going this route.

Not sure how to set the center point in practice, but once it is set then fiddling with the square scale may be a simple matter of seeing how the pitch (mis)behaves very near the antenna.

New spreadsheet is here:

http://www.mediafire.com/download/23er36csaqx46p2/Theremin_simulation_v8_2013-07-12.xls

It would be a simple matter to have separate high and low square scaling factors, one for the near field and one for the far field, though this would likely be even more difficult to adjust correctly.  (From my tests without any linearity correction, it seems that if the null point is set to somewhere around the distance of the player's body and the playing hand is positioned between the antenna and body, then the far field is automatically roughly linearized due to a ratiometric (?) capacitance thing going on - I believe this is why a lot of Thereminists appear to play the far field very close to their chests.)

Posted: 7/26/2013 11:03:25 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Just upped a spreadsheet that shows how to do log2 and exp2:

http://www.mediafire.com/download/i3b6xi5q5t5j52y/log2_exp2_2013-07-26.xls

The function exp2 (2^n) is not too surprisingly the opposite of log2, but successive square roots are costly to compute on the fly so successive squaring of the smallest root is used instead with a tiny (LSB) "fudge factor" optionally applied each time in order to reign in both local and cumulative truncation error (this is quite effective).  I haven't coded it up as a Hive subroutine yet but it seems straightforward.

Posted: 7/30/2013 4:04:20 AM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

I wound my first combined air core transformer / EQ coil today!  It's sitting on my workbench, resonating @ ~780 kHz to stimulation from a function generator, with drive and detection relative phase displayed on the scope.  This is the heart of my novel "capless" oscillator design, where the tank and EQ coils resonate only with the antenna & hand capacitance, there are no capacitive components otherwise.

Above is my winding jig.  The wire feeds from the back under the coil, under the copper pipe in the front, and up to the coil in front.  This arrangement allows me to easily rest my hand on the copper pipe and my index finger at the winding point to direct the placement.  I used plumbing knock-outs to hold the tube on the 5/16" threaded rod.  Those are 4" angle irons with the left one slotted on the top for quick release, nothing fancy.  The winding crank diameter is too small, it will be replaced.

A rough measurement is all that is necessary for a digital Theremin.  50 mm of 34 gauge AWG wire tightly wound on on a 60 mm diameter former (2" PVC) gives ~300 turns and ~4 mH.  The 50 mm spacing gives negligible coupling of k=0.036 or so between the left and right windings.  The coil on the left is the EQ section.  The coil on the right got an identical second layer on top with much higher coupling (measured k=0.983) to form the tank transformer.  Winding each coil took about 5 minutes, the fiddly stuff later (securing the end windings with nail polish, connecting wire wrap wire, heat shrinking the whole deal) took an hour or more.  I lightly sanded the PVC before winding which cleaned it up and maybe helped the wire grip a bit better.

Here it is sitting on my workbench, sporting clear heatshrink tubing and hooked up to life support, transformer winding on the bottom & EQ on top. 

The primary / secondary turns interwinding capacitance is quite high (it measures 3043 pF!) which I believe is giving me less phase delay @ peak response than the 180 degrees I was expecting (see scope above; interwinding capacitance unfortunately isn't included in my spreadsheet sim.).  I think I need to remove the primary, install a 2 mm or so spacer, and rewind it, which should give ~k=0.9 and a capacitance reduction factor of ~40.  Otherwise it qualitatively seems quite sensitive to my hand near the jerry rigged antenna.  The entire EQ end is very sensitive to proximity, I can see why this coil is physically mounted vertically directly under the pitch antenna in Theremin's own designs.

Encouraging and interesting stuff!  I wonder how thermally stable it will prove to be...

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