[sdiy] Integer exponential envelope generation

Scott Gravenhorst music.maker at gte.net
Tue Nov 22 15:43:00 CET 2011


Gordon JC Pearce <gordonjcp at gjcp.net> wrote:
>Ages ago there was a discussion about generating envelopes with 
>integer arithmetic, for microprocessors. I can't now find that, 
>because I can't remember exactly when it was or what the subject 
>line was. Browsing back through the mail archive hasn't fired any 
>rusty neurons, either. 
>
>Can anyone remember much about it, and give me a clue?
>

Not sure if this is what you wanted but:

Integer arithmetic can be used to facilitate fixed point arithmetic. 
Commonly, a 16 bit integer is used as "1.15" or one integer bit (the
sign bit) and 15 bits after the binary point.  This method represents
numbers in the range of approximately -0.9999 to +0.9999.

My ADSRs use this format.  

As for exponential response, a single pole IIR lowpass filter is used.
 For example, if the memory element (y in the formulae below) is
cleared and then a value of 0.9999 is presented to the input, the
output will follow an exponential curve until 0.9999 is reached.

There are two forms to choose from depending on whether negative values
will be needed.

for +/- values:

y = a0 * input + b1 * y  (where b1 = 1.0 - a0)

for + only values

y = y + b1 * (input - y)  (where b1 is the "time constant")

This models a simple passive RC lowpass filter.

-- ScottG
________________________________________________________________________
-- 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 mailing list