Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

K1 - RMS compressor

Post any examples or modules that you want to share here

K1 - RMS compressor

Postby Rocko » 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:


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
Attachments
K1_RMS.fsm
(10.21 KiB) Downloaded 1522 times
Last edited by Rocko on Mon Dec 26, 2016 10:15 am, edited 4 times in total.
Rocko
 
Posts: 186
Joined: Tue May 15, 2012 12:42 pm

Re: K1 - Pro Grade compressor (?)

Postby Wassaka » Thu Nov 24, 2016 8:33 pm

Thank you very much for making the effort! Very nice! :mrgreen:
Wassaka
 
Posts: 85
Joined: Wed Dec 30, 2015 3:41 am

Re: K1 - Pro Grade compressor (?)

Postby Spogg » Sat Nov 26, 2016 2:00 pm

Hi Rocko

Many thanks for making it compatible with 3.08 so I can try it out!
I'm impressed with the results on my microphone and it's nice and easy to use, so much so that I've added it to my toolbox.

Have you considered the following points:

- There is no output clipping. On my previous soundcard (X-Fi Platinum) if the output went above +/- 1 it would either hang up or turn off the stream for a short time. My new Focusrite USB interface doesn't do this but some folk may have issues.

- So-called Look-ahead is useful for initial transients. This, as I'm sure you know, involves putting a short delay in the live path to offset the lag of the side-chain due to the ED. The larger the rms window (Alpha) and the Attack time the more delay is needed so the side-chain aligns with the transient better.

- Mouse-operated controls are more convenient than data entry, but you could have both maybe.

- It's nice to be able to visualise the side-chain action in some way like a meter or bar graph, rather than rely on just listening.

These aren't criticisms, just suggestions and I really like this, so many thanks for sharing it here.

Cheers

Spogg
User avatar
Spogg
 
Posts: 3318
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England

Re: K1 - Pro Grade compressor (?)

Postby Rocko » Sun Nov 27, 2016 4:51 pm

Hey Spogg,

Thank you for your comments, most appreciate and Good points, if I may say.

Notice that I'm saving the GUI for last.

Regarding the clip-protection, agreed. Will do.

For the look-ahead, well this is more challenging. Adding a look ahead to the system is easy of course.
But what should the look ahead be set to?
Please remember that the 'Energy Detector' in this design can change its 'window time'. So, if I'll change the look-ahead according to that (on the fly, while running), I guess I could not report the correct PDC to DAW ??

Maybe I could just provide two versions, one with a constant look-ahead, another without ?
What do you think?
Rocko
 
Posts: 186
Joined: Tue May 15, 2012 12:42 pm

Re: K1 - Pro Grade compressor (?)

Postby Spogg » Sun Nov 27, 2016 5:15 pm

Rocko wrote:For the look-ahead, well this is more challenging. Adding a look ahead to the system is easy of course.
But what should the look ahead be set to?
Please remember that the 'Energy Detector' in this design can change its 'window time'. So, if I'll change the look-ahead according to that (on the fly, while running), I guess I could not report the correct PDC to DAW ??

Maybe I could just provide two versions, one with a constant look-ahead, another without ?
What do you think?


When I made my Quilcom Mistress I gave it a manual look-ahead knob but it could be automatic and relative to the Attack and Window settings. In my case the user chooses rms OR peak detection so it would have been tricky.
If you change the Attack or rms window the look-ahead will not align correctly. However, I found in practice that look-ahead is only useful if transient suppression is appropriate to the source, say for percussion. Also, in practice, the look-ahead time need only be typically a few mS when it's needed.
So I would personally avoid a fixed time for look-ahead because it would only be accurate for one setting of the ED.

Cheers

Spogg
User avatar
Spogg
 
Posts: 3318
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England

Re: K1 - Pro Grade compressor (?)

Postby Rocko » Sun Nov 27, 2016 6:36 pm

Hi,

Appreciated. I look into it and come back with new stuff.

BTW -
Do you happen to have a good anti-clipping solution to share, or should I just add:

Code: Select all
If [(x)>0.99 then x=0.99]
if (x)<-0.99 then x=-0.99
Rocko
 
Posts: 186
Joined: Tue May 15, 2012 12:42 pm

Re: K1 - Pro Grade compressor (?)

Postby martinvicanek » Sun Nov 27, 2016 11:19 pm

User avatar
martinvicanek
 
Posts: 1315
Joined: Sat Jun 22, 2013 8:28 pm

Re: K1 - Pro Grade compressor (?)

Postby Rocko » Mon Nov 28, 2016 8:42 am

Woha !!

The 'clipper' and explanation are tremendous, thanks.

Your "cycle meter" is a great tool. Thanks for sharing...

What if the schematic uses 'pack' 'unpack' as part of its design ? Even then it seems that MV's clipper is better (or same) CPU wise.

Thanks for sharing
Rocko
 
Posts: 186
Joined: Tue May 15, 2012 12:42 pm

Re: K1 - Pro Grade compressor (?)

Postby Spogg » Mon Nov 28, 2016 10:26 am

Another thought about look-ahead.
If you have a preset manager with presets you could manually tune the compressor for each source type, say vocal, percussion, mix etc. This way you could set a look-ahead delay time and all the other parameters to be ideal for the type of application.

Cheers

Spogg
User avatar
Spogg
 
Posts: 3318
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England

Re: K1 - Pro Grade compressor (?)

Postby Rocko » Mon Nov 28, 2016 12:07 pm

Hi,

Correct, but still the PDC reporting to DAW will be wrong...
That is the (only) advantage of having two different versions, one with fixed look-ahead and one without.

I tend to believe that your sugeestion (programmable Look-ahead) is better... Just highlighting the good/bad

Thanks,
Rocko
Rocko
 
Posts: 186
Joined: Tue May 15, 2012 12:42 pm

Next

Return to User Examples

Who is online

Users browsing this forum: No registered users and 56 guests