@@ -29,7 +29,7 @@ LSP_DSP_LIB_BEGIN_NAMESPACE
2929#pragma pack(push, 1)
3030
3131/**
32- * Compressor knee is a curve that constists of three parts:
32+ * Compressor knee is a curve that consists of three parts:
3333 * 1. Part with constant gain amplification in the range [-inf .. start] dB
3434 * 2. Soft compression knee in the range (start .. end) dB present by the quadratic function (2nd-order polynom)
3535 * 3. Gain reduction part in the range [end .. +inf] dB present by the linear function (1st-order polynom)
@@ -40,7 +40,7 @@ LSP_DSP_LIB_BEGIN_NAMESPACE
4040 * 3. Compute the natural logarithm of the x: lx = logf(x).
4141 * 4. If x < end then compute the gain using the 2nd-order polynom: gain = (herm[0]*lx + herm[1])*lx + herm[2]
4242 * 5. Otherwise compute the gain using the 1st-order polynom: gain = tilt[0]*lx + tilt[1]
43- * 6. return expf(gain)
43+ * 6. return expf(gain) * x
4444 */
4545typedef struct LSP_DSP_LIB_TYPE (compressor_knee_t )
4646{
@@ -61,6 +61,30 @@ typedef struct LSP_DSP_LIB_TYPE(compressor_x2_t)
6161 LSP_DSP_LIB_TYPE (compressor_knee_t ) k [2 ];
6262} LSP_DSP_LIB_TYPE (compressor_x2_t );
6363
64+
65+ /**
66+ * Gate knee is a curve that consists of three parts:
67+ * 1. Part with constant gain amplification in the range [-inf .. start] dB
68+ * 2. Transition zone in the range (start .. end) dB present by the quadratic function (2nd-order polynom)
69+ * 3. Part with constant gain amplification in the range [end .. +inf] dB
70+ *
71+ * The typical algorithm of computing the gate's curve:
72+ * 1. Take absolute value of the sample: x = fabfs(in)
73+ * 2. If x <= start then return gain_start * x
74+ * 3. If x <= end then return gain_end * x
75+ * 4. Compute the natural logarithm of the x: lx = logf(x).
76+ * 5. Compute the gain using the 3rd-order polynom: gain = ((herm[0]*lx + herm[1])*lx + herm[2]*lx) + herm[3]
77+ * 6. return expf(gain) * x
78+ */
79+ typedef struct LSP_DSP_LIB_TYPE (gate_knee_t )
80+ {
81+ float start ; // The start of the knee, in gain units
82+ float end ; // The end of the knee, in gain units
83+ float gain_start ; // Gain below the start threshold
84+ float gain_end ; // Gain above the end threshold
85+ float herm [4 ]; // Hermite interpolation of the knee with the 3rd-order polynom
86+ } LSP_DSP_LIB_TYPE (gate_knee_t );
87+
6488#pragma pack(pop)
6589
6690LSP_DSP_LIB_END_NAMESPACE
0 commit comments