|
From: Juan L. <co...@re...> - 2003-12-30 17:13:49
|
On Tuesday 30 December 2003 13:09, ian esten wrote: > > a lowpass filter with just a pole: > > y[i] = (x[i]-y[i])*c + y[i]; //x[i] is just a gate signal - 1 to turn > the env on, 0 to turn it off > > a linear segment: > > y[i] = y[i] + k; > > the lowpass filter costs you an extra add and multiply compared to a > linear segment, not much really. the trouble with the linear segment > method is that to approximate a log segment you have to do a fair number > of linear segments. it's the computation of a segments 'k' and how long > each segment must last to approximate the log shape that i believe will > make it more expensive when compared to the lowpass approach which does > the right shape in one segment with one coefficient. the only problem > with the lowpass approach is that it needs a tiny little bit of work to > guarantee that it is at maximum in a certain time, and to guarantee it > is off after a certain time. they are pretty trivial modifications > though. > another issue to consider is that the slower your attack time is, the > more segments you will need to use to approximate it without it sounding > bad. I have two things to add to this First, considering that a segment size is between 50 and 100 samples, updating the values between segments and ramping linearly inbetween (being the enveloped curved or not) will make absolutely NO audible difference than using a lowpass (I've implemented this several times, and I composed a few hundred of songs with the code :), and considering that this is the most critical part of the whole app, I have to say that i'm against adding more code in there. The segments are too small already, much smaller than the delta times between envelope points. I also read somewhere in the thread that updating every a few (4) samples would be a good idea, but I have to remind you that adding any kind of conditional inside the critical loop reduces the performance enormously in modern procesors, I believe this is because it stalls the instruction pipeline. Cheers! Juan Linietsky |