diff options
Diffstat (limited to 'common/alcomplex.h')
-rw-r--r-- | common/alcomplex.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/common/alcomplex.h b/common/alcomplex.h index 23b8114a..46dbb5bc 100644 --- a/common/alcomplex.h +++ b/common/alcomplex.h @@ -2,6 +2,7 @@ #define ALCOMPLEX_H #include <complex> +#include <type_traits> #include "alspan.h" @@ -10,21 +11,27 @@ * FFT and 1 is inverse FFT. Applies the Discrete Fourier Transform (DFT) to * the data supplied in the buffer, which MUST BE power of two. */ -void complex_fft(const al::span<std::complex<double>> buffer, const double sign); +template<typename Real> +std::enable_if_t<std::is_floating_point<Real>::value> +complex_fft(const al::span<std::complex<Real>> buffer, const Real sign); /** * Calculate the frequency-domain response of the time-domain signal in the * provided buffer, which MUST BE power of two. */ -inline void forward_fft(const al::span<std::complex<double>> buffer) -{ complex_fft(buffer, -1.0); } +template<typename Real> +std::enable_if_t<std::is_floating_point<Real>::value> +forward_fft(const al::span<std::complex<Real>> buffer) +{ complex_fft(buffer, Real{-1}); } /** * Calculate the time-domain signal of the frequency-domain response in the * provided buffer, which MUST BE power of two. */ -inline void inverse_fft(const al::span<std::complex<double>> buffer) -{ complex_fft(buffer, 1.0); } +template<typename Real> +std::enable_if_t<std::is_floating_point<Real>::value> +inverse_fft(const al::span<std::complex<Real>> buffer) +{ complex_fft(buffer, Real{1}); } /** * Calculate the complex helical sequence (discrete-time analytical signal) of |