summaryrefslogtreecommitdiffhomepage
path: root/fft.h
diff options
context:
space:
mode:
Diffstat (limited to 'fft.h')
-rw-r--r--fft.h36
1 files changed, 31 insertions, 5 deletions
diff --git a/fft.h b/fft.h
index f2b7038..8c1e161 100644
--- a/fft.h
+++ b/fft.h
@@ -3,10 +3,12 @@
#pragma once
#include <complex>
+#include <memory>
#include <vector>
namespace RIT {
+// Fast Fourier Transform
class FFT {
private:
int mSize;
@@ -17,18 +19,42 @@ private:
public:
FFT(int size, bool halfOnly = false);
- std::vector<std::complex<double>> operator()(const std::vector<std::complex<double>> &v);
+ std::vector<std::complex<double>> operator()(const std::vector<std::complex<double>> &v) const;
FFT& SetHalfOnly(bool enable);
private:
- int bitreverse(int i);
+ int bitreverse(int i) const;
- 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);
+ void reorder(const std::vector<std::complex<double>>& src, std::vector<std::complex<double>>& dst) const;
+ void fft_recursive(std::vector<std::complex<double>>::iterator X, int N) const;
+ void fft_half(std::vector<std::complex<double>>::iterator X, int N) const;
}; // class FFT
+// Inverse FFT
+class IFFT {
+public:
+ IFFT(int size);
+ IFFT(std::shared_ptr<FFT> fft);
+ ~IFFT();
+ std::vector<std::complex<double>> operator()(const std::vector<std::complex<double>> &v) const;
+
+private:
+ struct Impl;
+ std::unique_ptr<Impl> mImpl;
+}; // class IFFT
+
+class AutoCorrelation {
+public:
+ AutoCorrelation(int size);
+ ~AutoCorrelation();
+ std::vector<std::complex<double>> operator()(const std::vector<std::complex<double>> &v) const;
+
+private:
+ struct Impl;
+ std::unique_ptr<Impl> mImpl;
+}; // class AutoCorrelation
+
std::vector<double> magnitudes(std::vector<std::complex<double>>& v);
} // namespace RIT