-
Notifications
You must be signed in to change notification settings - Fork 7
/
window.h
35 lines (29 loc) · 900 Bytes
/
window.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef _WINDOW_H_
#define _WINDOW_H_
#define _USE_MATH_DEFINES
#include <cmath>
#include <functional>
#include <tuple>
#include <vector>
#include <Eigen/Dense>
/**
* Signal processing functionality
*/
namespace signal_processing {
/**
* Function that calculated the Hann window for the input window length
* @param[in] window_length Desired length of window
* @return Vector filled with Hann window function evaluations based on input
* window length
*/
std::function<Eigen::VectorXd(unsigned int)> hann_window =
[](unsigned int window_length) -> Eigen::VectorXd {
Eigen::VectorXd hann(window_length);
double number_of_points = static_cast<double>(window_length - 1);
for (unsigned int i = 0; i < hann.size(); ++i) {
hann[i] = 0.5 * (1.0 - std::cos(2.0 * M_PI * i / number_of_points));
}
return hann;
};
} // namespace signal_processing
#endif // _WINDOW_H_