lmms icon indicating copy to clipboard operation
lmms copied to clipboard

Playing a sample or instrument with LS Filter's cutoff frequency near max mutes the project's audio.

Open husamalhomsi opened this issue 8 years ago • 22 comments

The project's audio can be unmuted by doing any of these: • Reloading the project. • Reloading the effect. • Disabling the effect.

husamalhomsi avatar Oct 31 '17 14:10 husamalhomsi

Confirmed, NaN...

zonkmachine avatar Oct 31 '17 14:10 zonkmachine

@Sawuare I assigned this to me but maybe you wan't to have a go at fixing this?

zonkmachine avatar Oct 31 '17 14:10 zonkmachine

How can I reproduce that? Could you please provide steps to reproduce?

PhysSong avatar Oct 31 '17 14:10 PhysSong

How can I reproduce that? Could you please provide steps to reproduce?

  1. Load a sample in a sample track or load an instrument.
  2. Add the LS Filter effect to what you loaded in the step above. Increase the cutoff frequency to max.
  3. Play the sample or play a note.

husamalhomsi avatar Oct 31 '17 14:10 husamalhomsi

@Sawuare I just reproduced that right before you post the comment. :smile:

PhysSong avatar Oct 31 '17 14:10 PhysSong

@Sawuare I assigned this to me but maybe you wan't to have a go at fixing this?

@zonkmachine Sure, but how?

husamalhomsi avatar Oct 31 '17 14:10 husamalhomsi

Sure, but how?

We have a super special debug flag when compiling but it's only for Linux and if I remember it correctly you are on Windows, no?

zonkmachine avatar Oct 31 '17 15:10 zonkmachine

https://github.com/LMMS/lmms/blob/68c85c8e0579827994759573698c5b27f9c71832/plugins/LadspaEffect/swh/util/biquad.h#L105-L118

Here alpha blows up for high frequencies, because omega approaches to π and sn to 0. Here a2 is set to NaN since it is zero times infinity. Possible workaround is: f->a2 = 1 - a0r * 2.0;

PhysSong avatar Oct 31 '17 15:10 PhysSong

We have a super special debug flag when compiling but it's only for Linux and if I remember it correctly you are on Windows, no?

Yes, I'm on Windows. Is there an alternative?

husamalhomsi avatar Oct 31 '17 15:10 husamalhomsi

I got this with the fpe flag. It happened when I tried to open the pluggin controls. In my book that isn't a bad call to powf. If I enter -0,00401606411^0,36787945 in a calculator I get −0,131367367 ...

Program received signal SIGFPE, Arithmetic exception.
0x00007ffff459893f in __ieee754_powf (x=x@entry=-0,00401606411, y=y@entry=0,36787945) at ../sysdeps/ieee754/flt-32/e_powf.c:125
125	../sysdeps/ieee754/flt-32/e_powf.c: No such file or directory.
(gdb) bt
#0  0x00007ffff459893f in __ieee754_powf (x=x@entry=-0,00401606411, y=y@entry=0,36787945) at ../sysdeps/ieee754/flt-32/e_powf.c:125
#1  0x00007ffff459d1db in __powf (x=-0,00401606411, y=0,36787945) at w_powf.c:27
#2  0x00000000004f08b7 in linearToLogScale (min=88,2000046, max=22050, value=0) at /home/zonkmachine/builds/lmms/lmms/include/lmms_math.h:223
#3  0x00000000004f1945 in AutomatableModel::inverseScaledValue (this=0x19f5d30, value=0)
    at /home/zonkmachine/builds/lmms/lmms/src/core/AutomatableModel.cpp:272
#4  0x000000000061818d in Knob::drawKnob (this=0x18dcf00, _p=0x7fffffffb430) at /home/zonkmachine/builds/lmms/lmms/src/gui/widgets/Knob.cpp:445
#5  0x000000000061957f in Knob::paintEvent (this=0x18dcf00, _me=0x7fffffffb810) at /home/zonkmachine/builds/lmms/lmms/src/gui/widgets/Knob.cpp:685
#6  0x00007ffff7122300 in QWidget::event (this=0x18dcf00, event=0x7fffffffb810) at kernel/qwidget.cpp:8533

zonkmachine avatar Oct 31 '17 15:10 zonkmachine

Yes, I'm on Windows. Is there an alternative?

I don't know how it works on Windows unfortunately. @PhysSong Is it possible to invoke the gnu debugger, gdb on Windows?

zonkmachine avatar Oct 31 '17 15:10 zonkmachine

Yes. You can run gdb on Windows. However, it will provide less information than Linux.

PhysSong avatar Oct 31 '17 15:10 PhysSong

@PhysSong Is it possible to invoke the gnu debugger, gdb on Windows?

Last we tried this, msys2 was broken with the debug flags. https://github.com/LMMS/lmms/pull/2205#issuecomment-126917960

tresf avatar Oct 31 '17 16:10 tresf

Increase the cutoff frequency to max.

That is the reason. It will produce a sound with absurd low freq. If you have ambient time, like several hours, the wave-form will dead slowly normalize and sound is re-established Look at the monitor-display, if im right, a horizontal line will be glued to the bottom of the display Could actually be interesting to add a graphic-EQ or SPAN and see what they display in this situation It is not the only filter-plugin that can cause this

musikBear avatar Oct 31 '17 17:10 musikBear

if im right

Probably not. See the explanation above.

zonkmachine avatar Oct 31 '17 17:10 zonkmachine

@gi0e5b06 No, you're doing definitely wrong math there. That is a little bit long to explain here. Anyway, the real problem is alpha, which blows up toward infinity. In strict sense, infinity isn't a number. It means it is larger than any number. However, we usually define 1 over infinity to be 0. And there is a clear fact, 0 * infinity is not defined. That's what we call NaN.

PhysSong avatar Oct 31 '17 23:10 PhysSong

If I enter -0,00401606411^0,36787945 in a calculator I get −0,131367367 ...

@zonkmachine You did a wrong calculation. -a^b is -(a^b)(here ^ denotes power, not the xor operator in C++), not (-a)^b. Such value can be defined using some mathematical techniques, but it never can be a real number. Moreover. there are some ambiguities with that, too. So (-0,00401606411)^(0,36787945) doesn't make sense in powf() and causes an arithmetic exception. That's a separate issue, I guess.

Edit: //! @brief Scales value from logarithmic to linear. Value should be in min-max range. It says everything.

PhysSong avatar Nov 01 '17 01:11 PhysSong

wrong calculation. -a^b is -(a^b)

Precisely that error. Doing it again I get an imaginary part. And yes, we're talking floating point operations.

zonkmachine avatar Nov 01 '17 03:11 zonkmachine

Is there an alternative?

Given how this issue is developing? A friendly advice. Stay away from it. You may not come out of it in one piece.

zonkmachine avatar Nov 01 '17 08:11 zonkmachine

@gi0e5b06 The problem is: abs(sn)<10E-10 looks harmless, but it is satisfied only if the frequency equals to the nyquist frequency. abs(M_LN2 / 2.0 * bw * omega / sn)<0.05 is definitely wrong, since omega / sn is always larger than 1, bw is between 1.0(resonance 0.0) and 0.1(resonance 1.0), M_LN2 / 2.0 is 0.34657359 ... , so it may cause issues.

PhysSong avatar Nov 01 '17 10:11 PhysSong

Unlike most of SWH filters, LS filter can have cutoff near the nyquist frequency(e.g. 0.5 * sampling rate). The usual value is 0.49 or 0.45(at least in other SWH plugins) times the sampling rate. https://github.com/LMMS/lmms/blob/46ef3c6a11e9713c24aa3e9b01c658b2941a58d6/plugins/LadspaEffect/swh/ls_filter_1908.c#L273

It is the same for upstream. @swh Is there any special reason for that?

PhysSong avatar Nov 26 '17 02:11 PhysSong

@PhysSong Maybe best to just send a PR for this if you feel initiated?

zonkmachine avatar Jun 02 '24 21:06 zonkmachine