summaryrefslogtreecommitdiff
path: root/src/window-function.hpp
diff options
context:
space:
mode:
authorVasile Vilvoiu <vasi.vilvoiu@gmail.com>2020-12-29 19:33:03 +0200
committerVasile Vilvoiu <vasi.vilvoiu@gmail.com>2020-12-29 19:33:03 +0200
commit26293db40f8ac62f3971e0e9dbbc0bf3439e61c0 (patch)
tree218c93aba851c3c3123e9e72d25c974aa65cfd52 /src/window-function.hpp
Initial commit
Diffstat (limited to 'src/window-function.hpp')
-rw-r--r--src/window-function.hpp65
1 files changed, 65 insertions, 0 deletions
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 <vasi.vilvoiu@gmail.com>
+ *
+ * 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 <vector>
+#include <complex>
+#include <memory>
+
+enum class WindowFunctionType {
+ kNone,
+ kHann,
+ kHamming,
+ kBlackman,
+ kNuttall
+};
+
+class WindowFunction {
+protected:
+ const std::size_t window_size_;
+ std::vector<double> cached_factors_;
+
+ explicit WindowFunction(std::size_t window_size);
+
+public:
+ WindowFunction() = delete;
+
+ ComplexWindow Apply(const ComplexWindow& window) const;
+
+ static std::unique_ptr<WindowFunction> FromType(WindowFunctionType type, std::size_t window_size);
+};
+
+class GeneralizedCosineWindowFunction : public WindowFunction {
+protected:
+public:
+ GeneralizedCosineWindowFunction(std::size_t window_size, const std::vector<double>& 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