[sdiy] Fast envelope generation
music.maker at gte.net
Tue Dec 18 15:25:21 CET 2012
Tom Wiltshire <tom at electricdruid.net> wrote:
>On 18 Dec 2012, at 13:44, Scott Gravenhorst wrote:
>> When I've needed an exponential response for an envelope, I've used a single pole
>> lowpass IIR filt. So far, I've used this only for the release phase of an ADSR, but it
>> works very nicely (in an FPGA) and I've not had a problem with
>it's computational expense. > > BUT - perhaps I don't understand
>what you are doing? Or am I confusing logarithmic and >
>No, I don't think there's any confusion, but my bet is you're
>both on platforms with nice wide number formats. Scott's on FPGA,
>and can make his variables as wide as he wants - 32, 48-bits,
>whatever - and I bet he does.
>The trouble with doing IIR on a little 8-bit uP is maintaining
>accuracy. If you use long multi-byte variables, you finish up
>needing to do long multi-byte multiplications - slow, especially
>on a PIC with no multiply instruction. If you *don't* use long
>variables, the accuracy goes to pot.
>At one point I looked into IIR for this job, and I needed better
>than 32-bit to get the range of delay times I needed. Though the
>calculation is "simple", it finished up needing more lines of
>code for the multiply than the simple table-lookup-with-interp.
>The advantage of that method is that you can easily change the
>times and the curves shapes without any worries about the
Indeed, I tried using 18 bit arithmetic in an FPGA and found it to be lacking. This particular
test wasn't an envelope, rather it was generating a slowly changing random signal, but the
principle is the same. I wound up using 36 bit arithmetic - which in an FPGA wasn't time expensive
the way I did it, but it used more real estate (4 hardware 18x18 multipliers). I wasn't aware that
this was being done in a 8-bitter, so I now see what the problem is and I would also have gone the
lookup table route as well if such a device was a requirement.
-- Scott Gravenhorst
-- FPGA MIDI Synth Info: jovianpyx.dyndns.org:8080/public/FPGA_synth/
-- FatMan Mods Etc.: jovianpyx.dyndns.org:8080/public/fatman/
-- Some Random Electronics Bits: jovianpyx.dyndns.org:8080/public/electronics/
-- When the going gets tough, the tough use the command line.
More information about the Synth-diy