Negating the effects of soft limiting

Well, I noticed that it is very common to use soft limiting to make audio louder, and I was wondering whether there is a viable way to test for amount and softness of limiting on waveforms, and remove it. I could not do it through any of my known waveform modification techniques, and the clip fix filter is totally useless. The technique I thought could work would be to take audio, copy it, re-apply what I think is the amount of limiting they did, invert it, and combine. Instead, this just produces a ridiculously-limited waveform. What am I doing wrong, and is there a more precise way to do this? I am aware of bit rate loss that can be somewhat fixed by oversampling.

If by “soft limiting” you mean “dynamic range compression”, then it is possible to reverse dynamic range compression using an expander.

There is a free plugin for Audacity called Chris’s Compressor, if you put a negative value in it for the “compression ratio” it acts as an expander: expanding the dynamic range, i.e. making the quiet bits quieter and the loud bits louder.

see “loudness war” … Loudness war - Wikipedia

Nono, not dynamic range compression. Getting rid of that is nearly impossible without some sort of breathing. I’m talking about soft limiting, which applies a variable amount of distortion and a big gain in loudness by crushing the waveform. No attack or release or anything.

Attached is a before-after example of using Chris’s Compressor as an expander to reverse dynamic range compression, (judge for yourself whether there is breathing or other obvious unpleasant artifacts in the “After” version) …

The effect you are referring to is more accurately described as “soft clipping”.
Yes it is possible to reverse soft clipping, but you need to know:

  1. the threshold level at which the “crushing” starts.
  2. the “contour” of the “crushing”.

The type of “limiting” that you are referring to works by applying non-linear amplification to the waveform.
Up to a set threshold level, the amplification is linear - in the most simple case a 1:1 ratio = what you put in is what you get out = no effect.
Above the threshold level, negative amplification is applied, so an increase in the input amplitude produces a smaller increase in the output amplitude.

In the most simple case, the amplification above the threshold is linear, but at a lower ratio.

Here’s an example of such a “soft limiter” written in Nyquist.

(setq thresh 0.5)
(setq ratio 4.0)

(setq nthresh (* -1 thresh))
(setq ratio (/ ratio))
(setq tops (s-max s thresh))
(setq mids (s-max (s-min s thresh) nthresh))
(setq bottoms (s-min s nthresh))

(setq tops (mult ratio tops))
(setq bottoms (mult ratio bottoms))

(sum tops mids bottoms)

To use this effect, Select the audio, then from the “Effect” menu select “Nyquist Prompt”.
Copy and paste the above code into the Nyquist Prompt text box and apply it.

Here’s a sine wave (amplitude 1.0) where I have applied the effect to a section:
trackpanel000.png
As you can see, the waveform above the threshold (+/- 0.5) has been “crushed” with a ratio of 4:1
This would allow the processed (soft clipped) wave to be amplified, producing a “louder” mix.

In this case we can easily reverse the effect by applying amplification with a ratio of 1:4 to the “crushed” part of the waveform.
Here’s the code (the only difference is that the 4th line of code has been omitted).

(setq thresh 0.5)
(setq ratio 4.0)

(setq nthresh (* -1 thresh))

(setq tops (s-max s thresh))
(setq mids (s-max (s-min s thresh) nthresh))
(setq bottoms (s-min s nthresh))

(setq tops (mult ratio tops))
(setq bottoms (mult ratio bottoms))

(sum tops mids bottoms)

The problem of reversing the initial effect is made slightly more complicated if we had amplified (maximised) the waveform after crushing the tops and bottoms.
In the given example, the crushed waveform could be amplified by about 4.1 dB (approximately 1.6 times).
In this case we would need to first amplify the waveform by -4.1 dB (1/1.6) in order to make room for the peaks that we wish to expand. This would also bring the “threshold” (the point at which the waveform starts to get clipped) back down to the original threshold level of 0.5 (approximately -6 dB).

Unfortunately the “simplest case” given above is rarely if ever used because for high “crushing” ratios it does not sound very good.
Rather than using a linear reduced gain above the threshold value, the gain is usually reduced progressively. Instead of having a “corner” in the gain map at the threshold level, the amplification will be curved rather than linear.

For example, the gain (amplification) at the threshold level may be 1:1, then just above the threshold it may reduce to 1:2, then a bit above that reduce further to 1:3, then 1:4 and so on in a curve. An example of this type of soft clipping can be found in the “Broadcast Limiter II (RFT-Limiter-II.ny)” Missing features - Audacity Support
The central part of the code for this plug-in is:

(scale (/ 1 (/ vl (db-to-linear 0.45))) (sim
  (scale 0.2 (clip s vl))
  (scale 0.2 (clip s (db-to-linear (- limit 0.25))))
  (scale 0.2 (clip s (db-to-linear (- limit 0.50))))
  (scale 0.2 (clip s (db-to-linear (- limit 0.75))))
  (scale 0.2 (clip s (db-to-linear (- limit 1.00))))
))

In effect, what this is doing is progressively decreasing the gain in 5 steps when the amplitude rises above the threshold level.
Although this is not a “smooth” curve, it is a lot smoother than having a single high ratio step. It also makes it a lot more difficult to accurately reverse the effect.
The effect can be approximately reversed using the second code example, provided that you can make a good guess of the threshold and ratio.

I think the decibal limit is at 5, and the softness is 0.1, so how would I approximate that?

“softness” is not a standard measurement. The amount of “crushing” will depend on what effect was used to create the soft clipping.
Probably the best you will do is to experiment with the code that I posted. Experiment with different values for “thresh” (threshold) and “ratio” and see which sounds best.