summaryrefslogtreecommitdiffhomepage
path: root/fft.h
diff options
context:
space:
mode:
Diffstat (limited to 'fft.h')
-rw-r--r--fft.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/fft.h b/fft.h
new file mode 100644
index 0000000..f2b7038
--- /dev/null
+++ b/fft.h
@@ -0,0 +1,34 @@
+// FFT
+
+#pragma once
+
+#include <complex>
+#include <vector>
+
+namespace RIT {
+
+class FFT {
+private:
+ int mSize;
+ std::vector<int> order;
+ std::vector<std::complex<double>> expLUT;
+
+ bool mFlagHalfOnly;
+
+public:
+ FFT(int size, bool halfOnly = false);
+ std::vector<std::complex<double>> operator()(const std::vector<std::complex<double>> &v);
+
+ FFT& SetHalfOnly(bool enable);
+
+private:
+ int bitreverse(int i);
+
+ void reorder(const std::vector<std::complex<double>>& src, std::vector<std::complex<double>>& dst);
+ void fft_recursive(std::vector<std::complex<double>>::iterator X, int N);
+ void fft_half(std::vector<std::complex<double>>::iterator X, int N);
+}; // class FFT
+
+std::vector<double> magnitudes(std::vector<std::complex<double>>& v);
+
+} // namespace RIT