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.
wfir.h
Go to the documentation of this file.
1 /*
2  July 15, 2015
3  Iowa Hills Software LLC
4  http://www.iowahills.com
5 
6  If you find a problem with this code, please leave us a note on:
7  http://www.iowahills.com/feedbackcomments.html
8 
9  Source: ~Projects\Common\BasicFIRFilterCode.cpp
10 
11  This generic FIR filter code is described in most textbooks.
12  e.g. Discrete Time Signal Processing, Oppenheim and Shafer
13 
14  A nice paper on this topic is:
15  http://dea.brunel.ac.uk/cmsp/Home_Saeed_Vaseghi/Chapter05-DigitalFilters.pdf
16 
17  This code first generates either a low pass, high pass, band pass, or notch
18  impulse response for a rectangular window. It then applies a window to this
19  impulse response.
20 
21  There are several windows available, including the Kaiser, Sinc, Hanning,
22  Blackman, and Hamming. Of these, the Kaiser and Sinc are probably the most useful
23  for FIR filters because their sidelobe levels can be controlled with the Beta parameter.
24 
25  This is a typical function call:
26  BasicFIR(FirCoeff, NumTaps, PassType, OmegaC, BW, wtKAISER, Beta);
27  BasicFIR(FirCoeff, 33, LPF, 0.2, 0.0, wtKAISER, 3.2);
28  33 tap, low pass, corner frequency at 0.2, BW=0 (ignored in the low pass code),
29  Kaiser window, Kaiser Beta = 3.2
30 
31  These variables should be defined similar to this:
32  double FirCoeff[MAXNUMTAPS];
33  int NumTaps; NumTaps can be even or odd, but must be less than the FirCoeff array size.
34  TPassTypeName PassType; PassType is an enum defined in the header file. LPF, HPF, BPF, or NOTCH
35  double OmegaC 0.0 < OmegaC < 1.0 The filters corner freq, or center freq if BPF or NOTCH
36  double BW 0.0 < BW < 1.0 The filters band width if BPF or NOTCH
37  TWindowType WindowType; WindowType is an enum defined in the header to be one of these.
38  wtNONE, wtKAISER, wtSINC, wtHANNING, .... and others.
39  double Beta; 0 <= Beta <= 10.0 Beta is used with the Kaiser, Sinc, and Sine windows only.
40  It controls the transition BW and sidelobe level of the filters.
41 
42 
43  If you want to use it, Kaiser originally defined Beta as follows.
44  He derived its value based on the desired sidelobe level, dBAtten.
45  double dBAtten, Beta, Beta1=0.0, Beta2=0.0;
46  if(dBAtten < 21.0)dBAtten = 21.0;
47  if(dBAtten > 50.0)Beta1 = 0.1102 * (dBAtten - 8.7);
48  if(dBAtten >= 21.0 && dBAtten <= 50.0) Beta2 = 0.5842 * pow(dBAtten - 21.0, 0.4) + 0.07886 * (dBAtten - 21.0);
49  Beta = Beta1 + Beta2;
50 
51  */
52 
53 #ifndef _WFIR_H_
54 #define _WFIR_H_
55 
56 #include "export.h"
57 
59 {
60 public:
62  {
63  LPF, HPF, BPF, NOTCH
64  };
65 
67  {
82  wtTEST
83  };
84 
85  static void BasicFIR(double *FirCoeff, int NumTaps, TPassTypeName PassType,
86  double OmegaC, double BW, TWindowType WindowType, double WinBeta);
87 
88 private:
89  static void WindowData(double *Data, int N, TWindowType WindowType,
90  double Alpha, double Beta, bool UnityGain);
91  static double Bessel(double x);
92  static double Sinc(double x);
93 };
94 
95 #endif
TWindowType
Definition: wfir.h:66
TPassTypeName
Definition: wfir.h:61
Definition: wfir.h:58
#define SDRBASE_API
Definition: export.h:40