[sdiy] Soft ADSR ways?
Magnus Danielson
magnus at rubidium.dyndns.org
Mon Feb 14 11:01:39 CET 2011
Hi Matthew,
On 14/02/11 04:09, Matthew Smith wrote:
> Quoth Magnus Danielson at 14/02/11 12:48...
> ...
>> y(n+1) = y(n) + x*b
>>
>> where x is the target level, b is a speed factor and y is the
>> instantaneous value.
>
> As someone who has serious problems with maths (I'm taking the digital
> approach because I *can* do Boolean Algebra - to a degree) I need to get
> my head around this - especially if it means I get lose the lookup table!
>
> So, let's see If I understand this correctly, using the attack phase as
> an example:
>
> x is target level - this being the number (going into the DAC) I reach
> at the end of the attack phase? If so, can I assign: x = 255 ?
For the attack part yes.
> y is instantaneous value - I guess this is the result I want to get out
> of the end, the number to push into the DAC.
yes
> b - speed factor - what is this?
>
> n - where does this come from?
The y(n) and y(n+1) is DPS-speech for "current sample value" and "next
sample value". Sorry for confusing things a bit. Essentially, for a
simple implementation you can drop the paranthesis notations in this case.
> I have been working on the basis that my attack phase y values will be
> going from 0 to 255 in 255 increments of 1. These increments would be t
> (whatever time units) long.
That will be a limitation of speed in how fast you can output that.
Rather, the approach I give will either skip steps for very fast
responses. Infact, when b = 1 then it is instantaneous, so would also a
= 1 be for the exponential variant.
> t would be 1/256 * the 8-bit ADC value from the attack pot, with
> real-world values ranging between 0 seconds and how ever many seconds I
> decide is suitable for an attack time. (Any suggestions for a maximum
> attack time would be welcome!)
>
> I now need to understand how b and n fit into this model OR if we are
> talking about a totally different way of doing it. Whatever happens, I
> know that delay between increments will still be between 0 and 255 *
> maximum attack time. (I think!)
Hack away the proposed algorithm in your favorite language and
experiment some. A simplified core would be:
y = y + (x-y)*b + x*a
You have four state to an ADSR:
1) Await trigger (gate goes high)
2) Attack phase, await maximum amplitude
3) Decay phase, await trigger (gate goes low)
4) Release phase (actually the same as await trigger)
The target value x has the following values for each state:
1) x = 0
2) x = max value
3) x = sustain value
4) x = 0
Cheers,
Magnus
More information about the Synth-diy
mailing list