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.
sdrbase
dsp
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
58
class
SDRBASE_API
WFIR
59
{
60
public
:
61
enum
TPassTypeName
62
{
63
LPF, HPF, BPF, NOTCH
64
};
65
66
enum
TWindowType
67
{
68
wtNONE
,
69
wtKAISER
,
70
wtSINC
,
71
wtHANNING
,
72
wtHAMMING
,
73
wtBLACKMAN
,
74
wtFLATTOP
,
75
wtBLACKMAN_HARRIS
,
76
wtBLACKMAN_NUTTALL
,
77
wtNUTTALL
,
78
wtKAISER_BESSEL
,
79
wtTRAPEZOID
,
80
wtGAUSS
,
81
wtSINE
,
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
WFIR::wtTRAPEZOID
Definition:
wfir.h:79
WFIR::wtNUTTALL
Definition:
wfir.h:77
WFIR::wtKAISER
Definition:
wfir.h:69
WFIR::wtFLATTOP
Definition:
wfir.h:74
WFIR::TWindowType
TWindowType
Definition:
wfir.h:66
WFIR::wtBLACKMAN_NUTTALL
Definition:
wfir.h:76
export.h
WFIR::wtKAISER_BESSEL
Definition:
wfir.h:78
WFIR::TPassTypeName
TPassTypeName
Definition:
wfir.h:61
WFIR::wtGAUSS
Definition:
wfir.h:80
WFIR::wtHAMMING
Definition:
wfir.h:72
WFIR::wtSINE
Definition:
wfir.h:81
WFIR
Definition:
wfir.h:58
WFIR::wtNONE
Definition:
wfir.h:68
WFIR::wtBLACKMAN_HARRIS
Definition:
wfir.h:75
WFIR::wtSINC
Definition:
wfir.h:70
WFIR::wtBLACKMAN
Definition:
wfir.h:73
SDRBASE_API
#define SDRBASE_API
Definition:
export.h:40
WFIR::wtHANNING
Definition:
wfir.h:71
Generated on Fri Aug 2 2019 17:56:33 for SDRAngel by
1.8.13