diff options
| author | Vasile Vilvoiu <vasi@vilvoiu.ro> | 2021-07-21 21:14:30 +0300 |
|---|---|---|
| committer | Vasile Vilvoiu <vasi@vilvoiu.ro> | 2021-07-21 21:14:30 +0300 |
| commit | ee8a1573204f76b16b9fb711608447aabee55696 (patch) | |
| tree | 50bbcf182716ee0b5b2e5c1ecf104f7143d0bbfe /src/window-function.hpp | |
| parent | a7c430fa81c9e22dbce74869a0a27304da78855b (diff) | |
Added header file comments for classes and methods.
Renamed all factory methods to ::Build().
Diffstat (limited to 'src/window-function.hpp')
| -rw-r--r-- | src/window-function.hpp | 45 |
1 files changed, 42 insertions, 3 deletions
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 <complex> #include <memory> +/** + * 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<double> cached_factors_; + const std::size_t window_size_; /* size of window */ + std::vector<double> 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<WindowFunction> 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<WindowFunction> 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<double>& 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); |
