K1 - RMS compressor
Posted: Thu Nov 24, 2016 3:01 pm
Hi all,
In the last few weeks I had been exploring compressor design. I'd like to share my findings with you, for feedback as a well as simple data sharing.
There are many approaches to audio compression, so let me start with a 'bread & butter' design - a feedforward, RMS based stereophonic compressor.
The first model for me to present here is named 'K1' (hopefully more will follow soon).
The K1 is a feed-forward compressor, designed for 'down-compression' i.e. lower the signal parts which are higher than the given threshold.
The 'side-chain' channel is the part which 'calcultaes' how much to compress (at this stage it is based on the original signal, not 'side-chain' of a different channel in the DAW).
The Side chain is marked in red in the following image.
http://imgur.com/RmrRBML
Open the compressor main module (named: compressor) and see its inside.
The 'side-chain' channel is based on:
(ED - Energy Detector) --> (TF - Transfer Function) --> (EF - Envelope Follower).
Being a none-linear device, the order of processors is important.
Note that the TF and EF are based on 'logarithmic' calculation.
The TF and EF are pretty much straight forward.
TF
TF will process the signal only if it has passed the threshold. It also decides 'how much to process' based on the ratio. (input controls: Threshold and Ratio).
EF
EF will 'smooth' the signal by 'Attack' and 'release' times. (input controls: Attack and Release).
Notice that 'Attack' and 'Release' are symmetric and carry the same 'time constant' function, which is:
T = 1-exponent^(-1/(Fs*T))
This is a 'by the book' calculation of time constants and might vary tremendously if compared to 'analog modelled' compressors or other proprietary solutions.
ED
Compressors vary much by the ED itself. After all this module will 'declare' the energy level of incoming signal for reference.
An RMS approach is used here, in which:
So, it is first order IIR filter like window with a 'weighting' function (a) which decides how much to rely on previous result Vs. incoming sample.
a is sometimes referred to as Alpha.
Alpha's time constant is similar to 'Attack' and 'Release'.
Using Alpha, attack and release, one can decide the full timing of the algorithm.
Stereo processing
Some thought has to be taken for stereo processing.
If one channel's input surpasses the threshold (and requires processing) - both channels (Left and Right) need to be processed simultaneously, to avoid the sound 'bouncing' from left to right.
So, the K5 first squares each of the inputs (L_sample and R_Sample) and then chooses the current maximal sample value.
Notice that one must first square the signal to avoid comparing a negative value (samples are originally bi-polar). This will reverse the meaning of 'maximum' of course.
Hope this contributes to the forum and friends... Any question/remarks please go ahead.
K1 is built using Flowstone 3.0.8.1 Skylark version.
Rocko
In the last few weeks I had been exploring compressor design. I'd like to share my findings with you, for feedback as a well as simple data sharing.
There are many approaches to audio compression, so let me start with a 'bread & butter' design - a feedforward, RMS based stereophonic compressor.
The first model for me to present here is named 'K1' (hopefully more will follow soon).
The K1 is a feed-forward compressor, designed for 'down-compression' i.e. lower the signal parts which are higher than the given threshold.
The 'side-chain' channel is the part which 'calcultaes' how much to compress (at this stage it is based on the original signal, not 'side-chain' of a different channel in the DAW).
The Side chain is marked in red in the following image.
http://imgur.com/RmrRBML
Open the compressor main module (named: compressor) and see its inside.
The 'side-chain' channel is based on:
(ED - Energy Detector) --> (TF - Transfer Function) --> (EF - Envelope Follower).
Being a none-linear device, the order of processors is important.
Note that the TF and EF are based on 'logarithmic' calculation.
The TF and EF are pretty much straight forward.
TF
TF will process the signal only if it has passed the threshold. It also decides 'how much to process' based on the ratio. (input controls: Threshold and Ratio).
EF
EF will 'smooth' the signal by 'Attack' and 'release' times. (input controls: Attack and Release).
Notice that 'Attack' and 'Release' are symmetric and carry the same 'time constant' function, which is:
T = 1-exponent^(-1/(Fs*T))
This is a 'by the book' calculation of time constants and might vary tremendously if compared to 'analog modelled' compressors or other proprietary solutions.
ED
Compressors vary much by the ED itself. After all this module will 'declare' the energy level of incoming signal for reference.
An RMS approach is used here, in which:
- Code: Select all
E = x^2*a+(1-a)*En1
En1 = E
So, it is first order IIR filter like window with a 'weighting' function (a) which decides how much to rely on previous result Vs. incoming sample.
a is sometimes referred to as Alpha.
Alpha's time constant is similar to 'Attack' and 'Release'.
Using Alpha, attack and release, one can decide the full timing of the algorithm.
Stereo processing
Some thought has to be taken for stereo processing.
If one channel's input surpasses the threshold (and requires processing) - both channels (Left and Right) need to be processed simultaneously, to avoid the sound 'bouncing' from left to right.
So, the K5 first squares each of the inputs (L_sample and R_Sample) and then chooses the current maximal sample value.
Notice that one must first square the signal to avoid comparing a negative value (samples are originally bi-polar). This will reverse the meaning of 'maximum' of course.
Hope this contributes to the forum and friends... Any question/remarks please go ahead.
K1 is built using Flowstone 3.0.8.1 Skylark version.
Rocko