Class for performing real or complex 1D FFTs. More...
#include <marvin_FFT.h>
Public Types | |
using | ValueType = typename getValueType<SampleType>::ValueType |
Public Member Functions | |
FFT (size_t order) | |
~FFT () noexcept | |
EngineType | getEngineType () const noexcept |
size_t | getFFTSize () const noexcept |
void | forward (std::span< SampleType > source, std::span< std::complex< ValueType > > dest) |
std::span< std::complex< ValueType > > | forward (std::span< SampleType > source) |
void | inverse (std::span< std::complex< ValueType > > source, std::span< SampleType > dest) |
std::span< SampleType > | inverse (std::span< std::complex< ValueType > > source) |
Class for performing real or complex 1D FFTs.
The template type SampleType
dictates whether the transform is real-only, or complex. Accepted types are float
, double
, std::complex<float>
, and std::complex<double>
. Performs no scaling on the forward data, and scales the inverse data by 1 / N
.
The implementation is chosen at compile-time based on a few factors:
The fallback implementation is still a WIP, and is actively being updated. Particularly, at the time of writing it only performs radix 2 transforms.
using marvin::dsp::spectral::FFT< SampleType >::ValueType = typename getValueType<SampleType>::ValueType |
|
explicit |
|
noexcept |
Because the PImpl is wrapped in a unique_ptr, we need a non-default destructor.
std::span< std::complex< ValueType > > marvin::dsp::spectral::FFT< SampleType >::forward | ( | std::span< SampleType > | source | ) |
Performs a forward transform on the data passed to source
, and writes the results to an internal vector preallocated to the correct size.
source | The input array-like to perform the transform on. Must be N points long. |
forward
will overwrite this data, so if it's needed, make sure to copy it between calls. The same sizing rules from the other overload of forward
apply. void marvin::dsp::spectral::FFT< SampleType >::forward | ( | std::span< SampleType > | source, |
std::span< std::complex< ValueType > > | dest ) |
Performs a forward transform on the data passed to source
, and writes the results to the array-like passed to dest
.
source | The input array-like to perform the transform on. must be N points long. |
dest | An array like to store the results in. If SampleType is a real (float or double ), dest.size() should be (N / 2) + 1 . In this case, DC is stored in bin 0's real component, and nyquist is stored in the final bin's real component.If SampleType is a std::complex<> , dest.size() should be N . |
|
nodiscardnoexcept |
|
nodiscardnoexcept |
Retrieves the FFT Size (2^order
passed into the constructor).
std::span< SampleType > marvin::dsp::spectral::FFT< SampleType >::inverse | ( | std::span< std::complex< ValueType > > | source | ) |
Performs an inverse transform on the data passed to source
, and writes the results to an internal vector preallocated to the right size.
source | The input array-like to perform the inverse transform on. Sizing rules from the other overload of inverse apply. |
inverse
will overwrite this data, so if it's needed, make sure to copy it between calls. void marvin::dsp::spectral::FFT< SampleType >::inverse | ( | std::span< std::complex< ValueType > > | source, |
std::span< SampleType > | dest ) |
Performs an inverse transform on the data passed to source
, and writes the results to the array-like passed to dest
.
Scales the data internally by 1/N
, so if you've done any scaling yourself, be sure to revert it before calling this function.
source | The input array-like to perform the inverse transform on. If SampleType is a real (float or double ), source.size() should be (N / 2) + 1 , with DC is stored in bin 0's real component, and nyquist stored in the final bin's real component.If SampleType is a std::complex<> , source.size() should be N . |
dest | The destination array-like to write the results to. Must be N points long. |