It seems that there was something funky after all in the compressor: the order of calculations was somewhat different from accepted practice. Namely, the current compressor is roughly:
- Calculate power (x^2)
- Attack/release smoothing
- Gain calculation
- Makeup gain (inverse gain)
However, looking at https://se.mathworks.com/help/audio/ref/compressor-system-object.html, we see quite clearly that the order on Matlab pages is
- Calculate power
- Gain calculation
- Attack/release smoothing
- Makeup gain
Thus, while the difference between these is not huge, the gain calculation is a nonlinear operation so it matters in which order the smoothing and gain calculation are done. And the current implementation does create a release that can look like linear, until it hits the threshold, and then stops releasing at unity (followed by makeup gain). Whereas, in the version on the matlab pages, the release will be IIR: after a sharp peak, the release is a first order response with infinite impulse response, with the gain approaching one.
This discrepancy might be the reason why Ronny reported problems with the compressor. Both approaches work, but perhaps the order on Matlab pages / the new approach is what people expect. Consider brutally changing to the new approach (breaking changes) or adding another compressor with the old approach.
It seems that there was something funky after all in the compressor: the order of calculations was somewhat different from accepted practice. Namely, the current compressor is roughly:
However, looking at https://se.mathworks.com/help/audio/ref/compressor-system-object.html, we see quite clearly that the order on Matlab pages is
Thus, while the difference between these is not huge, the gain calculation is a nonlinear operation so it matters in which order the smoothing and gain calculation are done. And the current implementation does create a release that can look like linear, until it hits the threshold, and then stops releasing at unity (followed by makeup gain). Whereas, in the version on the matlab pages, the release will be IIR: after a sharp peak, the release is a first order response with infinite impulse response, with the gain approaching one.
This discrepancy might be the reason why Ronny reported problems with the compressor. Both approaches work, but perhaps the order on Matlab pages / the new approach is what people expect. Consider brutally changing to the new approach (breaking changes) or adding another compressor with the old approach.