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

Posted: 11/23/2017 8:20:30 PM
oldtemecula

From: 60 Miles North of San Diego, CA

Joined: 10/1/2014

Good to see a demo, I was starting to become concerned your theremin was only in your mind.

Christopher

Posted: 11/23/2017 8:35:46 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"Good to see a demo, I was starting to become concerned your theremin was only in your mind." - Christopher

I know I've yammered on too much regarding things I hadn't fully tested, but there was a lot to do in order to get to this point.

Nothing like reality to quickly sort out what's important and real and what's not.

Christopher: what do you think of the tuner?  And what's the gain of your Theremins (notes per hand opened/closed)?  What's your take on variable gain?

Posted: 11/23/2017 11:20:52 PM
oldtemecula

From: 60 Miles North of San Diego, CA

Joined: 10/1/2014

Besides a couple of friends on the other side of the pond, you and I are all we got. I am not a musician and always agreed with the better Thereminist that play is more intuitive than anything else. The regular pitch-preview makes the most sense to me.

I overlaid my tuner with yours listening to the same note. Because I dismantled my hobby room I could not find any clip leads to hook up my frequency counter to see who is off target.

Your red LED's seemed sluggish, the white very responsive. Does the display represent G#, my tuner says A#

Download my tuner from my website to test it out or compare.

For my experimenting I have recommend this tuner the last 15 years. If there is latency in this tool it is not noticeable or minimal and finding the right note when things are muted is most important.

Christopher

 

 

Posted: 11/24/2017 4:00:22 AM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"Your red LED's seemed sluggish, the white very responsive. Does the display represent G#, my tuner says A#" - Christopher

As I said a couple of posts ago: "And no attempt to align the LED displayed pitch with actual A 440 pitch, which is just a gain or offset somewhere."  It should be trivial to have a tuner setup screen where sub note, note, and octave offsets can be set.  This is a minor detail I'll definitely address after I get the volume side working.  The tuner actually represents E in your screen grab, and I can do the math from the logic and code.

The red octave LEDs linearly PWM transition between B and C, which you are misinterpreting as "sluggishness".  Physically, there's no way the octave display can be slower than the note display as they are derived from the same number at the same time, and PWM'ed at the same rate.  I publish my code and you can review it if you don't believe me.  (The bandwidth for both are identical and cannot be less than 60Hz, the first zero of the CIC hum filter.)  Do you think having it "snap" to the next octave at the B-C boundary would be better for the player?  These things are just software and can be easily changed.

So, I asked you some questions?

Posted: 11/24/2017 3:23:01 PM
oldtemecula

From: 60 Miles North of San Diego, CA

Joined: 10/1/2014

dewster said: "what's the gain of your Theremins (notes per hand opened/closed)?  What's your take on variable gain?"

Never quite understood Gains or Decibels, my thinking is simple these days holding a glass of Scotch Whisky.

Download my tuner and listen to my rough sound byte to observe I had perfect pitch field linearity. This was anywhere in the pitch field using my simple Lev Antenna that made engineers cringe that could not understand it. There are always several ways to do anything. All my research was simple analog from an era gone by, the sound was beautiful. Each octave I am using the open to close hand method similar to carolina eyck.

What amazed me the linearity remained no matter what width of pitch field or octave spacing. Disconnect ground, the field is still linear but it compressed the pitch field or created tighter octave note spacing. Even more amazing why does the pitch field match the musical scale note-for-note all the way up to the antenna. One of nature's miracles I always figured.

Then there was how does her opera Voice come about! It took five years after the first time I heard it to figure out how to capture it again easily on tube or solid state. After 15 years past by people evolved and interest dwindled. Maybe everything I mention above is just the illusions of an old man and the invitation I got to build was delivered to the wrong person.

One thing is for sure... my project was a gift to me.

Christopher

Posted: 11/24/2017 7:31:57 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Tuner Correction

Calculations to align the pitch display are a bit involved.  The NCO does 32 bit modulo accumulation, so the pitch number that gets accumulated is really a fraction of 2^32.  Multiply this by the sampling rate of 48kHz (repeated additions are multiplication) to get the output frequency.  

Working backwards through EXP2, the UINT_32 function is really 2^(x*(2^-27)).  The sampling rate is a multiplier on the NCO side, but is an adder on the pitch display side.  Pulling the sampling rate back through EXP2 gives an offset of log2(48k) * (2^27) or 0x7C67EDEE.

Adding that number to the pitch display input gives an error of 4 octaves, which is just an octave numbering bookkeeping thing (every system - MIDI, etc. - numbers octaves differently) so we use 0x5C67EDEE to fix it.  But there remains an error of -40 cents (A440 measures ~430Hz).  Half a note I would understand due to PWM, but this is approximately 1/3 of a note so it's kind of a mystery and I can't just hand-wave (!) it away.  Maybe there's something I'm not taking into account with the PWM 4th power thing going on?  Ah, whatever, good enough for now (using 0x5C2F0A60 gives no significant error with the FFT based frequency measurer in Audition, but I'd certainly like to know why).

An offset at the input to the pitch display is definitely the way to handle this because it is 100% modulo - so no overflow or underflow to worry about.

Posted: 11/26/2017 11:09:47 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Menus, Volume Axis

Pretty productive day! After some thought yesterday I coded a menu system that allows multiple pages of parameter viewing and adjusting, so now I've got two pitch and two volume menus.

Just piped the linearized and exponentiated volume side number over to the pitch side (a signed & unsigned multiply) and tried it out. Sine wave with volume control sounds very much like a human whistle!  Playing while listening through headphones my wife asked if that was me whistling or the prototype.

The volume side parameter adjustment gains need tweaking, and I'll add a tuner menu tomorrow (octave, note, sub-note offsets).  I'd estimate 90 to 95% of the grunt work is over, now it's time to practice every day to hone my playing skills (I don't have my standard "I don't have a decent instrument" excuse) and to delve into vocal synthesis.  

I'm thinking reverse sense on the volume side (a menu setting now, actually) might be more my cup of tea.  I wonder if the traditional volume sense (louder farther away) is done that way mainly because of the non-linear response of the analog circuitry?  I haven't used my left hand much when playing in the past, and I wonder if it's partly because the response seemed kinda weird/lame to me?  A lot of it is probably anxiety of losing audible perception of the pitch, which seems to be compensated for with a decent pitch display. And having to keep my hand on the volume antenna just to shut the thing up seems like too much work (first world problems). When is touchless not touchless...

Posted: 11/27/2017 12:06:59 AM
Touchless

From: Tucson, AZ USA

Joined: 2/26/2011

dewster said "When is touchless not touchless..."

I remember this project back in the day of Fred, are you still beating this dead horse?

dewster also said: I'm thinking reverse sense on the volume side (a menu setting) might be more my cup of tea.

You need to be careful going against tradition. Tradition & rituals are very powerful, ask the Catholic Church when they fire up the incense when they need smoke and mirrors to hide what is really going on.

T

Posted: 11/27/2017 10:58:44 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"I remember this project back in the day of Fred, are you still beating this dead horse?" - Touchless

Are you being held at knife-point and forced to read TW?

"You need to be careful going against tradition."

Axis sense reversal is just a setting in the menu, it's not baked into the design.  Your concern is duly noted.

Posted: 11/28/2017 10:14:55 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Added another menu page to adjust the individual brightness of the octave and note displays, as well as a disable mode that turns the pitch display off.  At this point everything seems good enough to proceed to the final basic design issue, which is the anti-alias filter.  Not too surprisingly, I'm hearing tons of aliasing on mid and higher pitched square and ramp waveforms, so this must be addressed now.  Looking for efficient hardware or software solutions today, without a lot of luck.  Certainly everyone runs up against this at one point when doing DSP synthesis, it's strange that I'm not finding solutions almost instantly.  There is ~30% left of the target FPGA logic, so if it gobbles up a whole processor thread or more I may turn to a hardware solution of some sort.  For the heck of it I tried 4 first-order IIR's in series but that didn't make much of a dent.

For practice I'm playing along through headphones to my wife's younger students piano lessons going on upstairs.  Frosty the Snowman in the key of C is pretty easy, particularly when watching the regular patterns the tune forms on the tuner.

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