[sdiy] formula for exponential decay

Kenneth Martinez kmartinez at bency.com
Thu Feb 15 18:54:47 CET 2001


Just wanted to start out by thanking everyone on this list for being a
great source of information, and for inspiring me to begin building my
own analog synth.  I tried lots of virtual analogs and software synths,
but to me they just don't quite capture the sound of real analog
hardware.  Of course, being a software guy, I just *had* to go for a
computer-controlled analog ;-)  After several months, there's finally
some visible and audible progress...

Currently I'm making software envelopes to control my
still-on-the-breadboard hardware (I may add hardware envelopes later,
but I'm starting with software ones - reduces the initial hardware
complexity too).  I started simple by using linear attack and decay.  To
my ears, linear sounds fine for attack, but for decay I'd like to
include the traditional and more pleasant-sounding exponential decay.
Checked several circuits and saw that a discharging capacitor generates
this; checked a textbook which says the formula for an RC discharge is:

                                 -t / RC
    V  =  V          *   e
               initial

My formula for linear decay is just:

   V  =  V          -  ( t  *  decay slope)
               initial

Now, the program is designed to calculate the next envelope level by
taking the current level and subtracting a constant which was computed
from the user-selected decay setting and the fixed refresh time period
(since the above formula produces a straight line graph, and the first
derivative of that is a constant).  If the decay setting changes, the
periodic level change constant is recomputed and the envelope continues
from its current point with the new decay rate.  This method easily
allows retrigger of the attack phase during decay, or the attack phase
to be cut short and jump into the decay phase.

It is at the point where I attempt to do the same thing for exponential
decay that my atrophied math skills fail me...so...first, I'd like
confirmation that the RC formula above does in fact describe the decay
portion of  hardware-generated exponential envelopes; or if not, what is
the correct formula?  Then, if someone would be so kind as to show a
formula that could be applied to calculate the next envelope level given
the current level & time & RC constant (decay rate), that would be most
appreciated.  A reasonable approximation would be fine (particularly one
that's not terribly computation-intensive); I'm using floating-point
math now, but of course an integer-based solution could also be used.

Once I get this formula, I can also apply it for exponential portamento,
etc.  It's not holding up progress, but needs to be done at some point.

Thanks





More information about the Synth-diy mailing list