Audacity 3.2.0
|
Fast Fourier Transform routines. More...
#include "FFT.h"
#include "Internat.h"
#include "MemoryX.h"
#include <wx/wxcrtvararg.h>
#include <stdlib.h>
#include <math.h>
#include "RealFFTf.h"
Go to the source code of this file.
Typedefs | |
using | Floats = ArrayOf< float > |
Functions | |
static void | InitFFT () |
static bool | IsPowerOfTwo (size_t x) |
static size_t | NumberOfBitsNeeded (size_t PowerOfTwo) |
int | ReverseBits (size_t index, size_t NumBits) |
void | DeinitFFT () |
static size_t | FastReverseBits (size_t i, size_t NumBits) |
void | FFT (size_t NumSamples, bool InverseTransform, const float *RealIn, const float *ImagIn, float *RealOut, float *ImagOut) |
void | RealFFT (size_t NumSamples, const float *RealIn, float *RealOut, float *ImagOut) |
void | InverseRealFFT (size_t NumSamples, const float *RealIn, const float *ImagIn, float *RealOut) |
void | PowerSpectrum (size_t NumSamples, const float *In, float *Out) |
int | NumWindowFuncs () |
const TranslatableString | WindowFuncName (int whichFunction) |
void | NewWindowFunc (int whichFunction, size_t NumSamplesIn, bool extraSample, float *in) |
void | WindowFunc (int whichFunction, size_t NumSamples, float *in) |
void | DerivativeOfWindowFunc (int whichFunction, size_t NumSamples, bool extraSample, float *in) |
Variables | |
static ArraysOf< int > | gFFTBitTable |
static const size_t | MaxFastBits = 16 |
Fast Fourier Transform routines.
This file contains a few FFT routines, including a real-FFT routine that is almost twice as fast as a normal complex FFT, and a power spectrum routine when you know you don't care about phase information.
Some of this code was based on a free implementation of an FFT by Don Cross, available on the web at:
http://www.intersrv.com/~dcross/fft.html
The basic algorithm for his code was based on Numerican Recipes in Fortran. I optimized his code further by reducing array accesses, caching the bit reversal table, and eliminating float-to-double conversions, and I added the routines to calculate a real FFT and a real power spectrum.
Definition in file FFT.cpp.
void DeinitFFT | ( | ) |
Definition at line 112 of file FFT.cpp.
References gFFTBitTable.
Referenced by AudacityApp::OnExit().
void DerivativeOfWindowFunc | ( | int | whichFunction, |
size_t | NumSamples, | ||
bool | extraSample, | ||
float * | in | ||
) |
Definition at line 536 of file FFT.cpp.
References A, eWinFuncBartlett, eWinFuncBlackman, eWinFuncBlackmanHarris, eWinFuncGaussian25, eWinFuncGaussian35, eWinFuncGaussian45, eWinFuncHamming, eWinFuncHann, eWinFuncRectangular, eWinFuncWelch, and M_PI.
Referenced by anonymous_namespace{SpectrogramSettings.cpp}::RecreateWindow().
|
inlinestatic |
Definition at line 117 of file FFT.cpp.
References gFFTBitTable, MaxFastBits, and ReverseBits().
Referenced by FFT().
void FFT | ( | size_t | NumSamples, |
bool | InverseTransform, | ||
const float * | RealIn, | ||
const float * | ImagIn, | ||
float * | RealOut, | ||
float * | ImagOut | ||
) |
Definition at line 129 of file FFT.cpp.
References FastReverseBits(), gFFTBitTable, InitFFT(), IsPowerOfTwo(), M_PI, and NumberOfBitsNeeded().
Referenced by SpecPowerCalculation::CalcPower(), and PaulStretch::process().
|
static |
Definition at line 97 of file FFT.cpp.
References gFFTBitTable, MaxFastBits, and ReverseBits().
Referenced by FFT().
void InverseRealFFT | ( | size_t | NumSamples, |
const float * | RealIn, | ||
const float * | ImagIn, | ||
float * | RealOut | ||
) |
Definition at line 266 of file FFT.cpp.
References GetFFT(), InverseRealFFTf(), and ReorderToTime().
Referenced by EqualizationFilter::CalcFilter(), SpectrumAnalyst::Calculate(), and EqualizationPanel::Recalc().
|
static |
void NewWindowFunc | ( | int | whichFunction, |
size_t | NumSamplesIn, | ||
bool | extraSample, | ||
float * | in | ||
) |
Definition at line 368 of file FFT.cpp.
References A, eWinFuncBartlett, eWinFuncBlackman, eWinFuncBlackmanHarris, eWinFuncGaussian25, eWinFuncGaussian35, eWinFuncGaussian45, eWinFuncHamming, eWinFuncHann, eWinFuncRectangular, eWinFuncWelch, and M_PI.
Referenced by anonymous_namespace{SpectrogramSettings.cpp}::RecreateWindow(), SpectrumTransformer::SpectrumTransformer(), and WindowFunc().
|
static |
Definition at line 71 of file FFT.cpp.
Referenced by FFT().
int NumWindowFuncs | ( | ) |
Definition at line 327 of file FFT.cpp.
References eWinFuncCount.
Referenced by SpectrumAnalyst::Calculate(), FrequencyPlotDialog::Populate(), SpectrumPrefs::Populate(), and SpectrogramSettings::Validate().
void PowerSpectrum | ( | size_t | NumSamples, |
const float * | In, | ||
float * | Out | ||
) |
Definition at line 302 of file FFT.cpp.
References GetFFT(), and RealFFTf().
Referenced by SpectrumAnalyst::Calculate(), and ComputeSpectrum().
void RealFFT | ( | size_t | NumSamples, |
const float * | RealIn, | ||
float * | RealOut, | ||
float * | ImagOut | ||
) |
Definition at line 228 of file FFT.cpp.
References GetFFT(), and RealFFTf().
Referenced by EqualizationFilter::CalcFilter(), SpectrumAnalyst::Calculate(), ComputeSpectrum(), and PaulStretch::process().
int ReverseBits | ( | size_t | index, |
size_t | NumBits | ||
) |
Definition at line 85 of file FFT.cpp.
Referenced by FastReverseBits(), and InitFFT().
void WindowFunc | ( | int | whichFunction, |
size_t | NumSamples, | ||
float * | in | ||
) |
Definition at line 513 of file FFT.cpp.
References eWinFuncBartlett, eWinFuncBlackman, eWinFuncBlackmanHarris, eWinFuncHamming, eWinFuncHann, and NewWindowFunc().
Referenced by SpectrumAnalyst::Calculate(), ComputeSpectrum(), and PaulStretch::process().
const TranslatableString WindowFuncName | ( | int | whichFunction | ) |
Definition at line 332 of file FFT.cpp.
References eWinFuncBartlett, eWinFuncBlackman, eWinFuncBlackmanHarris, eWinFuncGaussian25, eWinFuncGaussian35, eWinFuncGaussian45, eWinFuncHamming, eWinFuncHann, eWinFuncRectangular, eWinFuncWelch, and XO().
Referenced by FrequencyPlotDialog::Populate(), and SpectrumPrefs::Populate().
|
static |
Definition at line 54 of file FFT.cpp.
Referenced by DeinitFFT(), FastReverseBits(), FFT(), and InitFFT().
|
static |
Definition at line 55 of file FFT.cpp.
Referenced by FastReverseBits(), and InitFFT().