diff options
author | Roland Stigge <stigge@antcom.de> | 2019-02-16 23:37:21 +0100 |
---|---|---|
committer | Roland Stigge <stigge@antcom.de> | 2019-02-16 23:37:21 +0100 |
commit | 1a219839034e9b11a4771fb84c90d4a2667365ce (patch) | |
tree | 143f74f6ea722abf44545c8e709b8c51aa799f03 /fft.h | |
parent | fe8b95b29e69946c81e65dfb7fd838c2922c5c00 (diff) |
Added IFFT + AutoCorrelation
Diffstat (limited to 'fft.h')
-rw-r--r-- | fft.h | 36 |
1 files changed, 31 insertions, 5 deletions
@@ -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 |