summaryrefslogtreecommitdiffhomepage
path: root/fft.h
diff options
context:
space:
mode:
authorRoland Stigge <stigge@antcom.de>2019-01-27 13:32:40 +0100
committerRoland Stigge <stigge@antcom.de>2019-01-27 13:32:40 +0100
commitba9179c7991eeaf1b8d59a0db3975f049b2735b7 (patch)
treeec07f6f8144b95f92f57ed076da215cca964a77a /fft.h
parentdb0d20a6c322211593fecf209898f2435468e813 (diff)
Added half FFT and magnitudes
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