This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

CMSIS DSP arm_rfft_fast_f32()

Hello, I am working on an audio spectrum analyzer with LPCXpresso54608 (Cortex-M4F).
I am working on a program to calculate the FFT spectrum of an input signal.
All the functions from CMSIS library work fine but I don't understand the length of the input and output vectors.
The ARM CMSIS official documentation is, in my opinion, a bit confusing on this topic and I'd like to share my thoughts.

Here's an outline of my algorithm:

Start with a sample buffer of length N=1024 (Skip how the samples are acquired, let's just assume they are there)

float rx_buffer[1024];

Now this is a real signal, so calculate the FFT using arm_rfft_fast_f32():

float fft_out[1024];
arm_rfft_fast_instance_f32 fftInstance;
arm_rfft_fast_init_f32(&fftInstance, 1024);
arm_rfft_fast_f32(&fftInstance, rx_buffer, fft_out, 0);

From the official documentation (www.keil.com/.../group__RealFFT.html),
I understand that arm_rfft_fast_f32() outputs an array of N=1024 floats: N/2 are the real parts and N/2 are imaginary parts interleaved, in total N/2 complex pairs.
This is only one half of the spectrum since the other half is symmetric. So the spectrum is not replicated.

Now, I want to calculate the magnitude of each complex number so I do:

float fft_magnitude[512];
arm_cmplx_mag_squared_f32(fft_out, fft_magnitude, 512);

With this, I get a spectrum of 512 points, symmetric arround the point 256. So in total, I get 256 useful points. Is this the expected behavior? I thought that arm_rfft_fast_f32() output already only half of the spectrum, thus I should end up with 512 useful points. Where am I wrong?

Cheers.

Parents Reply Children
No data