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

soft knee compression

Discussion in 'Building With Reaktor' started by Tun, Aug 15, 2014.

  1. Tun

    Tun NI Product Owner

    Messages:
    224
    Hi everyone, its been a while :)

    ive been trying to build a compressor with a soft knee, but i cant get my head around how to get a soft knee!

    ideally i would like the knee "edge" to be adjustable, but to understand how to create one at all would be nice.

    my first thought was to lower the threshold of the side chain by the knee amount, then apply the curve, then add the knee amount back to the side chain again after.
    when it came to getting the curve right though i could not get it smooth.

    ive looked everywhere for this and im confused as anything.

    thank you for the help
     
  2. Tun

    Tun NI Product Owner

    Messages:
    224
    nobody?
     
  3. salamanderanagram

    salamanderanagram NI Product Owner

    Messages:
    3,454
    personally i don't know anything about making a decent compressor.

    if you're looking to make nice smooth curves, though, i suggest bezier curves. i uploaded an ensemble to the UL called curveball recently that has a pretty nice bezier generator in it.
     
    Last edited: Aug 19, 2014
    • Like Like x 1
  4. colB

    colB NI Product Owner

    Messages:
    3,969
    I guess not many folks have tried implementing this - I know I haven't.

    I suppose the basic approach would be something like:

    If I'm right (it's possible, but, I'm no expert in this area), in a normal compressor, you are monitoring the signals peak level (or RMS if you want to be fancy), and if it goes above a certain threshold level, you scale it down by a combination of the amount it's over the threshold by, and a 'compression amount' factor?.
    The knee is at the threshold, and its angle depends on the compression amount.

    To make a soft knee, I guess that instead of having I fixed value above which you scale the level down, you have a region. Below the 'knee' region, you pass the signal unaltered, above the region, you use the standard compression level approach.
    Within the region, you vary the compression level depending on where about in the region you are. I guess you could use various approaches to map a curve onto this...

    I'd try something like:
    Code:
    if level > kStart AND level < kEnd               //we are in the region
          kSize = kEnd - kStart
          cScale = (1 - ((level - kStart) / kSize))       //scale to 0..1 and flip - the flip is so our curve is convex rather than concave
          cScale = cScale * cScale * cScale         //cube to get a curve
          cScale = 1 - cScale                              //un flip
          compression = compression * cScale     //scale the compression amount by the knee curve
    
    (I suppose kStart would be 'threshold - kneeSize/2' and kEnd would be 'threshold + kneeSize/2')
    
    The idea is that if we are in the knee region, the amount of compression varies with a curve from none at the bottom to our chosen compression level at the top. It should be trivial to vary the size of the knee, and if you stick to a power curve, you can try power of two or power of 4 instead of 3... A logarithmic knee would be trickier, but doable.

    NB, I have just made this up on the spot. It is untested, and the reality is probably way more complicated :)

    col
     
    Last edited: Aug 19, 2014
    • Like Like x 1
  5. Tun

    Tun NI Product Owner

    Messages:
    224
    @salamanderanagram

    thanks for the suggestion. it is the curve i am having the biggest problem with. i will have a look into that and see if i can get it to work.



    @colB

    youre spot on, thats exactly what ive been trying to do :)
    the biggest problem im having though is getting that curve within the knee region to be correct and smooth.
    i think i might have to redesign my compressor though. i made a compressor that i am really happy with and i have been trying to add on to that, but i think the whole sidechain section might need to be rebuilt from scratch :(



    thank you both for the replies.
     
  6. salamanderanagram

    salamanderanagram NI Product Owner

    Messages:
    3,454
    if you set y to a value greater than 0.5 and x = 1-y, you should get a nice clean curve out of the curveball generator (as opposed to using the XY module that is currently controlling those values.

    anyway the GUI should give you an idea if you can get the right curves or not.
     
    • Like Like x 1
  7. colB

    colB NI Product Owner

    Messages:
    3,969
    What do you think it is about your existing design that's causing the problem?
    In what way are your results incorrect or un-smooth?
    What does the output of your compressor look like when you run a slow ramp through it?
     
    • Like Like x 1
  8. Tun

    Tun NI Product Owner

    Messages:
    224
    thanks. i think i can work that into my build. it will take a lot of editing but the curve is beautiful and very flexible.

    thank you
     
  9. Tun

    Tun NI Product Owner

    Messages:
    224
    my first attempt created a curve that was fixed and didnt adjust to the ratio and my second attempt curved past the "angle" that the ratio required, giving it an odd shape that suddenly redirected at the end of the curve :)

    i think the problem was with the way i was separating the curve from the rest of the shape and with the curve i was using (i tried to recycle something from an old waveshaper i built).

    to be honest i think i need to go back to it with a fresh mind because ive only had one go at it. after talking to you and salamanderanagram i think i am on the right route, and i think with the bezier curve method in salamanderanagrams curveball i should be able to make something work.

    i originally started this thread thinking that i was on the complete wrong track and there was a method that i am missing, but separating the curve section seems to be the best way to do it.

    thank you for the help. i will analyse curveball and have another go at this when i get a chance and come back with my results.
     
  10. colB

    colB NI Product Owner

    Messages:
    3,969
    Thinking about this some more, I'm not sure that you need a Bezier curve, or even a power curve.
    If you vary the compression linearly with the level within the knee region, won't that give you a curve automatically?
    Think about it, if you vary the compression linearly, each step up in level within the knee region will change the angle of the compression ratio, multiple tiny changes in angle makes a curve !
     
    Last edited: Aug 20, 2014
    • Like Like x 1
  11. Tun

    Tun NI Product Owner

    Messages:
    224
    excellent suggestion! this would probably save a whole lot of CPU too.
    i will try that first.

    thank you