aboutsummaryrefslogtreecommitdiffstats
path: root/common/alcomplex.h
diff options
context:
space:
mode:
authorChris Robinson <chris.kcat@gmail.com>2022-11-24 22:00:02 -0800
committerChris Robinson <chris.kcat@gmail.com>2022-11-24 22:00:02 -0800
commit9bf67c75aa78ed3d53e8f31edb7e31707cc1399f (patch)
treec122692e36c5ba17216ff247330a6654f2994a65 /common/alcomplex.h
parentcbcb14076016921ab90c386eba073d96c761c5c6 (diff)
Use complex floats for convolution reverb FFTs
Diffstat (limited to 'common/alcomplex.h')
-rw-r--r--common/alcomplex.h17
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