1. IMPORTANT:
    We launched a new online community and this space is now closed. This community will be available as a read-only resources until further notice.
    JOIN US HERE

I need advice building a compressor...

Discussion in 'REAKTOR' started by Michael O'Hagan, Feb 1, 2018.

  1. Michael O'Hagan

    Michael O'Hagan NI Product Owner

    Messages:
    1,163
    I've never tangled with building a compressor before, I have no idea where to start.

    I know synths and samplers and drum machines, but compressors are a sticking point for me, I'm all done with my instrument and it could just use a light cpu compressor, I've been looking at other peoples (Salamander Anagram's) compressors but I don't really understand whats doing what inside.

    Any advice or guidance on this one is greatly appreciated.

    Thanks.
     
  2. salamanderanagram

    salamanderanagram NI Product Owner

    Messages:
    3,454
    • Like Like x 2
  3. colB

    colB NI Product Owner

    Messages:
    3,969
    You got me started damnit :)
    Here's a pretty basic compressor that should be relatively easy to understand. And I can explain the bits that don't makes sense because it all makes sense to me... scratch that, I can't attach it. I'll stick it in the experimental section of the UL and post a link.

    It's based on the very simplest compressor I know which looks something like this:

    compress.PNG

    1/u is the compression coefficient - basically the level edjustment

    The input is multiplied by the previous tick's coefficient and rectified, then low passed filtered. This gives a rough idea of the current audio level (its a feedback feedforward combination where the feedforward new input level is combined with the feedback previous coefficient - might be worth trying alternatives to this).
    This level is then clipped to ensure sensible 'goldilocks' values which are then inverted to generate the coefficient for the next tick...
    then the output of the filter is large inverting it will give a small coefficient to reduce the level. When the output of the filter is small, inverting it will give a larger coefficient to increase the level.
    Tweaking the input an ouput levels of this module and the filter frequency give some control, but it isn't going to win any prizes :)
    (I got the concept from a paper on analog delay where there is a complimentary expander circuit... compressor before the delay, expander after...)

    I've basically done two things to 'improve' this idea. Here's the 'still simple but not quite as much' version:
    compressor2.PNG

    #1 Improved the level envelope: The problem is that in the simple compressor, a fast attack means using a higher frequency for the low pass filter, but this also gives a fast decay - it's a massive compromise. What I've done is build a very simple exponential decay peak detector. This feeds into the low pass filter. Now the decay of the peak detector becomes the decay of the level envelope and the frequency of the filter softens the attack - so we have separate attack and decay parameters - yay. They are somewhat interactive, but not so much that its an issue.

    #2 Added ratio control: in the simple version, compression is just 1/u where u is the level tracking. If we raise the level to a power before inverting it, we get variable compression. From power of 0 gives 1, 1/1 = 1 so no compression through power of 1 gives the same as the simple version, up to power of 2 where levels below 1 give progressively smaller levels, and larger squared 1/u values while levels above 1 give much smaller 1/u values... result is more extreme compression.

    It's still really basic, and the attack and decay don't work quite like they would on a 'proper' compressor, but there are lots of settings that work and a range of squishing effects on offer.

    Possible improvements:
    *Side-chaining should be reasonably easy, just mixing/injecting a sidechain signal into the input of the peak follower might be enough, with a mix control...
    *some smoother clipping curve rather than hard clipping for the level value might be an improvement maybe one of tanh/asinh/atan scaled or something similar. I suppose this would provide a 'soft knee'? not sure...
    *A more rigorous mathematical approach might provide actual numbers for the attack/decay times... and maybe some alternative approach for attack would be better in general. To give the effect where transients can get through... not sure...

    It sure is an interesting project though :)
     
    • Like Like x 2
  4. Michael O'Hagan

    Michael O'Hagan NI Product Owner

    Messages:
    1,163
    Thank you ColB, I'll give this a look and see if it fits my needs, thank you my friend.
     
  5. colB

    colB NI Product Owner

    Messages:
    3,969
    It was really more as an example to show one way to build a compressor.
    But if it turns out to be useful, all the better :)
     
  6. Michael O'Hagan

    Michael O'Hagan NI Product Owner

    Messages:
    1,163
    I actually think I mis spoke my words, so to speak, I'm trying to create a brick wall limiter with high quality transparency, I just typed compressor on accident.:confused:
     
  7. colB

    colB NI Product Owner

    Messages:
    3,969
    Well, this 'aint that!

    limiter with transparency uses the same principals, but set up slightly differently. I'm not any kind of expert in this area, but I think Don's 'Pressure' would be more appropriate. It has a look ahead feature, so it can catch transients more easily and AFAIKT it's a feedforward design, so more precisely controllable, and more subtle. If you use look-ahead, it does impart some latency, but that's unavoidable. Without look ahead, you can't have transparency with anything close to brickwall settings because to catch transients an squish them without look ahead, you would need a very fast attack, and that will always cause audible artefacts. Look ahead lets you catch transients with a slower (and therefore more transparent) attack.
    A Transparent 'brickwall' limiter is a mastering tool anyway, so look ahead latency is not an issue.
    You should definitely look at Dons compressor. The internal process is actually pretty straightforward, and it's very well laid out as you would expect.

    FWIW, I've been playing around with my squisher, ducking a kick drum into a bassline with sidechain which works well. It's pumping compression though - the antithesis of transparent. Although the initial parameter ranges for attack and decay are way off. I'll maybe turn it into a Block. It's a nice way to tie the kick and bass together and I've also fed the envelope follower signal to an output which can modulate the filter cutoff on the bass, or whatever else...