[sdiy] formula for exponential decay

Kenneth Martinez kmartinez at bency.com
Thu Feb 15 23:43:57 CET 2001


> > ...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
>
> Should really be
>
>                      t
> V = V        (1 - ------)
>      initial      t
>                    slope
>
> where 0 <= t <= tslope, those, tslope is the length of the slope.

oh, right


> ...First off, you don't want to calculate with the actual time t as a
> basis, but rather suffice with a method to acheive the same thing
> incrementally per sample, that is, every ts.
>
> For exponential equations this is fortunately easy. You just multiply
> instead of add!
>
> ...For the exponential decay you would do
>
> Prepare:
> C = exp(-ts/tslope)
> X(0) = 1
>
> Repeat:
> X(n+1) = X(n) * C

great!  played around with this a bit...I take it tslope represents RC from
the discharge equation...I want my expo-slope envelope to reach the sustain
level at about the same time as the linear...looking again in the The Art of
Electronics, if I account for the "5RC rule of thumb" and divide tslope by 5
in the "Prepare" equation, then the expo formula gets close to zero at the
same time as the linear.  That way I can offer selectable slope and feed the
same decay time into both formulas. Anyway, it looks good when I graph it;
we'll see how it sounds.


> Have fun, and most importantly, let us know how it goes!

Will do, once I'm far enough along to have something useful to share





More information about the Synth-diy mailing list