samspots wrote: 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.
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.
Code: Select all
(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 (9.19 KiB) Viewed 2267 times
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).
Code: Select all
(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)"
http://wiki.audacityteam.org/wiki/Downl ... t_plug-ins
The central part of the code for this plug-in is:
Code: Select all
(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.