From ee8a1573204f76b16b9fb711608447aabee55696 Mon Sep 17 00:00:00 2001 From: Vasile Vilvoiu Date: Wed, 21 Jul 2021 21:14:30 +0300 Subject: Added header file comments for classes and methods. Renamed all factory methods to ::Build(). --- src/window-function.hpp | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) (limited to 'src/window-function.hpp') diff --git a/src/window-function.hpp b/src/window-function.hpp index 05f1e13..1f212a7 100644 --- a/src/window-function.hpp +++ b/src/window-function.hpp @@ -13,6 +13,9 @@ #include #include +/** + * Types of supported window functions + */ enum class WindowFunctionType { kNone, kHann, @@ -21,42 +24,78 @@ enum class WindowFunctionType { kNuttall }; +/** + * Base window function class. + */ class WindowFunction { protected: - const std::size_t window_size_; - std::vector cached_factors_; + const std::size_t window_size_; /* size of window */ + std::vector cached_factors_; /* precomputed factors for each element in window */ + /** + * @param window_size Window size. + */ explicit WindowFunction(std::size_t window_size); public: WindowFunction() = delete; + /** + * Apply function to a window. + * @param window Array of complex numbers. + * @return Element-wise multiplication between window and precomputed factors. + */ ComplexWindow Apply(const ComplexWindow& window) const; - static std::unique_ptr FromType(WindowFunctionType type, std::size_t window_size); + /** + * Build a fitting window function. + * @param type One of WindowFunctionType + * @param window_size Size of window. + * @return New WindowFunction instance. + */ + static std::unique_ptr Build(WindowFunctionType type, std::size_t window_size); }; +/** + * Specialization for generalized cosine window functions. + */ class GeneralizedCosineWindowFunction : public WindowFunction { protected: public: + /** + * @param window_size Window size. + * @param a List of coefficients. + */ GeneralizedCosineWindowFunction(std::size_t window_size, const std::vector& a); }; +/** + * Specialization for Hann windows. + */ class HannWindowFunction : public GeneralizedCosineWindowFunction { public: explicit HannWindowFunction(std::size_t window_size); }; +/** + * Specialization for Hamming windows. + */ class HammingWindowFunction : public GeneralizedCosineWindowFunction { public: explicit HammingWindowFunction(std::size_t window_size); }; +/** + * Specialization for Blackman windows. + */ class BlackmanWindowFunction : public GeneralizedCosineWindowFunction { public: explicit BlackmanWindowFunction(std::size_t window_size); }; +/** + * Specialization for Nuttall windows. + */ class NuttallWindowFunction : public GeneralizedCosineWindowFunction { public: explicit NuttallWindowFunction(std::size_t window_size); -- cgit v1.2.3