[sdiy] Soft ADSR ways?
Tom Wiltshire
tom at electricdruid.net
Sun Feb 13 11:41:11 CET 2011
You always finish up with a LUT because anyone who tries to do maths on a $2 processor is having a laugh. Doing all the maths beforehand and storing the results in a LUT is the only sensible way to avoid hard sums. There are one or two situations where doing actual, real sums is unavoidable. I had such a case with the Tap Tempo LFO. The user provides a time period given as a pair of taps, and that needs to be converted to a frequency increment value. I spent a good while thinking about how to turn that into a lookup, but in the end had to bite the bullet and do a 24-bit by 16-bit division or whatever it was. There were simply too many possible inputs to use a lookup table, and interpolation between fewer table entries wouldn't have given me enough accuracy in that case.
Hi Karl,
I tried various approaches along the lines of calculating simple RC charging/discharging curves when I was designing my VCADSR. This is essentially an impulse and a IIR filter, I guess. I found that the output wasn't bad, but that getting sufficient control resolution was very difficult. I wanted a 1:10000 range (1ms to 10secs) and I found I needed ridiculous levels of accuracy for my control variables. Ridiculous for an 8-bit PIC, anyway.
The advantages of the counter+LUT approach I finished up with were that it provided a simple way to "stretch" the envelope curve in time, the counter accuracy wasn't too extreme, and you get arbitrary envelope curves for free.
Also, you don't have to think about the whole envelope. Each stage is basically identical, with start and and end levels, a curve table to use, and a time taken. If you can do one, you can do any number. The only part that's different is "sustain", but that is easily implemented as a pause at the level which represents the end of the decay stage and the start of the release stage, assuming you want ADSR-type behaviour.
Good luck,
Tom
On 13 Feb 2011, at 10:06, karl dalen wrote:
> How many ways could one do an ADSR in? Which one are
> fastest and which one are fast and code efficient??
>
> 1.Impulse + low pass something, tight code? conceptually tricky?
>
> 2.Divide 1.0 with (time*samplerate), add/subtract value
> from envelope level for the appropriate number of samples
> does that need a LUT, no?
>
> 3.As 2 but use change state based on the envelope level +LUT?
>
> 4.Counter + level state machine + large/medium LUT?
>
> 5.Same as 4 but interpolate small LUT?
>
> 6.cube muls something?
>
> 7.......more ways?
>
> Why do i constantly end up with a LUT?!!?
> I still need to interpolate i.....hmmm..
>
> Reg
> KD (dont talk math with me im crap at it)
>
>
>
> _______________________________________________
> Synth-diy mailing list
> Synth-diy at dropmix.xs4all.nl
> http://dropmix.xs4all.nl/mailman/listinfo/synth-diy
More information about the Synth-diy
mailing list