# [music-dsp] Soft-knee algo & implementation

Citizen Chunk citizenchunk at nyc.rr.com
Sun Jan 4 13:50:01 EST 2004

```followup:

i think i have a good transfer function now, but am having trouble
figuring out what softThreshHi should be.

(ignore the use of pow(). i'll get efficient later.)

Soft is a parameter that controls the width of the soft-knee. at Soft =
0, the knee is nonexistent, and hence, "hard". at Soft = 1, the knee
extends from the threshold^2 (in dB, this would be double the
threshold) to some intersection above the threshold. i can't seem to
figure out a formular for this intersection, which would be my
softThreshHi.

[code]

// soft-knee thresholds
softThreshLo = pow ( Thresh, (1.0 + Soft);
softThreshHi = ?????

// in sample loop ...
if ( env > softThreshHi )
gR = pow ( (thresh / env), (1.0 - ratio) );
else if ( env > softThreshLo )
gR = pow ( ( ( 1.0 - env + thresh*(env - softThreshLo) ) / (1.0 -
softThrehLo) ), (1.0 - ratio) );
else
gR = 1.0;

[/code]

i tried setting up an equality with my regular comp function and my
soft comp function, but i just couldn't reduce it to something that
gave me the upper intersection.

does anyone have any ideas? if you have a completely different way of
doing this, please let me know.

On Jan 4, 2004, at 12:36 AM, Citizen Chunk wrote:

> hi all. happy new year!
>
> i've been trying to figure out how to implement a soft-knee in my VST
> compressor. the Soft parameter will range from 0 to 1.0, where 1.0 is
> a curve from twice the threshold (in dB) to half of the threshold.
> e.g. if thresh = -12dB, the curve will run from -24dB to -6dB when the
> soft-knee is set to 1.0. at soft = 0, there will be a corner at -12dB.
>
> i first figured that i should set a Hi and Lo soft threshold, based on
> the criteria above. i came up with:
>
> softThreshLo = thresh ^ ( 1 + k )
>
> softThreshHi = thresh ^ ( 1 / (  1 + k ) )
>
> then in my sample loop, after the envelope has been calculated ...
>
> if ( env > softThreshHi )	// if the envelope is out of soft knee range
> 	gR = ( thresh / env ) ^ ( 1 - ratio )	// regular gain reduction
> else if ( env > softThreshLo )	// if envelope is in soft range
> 	gR = ( thresh / env ) ^ ( 1 - ratio )	// calculate regular gain
> reduction
> 	gR = gR ^ ( (env - softThreshLo) / (softThreshHi - softThreshLo) )
> else
> 	gR = 1	// otherwise, gain reduction set to unity
>
> out = in * gR
>
> the problem with this scenario is that, if you graph it, the transfer
> curve has a hump in the soft-knee range. in other words, the soft-knee
> is actually LOUDER than the hard-knee transfer function in the
> "soft-zone". i've tried all sorts of different transfer functions, but
> nothing seems to work.
>
> does anyone have some advice? perhaps a better way of going about
> this? am i missing something fundamental here?
>
> dupswapdrop -- the music-dsp mailing list and website: subscription
> info, FAQ, source code archive, list archive, book reviews, dsp links
> http://shoko.calarts.edu/musicdsp
> http://ceait.calarts.edu/mailman/listinfo/music-dsp
>

```