LMMS / lmms

Cross-platform music production software
https://lmms.io
GNU General Public License v2.0
7.95k stars 993 forks source link

Audible click when switching effect on/off or effect parameters via automation track #7093

Open psilhavy opened 6 months ago

psilhavy commented 6 months ago

Bug Summary

Short noise/click is generated during automation track assisted switching of

Click friendly instruments

Clicks are visible on "Spectrum Analyzer" and hearable on play or rendered track. Looks like "knob" type controls are not affected ( volume, pan, freq, ... )

Steps to reproduce

example https://disk.yandex.com/d/Z2smVIGIoM9GpA

Expected behavior

no click

Actual behavior

click

Screenshot

Affected LMMS versions

current master LMMS 1.3.0-alpha.1.517+gc2052151a (Linux x86_64, Qt 5.15.12, GCC 13.2.0)

musikBear commented 6 months ago

Cant open your attachment -What is it -Video?, then uploadt at youTube But That click will always happen if the on/off switching is done where the wave-spectrum is off the 0dB-line. Are you sure that is not what you have here too? image

Does it click if there is no sound played, eg- only automation is on/offe'd

psilhavy commented 6 months ago

Example https://disk.yandex.com/d/Z2smVIGIoM9GpA is lmms .mmpz compressed file . If no sound is played, there is no click, automation track alone does not "click". Over volume is not click source - enough room under 0dB. Clicks images here click-sid click-zyn

musikBear commented 6 months ago

If no sound is played, there is no click

That is what i thought. It is most likely the wave-spectrum that is not on 0dB line when the automation invokes on/off. On/off is really not different from an initiation-point, and there is always clicks if that is not on 0dB-line: https://i.imgur.com/shjUWQ1.png Only purple point-positions are safe, and wont click.

Spekular commented 6 months ago

While cutting audio at zero crossings can prevent the introduction of large instantaneous amplitude jumps, I'm pretty sure this is a much more general issue (and maybe a wontfix?).

Automating an effect on/off will lead to an instant switch between the dry and wet signal, so it's hardly surprising that this would result in clicks. As for switching [model / filter / distortion] types, this is essentially the same issue (except it's up to plugins themselves rather than LMMS itself to deal with).

OP: rather than automating the effect on/off, have you tried automating the wet/dry knob with a short linear automation?

michaelgregorius commented 6 months ago

That is what i thought. It is most likely the wave-spectrum that is not on 0dB line when the automation invokes on/off. On/off is really not different from an initiation-point, and there is always clicks if that is not on 0dB-line: https://i.imgur.com/shjUWQ1.png Only purple point-positions are safe, and wont click.

Just for educational purposes and because I have read that misconception several times here: it will also click if the last sample ends perfectly on the 0dBFS line. So the purple points are not safe. No point is safe if a signal is cut off abruptly.

If you want to experience this yourself then arrange the sample contained in ClickSineShortened.zip as shown here and play the "song":

ClickSineArrangement

You will hear a click each time the sample ends. If you inspect the sample you will find that it ends on the 0dBFS line.

Clicks do not occur because the sample does not end on the 0dbFS line. They occur because the direction changes too fast. Just imagine you would be traveling on the line of the sine signal. While the sine is playing the direction changes are smooth and "rounded" but at the end you suddenly have to make a sharp turn to the right if you approach the 0dBFS line from below as is the case for the example sample.

michaelgregorius commented 6 months ago

While cutting audio at zero crossings can prevent the introduction of large instantaneous amplitude jumps, I'm pretty sure this is a much more general issue (and maybe a wontfix?).

Automating an effect on/off will lead to an instant switch between the dry and wet signal, so it's hardly surprising that this would result in clicks. As for switching [model / filter / distortion] types, this is essentially the same issue (except it's up to plugins themselves rather than LMMS itself to deal with).

Fully agree that this looks like a "won't fix" or rather a "very hard to fix". If LMMS' implementation of the on/off switching is not adjusted somehow then the fix would have to be made per plugin. And this in turn would mean to fix it in every upstream plugin as well.

It would be interesting to know though if other DAWs perhaps implement the on/off as an internal cross-fade between the processed and dry signal. But if they did then this might lead to undesirable/unexpected behavior as well. :thinking:

michaelgregorius commented 6 months ago

I have just tested with REAPER and it also clicks if you for example turn a distortion on and off (interactively). Here's the project: TestOnOffSwitch.zip

psilhavy commented 6 months ago

Just another (silly?) example - FreeBoy trying to play 1/2 E1/B1 - which produces no sound here, just nice clicks. https://disk.yandex.com/d/06dwfhCJXrVCpg

michaelgregorius commented 6 months ago

Hi @psilhavy,

this seems to be a problem with FreeBoy because the problem persists even if I remove all automation and effects from the file that you have provided. It seems that FreeBoy only plays real sound starting at C2 and your notes are all below that note. If you move the notes up you should be able to hear something.

psilhavy commented 6 months ago

@michaelgregorius Michael Gregorius"

 Hi @psilhavy,this seems to be a problem with FreeBoy because the problem persists even if I remove all automation and effects from the file that you have

Right, wrong sample. If you replace FreeBoy with SID/Organic/Xpressive/Kicker this combination makes nice 20+kHz click + expected signal without  automation and other filters too. Watsyn clicks are below 15kHz. LB302,ZynAddSubFX,SF2 works with no clicks AFAIK. 

musikBear commented 6 months ago

it will also click if the last sample ends perfectly on the 0dBFS line.

But is that not eradicated is the shape has even the slightest inclination? Eg it does no start or end on a vertical segment I mean: 1 will click 2 wont click image Isent that correct?

michaelgregorius commented 6 months ago

If you inspect the sine signal that I have linked above you will find that it also has an inclination and that it is not a vertical segment as shown in figure 1.

SineAndDerivative

In mathematical terms the inclination is 1 or a slope of 45 degrees: sin'(0) = cos(0) = 1. And it still clicks.

To remove clicks you could:

I'd say the "usual" way is to attenuate the signal, e.g. with an ADSR that has a non-zero release.

michaelgregorius commented 6 months ago

Here's another visualization of how the sine looks if it is turned off at exactly 0:

SineEdge

The problem is the edge or the "sharp turn" at 0. What's causing the click is that the derivative is not continuous anymore when we do something like this. As noted above the derivative of sin(x) is cos(x). The derivative of the constant 0 is 0. Hence the derivative for the function above looks as follows:

SineEdgeDerivative

As you can see there's a jump at 0. This is what's causing the clicks and what I have meant with the "sharp turn". The direction changes too quickly.

musikBear commented 6 months ago

The direction changes too quickly.

Thanks for the explanation! 👍