summaryrefslogtreecommitdiff
path: root/src/window-function.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/window-function.hpp')
-rw-r--r--src/window-function.hpp45
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);