A clean yet fast lookahead limiter written in Faust. It uses somewhat of a 'brute force' algorithm , so it's quite CPU-hungry.
In combination, these features provide the holy grail of limiters: fast reaction on peaks, yet hardly any distortion on sustained material. Sine waves even have zero distortion down to the very low bass, at any level.
The cost is heavy CPU usage, and a lot of latency (186 ms by default)
git clone https://github.com/magnetophon/LazyLimiter
cd CharacterCompressor
make
sudo make install
There will never be less gain reduction then what these setting dictate.
You can have gain reduction completely without distortion, yet still react quick to transients.
To hear this effect, set the minimum hold time from the next section to full and the anti pump from the 3rd section to 0.
While very clean and fast, this sound has two problems:
Input gain in dB
maximum output level in dB
0 gives a linear attack (slow), 1 a strongly exponential one (fast).
Linear sounds cleaner, exponential punchier/louder.
This is how the curve of the attack varies it's shape:
Minimum time in ms for the GR to go up
0 means independent, 1 fully linked
The GR will not go up if it has to be back here within the hold time.
maximum hold time in ms
minimum hold time in ms
shorten the hold time when the GR is below AVG
shape the curve of the hold time
scale the curve of the hold time
this section fine tunes the release to sound musical
release rate when the GR is at AVG, in dB/s
speed up the release when the GR is below AVG
slow down the release when the GR is above AVG
time in ms for the AVG to go down
time in ms for the AVG to go up
Here is a block-diagram to help explain. A clickable version can be found at https://magnetophon.github.io/LazyLimiter/. In this example, the lookahead time has been set to 4 samples, the actual limiter uses 8192 at a samplerate of 44100, and even more at higher samplerates.
As with any lookahead limiter, there is a block calculating the gain reduction (GR), and that value is multiplied with the delayed signal.
Notice that all values inside GainCalculator are in dB: 0dB meaning no gain reduction, and -infinite meaning full gain reduction; silence, and In other words, the smaller the value, the more gain reduction.
Inside the GainCalculator, there are 3 blocks doing the work: attackGainReduction, hold and releaseEnvelope.
The attack is calculated as follows:
currentdown@1*(1/4)
currentdown@2*(2/4)
currentdown@3*(3/4)
currentdown@4*(4/4)
Hold works as follows:
(currentdown@(0):max(lastdown))
(currentdown@(1):max(lastdown))
(currentdown@(2):max(lastdown))
(currentdown@(3):max(lastdown))
We take the minimum of attack and hold, and enter it into the release function, which is just a 0 attack, logarithmic release envelope follower. This is the signal that is multiplied with the delayed audio, as mentioned in the explanation of attack.
You can choose the maximum attack and hold time at compile time by changing maxAttackTime and maxHoldTime. This way various compromises between quality and CPU usage can be made. They are scaled with samplerate, but you have to manually set it at compile time.
I've made the shape of the attack curve variable, by putting a wave-shaping function after the "1/4 trough 4/4" of the attack example. Both the hold time and the time of the releaseEnvelope automatically adapt to the input material.
I am looking for ways to reduce the amount of parameters, either by choosing good defaults or by intelligently coupling them.
I got a lot of inspiration from Sampo Savolainen's foo-plugins.
My first implementation was a lot like the blockdiagram in the explanation; at usable predelay values it ate CPU's for breakfast. Yann Orlarey provided the brainpower to replace the cpu-power and made this thing actually usable!
Many thanks, also to the rest of the Faust team!