MCPcopy Create free account
hub / github.com/audacity/audacity / PowerSpectrum

Function PowerSpectrum

libraries/lib-fft/FFT.cpp:302–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300 */
301
302void 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

Callers 2

CalculateMethod · 0.70
ComputeSpectrumFunction · 0.70

Calls 3

GetFFTFunction · 0.85
RealFFTfFunction · 0.85
getMethod · 0.45

Tested by 2

CalculateMethod · 0.56
ComputeSpectrumFunction · 0.56