[sdiy] Soft ADSR ways?
Magnus Danielson
magnus at rubidium.dyndns.org
Mon Feb 14 03:18:56 CET 2011
On 14/02/11 00:30, David Moylan wrote:
> Isn't it possible to use a difference equation? For instance you figure
> out the difference between the current envelope value and the asymptote
> value, the divide (preferable by a power of 2, so you can just bit
> shift) then add that back to the envelope val?
For linear slopes the state y progresses from input x with
y(n+1) = y(n) + x*b
where x is the target level, b is a speed factor and y is the
instantaneous value.
Similarly for an exponential slope
y(n+1) = y(n) * (1-a) + x*a
which is better described as
y(n+1) = y(n) + (x-y(n))*a
since it becomes evident that the difference between current value y(n)
and target valye x steers the rate of change, and not only the a factor.
A combined variant could be
y(n+1) = y(n) + (x-y(n))*a + x*b
per sample:
2 additions
1 subtraction
2 multiplications
Vary a and b according to taste.
About the same thing can be done in analogue.
Cheers,
Magnus
More information about the Synth-diy
mailing list