-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Make FFT.analyzeSample() correctly analyze samples which aren't a power of 2 #104
Comments
Thanks for reporting! I had a look at the code and I think the issue is not with the length of the target array, but with that of the sample array which, at least based on the current implementation of processing-sound/src/processing/sound/FFT.java Lines 138 to 139 in 23108c9
For now, if you change the length of |
I think that's the issue. 🤦♂️ This should be changed as soon as possible.
Seems to work. I guess one of the devs got those arrays mixed up. |
Thanks for the pull request, I'll merge it for now but it introduces another quirk: after the change, The processing-sound/src/processing/sound/JSynFFT.java Lines 39 to 41 in 23108c9
The application of such a window should probably be moved to the FFT.calculateMagnitudesFromSample() method anyway (I've got a hunch that the JSynFFT class should be ditched altogether, actually the only instance variable necessary is the FixedMonoWriter with its buffer, all the arrays used for computations are never concurrent and can therefore be shared between instances).
|
I dug into the Processing source code to figure out why this is happening, and it apparently thinks that powers of 2 aren't powers of 2 when passing into the assert line in the numBits function of the FourierMath class in jsyn's softsynth code, even though it gets past the check in this function.
Here's the code I'm trying to run (just copy and paste it into the IDE, version 4.3). Even adapting and printing out the
PowerOf2 & (PowerOf2 - 1)
expression in my own code gives a0
on the console:Something seems to be altering the perceived length of those target arrays between checks. Could it have to do with using 2D arrays?
The text was updated successfully, but these errors were encountered: