Hey guys,
I'm looking to design a simple signal compressor. I've got the code for an envelope follower where the attack and decay rate of the follower can both be independently controlled (up to a point). What I'm looking to do now is convert this into a compressor, can anybody help me on this? My first assumption was to add 1 to the envelope signal and divide the input signal by this sum as a crude version of compression. Any help is appreciated! Btw, I've only currently simulated the envelope code in Matlab though I'm 99% sure it should work fine in C too.
Code snippet:
if(abs(In) > Env){
Env = abs(In); //Peak detection
}
Env = Env - Env/Speed; //Envelope decay - "Release"
EnvLP = EnvLP + (Env - EnvLP)/Smooth; //"Attack" portion (merely a low passed envelope)