References : Posted by Bram
Basicaly a one-pole LP filter with different coefficients for attack and release fed by the abs() of the signal. If you don't need different attack and decay settings, just use in->abs()->LP
//attack and release in milliseconds
float ga = (float) exp(-1/(SampleRate*attack));
float gr = (float) exp(-1/(SampleRate*release));
//get your data into 'input'
EnvIn = abs(input);
if(envelope < EnvIn)
envelope *= ga;
envelope += (1-ga)*EnvIn;
envelope *= gr;
envelope += (1-gr)*EnvIn;
//envelope now contains.........the envelope ;)
Added on : 15/04/02 by arguru[ AT ]smartelectronix
Nice , just a typo: //attack and release is entered in SECONDS actually in this code ;)
Added on : 17/05/05 by antiprosynthesis[ AT ]gmail[ DOT ]com
// Slightly faster version of the envelope follower using one multiply form.
// attTime and relTime is in seconds
float ga = exp(-1.0f/(sampleRate*attTime));
float gr = exp(-1.0f/(sampleRate*relTime));
float envOut = 0.0f;
for( ... )
// get your data into 'input'
envIn = fabs(input);
if( envOut < envIn )
envOut = envIn + ga * (envOut - envIn);
envOut = envIn + gr * (envOut - envIn);
// envOut now contains the envelope
Added on : 14/11/05 by madgel79[ AT ]nate[ DOT ]com
in my code , attack_coef and release_coef are always '0'.
If I use only 'abs()' , it also work well.
why can it be possible?
Would you please give me some infomation about this problem.
Added on : 19/05/09 by bob[ AT ]yahoob[ DOT ]com
Should use "fabsf" really. :)
Added on : 04/09/12 by bouzidom[ AT ]yahoo[ DOT ]com
i have a signal and i need to extract the envelope usig this code, so what are the initial attack and release values?
|Add your own comment|
Comments are displayed in fixed width, no HTML code allowed!