SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Types | Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
FFTWindow Class Reference

#include <fftwindow.h>

Public Types

enum  Function {
  Bartlett, BlackmanHarris, Flattop, Hamming,
  Hanning, Rectangle
}
 

Public Member Functions

void create (Function function, int n)
 
void apply (const std::vector< Real > &in, std::vector< Real > *out)
 
void apply (const std::vector< Complex > &in, std::vector< Complex > *out)
 
void apply (const Complex *in, Complex *out)
 

Static Private Member Functions

static Real flatTop (Real n, Real i)
 
static Real bartlett (Real n, Real i)
 
static Real blackmanHarris (Real n, Real i)
 
static Real hamming (Real n, Real i)
 
static Real hanning (Real n, Real i)
 
static Real rectangle (Real, Real)
 

Private Attributes

std::vector< float > m_window
 

Detailed Description

Definition at line 31 of file fftwindow.h.

Member Enumeration Documentation

◆ Function

Enumerator
Bartlett 
BlackmanHarris 
Flattop 
Hamming 
Hanning 
Rectangle 

Definition at line 33 of file fftwindow.h.

Member Function Documentation

◆ apply() [1/3]

void FFTWindow::apply ( const std::vector< Real > &  in,
std::vector< Real > *  out 
)

Definition at line 58 of file fftwindow.cpp.

References i, and m_window.

Referenced by SpectrumVis::feed().

59 {
60  for(size_t i = 0; i < m_window.size(); i++)
61  (*out)[i] = in[i] * m_window[i];
62 }
int32_t i
Definition: decimators.h:244
std::vector< float > m_window
Definition: fftwindow.h:48
+ Here is the caller graph for this function:

◆ apply() [2/3]

void FFTWindow::apply ( const std::vector< Complex > &  in,
std::vector< Complex > *  out 
)

Definition at line 64 of file fftwindow.cpp.

References i, and m_window.

65 {
66  for(size_t i = 0; i < m_window.size(); i++)
67  (*out)[i] = in[i] * m_window[i];
68 }
int32_t i
Definition: decimators.h:244
std::vector< float > m_window
Definition: fftwindow.h:48

◆ apply() [3/3]

void FFTWindow::apply ( const Complex in,
Complex out 
)

Definition at line 70 of file fftwindow.cpp.

References i, and m_window.

71 {
72  for(size_t i = 0; i < m_window.size(); i++)
73  out[i] = in[i] * m_window[i];
74 }
int32_t i
Definition: decimators.h:244
std::vector< float > m_window
Definition: fftwindow.h:48

◆ bartlett()

static Real FFTWindow::bartlett ( Real  n,
Real  i 
)
inlinestaticprivate

Definition at line 56 of file fftwindow.h.

Referenced by create().

57  {
58  // amplitude correction = 2.0
59  return (2.0 / (n - 1.0)) * ( (n - 1.0) / 2.0 - fabs(i - (n - 1.0) / 2.0)) * 2.0;
60  }
int32_t i
Definition: decimators.h:244
+ Here is the caller graph for this function:

◆ blackmanHarris()

static Real FFTWindow::blackmanHarris ( Real  n,
Real  i 
)
inlinestaticprivate

Definition at line 62 of file fftwindow.h.

References cos(), and M_PI.

Referenced by create().

63  {
64  // amplitude correction = 2.79
65  return (0.35875 - 0.48829 * cos((2.0 * M_PI * i) / n) + 0.14128 * cos((4.0 * M_PI * i) / n) - 0.01168 * cos((6.0 * M_PI * i) / n)) * 2.79;
66  }
Fixed< IntType, IntBits > cos(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2271
int32_t i
Definition: decimators.h:244
#define M_PI
Definition: fftwindow.h:29
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create()

void FFTWindow::create ( Function  function,
int  n 
)

Definition at line 21 of file fftwindow.cpp.

References Bartlett, bartlett(), BlackmanHarris, blackmanHarris(), Flattop, flatTop(), Hamming, hamming(), Hanning, hanning(), i, m_window, Rectangle, and rectangle().

Referenced by SpectrumVis::handleConfigure().

22 {
23  Real (*wFunc)(Real n, Real i);
24 
25  m_window.clear();
26 
27  switch(function) {
28  case Flattop:
29  wFunc = flatTop;
30  break;
31 
32  case Bartlett:
33  wFunc = bartlett;
34  break;
35 
36  case BlackmanHarris:
37  wFunc = blackmanHarris;
38  break;
39 
40  case Hamming:
41  wFunc = hamming;
42  break;
43 
44  case Hanning:
45  wFunc = hanning;
46  break;
47 
48  case Rectangle:
49  default:
50  wFunc = rectangle;
51  break;
52  }
53 
54  for(int i = 0; i < n; i++)
55  m_window.push_back(wFunc(n, i));
56 }
static Real rectangle(Real, Real)
Definition: fftwindow.h:80
static Real flatTop(Real n, Real i)
Definition: fftwindow.h:50
int32_t i
Definition: decimators.h:244
static Real blackmanHarris(Real n, Real i)
Definition: fftwindow.h:62
static Real hamming(Real n, Real i)
Definition: fftwindow.h:68
static Real bartlett(Real n, Real i)
Definition: fftwindow.h:56
static Real hanning(Real n, Real i)
Definition: fftwindow.h:74
std::vector< float > m_window
Definition: fftwindow.h:48
float Real
Definition: dsptypes.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ flatTop()

static Real FFTWindow::flatTop ( Real  n,
Real  i 
)
inlinestaticprivate

Definition at line 50 of file fftwindow.h.

References cos(), and M_PI.

Referenced by create().

51  {
52  // correction ?
53  return 1.0 - 1.93 * cos((2.0 * M_PI * i) / n) + 1.29 * cos((4.0 * M_PI * i) / n) - 0.388 * cos((6.0 * M_PI * i) / n) + 0.03222 * cos((8.0 * M_PI * i) / n);
54  }
Fixed< IntType, IntBits > cos(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2271
int32_t i
Definition: decimators.h:244
#define M_PI
Definition: fftwindow.h:29
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hamming()

static Real FFTWindow::hamming ( Real  n,
Real  i 
)
inlinestaticprivate

Definition at line 68 of file fftwindow.h.

References cos(), and M_PI.

Referenced by create().

69  {
70  // amplitude correction = 1.855, energy correction = 1.586
71  return (0.54 - 0.46 * cos((2.0 * M_PI * i) / n)) * 1.855;
72  }
Fixed< IntType, IntBits > cos(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2271
int32_t i
Definition: decimators.h:244
#define M_PI
Definition: fftwindow.h:29
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hanning()

static Real FFTWindow::hanning ( Real  n,
Real  i 
)
inlinestaticprivate

Definition at line 74 of file fftwindow.h.

References cos(), and M_PI.

Referenced by create().

75  {
76  // amplitude correction = 2.0, energy correction = 1.633
77  return (0.5 - 0.5 * cos((2.0 * M_PI * i) / n)) * 2.0;
78  }
Fixed< IntType, IntBits > cos(Fixed< IntType, IntBits > const &x)
Definition: fixed.h:2271
int32_t i
Definition: decimators.h:244
#define M_PI
Definition: fftwindow.h:29
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rectangle()

static Real FFTWindow::rectangle ( Real  ,
Real   
)
inlinestaticprivate

Definition at line 80 of file fftwindow.h.

Referenced by create().

81  {
82  return 1.0;
83  }
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_window

std::vector<float> FFTWindow::m_window
private

Definition at line 48 of file fftwindow.h.

Referenced by apply(), and create().


The documentation for this class was generated from the following files: