RTXI  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
hann.cpp
Go to the documentation of this file.
1 /*
2  * Hann window, not to be confused with Hanning window
3  */
4 
5 #include "hann.h"
6 #include "misdefs.h"
7 #include <gsl/gsl_math.h>
8 #include <math.h>
9 
10 HannWindow::HannWindow(int num_taps, int zero_ends)
11  : GenericWindow(num_taps)
12 {
13  GenerateWindow(num_taps, zero_ends);
14 }
15 
16 void
17 HannWindow::GenerateWindow(int length, int zero_ends)
18 {
19  for (int n = 0; n < Half_Length; n++) {
20  if (length % 2) // odd length
21  {
22  if (zero_ends) {
23  Half_Lag_Win[n] = 0.5 + 0.5 * cos(M_PI * 2 * n / (length - 1));
24  } else {
25  Half_Lag_Win[n] = 0.5 + 0.5 * cos(M_PI * 2 * n / (length + 1));
26  }
27  } else {
28  if (zero_ends) {
29  Half_Lag_Win[n] = 0.5 + 0.5 * cos((2 * n + 1) * M_PI / (length - 1));
30  } else {
31  Half_Lag_Win[n] = 0.5 + 0.5 * cos((2 * n + 1) * M_PI / (length + 1));
32  }
33  }
34  // std::cout << n << " " << Half_Lag_Win[n] << std::endl;
35  }
36  return;
37 }
HannWindow(int length, int zero_ends)
Definition: hann.cpp:10
double * Half_Lag_Win
Definition: gen_win.h:32
void GenerateWindow(int length, int zero_ends)
Definition: hann.cpp:17
int Half_Length
Definition: gen_win.h:31