| 300 | */ |
| 301 | |
| 302 | void PowerSpectrum(size_t NumSamples, const float *In, float *Out) |
| 303 | { |
| 304 | auto hFFT = GetFFT(NumSamples); |
| 305 | Floats pFFT{ NumSamples }; |
| 306 | // Copy the data into the processing buffer |
| 307 | for (size_t i = 0; i<NumSamples; i++) |
| 308 | pFFT[i] = In[i]; |
| 309 | |
| 310 | // Perform the FFT |
| 311 | RealFFTf(pFFT.get(), hFFT.get()); |
| 312 | |
| 313 | // Copy the data into the real and imaginary outputs |
| 314 | for (size_t i = 1; i<NumSamples / 2; i++) { |
| 315 | Out[i]= (pFFT[hFFT->BitReversed[i] ]*pFFT[hFFT->BitReversed[i] ]) |
| 316 | + (pFFT[hFFT->BitReversed[i]+1]*pFFT[hFFT->BitReversed[i]+1]); |
| 317 | } |
| 318 | // Handle the (real-only) DC and Fs/2 bins |
| 319 | Out[0] = pFFT[0]*pFFT[0]; |
| 320 | Out[NumSamples / 2] = pFFT[1]*pFFT[1]; |
| 321 | } |
| 322 | |
| 323 | /* |
| 324 | * Windowing Functions |