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

Posted: 9/4/2018 2:51:20 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"I believe it would sound much better with reverb."  - Buggins

I actually put a bit of reverb on that.  Didn't drench it in reverb like I normally do!

I don't have the real-time cycles or memory to do reverb.  Probably a good thing, researching and implementing a decent reverb might take a year or more to do right.

Posted: 9/4/2018 6:59:26 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Resonators

While looking for violin body resonance info I ran into this interesting paper: "Electronic simulation of violin resonances" by M. V. Mathews and J. Kohut, 1974. They stick what is essentially an electric guitar pickup on what seems to be a non-acoustic violin setup, feed this to a bank of bandpass filters, and subjectively adjust and evaluate the sound while comparing it to a recoding of a real violin.  As I have found with with vocal sim, they find too much or too little Q produces an unrealistic tone.  It seems 20 to 40 resonances roughly exponentially spaced are necessary to make a good, realistic violin sound.  The paper also makes the observation that at least part of the job of vibrato is to "reveal" the resonances, something I hadn't considered, but it makes sense. Playing my measly 6 resonances viola / cello (or 4 resonances human voice) sounds much better and much more realistic with vibrato.  

A quote from the paper:  "Having recognized the effects of bumpy frequency responses, one can identify a naturally occurring continuum of bump responses. Brasses and woodwinds may have one or two spectral peaks which have some formant-like character in the acoustically important frequency range up to 5 kHz; the human voice has four or five; violins have twenty or thirty; reverberation chambers may have 100 to 200 depending on their size. By selecting an appropriate number of peaks, a resonant filter can approximate one of these naturally occurring effects or can produce effects intermediate between two natural ones."

It would be nice if there were some filtering construct that automatically and efficiently generated exponentially spaced resonances, but I'm not aware of it (anyone?).  So I'm looking at 2nd order resonators.  The standard one uses only feedback, has difficulty with low frequencies, and needs polynomial tuning, so I'm looking instead to modify the modified Chamberlin.  A nice feature to have would be constant peak gain regardless of Q, as I'm always having to reduce the input amplitude to get rid of clipping for higher Q settings.  Another feature that might be nice is constant bandwidth rather than constant Q with changing center frequency.  This would give a constant resonance decay rate with changing center frequency.  However, I don't know which (constant Q or constant BW) is more consistent with the physics of wooden violin bodies - it would be nice to have a single Q or BW control for all of the resonances.  It would be even nicer if the resonances didn't need individual amplitude adjustments.

I'm also looking into how to implement digital bass and treble tone controls, a somewhat thornier / vaguer subject than you might expect.  On our Roland RDX-700 keyboard the EQ can be assigned to be a system function or a per patch function.

Posted: 9/4/2018 7:44:50 PM
tinkeringdude

From: Germany

Joined: 8/30/2014

Reverb:
Slap-on a Raspberry Pi zero, then you have lots of RAM and extra cycles  Or PocketBeagle (more I/Os, IIRC).

Let's pretend for the moment I was being serious...
Or run the whole damn show on it? (I have no idea about the kind of processing and I/O your device uses and in how far your code would be painlessly portable). 
Availability: Worry only about the CPU/SOC, I know for a fact that SeeedStudio will produce a BeagleBone as custom order even if a certain model is not normally available anymore, even customized IIRC, well, it's all open source I believe.
It certainly has some processing power for such a task, even if the embedded (weak-ish) GPU is not used (and lots of crap you don't need, the "Zero" / "Pocket" variants less so.)
Naked, a Pi Zero board can be had for about 10 bucks (i.e. no case or other accessories)
- 1 GHz ARM Cortex A? core, with GPU attached (using the latter meaningfully would be considerable extra effort)
- 512 MB RAM, bounce sound around until the cows come home!
- I²C, SPI, GPIOs, some not too great ADCs on the Beagle, no idea about the Pi
- 4GB internal flash on the Beagle, to run the OS from (e.g. some Debian Linux / derivate), alternatively from the SD-card slot
- Rasp Pi needs to run the OS from card

Starting Linux can take a while, which is not nice for such devices. Can be considerably trimmed down, though. Default Linux image has "everything you're ever gonna need" for the target audience. (There is a ready image without desktop environment for one thing, though)

As for "1 year research", there is some open source (no idea about license) implementation of a convolution reverb, I forgot the name, but doesn't it basically mean you "just" need to record the response of a nice sounding room, and Bob's your uncle? (do only Aussies say that? I hear one saying that frequently.)

But I guess you have lots of code optimized for your meager bare metal target and porting it to a more generic computer takes more effort than recompiling, eh?


I recently played with those boards. And they're so cute and have so low cost and, compared to my bare metal MCUs I used prior, so much steam behind them! Even if skimpy on the peripherals. I had to mention them

Posted: 9/5/2018 12:36:44 AM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"Slap-on a Raspberry Pi zero, then you have lots of RAM and extra cycles  Or PocketBeagle (more I/Os, IIRC)."  - tinkeringdude

Yes.  And thanks, I do appreciate it.  And you're right, this is the thing to do, should one want all the bells and whistles (and I do).  

"Or run the whole damn show on it? (I have no idea about the kind of processing and I/O your device uses and in how far your code would be painlessly portable)."

I kind of doubt that that would work.  Too much ~200MHz custom logic.  But it could certainly be put in a smaller FPGA and run as a peripheral.  That's what the rational person would do!

"Starting Linux can take a while, which is not nice for such devices. Can be considerably trimmed down, though. Default Linux image has "everything you're ever gonna need" for the target audience. (There is a ready image without desktop environment for one thing, though)"

My prototype "boots up" in about a second, which is reading the code from the SPI EEPROM and doing a CRC32 on it, then reading it again and sticking it in FPGA BRAM if OK, else fall back to the image already in the FPGA (part of the logic pump).  I don't think I could stand much more than a few seconds of boot.  Our digital piano takes 10 seconds or so, which seems like an eternity for some reason.  Musical instruments should boot instantly IMO, creative impulse can pass so quickly.

"As for "1 year research", there is some open source (no idea about license) implementation of a convolution reverb, I forgot the name, but doesn't it basically mean you "just" need to record the response of a nice sounding room, and Bob's your uncle? (do only Aussies say that? I hear one saying that frequently.)"

Well, a huge part of this project has been to become intimately familiar with all the DSP / electronic music stuff I've been missing out on all these years, and in that sense at least it's been quite valuable (to me at least).  The linearized C sensing has been fascinating, the vocal sim almost equally so, the processor design portion is something I couldn't shake to save my life.  I've read many papers on reverb and feel I could probably do a passable one in a month or so, if the HW resources were available, but who knows how long I'd practically spend in that rabbit hole?  For those who really get into it it's an entire career, which sort of scares me.  I loooove reverb!

"But I guess you have lots of code optimized for your meager bare metal target and porting it to a more generic computer takes more effort than recompiling, eh?"

Kind of.  The thing with a very simple processor is that the timing is quite deterministic.  You can depend on it to never leave the room and go make a sandwich (e.g. cache miss) in the heat of the moment.

"I recently played with those boards. And they're so cute and have so low cost and, compared to my bare metal MCUs I used prior, so much steam behind them! Even if skimpy on the peripherals. I had to mention them"

I completely get where you're coming from, and have to re-convince myself on a regular basis that I'm doing the right thing, for the moment at least.  All that >GHz horsepower out there with a boatload of memory for almost no scratch.

Another aspect of it all is the UI.  Color touchscreens cost almost nothing, but I really don't want to go there at this point.  For one I don't have the memory to map fonts and graphics, for another I think the ancient 4x20 LCD and 8 encoders pretty much do the job (but it's my baby, so I'm kinda blind).  It could be sexier, but would that be inherently better?

In a few years FPGA technology should get to the point where 2 or more Hive images with plenty of memory could be instantiated in a very low end part, and integrating reverb would then be pretty simple.  I suppose that's where my head is at as regards this project.  Or, who knows, maybe someone else will do the integration.  For now I'm focusing on sound generation and filtering, and I wish I'd done this whole thing ages ago.  Life is quite short, and one's creative time on this earth even shorter.

Posted: 9/6/2018 3:11:31 AM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Violin < Reverb?

The violin paper I noted above used test resonance frequencies selected from a really busy Stradivarius spectrum, so maybe they weren't inherently spaced exponentially?  Picking exponential spacing might just be an economically convenient way of covering the bandwidth evenly?  The paper was from 1974 so gobs of filters might not have been all that easy to do, even for Bell Labs?  I don't know.

I'm looking at reverb papers again as they use comb and all-pass filters to generate gigantically huge gobs of resonances.  Comb resonances are linearly spaced, so they use multiple combs (with different, prime-ish delays) in parallel to generate them, with multiple all-pass filters (with different, prime-ish delays) in series to somehow multiply them (still pondering at this).  A couple of papers uses nested all-pass filters, and one paper uses only nested all-pass with local feed-forward and global feedback.  Anyway, I'm wondering if a butchered down reverb might make a decent violin body resonator?

A couple of days ago the car put one last tire in the grave (power steering blew out, exhaust is rotten), the lawn needs mowing, the piano lessons start next week, the concrete driveway is slowly disappearing one pit at a time - my raison d'etre (Theremin research) is in something of a holding pattern.

Posted: 9/6/2018 5:27:11 PM
Buggins

From: Theremin Motherland

Joined: 3/16/2017


I'm looking at reverb papers again as they use comb and all-pass filters to generate gigantically huge gobs of resonances.  Comb resonances are linearly spaced, so they use multiple combs (with different, prime-ish delays) in parallel to generate them, with multiple all-pass filters (with different, prime-ish delays) in series to somehow multiply them (still pondering at this).  A couple of papers uses nested all-pass filters, and one paper uses only nested all-pass with local feed-forward and global feedback.

It looks like there is no possibility to implement straightforward reverb based on impulse response even in FPGA since IR usually lasts several seconds.

So, direct convolution cannot be done.
Convolution via FFT - probably, yes, but such algorythms will add big latency.
Having a set of filters taking differently delayed signal looks more realistic.
I wonder if there is any method to convert IR into set of filters and delay values.


Anyway, I'm wondering if a butchered down reverb might make a decent violin body resonator?

Nice idea.

Posted: 9/6/2018 9:47:16 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"Convolution via FFT - probably, yes, but such algorythms will add big latency."  - Buggins

I haven't read this paper, but it seems to claim that the latency can be dealt with.

Posted: 9/10/2018 4:38:14 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Sensitivity & Playing Technique

Before the prototype reached the point of playability and I began learning to play it, I suppose I had some inkling that altering the basic sensitivity of the pitch axis would require a concomitant alteration of the "standard" ways in which the Theremin is played.  I was fairly resistant to learning on a conventional analog Theremin because I didn't want to get stuck in a rut due to the limitations of a particular instrument implementation (also: I'm lazy, and the EWS has no pitch display).  Now that I've become somewhat sorta OK at playing a handful of pieces (I can sometimes get through a short piece without a major pitch flub) I feel we should discuss methods of playing a reduced sensitivity instrument.

The sensitivity of an analog Theremin without series EQ inductor, when adjusted for maximum linearity in the mid-field, is approximately one octave per open/closed hand.  I presume / believe Theremins with EQ inductors also have roughly this same sensitivity, with the EQ inductor mainly serving to help linearize the near-field (when properly adjusted).  This "invariant" sensitivity response is due to the direct use of the pitch subtraction result of heterodyning in an exponential manner (the pitch sense of the ear is logarithmic so it "hears" exponentially spaced pitch as linearly spaced).  The basic physics of the arrangement mean you can't substantially change the sensitivity of a heterodyned Theremin without negatively impacting linearity, and setting things for optimal linearity will always give you pretty much the same open/closed hand = 1 octave sensitivity.  Let's call this "ATSI" for "Analog Theremin Sensitivity Invariant."  The only way around this that I'm aware of is to address the pitch antenna obliquely, which would lower sensitivity.  

Not a sales pitch, but the sensitivity of my digital prototype is an infinitely variable preset based on taking the mathematical root of the frequency difference (no actual heterodyning is going on, just a mathematical subtraction of the axis value from a constant, though the end result is the same).  Except for doing special effects and the like, I don't think anyone in their right mind would set the sensitivity higher than ATSI to play tunes.  The problem of needing to stand stock-still, or even breathing, would be amplified.  Nearby disturbances (people walking by) would also be amplified, throwing off your performance even more.  So this leaves ATSI or lower as a realistic option for non-aleatoric players.  Historically, until the Theremini, this option hasn't been available to the player, so there probably hasn't been a real discussion of what the "optimal" sensitivity might be for most players, and for the various playing techniques.

Obviously, for "aerial fingering" as it's generally practiced you will want ATSI sensitivity.  In fact, if you've spent years developing "any" technique you probably want ATSI, as it will be immediately familiar and therefor maximally useful to you.  Those who are new to the Theremin, or aren't too deep into learning how to play it, would probably find something significantly less than ATSI, such as ATSI/2 or ATSI/3, easier to play initially as it isn't nearly as squirrelly as a conventional Theremin.  With substantially lower sensitivity you can more or less just casually stand at the Theremin - it doesn't demand a "Tai Chi stability pose" to maintain a steady pitch - and less nuanced hand movements can be used to select the desired pitch.   

In general, there is a tension between low and high sensitivities.  Here is a list of the pros and cons of low vs. high as I see them:

Low (vs. High) Sensitivity
PROS: Subjectively much easier to play initially.  Doesn't require a statuesque playing pose.  Introduction of vibrato is fairly straightforward.
CONS: Not as amenable to quick & precise intonation techniques such as "aerial fingering."  Lower vibrato speeds more difficult.

My ATSI/3 Playing Technique (so far)
I started out (for reasons that I can't recall) using ATSI/3, and am so accustomed to it at this point that (other than the ATSI response of my old EWS) I am likely a poor judge of the objective merits of alternative sensitivities.  I hold my thumb and index finger loosely together, with the tip of my index finger positioned under the center of the end joint of my thumb.  My other fingers are almost completely relaxed, not held together nor far apart, with all of the joints fairly straight, and all fingers the same initial angle as the base joint of my index finger.  My wrist is relaxed and slightly curved in, and my forearm is mostly perpendicular to the antenna.  So the backs of my fingers address the antenna at maybe a 30 degree angle.  For vibrato I twist my forearm.  To articulate quick notes I hinge all of my free fingers together to get +/- one or two half steps, beyond that I hinge my wrist to reach +/- 4 half steps or so, and anything larger I move my whole arm.  With this arrangement, I feel the natural resonance of my twisting forearm is a bit too high, so I have consciously slow it so as not to sound like the rapidly trilling crooners from the roaring 20's.  Due to the frequent larger scale hand and arm movements, this technique works best if you have audible pitch preview or a real-time pitch display, and some pitch correction generally doesn't hurt either.

Posted: 9/10/2018 10:00:21 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Volume Axis Thoughts

The volume side of the Theremin usually doesn't get enough attention from designers IMO.  You really want a linear volume axis response.   On top of this I've found a field sensitivity that goes from full off to full on over the space of about 6" to 8" is preferable, and with my hand never needing to get any closer than 8" or so is pretty comfortable (I don't like approaching either antenna closely in the course of playing).  A knee, or two zone sensitivity in the field, helps a lot with things like human vocals, violins, horns, etc. which tend to start more abruptly.  I usually have the knee point set to around the -16dB point, with the softer side sensitivity set to around 4x of the louder side sensitivity.  A really sharp knee facilitates velocity sensing, as the softer side ramps almost immediately from zero to the knee point, which gives the velocity logic a big delta to work with, and a definite point in space where an attack can be easily be played, and quickly and repeatedly replayed.  All of this is adjustable on the prototype.  A knee is key to the majority of playing situations and voice types IMO, and keeps you from having to whip your hand around a lot over large distances when you want a faster attack or decay, while still giving you the ability to easily swell once past the knee.

I haven't concentrated on my volume axis technique much at all, and I think my playing is beginning to suffer due to that.  I've noticed that pro players often quickly lower the volume when transitioning to a new note, then slowly increase it, much like operatic singers do (though operatic singers sometimes take it to such extremes that I find it irritating).  Volume dip during pitch transition really masks not hitting the target pitch exactly right, so that in itself makes it a useful technique for Thereminists to learn.

Posted: 9/11/2018 10:10:37 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Violin Body Resonances

Interesting paper [LINK]MODELING HIGH-FREQUENCY MODES OF COMPLEX RESONATORS USING A WAVEGUIDE MESH by Patty Huang, Stefania Serafin, and Julius O. Smith III.  They use 8 or 9 second order resonators to model the resonances up to 1.4kHz, then a 2D mesh to model the higher resonances.  So there's increasing hope that a lobotomized reverb plus maybe a handful of formants could do a passable violin.

I'm working on somewhat simplifying the formant structures, and on making the gain / overload point largely independent of Q.  And I want to play with some simple reverberators to see how they perform with really small "room" size delays.  Ideally, I'll stumble over a generic resonant filtering synthesis element.

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