From 26293db40f8ac62f3971e0e9dbbc0bf3439e61c0 Mon Sep 17 00:00:00 2001 From: Vasile Vilvoiu Date: Tue, 29 Dec 2020 19:33:03 +0200 Subject: Initial commit --- src/fft.hpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/fft.hpp (limited to 'src/fft.hpp') diff --git a/src/fft.hpp b/src/fft.hpp new file mode 100644 index 0000000..9eac372 --- /dev/null +++ b/src/fft.hpp @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2020-2021 Vasile Vilvoiu + * + * specgram is free software; you can redistribute it and/or modify + * it under the terms of the MIT license. See LICENSE for details. + */ + +#ifndef _FFT_HPP_ +#define _FFT_HPP_ + +#include "window-function.hpp" + +#include + +class FFT { +private: + /* FFT window width */ + const std::size_t window_width_; + + /* fftw buffers */ + fftw_complex *in_; + fftw_complex *out_; + + /* fftw plan */ + fftw_plan plan_; + + /* window function */ + std::unique_ptr window_function_; + +public: + FFT() = delete; + FFT(const FFT &c) = delete; + FFT(FFT &&) = delete; + FFT & operator=(const FFT&) = delete; + + FFT(std::size_t win_width, std::unique_ptr& win_func); + virtual ~FFT(); + + ComplexWindow Compute(const ComplexWindow& input); + + static RealWindow GetMagnitude(const ComplexWindow& input, bool alias); + static std::tuple GetFrequencyLimits(double rate, std::size_t width); + static double GetFrequencyIndex(double rate, std::size_t width, double f); + static RealWindow Resample(const RealWindow& input, double rate, std::size_t width, double fmin, double fmax); + static RealWindow Crop(const RealWindow& input, double rate, double fmin, double fmax); +}; + +#endif \ No newline at end of file -- cgit v1.2.3