Inverted parabolic envelope

Type : envellope generation
References : Posted by James McCartney
Code :
dur = duration in samples
midlevel = amplitude at midpoint
beglevel = beginning and ending level (typically zero)

amp = midlevel - beglevel;

rdur = 1.0 / dur;
rdur2 = rdur * rdur;

level = beglevel;
slope = 4.0 * amp * (rdur - rdur2);
curve = -8.0 * amp * rdur2;

...

for (i=0; i<dur; ++i) {
        level += slope;
        slope += curve;
}

Comments
from : krakengore[AT]libero[DOT]it
comment : This parabola approximation seems more like a linear than a parab/expo envelope... or i'm mistaking something but i tryed everything and is only linear.

from : ex0r0x0r[AT]hotmail[DOT]com
comment : slope is linear, but 'slope' is a function of 'curve'. If you imagine you threw a ball upwards, think of 'curve' as the gravity, 'slope' as the vertical velocity, and 'level' as the vertical displacement.

from : asynth(at)io(dot)com
comment : This is not an approximation of a parabola, it IS a parabola. This entry has become corrupted since it was first posted. Should be: for (i=0; i<dur; ++i) { out = level; level += slope; slope += curve; }