wwmm / easyeffects

Limiter, compressor, convolver, equalizer and auto volume and many other plugins for PipeWire applications
GNU General Public License v3.0
6.46k stars 269 forks source link

Feature request: LSP Gate #1596

Closed LebedevRI closed 2 years ago

LebedevRI commented 2 years ago

Hi!

Now that easyeffects has been packaged in debian, i was finally able to migrate to pipewire and not-an-ancient version of easyeffects :)

The current Gate Effect is based on Calf Studio Gear. LSP also implements a Gate Effect: https://lsp-plug.in/?page=manuals&section=gate_stereo

While i don't know which one is better/worse, there is one 'big' thing i'm missing in the current one - separate Thresholds for Attack and Release. While i have filed an upstream issue https://github.com/calf-studio-gear/calf/issues/314, it may take an unspecified amount of time for that to be implemented.

At the same time, i do believe LSP does support that already:

* Hysteresis L, R - enables additional hysteresis curve:
* * Thresh - threshold (relative to basic curve), the level of input signal at which the gate starts to close.
* * Zone - the size of the transition zone below the hysteresis threshold.

I see that the Compressor was recently ported to use LSP: https://github.com/wwmm/easyeffects/pull/1056 What are general thoughts on doing the same for Gate?

wwmm commented 2 years ago

What are general thoughts on doing the same for Gate?

I see no problems. I even considered using the one from LSP in the past. But I did not have time and other things had higher priority.

LebedevRI commented 2 years ago

Thanks!

@sadko4u can correct me, but i think there will be an issue with multiband gating though. The current Multiband Gate allows to easily reject Low/High bands, however i'm not confident if that is possible in LSP, only the Band Start can be set.

You can of course do that via Equalizer, but it's not as straight-forward, and may get convoluted UI-wise if there's also an actual equalization going on...

It almost seems like there should be a simple Frequency Selector module, where you could select Low and High frequencies, roll-off (dB/Octave), and it would attenuate everything outside of the selected frequency range. I suppose it can be implemented on top of LSP's Equalizer?

Digitalone1 commented 2 years ago

Months ago I tried to use the LSP Gate on my usual preset in carla-rack and didn't find a way to set it as it works now in Calf Gate. To me Calf version is enough, but won't oppose if in the future someone wants to implement it.

Digitalone1 commented 2 years ago

I'm looking at it another time and now I remember why I didn't like it.

https://lsp-plug.in/?page=manuals&section=gate_stereo

It misses the ratio control. I wonder why such basic parameter isn't included in the LSP version.

In the Calf one I could have an idea of how the gate will perform while the signal goes below the threshold. With ratio 2, the amount of gain reduction would be approximately two time the difference between the current signal level and the threshold. Then there's the maximum reduction to stop the gain going too below.

But how is this working in LSP? Never understood properly. There's only the gain reduction, then there's the hysteresis which is much more complicated to understand.

To me the Calf Gate is enough and more straightforward.

LebedevRI commented 2 years ago

Oh, that is interesting, i admit i did not notice that yet.

wwmm commented 2 years ago

But how is this working in LSP? Never understood properly. There's only the gain reduction, then there's the hysteresis which is much more complicated to understand.

Looking at the docs from the gate and the compressor I have the feeling there is the following "similarity table" when it comes to how they work

Gate Reduction -> a direct way to set the reduction that is usually done through the ratio control

Gate Curve Threshold -> Compressor Attack Threshold

Gate Hysteresis threshold -> Compressor Relative Threshold

But as I do not use gates frequently I may be confusing things.

sadko4u commented 2 years ago

The gate works in a bit another manner. Consider you have two levels of the signal: one reducted and one normal. And there is a transition interval between them which connects them into the smooth curve. You can set the lowest level of the non-reducted envelope of the signal as Curve Thresh and the size of the transition zone as the Curve Zone parameter. The Curve Thresh, Curve Zone, and Reduction are the parameters that allow to fully define the S-shaped curve of the gate. The Hysteresis feature allows to set up additional curve which will be used when the gate becomes open and the second defined curve becomes active instead of the first. this allows to keep gate fully open even if the envelope becomes less than the Curve Thresh parameter. When the gate becomes fully closed, then the first curve becomes active again. The Attack and Release parameters work as in other dynamic processing plugins and allow to control how the envelope of the signal is changed in the time. Also remember that the envelope of the signal controls the position of the point on the dynamic curve but not the level of the input signal.

Digitalone1 commented 2 years ago

@sadko4u no doubt it's working the way it is intended to. I mean the Calf version is more straightforward to understand. Maybe because it's designed more like a compressor. You can see it by the description:

https://calf-studio-gear.org/doc/Gate.html

A gate is mainly used to reduce lower parts of a signal.

Gating: The level of reduction on the original signal

Gating is done by detecting the volume below a chosen level ("Threshold") and divide it by the factor set with "Ratio". The bottom of the noise floor is set via Max Gain Reduction. Because an exact manipulation of the signal would cause distrotion of the waveform the reduction can be levelled over the time. This is done by setting "Attack" and "Release".

Another parameter missing in the LSP Gate is the Knee.

Knee: Curve the sharp knee around the threshold to enter gain reduction more softly

The LSP version is conceived in a different way. As I understood, you have to draw a curve which represent the reduction applied to the signal. This is more difficult to understand and I think the chart in the LSP Gate UI is a must have to shape it better, but we can't replicate it in our UI.

A year ago I wanted the replace the Calf MB Compressor with the LSP one because it was superior and the Calf version was limited since you couldn't set the number of active bands or you couldn't perform the upward compression.

The LSP Gate could be superior but I don't think it's worth adding it in EasyEffects because I suppose you can do the same in the Calf version, but in a different manner and with different parameters.

If this is not true, please explain what the LSP Gate offer more than the Calf one. Especially regarding the Ratio and the Knee, how these parameters can be related to the LSP Gate controls?

In any case, thanks for your great work! 4 of 5 effects I use more are from LSP.

sadko4u commented 2 years ago

Calf gate works like a downward expander with the limited gain reduction. That's why LSP Plugins do not have the 'ratio' and 'knee' as possible parameters. Instead of this, the non-reducted part of curve and gain-reduced part of the curve are connected one to another with the interpolated by the 3-rd order polynom curve which is obtained from the hermite equation. More details about the hermite polynomials are here: https://en.wikipedia.org/wiki/Hermite_polynomials For the compressor, the second-order hermite polynomial is enough to simulate the knee. But that gives a sharp characteristic where the gain reduced curve connects with the transition part of the curve. So that's the main difference. We know two connection points on the curve and do not have any necessity to simulate knees and ratios for that.

LebedevRI commented 2 years ago

If this is not true, please explain what the LSP Gate offer more than the Calf one.

Personally, i've stated in the first comment why i want to do this - because it provides more fine-grained control over release, via the Hysteresis. That is not possible to do/emulate in Calf's Gate.

sadko4u commented 2 years ago

So, actually, the difference is here: изображение

vs LSP:

изображение

Digitalone1 commented 2 years ago

Thank you @sadko4u for the explanation.

Personally, i've stated in the first comment why i want to do this - because it provides more fine-grained control over release, via the Hysteresis. That is not possible to do/emulate in Calf's Gate.

No problem. As I said before, I won't oppose if @wwmm or some other one will implement it. :)

LebedevRI commented 2 years ago

Thank you all! Now that it seems there's consensus, i will look into actually implementing it. Note that i'm NOT planning on dealing with MB Gate, and hope that it stays as-is until https://github.com/wwmm/easyeffects/issues/1596#issuecomment-1166357799 is resolved.

sadko4u commented 2 years ago

@sadko4u can correct me, but i think there will be an issue with multiband gating though. The current Multiband Gate allows to easily reject Low/High bands, however i'm not confident if that is possible in LSP, only the Band Start can be set.

If you have played once with JACK standalone, LV2 or VST2 UI of multiband plugin, then you could easily understand how this option works. Consider you have the audible frequency range which should be split into set of bands where the number of bands varies from 1 to 8. Then, we have at least one band which is always working band at the lowest frequency range. If we want to add one more band, then we need to split the audible frequency range at some frequency. After that, we get two bands. The first band works at the low frequencies and ends up at the split frequency, and the next band starts working at the split frequency and ends up at the nyquist frequency. Then we can add the 3rd, 4th band and so on.

You can enter any split frequency to any band except the first one with index 0. After that, all bands become sorted in ascending order according to the growing value of their split frequencies (the band should be also enabled, too). Then the full frequency range becomes split by the specified set of frequencies and given to the corresponding band.

So, as you see, Band Start is pretty enough to control the frequency range of the band.

wwmm commented 2 years ago

Now that it seems there's consensus, i will look into actually implementing it.

In this case I suggest you take a look at how we have integrated the LSP compressor. In its case we have chosen the variant that accepts an external source in the sidechain input. Maybe it is a good idea to do the same with the gate. Feel free to ask for help.

Note that i'm NOT planning on dealing with MB Gate, and hope that it stays as-is until...

Ok. But I think that eventually we will have to do something about the MB Gate. If I remember well one of the reasons why we have started to use the LSP MB compressor was that the one from Calf had problems in its band splitting code. I imagine the same issues must be present in their MB Gate.

LebedevRI commented 2 years ago

Now that it seems there's consensus, i will look into actually implementing it.

In this case I suggest you take a look at how we have integrated the LSP compressor. In its case we have chosen the variant that accepts an external source in the sidechain input. Maybe it is a good idea to do the same with the gate. Feel free to ask for help.

Yeah, i've already looked at the code before ever posting that (and played around a bit). It is obvious that the integration of LSP Gate should largely be a copy-paste of the LSP Compressor integration, with minimal adjustments.

Note that i'm NOT planning on dealing with MB Gate, and hope that it stays as-is until...

Ok. But I think that eventually we will have to do something about the MB Gate. If I remember well one of the reasons why we have started to use the LSP MB compressor was that the one from Calf had problems in its band splitting code. I imagine the same issues must be present in their MB Gate.

Right.

LebedevRI commented 2 years ago

Okay, given how smoothly the plain Gate went, i suppose i could look into Multiband Gate.

But before i do that, @wwmm, am i guessing correctly that there's no interest for having a dedicated Effect for low-/high- pass filtering? (https://github.com/wwmm/easyeffects/issues/1596#issuecomment-1166357799)

wwmm commented 2 years ago

But before i do that, @wwmm, am i guessing correctly that there's no interest for having a dedicated Effect for low-/high- pass filtering?

Depending on how you configure the compressor bands frequency and attenuation you can reject high/low bands with the one from LSP too. So the compressor doesn't really need this. Two of its eight bands can be dedicated to this.

That being said we already have the "Filter" plugin from Calf that offers some filtering. But as there is still some work I have to do before multiple filters instances are possible this filter could be used to reject only one band. But if combined with the equalizer the task could be done even if multiple instances are not possible yet.

LebedevRI commented 2 years ago

Got it, thanks.