Adafruit_ZeroFFT icon indicating copy to clipboard operation
Adafruit_ZeroFFT copied to clipboard

Return FFT's magnitude

Open nkonopinski opened this issue 4 years ago • 5 comments

This changes the output of the function to return the value users would expect from an FFT, it's magnitude.

The previous behavior was to discard the imaginary data, which can cause the output to vary sinusoidally over time. Returning the magnitude of the real and imaginary vector produces a consistent result.

Calculating the magnitude with multiplications and square roots can be computationally expensive. It can slow the function down by 4x for a 1024 length input. This approach uses the alpha max plus beta min algorithm (https://en.wikipedia.org/wiki/Alpha_max_plus_beta_min_algorithm) to efficiently return the magnitude. Using this method produced no measurable differences in the function's runtime.

nkonopinski avatar Mar 08 '20 01:03 nkonopinski