Bugzilla – Bug 564
Nyquist FFT does not produce expected results (32 bit system)
Last modified: 2018-08-20 11:51:44 UTC
This is regarding Nyquist on 32-bit machines. The same problem occurs in standalone Nyquist. I'm posting here as there is no bug tracking system for standalone Nyquist. The expected results from FFT (according to the documentation) are: the DC component goes in array element 0 the Cosine part is in elements 2i - 1 the Sine part is in elements 2i the Nyquist frequency component is in the last element This does not appear to happen (see "Steps to Reproduce"). The tutorial produces the expected results in Audacity 1.3.4. I don't know if this is a problem with the Nyquist FFT function or just a documentation error.
Why the supposition this is connected with bug 336? I would test on 64-bit, but the tutorial code snippets just produce "Nyquist did not return audio" on Win 7 x64, or the tutorial assumes far too much prior knowledge for Nyquist newbies.
(In reply to comment #1) bug 336 is a separate issue. If the tutorial (steps to reproduce) is done right on a 64 bit system it produces garbage. That is a bug that is specific to 64 bit systems (bug 336). If the tutorial (steps to reproduce) is done right on a 32 bit system, it does not appear to produce garbage, but there is a (big) discrepancy between what the documentation says will happen and what actually does happen. You're right, this is not an issue for Nyquist newbies :=) but it has come up a couple of times on the forum. The documentation states that: the DC component goes in array element 0 the Cosine part is in elements 2i - 1 the Sine part is in elements 2i the Nyquist frequency component is in the last element This does not appear to happen. There are a lot of numbers produced, but users have no idea what they mean/represent as they are not as described in the manual, thus the FFT and IFFT functions are pretty well unusable as no one has been able to work out what values are actually being produced. I marked this bug as blocking 336 because if bug 336 is fixed it will presumably produce the same values as a 32 bit system, but as per this bug (564) those values will still be "wrong" according to the documentation. I don't see that bug 336 can be said to be fixed unless we know what values should be produced. My assumption is that Nyquist is doing "the right thing" on 32 bit systems, but that the documentation refers to an older version, but that is only my assumption. It could be that 32 bit systems are also producing the wrong values (but different wrong values to 64 bit systems). Roger Dannenberg is probably the only person that can shed light on this.
> I'm posting here as there is no bug tracking system for standalone Nyquist. Nyquist is on SourceForge. There's a bug tracking system there, but it's best to send email to rbd at cs.cmu.edu. > The tutorial produces the expected results in Audacity 1.3.4. > I don't know if this is a problem with the Nyquist FFT function or just a > documentation error. As far as I can tell, there was a bug (maybe an accidental divide-by-N) in an early version that led to a mistake in the documentation. I've updated my local copy of the documentation and will be committing that and other code updates before long. The current FFT appears to be correct. > If the tutorial (steps to reproduce) is done right on a 64 bit system... There is no way to do the tutorial "right" on a 64 bit system unless you are running in 32-bit mode. Nyquist does not run on 64-bit architectures. No one seems to believe this or pay attention, so I realize people are compiling Nyquist for 64-bit architectures. I'm finally in a position to port Nyquist to 64-bit architectures, so this should not be an issue much longer. > The documentation states that: > the DC component goes in array element 0 > the Cosine part is in elements 2i - 1 > the Sine part is in elements 2i > the Nyquist frequency component is in the last element This is correct > This does not appear to happen. Can you send a counterexample? Remember that FFT coefficients that are theoretically zero often show up as some small value, e.g. 1.0e-7.
(In reply to comment #3) > Nyquist does not run on 64-bit architectures. > No one seems to believe this or pay attention, I do believe you :=) That is what I meant. >> This does not appear to happen. > Can you send a counterexample? No I can't. I drew an incorrect conclusion from the discrepancy between the documentation and what I was seeing. As a user it's difficult to know what conclusions to draw when the results appear to be wrong. > The current FFT appears to be correct. Terrific. Thank you.
It sounds as if this is no longer relevant, but Steve gave me a plug-in that runs fft (and ifft) tests as per the tutorial. On 64-bit the debug output shows: fft-test : (SEND FFT-ITER :NEXT) = #(4.89859e-016 0 0 0 0 0 0 3.37175e-007 -16 0 0 0 0 0 0 4.89859e-016 -0 0 0 0 0 0 0 -3.37175e-007 0 0 0 0 0 0 0 4.89859e-016) What about the different result with 1.3.4 as noted by Steve? He told me "It is not just a simple typo in the manual because with Audacity 1.3.4 it does give -1 as the 9th element."
My earlier post alluded to the change in behavior of FFT from 1.3.4 to what we have now. I haven't looked for the code change, but I agree something changed. My guess is the tutorial was based on real output, and later it was found to contain a bug (probably an incorrect divide-by-N or a confusion between calling ifft and fft). I think the bug was fixed but the example was not. I've fixed it in my local copy of Nyquist, where I'm working on more bug fixes before a commit.
(In reply to comment #6) > I think the bug was fixed but the example was not. OK Roger, it sounds as if you are fine with closing this invalid, so I have done that.