[sdiy] Fast envelope generation

Jim Credland jim at cernproductions.com
Tue Dec 18 12:55:50 CET 2012


Firstly, hello, it's my first post to what looks like a really
interesting group of people. 

I had a punt at something very similar earlier in the year.  I was
planning on copying amplitude envelopes from my favourite, usually
already compressed, drum samples so I could use them in the modular. 
Calcuating them on the fly wasn't going to work for that plan so I built
a table and interpolation based solution. 

On the way to a final design I built some tables of different decay
curves in excel, moved them into the microcontroller and added a curve
select knob which would  interpolate smoothly between them.  It worked
pretty well and interpolation made scaling the decay knob from fractions
of a second to a minute an absolute doddle.  

I've still got it on a breadboard here, but I'm planning on changing the
architecture to reduce the number of components.  

I've also hit a barrier with the type of DAC I've been using: there
seems to be an inherent latency in the delta-sigma based DAC in the
dsPIC of around 120uS.   Hopefully a new design based on an R2R DAC will
get rid of this issue. 

Happy to share the code if it's useful. 

cheers, J

On Tue, Dec 18, 2012, at 10:54 AM, Tom Wiltshire wrote:
> 
> On 18 Dec 2012, at 01:05, Gordon JC Pearce wrote:
> 
> > Hi all,
> > 
> > I had a thought about generating exponential envelopes on "small" microcontrollers.  Actually calculating an exponential decay is computationally expensive, so how about using a lookup table and then using something akin to a phase accumulator to set the decay time?
> > 
> > I'd need to work out exactly how to go from the attack phase to the release phase, if you released the key during attack.  However for a simple decay/release envelope like on a TB303 it would be fine.
> > 
> > I await the onslaught of "it's been done" and "it doesn't work" ;-)
> 
> This is my own example of exactly what you're talking about:
> 
> 	http://www.electricdruid.net/index.php?page=projects.envgen7
> 
> The technique is good, but needs linear interpolation to hide the gaps
> between table entries at very slow times. Which isn't an argument against
> it, just an observation. For shorter stage times and long tables, you
> could get away without it.
> 
> The only tricky bits are:
> 
> 1) Making sure you have enough bits for the variables to give you the
> range you need. I wanted a 1msec-10sec range on the curves, and the first
> version with a 16-bit accumulator couldn't do it. I had to up it to
> 24-bit.
> 
> 2) Dealing with the scaling and offset of the curve sections. As you've
> already spotted, the release stage has to be scaled from *whatever the
> value is when the gate goes low* to zero. Similarly the attack is scaled
> between whatever the value when the gate goes high and the max value.
> 
> It's a simple technique, but very versatile.
> 
> HTH,
> Tom
> 
> _______________________________________________
> Synth-diy mailing list
> Synth-diy at dropmix.xs4all.nl
> http://dropmix.xs4all.nl/mailman/listinfo/synth-diy


-- 
  Jim Credland
  jim at cernproductions.com



More information about the Synth-diy mailing list