Sali Andre,

I'm just now seeing your answer, thanks!  It seems a lot more
complicated--but probably far more thorough--an explanation than I have.

The solution I hit upon to generate coefficients "multiplier" and "delta"
for the sample-by-sample calculation

current = previous * multiplier + delta

was to do the following calculations ONCE, AT INITIALIZATION TIME:

1)  multiplier = pow( startLevel / endLevel, curve / secs / sampleRate )

This can be thought of as "curve" being approximately how steep the curve
should start, relative to linear, than exponential.  curve=2 will be twice
as steep initially (for falling segment) or finally (for rising segment).
curve=.5 will split the distance between the linear and exponential curve's
initial (final) slope, and so on.  Pretty intuitive.

2) solve for delta with a binary search over [-1,1] (can be much more
optimized), to find a delta that reaches endLevel in the right number of
samples.  (Seems to take at most 40 iterations for 1/2 second curves).

 Curve of 0 gives a multiplier of 1, so you get a linear "curve."  For this
special and very common curve, just calculate:

delta = ( endLevel - startLevel ) / sec / sampleRate

Curve of 1 will give an exponential curve that needs no delta.  For this
special and very common curve, just calculate:

delta = 0.

Otherwise the iterative method finds a delta for curve values about
[-6.6,6.6] for a half-second curve rising from 0+-47dB to 1+-47dB.  (-47dB
is a default value in my envelope for an epsilon shift, allowing
exponential curves to reach 0.)  Negative curve values will produce the
exact same curve as the corresponding positive, except reversed top to
bottom and left to right.

It looks like your delta calculation is going to be much faster than my
iteration :-D  But one little advantage of the  iterative search is that it
will find a delta that actually works (if there is one), even if floating
point rounding errors make the theoretical number not work.

----------------

Reading your paper, it looks like you have a definition of "bend" than my
"curve".  Your bend seems to be (0,1) with .5=linear.  My curve is
theoretically infinite range but in practice more like [-5,5] with
0=linear.  Since your delta calculation refers to your bend, I won't be
able to use your formula directly.  However seeing that you found a
solution for your "bend" gives me hope that there's a solution for my
"curve."

Gruss, Frank
_______________________________________________
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Reply via email to