Skip to content

Ensure RFFT spectrum is always positive#26

Closed
dy wants to merge 1 commit into
corbanbrook:masterfrom
dy:patch-1
Closed

Ensure RFFT spectrum is always positive#26
dy wants to merge 1 commit into
corbanbrook:masterfrom
dy:patch-1

Conversation

@dy

@dy dy commented May 14, 2016

Copy link
Copy Markdown

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

dy commented Sep 25, 2016

Copy link
Copy Markdown
Author

@corbanbrook is there anything on that?

@danigb

danigb commented Jan 14, 2017

Copy link
Copy Markdown

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

dy commented Jun 21, 2017

Copy link
Copy Markdown
Author

@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