Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure RFFT spectrum is always positive #26

Closed
wants to merge 1 commit into from
Closed

Ensure RFFT spectrum is always positive #26

wants to merge 1 commit into from

Conversation

dy
Copy link

@dy dy commented May 14, 2016

Hi @corbanbrook!
The RFFT forward transform sometimes exhibits negative spectrum value for a static item.
That is because of not really measuring the length of phasor as in the loop above, but supposition that zero frequency has positive value, which is not always true.
e.g.

var N = 16;
var real = new Float32Array(N);
for (var i = 0; i < N; i++) {
    real[i] = Math.sin(10000 * (i / N) / (Math.PI * 2))
}

var dsp = require('dsp.js');
var fft = new dsp.RFFT(N, 44100);
fft.forward(real);
console.log(fft.spectrum);

gives

 Float32Array [
-0.2007274180650711,
0.29625651240348816,
0.6431688070297241,
0.628587007522583,
0.10844749957323074,
0.04224899411201477,
0.016048559918999672,
0.013186296448111534 ]

@dy
Copy link
Author

dy commented Sep 25, 2016

@corbanbrook is there anything on that?

@danigb
Copy link

danigb commented Jan 14, 2017

Hi @dfcreative

I'm learning dsp and, since this library is now unmaintained, building my own dsp library taking parts from different projects. I would like to adopt rfft as the default FFT method (because of performance) but I found several issues. Take a look my comments to: #5

Maybe you can give me some clues about that...

Thanks!

@dy
Copy link
Author

dy commented Jun 21, 2017

@corbanbrook is there any chance it will be merged? If no, I suggest closing this PR

@dy dy closed this Jan 25, 2023
@dy dy deleted the patch-1 branch January 25, 2023 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants