audacity / audacity

Audio Editor
https://wiki.audacityteam.org/wiki/For_Developers
Other
11.59k stars 2.2k forks source link

Real-time-capable limiter #6305

Open saintmatthieu opened 1 month ago

saintmatthieu commented 1 month ago

Your idea

A limiter is an essential component in a mastering chain to reduce severeness of clipping. Add a limiter to Audacity's built-in real-time effects. If appropriate, design it so that it can also be used as compressor. Stretch goal: make it configurable for extra smoothness and classical music, in a Chris's compressor style.

Problem to be solved

Also, Audacity lacks real-time limiter and compressor, although these are essential to mastering. Stretch goal would also resolve #2397.

Prior art

No response

Additional context

No response

forart commented 3 weeks ago

....what about "porting" existing opensource ones ?

Some examples:

EDIT: @saintmatthieu I've collected some interesting open source Mastering tools for my HyMPS project: enjoy.

Hope that inspires.

nhthn commented 3 weeks ago

Flattered, but I don't recommend my SafetyLimiter -- I've found cases where it sounds bad. Designing a good brickwall limiter is pretty challenging, it turns out.

saintmatthieu commented 3 weeks ago

Great resource, @forart, thank you very much! I haven't looked at all the referred repos in depth, but it looks indeed like a gold mine of inspiration. FYI I'm integrating Daniel Rudrich's SimpleCompressor, at least as starting point. (I haven't seen this repo mentioned in your HyMPS project?) Besides readily being in C++, it is predictable, has all controls primarily needed, and is well documented.

forart commented 3 weeks ago

Great resource, @forart, thank you very much! I haven't looked at all the referred repos in depth, but it looks indeed like a gold mine of inspiration.

Well, that's why the HyMPS project exists: stimulate collaborations/knowledge-exchange between open source developers to favor their projects/softwares mutual evolution.

FYI I'm integrating Daniel Rudrich's SimpleCompressor, at least as starting point.

AAYSR (ask and you shall receive): just added this interesting @DanielRudrich's resource to brand new AUDIO \ Effects \ General subsection ! (note: given that it seems to perform dual functionality - compressor & limiter - do you think it would be better to move it under Multi?)

EDIT: Since @intel's OpenVINO™ AI Plugins for Audacity has been released, it could be interesting to involve @RyanMetcalfeInt8 in AI Compressor by @jamesnapierstuart port. Check out this discussion.

(I haven't seen this repo mentioned in your HyMPS project?) Besides readily being in C++, it is predictable, has all controls primarily needed, and is well documented.

Well, although it's starting to get pretty meaty, consider that actually I'm (manually) maintaining/expanding/revising the whole HyMPS project alone: of course (constructive) contributions are always welcomed !

Happy coding !

saintmatthieu commented 3 weeks ago

(note: given that it seems to perform dual functionality - compressor & limiter - do you think it would be better to move it under Multi?)

It's definitely not just a limiter. Either under "multi" or "compressing".

DanielRudrich commented 3 weeks ago

How about Dynamics? Thanks for adding it to your list!

Jesse-Hufstetler commented 3 weeks ago

I ported starfish limiter to C++ a while ago, the code is lying around somewhere if anybody wants it

bastibe commented 3 weeks ago

I can't recommend my Simple Cython Limiter, either. It was written more of a demonstration of Cython than a good limiter.

pzelasko commented 3 weeks ago

My cylimiter is based on @bastibe implementation, just rewritten to C++, a bit more optimized, wrapped to Python and PyPI packaged. It works well for machine learning applications and managing gain for speech ML model inputs and outputs but it hasn’t been evaluated for quality on music.

x42 commented 3 weeks ago

The code use in https://github.com/x42/sound-gambit is a somewhat cleaner version of what is used https://x42-plugins.com/x42/x42-limiter as well as Ardour's LUFS normalization during export (https://github.com/Ardour/ardour/blob/master/libs/audiographer/private/limiter/limiter.cc). It is based on Fons Adriansens DPL-1 with the addition of true-peak support.

It is close to audibly transparent, works very well for music and does not allow a single sample above the threshold. It also maximize the signal with respect to phase rotation, and best of all it's realtime safe and doesn't take a lot of DSP. It's mostly C with a few sensible features of C++ and just a single source file and a header.

You don't have to take my word for it. Since audacity supports LV2 plugins you can already use it today and evaluate it. Cross platform binaries are available from https://x42-plugins.com/x42/x42-limiter

saintmatthieu commented 3 weeks ago

Interesting, I wasn't planning on adding a true-peak feature, but this makes it tempting. By "maximizing the signal wrt phase rotation" do you mean something other than the true-peak feature ?

x42 commented 3 weeks ago

It is unrelated to true-peak detection.

Details on phase roration I should not have mentioned it since it's a feature common to pro audio limiters. e.g. u-he's presswerk has an option for this. Phase rotation is about altering the waveform shape but not the perceived sound [1]. It originated in FM broadcast to help make asymmetrical waveforms more symmetrical, which allows more gain before clipping. These days phase rotation circuits are used during mastering to increase headroom. In case of x42-limiter it is a side-effect of how the DSP works. Rotating the phase of the resulting signal will always only increase the signal level. -- [1] specifically it is a phase shift, where different components of the signal are delayed differently depending on their frequency. The interesting aspect is that phase rotation does not alter the sound of the signal nor the loudness. However changing the phase vs. frequency relationship between lower and upper harmonics changes the waveform and can affect where the [digital] peak occurs.