SimpleCompressor: JUCE processor with article of how to implement look-ahead

Hey everyone,
I finally found some time to publish my little compressor class on github along with an article about look-ahead limiters, as there are plenty of wrong implementations out there.
Spoiler: it’s not just delaying the input signal :wink:

The two main classes are purely C++ without any dependencies other than the std lib. There’s also a wrapper to act as a JUCE dsp processor, so it can be easily used with JUCE.

There’s also a visualization of the compressor characteristic curve, and a small multi-channel sample delay class, which is needed for the look-ahead.

Two JUCE plug-in projects demonstrate the use of the wrapper and the classes for the look-ahead compressor / limiter.

Check it out here:

The article: https://github.com/DanielRudrich/SimpleCompressor/blob/master/docs/lookAheadLimiter.md

In case you find any bugs, or possible optimizations, let me know :slight_smile:
Cheers
Daniel

22 Likes

Finally someone explained look-ahead properly with open source code !

A few quick remarks for now:

  • I had a bunch of warnings (float to int conversion) and errors on Windows (std::atomic or std::min not available)
  • I think the plug-in should report the 5 ms of latency when the option is enabled :wink:

Thanks a lot for sharing this project !

Thanks for the feedback!
Valid point with the latency, will add it!
To be honest, I haven’t tested it on windows, but will do :slight_smile:

2 Likes

Yeah, all I can say is thanks for the explanation and code samples. :slight_smile:

3 Likes

Just diving in your article this morning. Great explanation, thanks for sharing this.
One question though. You mention delaying both input and side chain. Can we spare a delay line by first doing step 2, delaying the input channels. From there, calculate the gain reduction.

Thanks,
Milan

That would be the setup without lookahead.
The lookahead works by evaluating the sidechain at a different time, i.e. earlier.
Because you need to be independent from the block size, you need both delay lines.

Yes that was my first though as well. Then i read in the article that " Delaying both input and gain reduction signals" is the second step. Using the same delay time. That would mean we can calculate the gain reduction from that point right. Then at step 3, the actual lookahead function begins.