| 12 | namespace { |
| 13 | |
| 14 | std::vector<float> make_hann_window(int64_t win_length) { |
| 15 | std::vector<float> window(static_cast<size_t>(win_length), 0.0f); |
| 16 | if (win_length == 1) { |
| 17 | window[0] = 1.0f; |
| 18 | return window; |
| 19 | } |
| 20 | constexpr long double kPi = 3.14159265358979323846264338327950288L; |
| 21 | for (int64_t i = 0; i < win_length; ++i) { |
| 22 | window[static_cast<size_t>(i)] = |
| 23 | 0.5f - 0.5f * std::cos(2.0L * kPi * static_cast<long double>(i) / |
| 24 | static_cast<long double>(win_length - 1)); |
| 25 | } |
| 26 | return window; |
| 27 | } |
| 28 | |
| 29 | } // namespace |
| 30 | |