lsp-plugins / lsp-plugins

Linux Studio Plugins Project
https://lsp-plug.in/
GNU Lesser General Public License v3.0
501 stars 42 forks source link

Feedback overdrive protection #370

Open Efenstor opened 6 months ago

Efenstor commented 6 months ago

Is it possible to implement some sort of feedback overdrive protection for all plugins if output of a plugin was accidentally routed to the input? It may happen when using external sends or multiple signal processing buses. Currently sometimes even turning on a previously disabled band in a multiband plugin can provoke uncontrollable signal buildup if there is somehow a feedback path between input and sidechain/output, even if it's attenuated, and the result is the speaker overdrive and the total freeze of Ardour. Ardour and Jack themselves seem to have some sort of protection against that scenario, at least it does not cause a speaker overdrive and a freeze. Soft turning on/off of bands in multiband plugins would be very useful in general as well.

sadko4u commented 6 months ago

The main question here is, how to detect the feedback?

Efenstor commented 6 months ago

Feedback or not feedback, total overload of the output is undesirable in 99% of cases (for the rest it can be manually deactivated). A sort of analog approach can be implemented, for example in hi-fi amplifiers overload is detected by measuring the output current, at some point the protection transistor begins to conduct which triggers the volume control motor to turn the volume down. Although it is not directly applicable to the plugins but the idea is to soften up-ramp signal if it reaches the digital max in almost no time (e.g. 1-2 samples) by temporarily applying some limiting multiplier. In this case the signal won't stay at the digital max all the time (or go from the plus to minus in 1-2 sample time), and the speakers will be safe. That is the general idea.

sadko4u commented 6 months ago

In digital audio systems, 0 dBFS is the upper limit that causes the overload. All above 0 dBFS will be hard-clipped by the PCM output system because the signal will be out of the quantization scale. But it is pretty OK when plugin output is greater than 0 dBFS but the output volume of the bus compensates such 'overdrive'.

From another side, such protection requires additional computation resources multiplied by the number of plugins used. This is pretty expensive (especially related to my last fight with memory copies on delay lines which took most of CPU resources on processing), and the case is almost unusable when you're understanding what you're actually doing with the routing.

The simplier solution is, just to place the limiter to the output bus.

Efenstor commented 6 months ago

The simplier solution is, just to place the limiter to the output bus.

That does not solve the problem of feedback loop inside a particular track/bus when using external sends or just some complex input/output connections, because anything can be connected to anything.

I suggest may be at least implement soft turn on/off of bands in multiband plugins? Sometimes it may provoke signal buildup, that is the problem I stumbled upon in practice.