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

Posted: 2/12/2018 7:14:36 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Good Filtering Info

1. J. O. Smith on the Chamberlin filter: link (Smith also does physical modeling work, it's all on his web pages.)

2. John Dattoro on filters and effects: link link link link (Dattoro is a refreshing blend of mathy, practical, and passionate; you can safely ignore the derivations and jump to his conclusions.  He gives the most in-depth and useful analysis of the Chamberlin I've seen anywhere.)

3. Zolzer DAFX book: link  (Zolzer designed a variation on the Chamberlin filter.)

4: Duane K. Wise on a Chamberlin variation: link (Wise has some other papers on audio filtering behind the stupid paywalls.)

The above because I'm taking another look at the topology of the filters I've implemented.  Some papers show the BP output as delayed, others not, and I'm wondering which I should use if I'm going to implement a fader control that varies from from all input to all output (have to watch the phase when mixing them or else bad things will happen).

[EDIT] I don't think one clock phase difference makes much difference when mixing, so it likely doesn't matter where BP gets tapped off of.  In Excel sim I'm seeing some strangeness associated with mixing HP and LP due to the grosser phase differences of their outputs.  I believe the right way to do this is via all-pass fed to the mixer, where the phase difference does the actual filtering and works for you.

Posted: 2/13/2018 10:45:47 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Volume Processing Times Infinity (nth time's the charm)

Can't believe how much time I've spent on this one dumb thing and with almost nothing to show for it.  I just realized that my "cheating" in the video above actually makes the most sense in a way, and is the most intuitive, playable, and comfortable.  You don't want to have to flick your hand quickly (velocity threshold) to have the envelope generator kick in, you instead want to merely move your hand past fixed positional threshold in space to trigger it, and use the velocity at the crossing to set the attack amplitude.  The position will necessarily be outside the normal playing field (or inside it if you have it set for farther = louder), and you don't want velocity kicking in when you're playing normally, so I believe this is the best approach all around.  Yarg...

Posted: 2/15/2018 12:22:22 AM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Decent Volume Envelope Triggering & Generation

A lot of time and effort went into this but it's working about as well as I had hoped (sorry about the whining):

Measuring velocity by sampling the volume position number with a difference in time of 48kHz (one PCM period).  Subtracting the two numbers as they pass the equivalent volume threshold of -48dB full scale gives the velocity, and we take the positive difference so it only triggers in one direction.  Then some gain, and I found a rough square root following this helps to tame things and gives better control over the variable velocity.  This is mixed back into the volume number and presented to a peak detector.  The detector obviously replaces any smaller input numbers with larger ones, and this is used to retain the attack velocity amplitude while the following accumulator works its way up to it by successively adding the attack number.  Once there, it successively subtracts the decay number until it reaches the input value, while also telling the peak detector to now follow its input.  Retriggering is automatic because the peak detector also compares its value to the accumulator value.

It took me a while to set the right volume threshold at which to measure the velocity.  -48dB is where all 4 LEDs on the bar graph are extinguished, and also very near the edge of audibility, which seems just about right.  If you snap back just a tad after triggering it then you don't hear any constant tone, and if you do want constant tone after a trigger it's right there with very little additional movement needed.  I added the square root about an hour ago and it seems to really help - there's probably a kinematics physics reason for it but I can't think of one right off.

Here's a quick video.  The koto sound is obviously just a percussive female vocal sound.  The chime sound is just a click (fast attack and decay of a sine wave) fed through the female formants set to really high Q.  The drum sound is a sine wave.  I should have included a reverse envelope, it does those pretty well too:

[UPDATE] Just improved the velocity detector.  It takes the peak positive velocity over the -60dB to -48dB range and spits it out for a single cycle at the -48dB boundary.  Negative velocities and positions outside this 30mm or so window (the way I currently have the volume sensitivity set, it's entirely adjustable) clear the peak and output 0.  Seems more responsive and reliable now, lower velocities are easier to do with higher trigger gains, which means less arm movement is required.

In case it isn't clear from the above discussions, the volume processing pipe is rather passive and really messes with the general response times, and the envelope is generated by the velocity spike going down it.  Unlike the pitch side, the volume side can take more of a hit in terms of absolute response time without too much trouble.  At any rate, setting the trigger gain to 0 and the attack and decay values rather high makes it all transparent.

[EDIT] All my dB figures in this post were off by a factor of 2!  They're fixed now.  The volume LED bargraph on the prototype has 12dB per LED (which is a 4:1 ratio).

Posted: 2/15/2018 11:33:07 AM
invisiblejelly

Joined: 3/18/2012

Excellent work dewster, what fun (and hard work) you have been having (doing).Do the different sounds respond differently on the pitch side?I thought the chime sound didn't seem to change a great deal on the pitch side even though you moved the pitch hand quite a bit.I really liked the koto and theremin combo....that alone seems like a nice instrument in itself, a 'therekoto'. That to me sounded really impressive.You would have a big market in Japan for a stand alone 'therekoto'.I couldn't quite tell from the video but can you do a softer and louder pluck?

Posted: 2/16/2018 12:50:03 AM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"Do the different sounds respond differently on the pitch side?I thought the chime sound didn't seem to change a great deal on the pitch side even though you moved the pitch hand quite a bit."  - invisiblejelly

The only thing changing during the chime part was the wave in the short attack / decay stimulating the filters, not the resonance of the formant filters themselves.  It's subtle, but it makes it sound like different composition mallets are being used, or the chime is being banged on in different locations.  I do have pitch following on other filters, just not the formants yet.  It's probably time to implement some kind of modulation matrix.

"I couldn't quite tell from the video but can you do a softer and louder pluck?"

Yes, and worked on that more today.  The square root helps tame the hand velocities, but LOG2 really tames them, and gives something of a variable velocity curve.  Multiplying the trigger before the LOG2 treatment with a small value favors softer amplitudes, larger values favor louder amplitudes.  It seems to be considerably easier to control the dynamics with LOG2 vs. SQRT.

Here's a quick video where I show reverse envelope, and soft, medium, and hard velocity curve:

Posted: 2/16/2018 1:16:33 PM
invisiblejelly

Joined: 3/18/2012

A very interesting instrument you have developed there.

BTW your theremin playing style (sound of music in your other video) reminds me of this guy's style.

about 42 seconds in....

https://www.youtube.com/watch?v=B3lq6U4PDZo

Posted: 2/16/2018 2:00:59 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"A very interesting instrument you have developed there."  - invisiblejelly

Thanks!  Have I mentioned that the pitch antenna is about a foot from a fluorescent desk lamp?  And that the volume antenna is about 2" from a particle board bench and a bunch of metal tools?   Auto-calibration (at power-up, and when I press one of the encoders) covers all of this, and I've never once heard it pick up any mains hum, even when listening through good headphones with the volume way up.  The mains filters gobble up a lot of the tiny processor memory, but man are they worth it.

"BTW your theremin playing style (sound of music in your other video) reminds me of this guy's style."

He's a decent player, and I like his composition, though the intervals in it don't look too hard, and I'm becoming wise to the techniques Thereminists use to hit notes, such as the slow correction he used a couple of times.  If you miss a note but correct it quickly enough it doesn't seem as bad.

Yesterday I set the pitch sensitivity on the prototype to that of a conventional Theremin and memories of EW ownership came rushing back.  I couldn't move my body at all because the tiniest thing threw my notes off, and controlling vibrato was more difficult.  Though I must say that dialing the sensitivity back to where I've been practicing means you need more exaggerated vibrato movements, which can be tiring, and can appear rather weirdly palsied.  I'm also out of shape on guitar and can only play for 10 or 15 minutes before my left hand fingertips start complaining, so I suppose tiring out on Theremin after about the same amount of time isn't too alarming.

One of the main things that makes developing a Theremin technique so difficult is the tension between the gestures needed to hit the pitch and induce the vibrato.  With a lowered sensitivity it seems easier to use my arm to hit the pitch and my hand to do the vibrato, though quick precise little notes are difficult with this approach.

Posted: 2/19/2018 2:41:10 AM
invisiblejelly

Joined: 3/18/2012

"The mains filters gobble up a lot of the tiny processor memory, but man are they worth it."

Maybe use batteries.The Harrison 302 uses just one nine volt battery.But I guess if you got lots of processing to do.

"Yesterday I set the pitch sensitivity on the prototype to that of a conventional Theremin and memories of EW ownership came rushing back"

I think the EW has too many octaves, 4 well spaced octaves is ideal for me...and not too high up the scale.A cello,which the theremin is based on...it's like a single string cello,and a cello has only 3 and 1/2 octaves of playable notes.

Well dewster you have inspired me to make my own theremin from scratch,I spend the weekend making some adjustable coils...which I can adjust with bolts screwing in and out of the centre...I measured different sized bolts and the effect they had on the changing induction...even a small nail can change it.I'll see how I go and report any successes here.

 

Posted: 2/19/2018 3:03:52 AM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"Maybe use batteries."  - invisiblejelly

The thing is, the mains field is pretty much everywhere, regardless of how you power things.  Theremin antennas are generally high impedance, so they can pick it up quite easily.  And if the Theremin relies on AM to do things like the volume envelope then it can sneak into the audio signal path.  I believe the mains field also influences FM or phase detection, so it's important to have comb, CIC, higher order low pass, or some combination thereof on both the pitch and volume sides.  With an analog Theremin you can do this on the volume side, but I'm not sure how you might do it on the pitch side.

"Well dewster you have inspired me to make my own theremin from scratch,I spend the weekend making some adjustable coils...which I can adjust with bolts screwing in and out of the centre...I measured different sized bolts and the effect they had on the changing induction...even a small nail can change it.I'll see how I go and report any successes here."

I'd suggest oscillators with fixed air-core inductors and trimmer caps to tune it, but there are many ways to skin the cat as it were.  I like ILYA's approach of higher frequencies (which give you physically much smaller inductors) with dividers and low pass filters before the mixer.  I often fall back to a sine wave, or a slightly morphed one, to give a touch of harmonics.  Whatever you do, use a 3 terminal voltage regulator - a stable supply is your first line of defense when it comes to oscillator stability.  And, as a sort of rule, the less current your oscillator draws on average the better, as that can mitigate thermal drift issues, and can often lower noise issues.

Posted: 2/20/2018 2:16:01 AM
invisiblejelly

Joined: 3/18/2012

Thanks for the sound advice dewster...I've seen some of ILYA's interesting posts and there is a wealth of other material here...I'll just plod along and see how I go.

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