Skip to content

switching the order of gain calculations and smoothing in compressor #203

@vsariola

Description

@vsariola

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:

  1. Calculate power (x^2)
  2. Attack/release smoothing
  3. Gain calculation
  4. 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

  1. Calculate power
  2. Gain calculation
  3. Attack/release smoothing
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions