aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-09-13 04:18:40 -0700
committerChris Robinson <[email protected]>2020-09-13 04:18:40 -0700
commit0974b6b47c55b58989dde329160474ac0d58140a (patch)
treefe71cdf078c10dda503f5991ad1020956a0a5936 /common
parent9a883f50462f22474601204b0052ca9ef4fce676 (diff)
Use inline wrappers to clarify forward/inverse FFTs
Diffstat (limited to 'common')
-rw-r--r--common/alcomplex.cpp4
-rw-r--r--common/alcomplex.h19
2 files changed, 18 insertions, 5 deletions
diff --git a/common/alcomplex.cpp b/common/alcomplex.cpp
index 0af9fc98..f1d13551 100644
--- a/common/alcomplex.cpp
+++ b/common/alcomplex.cpp
@@ -51,7 +51,7 @@ void complex_fft(const al::span<std::complex<double>> buffer, const double sign)
void complex_hilbert(const al::span<std::complex<double>> buffer)
{
- complex_fft(buffer, 1.0);
+ inverse_fft(buffer);
const double inverse_size = 1.0/static_cast<double>(buffer.size());
auto bufiter = buffer.begin();
@@ -65,5 +65,5 @@ void complex_hilbert(const al::span<std::complex<double>> buffer)
std::fill(bufiter, buffer.end(), std::complex<double>{});
- complex_fft(buffer, -1.0);
+ forward_fft(buffer);
}
diff --git a/common/alcomplex.h b/common/alcomplex.h
index 12b86436..23b8114a 100644
--- a/common/alcomplex.h
+++ b/common/alcomplex.h
@@ -7,13 +7,26 @@
/**
* Iterative implementation of 2-radix FFT (In-place algorithm). Sign = -1 is
- * FFT and 1 is iFFT (inverse). Fills the buffer with the Discrete Fourier
- * Transform (DFT) of the time domain data stored in the buffer. The buffer is
- * an array of complex numbers, and MUST BE power of two.
+ * 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);
/**
+ * 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); }
+
+/**
+ * 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); }
+
+/**
* Calculate the complex helical sequence (discrete-time analytical signal) of
* the given input using the discrete Hilbert transform (In-place algorithm).
* Fills the buffer with the discrete-time analytical signal stored in the