#pragma once #include "lasp_mathtypes.h" /** * @brief Window (aka taper) functions of a certain type */ class Window { public: enum class WindowType { Hann = 0, Hamming = 1, Rectangular = 2, Bartlett = 3, Blackman = 4, }; /** * @brief Convert a window type enum to its equivalent text. * * @param wt The window type to convert * * @return Text string */ static std::string toText(const WindowType wt) { switch(wt) { case(WindowType::Hann): { return "Hann"; } break; case(WindowType::Hamming): { return "Hamming"; } break; case(WindowType::Rectangular): { return "Rectangular"; } break; case(WindowType::Bartlett): { return "Bartlett"; } break; case(WindowType::Blackman): { return "Blackman"; } break; } throw std::runtime_error("Not implemenented window type"); } /** * @brief Dispatcher: create a window based on enum type and len * * @param w Window type * @param len Length of the window (typically, integer power of two). * * @return Window vector of values */ static vd create(const WindowType w,const us len); /** * @brief Hann window * * @param len Length of the window (typically, integer power of two). * * @return vector of values */ static vd hann(const us len); /** * @brief Hamming window * * @param len Length of the window (typically, integer power of two). * * @return vector of values */ static vd hamming(const us len); /** * @brief Rectangular (boxcar) window. * * @param len Length of the window (typically, integer power of two). * * @return vector of values */ static vd rectangular(const us len); /** * @brief Bartlett window. * * @param len Length of the window (typically, integer power of two). * * @return vector of values */ static vd bartlett(const us len); /** * @brief Blackman window. * * @param len Length of the window (typically, integer power of two). * * @return vector of values */ static vd blackman(const us len); };