Closed neevek closed 3 years ago
If
rate
is integral multiple offreq
It isn't for most values of freq
... but let's assume it is.
If freq
is set to 441Hz, and rate
is set to 44100 samples per second, then omega
will be:
2 PI 441 / 44100 = 0.06283185307179585
Then sn
and cs
will be:
Sin(0.06283185307179585) = 0.06279051952931336 Cos(0.06283185307179585) = 0.9980267284282716
That being said, now that I'm looking at the code, if freq
<= 0 or >= rate/2
, then it looks like your logic is right -- sn
will be 0, which gets a divide by zero. If I trace the sources of freq
, I can see that a user could pass in a 0 for basslpf
in the advanced options, and cause that to happen.
So I think the clamp should probably be fixed.
I just run into the case that freq >= rate/2
with default settings with all presets other than LARGEHALL1
and LARGEHALL2
. With the same input, only LARGEHALL1
and LARGEHALL2
work, all other presets will zero out the samples because of the divide by zero issue.
I don't have time to fix at the moment, but a quick fix is to simply change the biquad coefficients to be a passthrough. In order to do that, you set b0
to 1
, and the rest (b1
, b2
, a1
, a2
) to 0
.
I don't have time to fix at the moment, but a quick fix is to simply change the biquad coefficients to be a passthrough. In order to do that, you set
b0
to1
, and the rest (b1
,b2
,a1
,a2
) to0
.
I set alpha
to 1 when sn
is 0, which seemed to work as expected.
thanks, sorry it took so long to fix, I don't check here often but I had some free time today
In the
biquad_makeLPF
function inreverb.c
:If
rate
is integral multiple offreq
, thenomega
will be integral multiple ofPI
, andsn = sinf(M_PI)
is 0,sn
is used as a divisor for calculatingalpha
, the result ofalpha
will beINFINITY
, which causes any other values to beNaN
when calculated withalpha
.Can I test the value of
alpha
withisinf()
, if it is true, assign a valid value to it? But what is the valid value range ofalpha
? Or what is the valid value for it if it isINFINITY
?