RTXI  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
trianglr.cpp
Go to the documentation of this file.
1 /*
2  * Triangular window
3  */
4 
5 #include "trianglr.h"
6 #include "misdefs.h"
7 #include <gsl/gsl_math.h>
8 #include <math.h>
9 
10 TriangularWindow::TriangularWindow(int num_taps, int zero_ends)
11  : GenericWindow(num_taps)
12 {
13  GenerateWindow(num_taps, zero_ends);
14 }
15 
16 void
17 TriangularWindow::GenerateWindow(int length, int zero_ends)
18 {
19  if (zero_ends) {
20  if (length % 2) // odd length window centered at zero
21  {
22  for (int n = 0; n < Half_Length; n++) {
23  Half_Lag_Win[n] = 1.0 - (2.0 * n) / ((double)(Length - 1));
24  }
25  } else // even length window centered at -1/2
26  {
27  for (int n = 0; n < Half_Length; n++) {
28  Half_Lag_Win[n] = 1.0 - (2.0 * n + 1.0) / ((double)(Length - 1));
29  }
30  }
31  } else {
32  if (length % 2) // odd length window centered at zero
33  {
34  for (int n = 0; n < Half_Length; n++) {
35  Half_Lag_Win[n] = 1.0 - (2.0 * n) / ((double)(Length + 1));
36  }
37  } else // even length window centered at -1/2
38  {
39  for (int n = 0; n < Half_Length; n++) {
40  Half_Lag_Win[n] = 1.0 - (2.0 * n + 1.0) / ((double)(Length + 1));
41  }
42  }
43  }
44  return;
45 }
void GenerateWindow(int length, int zero_ends)
Definition: trianglr.cpp:17
int Length
Definition: gen_win.h:30
double * Half_Lag_Win
Definition: gen_win.h:32
int Half_Length
Definition: gen_win.h:31
TriangularWindow(int length, int zero_ends)
Definition: trianglr.cpp:10