ImFusion SDK 4.3
ImFusion::CpuFFT Namespace Reference

Fast Fourier Transform on the CPU. More...

Detailed Description

Fast Fourier Transform on the CPU.

For version 1.6, a complete redesign of this functionality occurred:

  • Amplitudes of forward transform result are now normalized w.r.t signal duration
  • Forward and backward transform are now their respective inver*ses (stable round trip)
  • Does not pad the buffer size beyond what is required for the FFT by default anymore
  • Buffer allocation no longer makes any assumptions about order of transformations
  • Uses std::complex of either floats or doubles instead of naked float pointers
  • Forward transform can provide an additional output with the frequencies of the bins in units of input signal duration
  • Is now a namespace instead of a class, since all of the methods work independently anyway
  • Consequently does not inherit from the FFT base class anymore Migrating from the previous implementation typically requires adapting to the normalization of the forward transform, which so far had to be done outside of CpuFFT itself.

Functions

template<typename T>
bool toFrequencyDomain (const std::vector< T > &in, std::vector< std::complex< T > > &out, std::vector< double > *frequencies=nullptr, T *suppressZero=nullptr)
 Forward transformation of a real-valued 1D signal.
 
template<typename T>
bool toFrequencyDomain (const TypedImage< T > &in, TypedImage< T > *&outReal, TypedImage< T > *&outImag, std::vector< double > *frequenciesX=nullptr, std::vector< double > *frequenciesY=nullptr)
 
template<typename T>
bool toTimeDomain (const std::vector< std::complex< T > > &in, std::vector< T > &out)
 Backwards transformation to a real-valued 1D signal.
 
template<typename T>
bool toFrequencyDomain (const std::vector< std::complex< T > > &in, std::vector< std::complex< T > > &out, std::vector< double > *frequencies=nullptr)
 Forward transformation of a 1D signal.
 
template<typename T>
bool toTimeDomain (const std::vector< std::complex< T > > &in, std::vector< std::complex< T > > &out)
 Backwards transformation of a 1D signal.
 
template<typename T>
bool toTimeDomain (const TypedImage< T > &inReal, const TypedImage< T > &inImag, TypedImage< T > *&outReal, TypedImage< T > *&outImag)
 
template<typename T>
bool toTimeDomain (const TypedImage< T > &inReal, const TypedImage< T > &inImag, TypedImage< T > *&outAmp)
 
template<typename T>
bool inplaceTransform1D (std::vector< std::complex< T > > &workbuffer, bool forward)
 Transforms a suitably padded buffer in either direction, without normalization or any other convinience.
 
void constructFrequencyAxis (std::vector< double > &freqs, int signalDuration, int transformDuration)
 Computes the frequency values of the bins for a forward transformation, in units of signal length base frequency.
 
bool sizeIsFine (int size)
 Checks if a buffer size is compatible, i.e. of length 2^n.
 
int nextValidSize (int size)
 Returns the smallest padded buffer size for any given input size, or -1 if the input size cannot not yield any useful FFT result.
 

Function Documentation

◆ toFrequencyDomain() [1/2]

template<typename T>
bool toFrequencyDomain ( const std::vector< T > & in,
std::vector< std::complex< T > > & out,
std::vector< double > * frequencies = nullptr,
T * suppressZero = nullptr )

Forward transformation of a real-valued 1D signal.

Can optionally compute the frequencies for the resulting bins in units of the input duration base frequency, i.e. the frequency of a single full oscillation with the length of the input array is 1. Can also subtract (and return) the average signal intensity before executing the transformation. Supported data types are float and double.

◆ toTimeDomain() [1/2]

template<typename T>
bool toTimeDomain ( const std::vector< std::complex< T > > & in,
std::vector< T > & out )

Backwards transformation to a real-valued 1D signal.

Note that this method performs no checks on whether the result is truly real-valued, the imaginary parts are simply dumped. Supported data types are float and double.

◆ toFrequencyDomain() [2/2]

template<typename T>
bool toFrequencyDomain ( const std::vector< std::complex< T > > & in,
std::vector< std::complex< T > > & out,
std::vector< double > * frequencies = nullptr )

Forward transformation of a 1D signal.

Can optionally compute the frequencies for the resulting bins in units of the input duration base frequency, i.e. the frequency of a single full oscillation with the length of the input array is 1. Supported data types are float and double.

◆ toTimeDomain() [2/2]

template<typename T>
bool toTimeDomain ( const std::vector< std::complex< T > > & in,
std::vector< std::complex< T > > & out )

Backwards transformation of a 1D signal.

Supported data types are float and double.

◆ inplaceTransform1D()

template<typename T>
bool inplaceTransform1D ( std::vector< std::complex< T > > & workbuffer,
bool forward )

Transforms a suitably padded buffer in either direction, without normalization or any other convinience.

Intended for advanced users and internal usage by the other methods of this class. Supported data types are float and double.

Search Tab / S to search, Esc to close