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

Posted: 11/12/2018 9:47:01 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Roger, I very much appreciate your notes and observations regarding the TC Helicon!  Particularly since I have no firsthand experience with these products. So I'm kind of engineering in the dark on this one.  It's interesting that they use dP/dt to engage/disengage the entire process.  I'm out of ideas, but I'm fairly content with the current pitch correction and always use it now (set to different rates depending on the voice), but any possibility to improve it is welcome.

I like that mine is always pulling to the center, this makes starting a note from silence trivially easy.  And I like that, unless you have the bandwidth cranked up into quantization territory, it doesn't mess with the vibrato depth. The main thing I don't like is that, if you have the bandwidth turned up rather high and your vibrato is wide or you are somewhat off the note with your vibrato, then the vibrato overlap into the neighboring note pulls it somewhat off center. This error is obviously worse the more you crank up the bandwidth, with note switching happening in the extreme case of quantization as one would fully expect, but it isn't onerous with a reasonable bandwidth setting. Turning the whole thing off in the presence of vibrato seems a bit drastic, but maybe that makes sense, though .  I don't get the window though?  I would think it would work opposite, as a dead band (or reduced action band) around note center, and that you would want correction outside this instead of inaction.  A 10 cent window seems like it might be hard to hit (humans can only hear ~3 cent deviations)?  Hmm.  I'm kind of surprised there isn't a dP/dt range / threshold control?

Posted: 11/12/2018 11:52:38 PM
pitts8rh

From: Minnesota USA

Joined: 11/27/2015

 It's interesting that they use dP/dt to engage/disengage the entire process.

That's just my theory, but it's been a long time since I played with it.  I do remember that certain settings allowed unrestricted vibrato because of the delay after any pitch change.  I wanted just a bit more delay that the processor was capable of giving.  It's intended for vocals, and on the 0-99 range I think I was at 1 or 2.
I like that mine is always pulling to the center, this makes starting a note from silence trivially easy.

But often when playing vocal or string pieces you want to slide up to the note (guitar term, I don't  know the correct terminology).

Turning the whole thing off in the presence of vibrato seems a bit drastic, but maybe that makes sense, though .

I can't say that it's turned off, but the whole ATTACK parameter function's purpose seems to be to inhibit pitch correction while pitch is in motion.  Does this mean reduced, killed, or something else?  Who knows.  I could study it on the bench with some stepped and swept frequencies, but I'm not all that interested unless you are. 

In my opinion internal pitch correction on a theremin could be ground-breaking if it was highly controllable to the point that experienced players would still want to use it but with almost all functionality (or interference if you will)  turned off, leaving only the very narrow-windowed and scaled pitch correction to assist in holding sustained notes in unison with accompaniment.

I don't get the window though?  I would think it would work opposite, as a dead band (or reduced action band) around note center, and that you would want correction outside this instead of inaction.

A narrow WINDOW setting assumes that the player or singer has enough musical sense to bring pitch to within 1/2 the WINDOW width surrounding the correct pitch.  If you are outside this window you are there for a reason - a very slow pitch transition for example.  
A 10 cent window seems like it might be hard to hit (humans can only hear ~3 cent deviations)

In a void, I agree - I have no idea what my pitch sense is without reference, but I'm guessing it's pretty bad.  Of course that would be easy to test but I just haven't done it lately.  I do know that I will drift sharp over time, so I would imagine that my interval sense is pretty poor too.  But playing along with a reference ( accompaniment or a drone pitch) is a different matter.  A 10 cent window is nearly impossible to hit on a theremin, but apparently not that difficult to settle on, after the over-undershoot corrections, when you have the reference tone or background music available. 

I just checked the Voicelive again and there it was -the last setting that it was on was a 10 cent window.  I know I had also played with wider windows, but near the end I was trying to dial everything down to keep it from interfering. As I last left it, the pitch correction was minimal to keep it from grabbing, but I remember being impressed with the stabilizing effect it still had.

Posted: 11/14/2018 12:30:06 AM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"But often when playing vocal or string pieces you want to slide up to the note (guitar term, I don't  know the correct terminology)."  - pitts8rh

You could start the slide from the center of the lower note and slide up?  Or turn down the bandwidth enough so that it isn't pulling so fast.  IMO it's really nice knowing that if you keep still for a bit, the note you play from silence will be on the note.  Maybe not dead center if the bandwidth is set really low and your hand is moving a little, but close enough not to sound bad.

"In my opinion internal pitch correction on a theremin could be ground-breaking if it was highly controllable to the point that experienced players would still want to use it but with almost all functionality (or interference if you will)  turned off, leaving only the very narrow-windowed and scaled pitch correction to assist in holding sustained notes in unison with accompaniment."

Yeah, the last thing you want is it fighting you.  Earlier versions of my pitch corrector used lower order filters that, among other issues, didn't sufficiently separate the vibrato from other hand movements, and I found myself fighting those more and wondering if they were even worth it.  I had those pitch correctors dialed way back all the time just to keep them out of the way of my playing.  I should try an 8th order filter...

"A narrow WINDOW setting assumes that the player or singer has enough musical sense to bring pitch to within 1/2 the WINDOW width surrounding the correct pitch.  If you are outside this window you are there for a reason - a very slow pitch transition for example."

Mine seems to function entirely differently.  Maybe I'll do a video demonstrating it working at several settings.  You wouldn't get the "feel" through the screen, but it might give you a better assessment.

Not making any value judgments, but this makes me think of PLLs.  PLLs are basically low pass phase noise filters, so they are implemented as linear control feedback systems.  Communication grade PLLs often have things like clock degradation monitors, auto-holdover, and other necessary (?) state-based cruft that tries to second guess impairments before the PLL sees them, in an attempt to keep downstream timing from getting too perturbed.  Commercial pitch correctors seem to have more of a software decision tree or state machine at their core, and for all I know that's the best way to go.  You could design a PLL as a state machine, but you would have to think about and cover every input scenario, and the result might have non-linearities that preclude it from acting like an ideal filter (how do you make a 4th order state machine?).  I guess what I'm trying to say is: fundamentally different solutions will arise depending on whether the problem domain is perceived as a linear controls type system vs. a state / decision type system by the given problem solver.  I would think that software types would favor the latter more or less by default.

Posted: 11/14/2018 9:20:40 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Pitch Correction Video

Not a whole lot of effort went into this, and sorry about the webcam audio, but making it even incrementally better would take the better part if an afternoon:

Due to the camera settings (to better expose the pitch LEDs) the octave display is so washed out here that it looks quite a bit dimmer than the pitch and volume displays - in real life it only looks a little dimmer.  And there is only brightness quantization on the pitch display, which is turned off here (I talk in the video like it's on both axis displays).  Around 1:00 when I say "you'll see no pulling" I should have said "you'll hear no pulling".

Also, I tried an 8th order LPF in the corrector, but over a few minutes of testing I couldn't tell any difference between it and the 4th order.

Posted: 11/15/2018 10:57:38 AM
pitts8rh

From: Minnesota USA

Joined: 11/27/2015

Thanks for the video - very well done.  I am looking forward to seeing the tuner in operation firsthand.

Some quick questions to keep me going for the next few days:

1) Can you tell me (again, I think) if you have a set of R and C values for the encoder debounce filtering that you recommend to go with whatever digital smoothing you have now?  I can't find where you talked about this earlier, and I need to order some surface mount parts for these boards.

2) I am pondering the wisdom of making a single main board (prototype-grade only) to interconnect and mechanically support the FPGA demo board, LCD display, eeprom, toslink module, RJ45s for ANT boards, and most of the interconnects between these parts.  If I don't do this I still need to make some type of board for the eeprom, toslink, RJ45s, and header distribution as you did, and then also make some separate mechanical support for the FPGA and display.  So the single board would not seem to be much more work.

I am picturing the main board (with FPGA and LCD daughterboards) having ribbons or a cat5 connecting to the tuner board and two ribbons going to each of the left and right encoder boards.  If the density is something that I can't handle without drilling a million holes for vias, I will probably just resort to the Dupont interconnects for some of the connections, but ideally still centered around a single board.

I'm not sure until I get into this if the trace and hole densities are achievable with my homemade pcbs. So before I even start on this part, how stable is the design (I mean in the sense of anticipated additions)?  Do you foresee any need for added memory, etc?  I hope to bring unused FPGA pins to headers, but if there might be a need for other ICs I could at least add sockets for those with breadboarding header pins for future use.

3)  If I recall correctly, antenna plate dimensions that you had given earlier seemed somewhat loose and were based on the sizes that you could fit in the plastic boxes.  Does the NCO/DPLL have sufficient range to accommodate variations here, or would it be best to bench-drive and pre-tune the plate/inductor/antenna board (AFE) combinations to be optimized within a specific frequency tolerance?

Pre-tuning would be preferable because it would be nice to be certain that the AFEs are optimized before connecting to the FPGA, plus I would be able to see effects (tuning related) that might not be otherwise apparent.

Thanks


 

Posted: 11/15/2018 1:43:14 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

1) Can you tell me (again, I think) if you have a set of R and C values for the encoder debounce filtering that you recommend to go with whatever digital smoothing you have now?  -- pitts8rh


At 3.3V, the FPGA pullup resistor can be between 7k and 41k.  So we size the pulldown resistor maybe 1/3 of the low end of the pullup to get 2.2k.  The encoder top speed is around 1kHz, so we size the time constant to be about 1/5 the high end of the pullup * C to get 5nF.  These are rough, ballpark numbers that should work but I haven't tested them.


2) ... So before I even start on this part, how stable is the design (I mean in the sense of anticipated additions)?  Do you foresee any need for added memory, etc?

I don't have any plans to add any hardware at this point.  FPGA utilization is 72% of the logic elements and 26/30 of the block RAM.  Hive memory is at 85% utilization, real-time is probably a little lower, so there isn't a ton of resource left, but enough to tinker around in. If anything, I'd move to a larger, newer FPGA to do things like reverb, but no plans in my head.


3)  ... Does the NCO/DPLL have sufficient range to accommodate variations here, or would it be best to bench-drive and pre-tune the plate/inductor/antenna board (AFE) combinations to be optimized within a specific frequency tolerance?

DPLL operation is limited on the high end of frequency by the sizing of the NCO phase accumulation.  I don't know what the low end is but probably some (somewhat sub-optimized) decades below the high end.  Optimization at FPGA build time is done by setting a few input values (maximum frequency, cutoff frequency, etc.) and automated via a pile of SV parameter math, so whatever you end up with (within reason) can be easily accommodated.  Since the dither noise is proportional to the operating frequency divided by the effective DPLL clock rate of ~400MHz, I would avoid operating frequencies that are above, say (pulls number out of ass) 2MHz or so.  As with all things DSP: the finer the grain, the better the emulation of a continuous time system.

Posted: 11/16/2018 11:00:03 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Encoder Velocity

Today I installed an upper limit on encoder delta over the 180Hz sample period.  Played around with various velocity scalings and  finally settled on this:

One of the encoder contacts is shown on the left along with the internal FPGA weak pullup resistor.  This is fed to a counter-based debouncer that acts much like a low pass filter with hysteresis.  The width of the counter is currently 12 bits, but it could go a little wider if needed.  This, along with the sister encoder contact given the same treatment, feeds a small state machine, which is just a Gray code to binary converter, followed by a counter plus logic that only allow single increments / decrements.  The result (-1, 0, +1) is stored in a Hive clear-on-read register.  All of that is in the Hive core 180MHz clock domain.  Software reads the register and accumulates the values at a 48kHz rate.  The accumulated results are read and cleared at 180Hz and fed to a non-linear function to impart velocity.  The absolute value of the signed accumulation is fed to the limiter (set to 7 here) then used to shift a 1 left (2^n or exponential via an opcode), then shifted right 3 (int divide by 8), the result summed with the abs max, and the sign restored.

I was using squaring here for velocity, but after I installed limiting squaring was too strong!  Seems there was more encoder reverse glitching going on than I thought.  Tried scaled cube, also simple square & cube polynomial, but exponential seems to give the best feel.  With two fast twists I can cover around a 200 value change, while still retaining good control over slower and medium spins.  With limiting now there seems to be much more consistency of action among all 8 encoders.

Velocity is necessary so that it doesn't take the user forever to get from one end of possibly 256 values to the other, and it minimizes encoder wear by requiring fewer detents.  It's extremely critical to the whole "look and feel" of the instrument, and so warrants all necessary design attention.

Posted: 11/17/2018 11:49:00 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

LED Tuner Video

Time for another crappy washed out video!


Did 3 takes on this one believe it or not, this was the best from a purely technical informational angle, though worst from an uptalk or high rising terminal aspect (yeesh).

And for some reason I couldn't play very well - I blame the tripod crowding me out of my normal position and altering the ether, the chill in the air downstairs, my lack of practice lately due to coding too much, the dog eating my homework, etc.

Posted: 11/18/2018 9:57:24 AM
pitts8rh

From: Minnesota USA

Joined: 11/27/2015

I'm glad you made this video because it demonstrates the logic behind the staggered concentric rings of leds and how the intensity balance between adjacent leds helps to indicate the note center. I'm still not convinced that the brain (or my brain) can interpret relative intensity levels faster or as fast as left/right motion (as with a strobe tuner) to indicate pitch deviation.  That doesn't mean that I disagree - I just won't know until I have tried both.   Strobe motion does seem effective, but I also want to try this. Commercial tuner products use multiple display methods (adding a color axis, too), and it could be because different people simply respond differently, so there may be no entirely correct answer.

I should mention that one of the many features that I like about the Windows-based soft tuner Spectratune is the ability to user-select the top note instead of having it fixed.

I hope that my earlier question regarding the possibility of reversing the rotation of the circular tuner display didn't give you the wrong idea.  I hadn't even entertained the possibility that someone might want to actually view the display in reverse.  I had a different reason for asking...

Earlier I had been considering the idea of putting the tuner display (detachable) out where it could be glanced at without distraction.  When my prototype enclosure started to take shape it appeared that the pitch plate orientation was getting suspiciously close to being useful for viewing a reversed-rotating tuner reflected in the direction of the player's hand, provided the tuner could be rotated to face the pitch plate (mirror).  It turns out that 1/8" acrylic mirror stock makes a fine conductive plate for a pitch antenna with some added benefits in that it is lightweight and it can also be heat-formed into simple or compound curves (gentle curves only to preserve the metalization) that may serve to benefit pitch contours at near-range.  And it comes in attractive transparent colors too.

Reversal of a stock 7-segment italic display would be a different matter, but that's a detail.

The downside of this is that the pitch/mirror plate would need to be aimed more toward the main console than normal, making it less than optimum for its intended purpose, and there may be other disadvantages that won't become apparent until the theremin is actually up and running.  A little bit of cylinder formed into the pitch plate/mirror would reduce the strict incidence/reflection angle positioning requirement (at the expense of introducing some degree of funhouse-mirror distortion), and may also be a good thing for close-field behavior.  We'll see.  If all else fails, a separate small mirror on a mic stand is still easier to deal with than a detachable wired tuner, at least in fixed settings where you could set it up and leave it.


Posted: 11/18/2018 1:50:40 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"I'm still not convinced that the brain (or my brain) can interpret relative intensity levels faster or as fast as left/right motion to indicate pitch deviation.  That doesn't mean that I disagree - I just won't know until I have tried both."  - pitts8rh

A tangent: While setting up for that video I was watching the tuner on my PC monitor, and the small but obvious transport delay made it markedly less playable.  I think any noticeable delay in performance feedback is absolutely deadly.  Since the axis process filtering on the prototype is > 8th order @100Hz, there's at least 0.01s of inertial delay, but I believe inertial delay is less intrusive playing-wise than transport delay.

"Commercial tuner products use multiple display methods (adding a color axis, too), and it could be because different people simply respond differently, so there may be no entirely correct answer."

Barely along those (color) lines: the tuner previously had white LEDs for the "white keys" and blue LEDs for the "black keys".  After a short period of time playing it this way I noticed my brain was paying much more attention to the patterns being traced out, that C major scale was so obvious it didn't need special marking, and that the different colors were actually interfering with recognition of the house pattern, and the two patterns rotated.

Also (color): Because I'm using different color LEDs I can't use a colored bezel in front of them to improve contrast, so was thinking of going with a smoked bezel, but that might hide the LED positions too much.  I believe one could go with a single color for everything and not hurt readability / recognition. A black PWB background for them would definitely raise contrast, something I intend to do on the next go-round.  Any thoughts on this?

The patterns are rather like stellar constellations, seeing an image in a bunch of dots.

"I hope that my earlier question regarding the possibility of reversing the rotation of the circular tuner display didn't give you the wrong idea.  I hadn't even entertained the possibility that someone might want to actually view the display in reverse.  I had a different reason for asking...

Earlier I had been considering the idea of putting the tuner display (detachable) out where it could be glanced at without distraction.  When my prototype enclosure started to take shape it appeared that the pitch plate orientation was getting suspiciously close to being useful for viewing a reversed-rotating tuner reflected in the direction of the player's hand, provided the tuner could be rotated to face the pitch plate (mirror).  It turns out that 1/8" acrylic mirror stock makes a fine conductive plate for a pitch antenna with some added benefits in that it is lightweight and it can also be heat-formed into simple or compound curves (gentle curves only to preserve the metalization) that may serve to benefit pitch contours at near-range.  And it comes in attractive transparent colors too."

You rascal! :-)  What an innovative idea!  It puts more distance between the tuner and you, thus making it appear smaller, but allows you to keep you eye on the pitch antenna.  If it weren't for interference I'd probably stick the tuner smack dab in the center of the pitch antenna, and this is one way to do it.  So you're going to do a mild parabola to make it appear bigger?  

I obviously haven't tried (nor even thought of!) your proposed arrangement, but I can say that a plate target isn't nearly as hard to "hit" pitch-wise as a rod.  I do wander a bit now and then when sleepy, but my pitch hand & plate are sufficiently in my field of view that I can pay attention to it when needed.  I've become accustomed to the tuner being about 1/2 meter from my face.  The tuner is only ~0.25m from the pitch antenna and the pitch antenna is located somewhat behind it.  But don't let me discourage you.

"Reversal of a stock 7-segment italic display would be a different matter, but that's a detail."

A parameter test and secondary 7-segment lookup table, ~20 lines of assembly.  Mode knob is already there (often the determining factor!).

"The downside of this is that the pitch/mirror plate would need to be aimed more toward the main console than normal, making it less than optimum for its intended purpose, and there may be other disadvantages that won't become apparent until the theremin is actually up and running.  A little bit of cylinder formed into the pitch plate/mirror would reduce the strict incidence/reflection angle positioning requirement (at the expense of introducing some degree of funhouse-mirror distortion), and may also be a good thing for close-field behavior.  We'll see.  If all else fails, a separate small mirror on a mic stand is still easier to deal with than a detachable wired tuner, at least in fixed settings where you could set it up and leave it."

It does seem like you could run into alignment issues.  The plate doesn't need to be 100% perpendicular to your playing arm, though when you find yourself playing super close to it any angle could be a factor in how close you can comfortably get, particularly with vibrato going on and depending on your style there.

I need to get another volume side "shoe box" and try to cramming the pitch side in there as an experiment.  The antenna could be a flattened U to retain surface area intrinsic C, but I'm mainly wondering if linearity would suffer much with that arrangement.  Would be nice to use the same squarish box for both antennas.  I believe it's much more about bulk surface area than the finer details of the geometry.

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