[sdiy] Fast envelope generation
rburnett at richieburnett.co.uk
Tue Dec 18 22:16:08 CET 2012
> From: "Donald Tillman" <don at till.com>
> ...As the voltage on a cap rises, the difference between the source
> voltage and the cap voltage is less,
> and thus the charging current through the resistor is less, so the voltage
> rises slower. Repeat.
> So all you really need to do is duplicate that process: on each iteration
> take the difference between the
> source voltage and cap voltage, scale that by the time constant, and add
> that to the cap voltage each time.
That's exactly what the IIR filter equation implements. Rewritten in terms
of capacitor voltage Vc and input voltage Vi.
Vc = Vc + r * (Vi - Vc)
But, for the reasons Tom Wiltshire stated the simple difference equation
might not be the easiest or most flexible way of arriving at the desired
result on a low-end 8-bit microcontroller with limited maths capabilities.
At the end of the day you can burn ROM and just read from a huge exponential
lookup-table, _OR_ have a smaller LUT and some clever bit shifting and
interpolation in software, _OR_ do it all in maths without any LUT at all.
How you use your ROM, RAM and CPU cycles is as ever the designers choice :-)
More information about the Synth-diy