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

Posted: 2/10/2020 11:48:08 PM

From: Northern NJ, USA

Joined: 2/17/2012

"What's that crackling on the audio? E.g. between 40..50 secs (and other places)."  - tinkeringdude

It's in the original video so I can't blame it on the YouTube transcoding!  I believe it's something to do with the Linux Mint audio subsystem.  Whenever I record in Audacity I have to set the buffer to >250ms (sometimes higher) or it injects those little "tick" sounds here and there.  This was recorded via guvcview, heaven only knows what audio sausage factory is under that hood.

"I briefly thought about whether it could make sense to input a "hand stepped through the field" curve and make some kind of more finely tuned correction curve from that to even stuff out. But then it seemed surrounding conditions vary too much for that to be of long usefulness, and no good relation to the laboriousness."

Wow you can buy anything these days!  But, yes, there are a million ways to skin the cat, the trick is to find a linearization method that is simple, stable, and manageable by most Theremin operators.  The one I stumbled across needs no attention past the initial setup, has a single knob, and the range of adjustment can only change the linearity a little, just enough to accommodate various antenna geometries, but not enough to get you in major trouble if it's set wrong.  It's 7 lines of assembly (though it calls a couple of basic math functions).


Posted: 2/11/2020 6:17:09 PM

From: Northern NJ, USA

Joined: 2/17/2012

99 Presets (of Beer on the Wall)

I have revisited the UI code and now have (what I believe to be) better ways to handle the reading and writing of presets.  It's back to the separate "Load" and "Stor" encoders I had in the first place, but it retains the two step write process, and adds new "following" features, as well as multiple system presets.

As before, the two-step write requires two sequential presses of either the "Stor" encoder or the new write pushbutton (in any combination).  The first press places the write logic in the "armed" state and now changes the encoder label (rather than the encoder value, as I was doing previously) from "Stor" to "!WR!" and blinks an LED.  The displayed "Stor" encoder value remains the write target slot (which is good), and once the write is performed the "Load" encoder is set to this value too.  Having "Load" follow "Stor" after a write seems like the safest thing to do, as you generally want to play and edit the copied-to preset after a write, and not the copied-from source.  And if the value of "Load" was different than that of "Stor" then the "Load" value change is additional confirmation of the write. 

Similarly, loading a preset by rotating the "Load" encoder sets the "Stor" encoder value to the same as that of the "Load" encoder (unless "Load" is set to a negative read-only slot, whereupon "Stor" is set to zero).  Having "Stor" follow "Load" after a preset read makes things safer because it automatically sets the write (and any edits you may be doing) to the slot & voice you're currently playing, and not some other (& therefore dangerous) slot.  I believe Roger suggested this change something like a million years ago - and as usual he was right!

By the way, the new SW debounce filtering is working like a champ on the sleazy RS write pushbutton, which I admit was a pleasant surprise!  I thought the debounce period might be too short for it, but I haven't seen a bounce or glitch out of it yet.

I've also implemented more than one slot for the global system preset parameters.  The motivation behind this is to cover the case where more than one person plays a particular D-Lev regularly, and perhaps one of the users likes a reversed volume field sense, or a non-linear volume field, or a different pitch field sensitivity, or a shifted pitch field, etc.  I've found changing these types of settings even slightly to be quite disorienting to my playing "style" and comfort level, a direct indication of how much I'm relying on "muscle memory" and spinal training to hit (or not hit, truth be told) the notes.  Even if the axis numbers were written down, it would be a bother to have to dial them back in every time you wanted to play the thing.  So saving them for each player is an important good thing, and the question is then how best to do this.

Previously, writing to preset slot 0 also stored the system parameters, and powering the thing on was the only way to load them.  This worked pretty well, but it obviously only covered the single user case and felt a bit non-intuitive.  Things were arranged so that preset [-127:-1] were read-only, and [0:127] were read/write.  Slots [-127:-1] could only be written to via the serial port librarian software, so they played the role of "factory" presets, and slot [-128] was where the lone system preset existed.

At first I tried the following, using the "Load" and "Stor" two encoder arrangement for everything:
[-127:-120] read-only system presets
[-119:-1] read-only voice presets
[0:119] read/write voice presets
[120:127] read/write system presets

To keep the system presets from instantly loading when the "Load" encoder was set to them, I made it so system preset reads required the pressing of the "Load" encoder to actually do the load, but this produced two unfortunate side effects.  The first was the loss of zeroing "Load" by pressing it, which I missed more than I thought I would.  The second was the unavoidable loading of slot 119/-119 when transitioning up/down to the system preset zones, which was just weird.

In the end I decided to pare the number of voice presets down to the following:
[-99:-1] read-only voice presets
[0:99] read/write voice presets

Unlike most other digital sound equipment/software that I've used, this is my first "bowing" to base 10 on the D-Lev, and I'm only doing it because I can't use the full range in the first place - and reducing the range gets me out of having to come up with tons of voices to fill it!

Access to the system preset load & store slots has been moved to two new "Load" and "Stor" encoders on the SYSTEM UI page:
[0:3] read/write system presets (located at slots [100:103])

This allowed me to restore "push to zero" back to both of the "Load" encoders, as loads can (and do) happen as soon as the "Load" encoder is changed to a new slot (with the "Stor" following it as described above).

I also decided to nix the read-only system presets.  They do have a use (immutable store for safety) but in the end their inclusion seemed more fluffy and confusing than substantial and useful.  Four R/W system presets should be more than enough.  As with the voice presets, system slot 0 (@ slot [100]) is loaded at power-up.

As a result of this exercise I more closely examined the roles of both sets of "Load" and "Stor" encoders, and I ultimately removed them from the system parameter EEPROM save / restore mechanism.  The only other encoder also outside of system storage was the UI page encoder on the lower right, and I was able to incorporate the display of it into the normal display of the other encoders.  It's more consistent and cleaner now.

So there it is, the first 90% of the D-Lev SW required 90% of the development time - and the final 10% required the other 90%!

Posted: 2/11/2020 7:38:08 PM

From: Germany

Joined: 8/30/2014

Wow you can buy anything these days

Well, still, not anything

Whenever I record in Audacity I have to set the buffer to >250ms (sometimes higher) or it injects those little "tick" sounds here and there

250ms, argh. But it's a normal PC, not an Android tablet, right?
There's some sort of equivalent of ASIO under Linux, but I forgot its name. But low-latency audio recording has much improved in Linux (if you have an audio hardware that supports those kind of drivers), so I was told anyway by someone who does music recording under Linux.

But, yes, there are a million ways to skin the cat

Is that hobo talk, or an aspect of American cuisine that eluded me so far?

Posted: 2/11/2020 7:53:45 PM

From: Northern NJ, USA

Joined: 2/17/2012

"250ms, argh. But it's a normal PC, not an Android tablet, right?"  - tinkeringdude

Double argh!  It's a normal (thought aging) PC.  With it I never had much trouble recording with low latency in WinXP.

"Is that hobo talk, or an aspect of American cuisine that eluded me so far?"

Hobo talk!  :-)  Kinda like "you can't swing a dead cat without hitting [something seemingly ubiquitous]".  As a cat loving child I loathed these phrases, but now find them to be rather quaint.

Posted: 2/11/2020 11:10:58 PM

From: Northern NJ, USA

Joined: 2/17/2012

Musical Instrument Samples

If anyone is looking for high quality samples of common acoustic instruments, the University of Iowa Electronic Music Studios has some nice ones:


To get to them you have to go up to the top menu and click on:

Musical Instrument Samples | Pre-2012 | Woodwinds | Flute, etc. 

Instruments are sampled note by note over their full range, and with various levels and forms of excitement.  I mostly grabbed the Pre-2012 MP3 ZIP file "blobs" where they were offered.

This sort of thing really helps when you are trying to analyze and "dial in" a particular instrument sound on an analog (or DSP-based analog analog) synth.

Posted: 2/12/2020 6:22:07 PM

From: Northern NJ, USA

Joined: 2/17/2012

Muted Trumpet

As a child I played trumpet in the school band for a couple of years.  When practicing at home I had to use a mute, which increased the back-pressure and made playing in general more difficult.  As a result of this experience, it took a me long time for me to not see a mute as a minor torture device, and to appreciate the interesting timbre that a mute can produce.

When researching muted trumpet physics a while back I found that the underlying trumpet sound is all harmonics fed through a very low Q second order bandpass filter set to around 800Hz.  Unlike most voices, adding a touch of odd harmonic emphasis doesn't seem to increase the realism*.  The mute is then implemented via three relatively high Q formants set to roughly 1.25kHz, 1.65kHz, and 2.5kHz**.

I was somewhat surprised that the mute sound didn't seem to need anything in the way of clipping or distortion, though the variable harmonic oscillator employed on the D-Lev is set on this voice patch to heavily modulate the harmonics with volume.  This can sound rather like clipping, even though it's an essentially linear process.

So the characteristic "mute sound" is the variable rich harmonics of the horn source stimulating a small handful of high Q mute formants, and that's about it.  As with string patches, applying vibrato to the muted horn helps to further reveal these formant locations by sweeping the harmonics through them, which increases the realism***. The muted trumpet timbre is so distinctive, one might easily think there is more going on in terms of the physics and non-linearity and such, but to a first degree at least there really isn't.  It's relatively low hanging fruit on the "kinda real sounding" (or at least: "I can identify what instrument you're trying to imitate") synthesis tree.


* Roger's name should be forever attached to this important and fundamental observation / discovery:  "Hessian Harmonics?"  "The Hess Factor?"  "Hess Oddness?"

** Formants are second order bandpass filters in parallel with each other in a "bank" - and this filter bank is placed in series with the source.

*** Here I've recorded the beginning of the Little Rascals theme, first without and then with vibrato: [MP3]

Posted: 2/12/2020 7:09:05 PM

From: Portland, Oregon

Joined: 2/22/2018

  This can sound rather like clipping, even though it's an essentially linear process.So the characteristic "mute sound" is the variable rich harmonics of the horn source stimulating a small handful of high Q mute formants, and that's about it. 

Interesting...OT but anyway: this is I am guessing for a straight mute - would a cup/harmon mute be different?

Posted: 2/12/2020 9:58:14 PM

From: Northern NJ, USA

Joined: 2/17/2012

"this is I am guessing for a straight mute - would a cup/harmon mute be different?"  - bendra

I first investigated muted trumpet here:


I'm going for that Harmon mute sound, with or with the stem:


These guys demonstrate a bunch of mutes:


The mute I had as a kid was an aluminum Harmon.  I guess what surprises me the most is that the metallic sound of a mute isn't so much the metal itself resonating.  You can get a very similar harsh sound from a rubber toilet plunger mute with a hole cut in the end.

Posted: 2/13/2020 6:03:48 PM

From: Northern NJ, USA

Joined: 2/17/2012

Minor UI Updates

Editing the editor / librarian to reflect the latest D-Lev SW changes:

You can see the new "Stor" encoder on the "D-LEV" page (upper left) which stores user voice presets.  And you can see the new "Load" and "Stor" encoders on the "SYSTEM" page (lower right) which load and store system presets.  None of these have values associated with them in the editor, and this is because their functionality exists outside of and over the preset system.  "Mute" is capitalized, since it is now a system parameter.

I've also renamed a few of the UI screens: 


On The SYSTEM page the "PPst" encoder enables pitch preview stereo when set to '1'.

Only four blank encoder slots left, one could handle LCD brightness.

Posted: 2/14/2020 1:14:32 AM

From: Northern NJ, USA

Joined: 2/17/2012

"Transformers" Case

Kicking some ideas around for enclosure-age.  Here's a craaazy one:

The cover is segmented three ways with the bottom segment hinged to the left, the middle segment hinged to the right, and the top segment hinged up.  Volume plate on left, pitch plate on right, tuner on top.  I'm guessing the AFE's and coils would be located under the plates, much like my current prototype, but I have no clue how cabling between the various elements might be accomplished.  The tuner could either be angled within the cover segment (shown), or the the segment hinge could be frictiony or something to allow it to not have to be positioned all the way back (not shown, but that seems like a better solution as it would allow the user to set the angle).  A "lefty" version would just be hinged opposite.

Conventional hinges and latches should work.  When closed the LCD would be under the tuner, the encoders would be under the pitch plate, and other I/O (not shown) would be under the volume plate.  Dimensions of the thing closed would be 430mm x 165mm x 200mm, with 165x165x100 plate housing dimensions (square plates).

I'm not thrilled about the ergonomics, which are obviously taking a back seat to style, but it's something that's been rattling around in my head for quite a while now, and I mostly just wanted to put it out there.

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