|
From: ian e. <de...@cu...> - 2003-12-30 16:09:49
|
On Tue, 2003-12-30 at 10:36, be...@ga... wrote:
> Scrive ian esten <de...@cu...>:
>
>
> > > For performance reasons I'd opt for a system that uses only linear
> > > segments for both volume and pitch enveloping.
> > > exp curves and other kind of envelopes can be easily simulated by
> > > using a serie of linear segments.
> >
> > i think you would probably find this to be more expensive than having
> > log/exp curves. to create the traditional log style envelopes is
> > actually very easy, and can be done with a modified one pole (no zero)
> > lowpass filter. that just requires one coefficient calculation for the
> > whole curve, rather than doing a whole load of calculations for each
> > linear segment.
> >
>
> Expensive ? I don't think so:
> let's make this example:
>
> with linear envelopes (let's assume we allow volume and pitch envelopes)
>
> for(i=0; i < numoutput_samples; i++) {
>
> output_sample[i] = curr_volume * sample[curr_pitch];
> curr_volume += volume_delta;
> curr_pitch += pitch_delta;
> }
>
> As you see with only two additions:
> curr_volume += volume_delta;
> curr_pitch += pitch_delta;
>
> you get arbitrary volume and pitch envelopes.
> if you keep the value to zero then there is no envelope.
> Otherwise just update
> volume_delta and/or pitch_delta from time to time
> (event based).
> The system is so fast that you could even update the delta values
> eg every 4 samples allowing for arbitrary curves without significant overhead.
> But in pratice even exponential curves can be emulated using relatively
> few linear segments (in the fast changing sections you can use more points).
>
> Am I missing something ?
> Ian can you post a small code example (like I did) to show me how
> many instruction the main sample rendering loop contains, and if we
> can achieve the same as in my case above (arbitrary modulation)
>
> cheers,
> Benno
> http://www.linuxsampler.org
>
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.
so, i would say if you want a log envelope, use a real log evelope
generator, as it will make life much much easier.
ian
|