[sdiy] Lin/Log VCAs and envelopes - compensating for log VCAs

Tom Wiltshire tom at electricdruid.net
Sun Feb 7 14:02:36 CET 2016


On 7 Feb 2016, at 12:17, rsdio at audiobanshee.com wrote:

> 
> On Feb 6, 2016, at 2:52 PM, Tom Wiltshire <tom at electricdruid.net> wrote:
>> On 6 Feb 2016, at 22:06, rsdio at audiobanshee.com wrote:
>>> On Feb 6, 2016, at 11:08 AM, Tom Wiltshire <tom at electricdruid.net> wrote:
>>>> To be honest, this doesn't look exceptionally "natural" to me. But I don't think I'm going to argue with 50 years of synth history. If that's what we like, that's what we like.
>>>> 
>>>> Now, what I'm thinking is that I could easily tweak the tables in one of my PIC envelope generators to give these "log" curves. I could then feed the envelope to a log VCA and get the same sound you get with a typical ADSR into a OTA/linear VCA. It's a "log-compensated" envelope. Being able to switch between the two curves would enable people to use either a log or linear VCA and still get the same effect.
>>>> 
>>>> What do you all think?
>>> 
>>> Although tables can be a great implementation choice for many PIC tasks, it might actually be better to use a single pole low-pass filter for your ADSR. That perfectly recreates an RC charging / discharging circuit without requiring a linear-to-logarithmic lookup. Besides, if you have a 16-bit DAC, you probably don't have room for a table large enough to hold all 64K possible log outputs. Even a 10-bit DAC would skip a lot of output codes unless your lookup table were significantly larger than 1K entries (probably at least 8K needed). The low-pass code will require a couple of multiply instructions, but most PIC chips can handle that. If you were programming a DSP chip, you'd be set.
>> 
>> Hi Brian,
>> 
>> A single-pole IIR is a possibility that I've recently looked into, but for other jobs. The problem is that it's only efficient if you limit the coefficients to what you can do using shifts. Otherwise, you have to do multi-byte multiplication, which means a look-up is definitely more efficient. On 18F chips or dsPICs, you're probably right, but I've been working on 12F and 16F chips with no multiply instruction, so it's a *big* cost. On my envelope generators, I've used a 256-entry look-up plus a linear interpolation - this is the same cost as a basic single byte multiplication, which still gives a gain over IIR, and also gives you arbitrary envelope curves. You can easily extend a 256-entry table to 12 or 14-bits without anyone detecting that it isn't curved. Note also that even a 64K table will miss some output values if the output is non-linear, as our example is.
>> 
>> My usual rule of thumb for these basic chips is "Don't do hard sums" !
> 
> I realize that PIC chips start at $0.50 and go up to about $3 for the PIC12 and $10 for the PIC16, but a TMS320 DSP can cost as little as $3.56 (C5532), so why even start a design with something that's less capable than even a PIC18F? I realize that analog and digital are different, but if you're going to go digital then why not choose a processor that won't handicap you to distorted linear approximations? If your goal is "natural," then a DSP seems like an obvious choice.
> 
> Would anyone really notice an extra $3 or even $12 in the cost if it meant smoother CV signals?
> 
> I'm biased because I've done extensive TMS320 coding (as well as PIC). I'd like to design with the SHARC, but they start at $13 or $14 and go up to hundreds. Mouser actually has one VDSP-SHARC-PCFLT-5 for $15,010.93 (and I see many reasons not to design with that!)
> 
> Brian

Where's the fun in that?! ;)
"Use a better chip" is always a solution to the two major problems of firmware coding (not enough time, not enough memory) but the challenge is in making it work on the cheaper low-end chips, not solving the problem, which has probably been done loads of times before anyway.
I've written plenty of envelope generators for better chips - for example, some 16-bit dsPIC ones for Modcan - so I'm not against using a better chip where that's the name of the game. But here, I'm trying to keep it cheap and cheerful, and get more out of less. YMMV.

As far as "distorted linear approximations" go, a 255-piece linear approximation to a exponential curve looks a lot like an exponential curve. If you plot it on a graph, you can't see the difference. Given that people can't hear less that a few dB of volume change, they certainly won't hear it in a VCA. The tough cases are high-res filter sweeps (sine wave osc, essentially) or envelope-to-pitch-CV, since our pitch perception is so much better than our volume perception. That said, in those cases it's the smoothness of the output that is the issue (e.g. no steps or jumps in slow attacks/decays) and not the curviness (which you don't hear for slow times anyway). Since the steppiness is eliminated by interpolation, the limitation is the number of bits in the output (what DAC do we have?) not the calculation.

Regards,
Tom




More information about the Synth-diy mailing list