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/window-function.hpp | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/window-function.hpp (limited to 'src/window-function.hpp') diff --git a/src/window-function.hpp b/src/window-function.hpp new file mode 100644 index 0000000..123a17e --- /dev/null +++ b/src/window-function.hpp @@ -0,0 +1,65 @@ +/* + * 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 _WINDOW_FUNCTION_HPP_ +#define _WINDOW_FUNCTION_HPP_ + +#include "input-parser.hpp" + +#include +#include +#include + +enum class WindowFunctionType { + kNone, + kHann, + kHamming, + kBlackman, + kNuttall +}; + +class WindowFunction { +protected: + const std::size_t window_size_; + std::vector cached_factors_; + + explicit WindowFunction(std::size_t window_size); + +public: + WindowFunction() = delete; + + ComplexWindow Apply(const ComplexWindow& window) const; + + static std::unique_ptr FromType(WindowFunctionType type, std::size_t window_size); +}; + +class GeneralizedCosineWindowFunction : public WindowFunction { +protected: +public: + GeneralizedCosineWindowFunction(std::size_t window_size, const std::vector& a); +}; + +class HannWindowFunction : public GeneralizedCosineWindowFunction { +public: + explicit HannWindowFunction(std::size_t window_size); +}; + +class HammingWindowFunction : public GeneralizedCosineWindowFunction { +public: + explicit HammingWindowFunction(std::size_t window_size); +}; + +class BlackmanWindowFunction : public GeneralizedCosineWindowFunction { +public: + explicit BlackmanWindowFunction(std::size_t window_size); +}; + +class NuttallWindowFunction : public GeneralizedCosineWindowFunction { +public: + explicit NuttallWindowFunction(std::size_t window_size); +}; + +#endif \ No newline at end of file -- cgit v1.2.3