-
Notifications
You must be signed in to change notification settings - Fork 38
/
Chebyshev.cpp
69 lines (65 loc) · 1.93 KB
/
Chebyshev.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "Chebyshev.h"
Chebyshev::Chebyshev(){}
Chebyshev::~Chebyshev(){}
/*
filterDesign for the time being returns precalculated
values for Chebyshev 3rd order highpass filter,
given the sample frequency of source signal
*/
std::vector<std::vector<double>> Chebyshev::filterDesign(int order, double ripple, double cutoffFreq, int sampleFreq, int type)
{
std::vector<std::vector<double>> cbCoefficients(2, std::vector<double>(4,0));
switch(sampleFreq){
case 200:
cbCoefficients[0][0] = 0,9953;
cbCoefficients[0][1] = -2.9858;
cbCoefficients[0][2] = 2,9858;
cbCoefficients[0][3] = -0,9953;
cbCoefficients[1][0] = 1.0000;
cbCoefficients[1][1] = -2,9904;
cbCoefficients[1][2] = 2,9811;
cbCoefficients[1][3] = -0,9906;
break;
case 250:
cbCoefficients[0][0] = 0,9963;
cbCoefficients[0][1] = -2,9887;
cbCoefficients[0][2] = 2,9887;
cbCoefficients[0][3] = -0,9963;
cbCoefficients[1][0] = 1.0000;
cbCoefficients[1][1] = -2,9924;
cbCoefficients[1][2] = 2,9850;
cbCoefficients[1][3] = -0,9926;
break;
case 300:
cbCoefficients[0][0] = 0.9969;
cbCoefficients[0][1] = -2.9906;
cbCoefficients[0][2] = 2.9906;
cbCoefficients[0][3] = -0.9969;
cbCoefficients[1][0] = 1.0000;
cbCoefficients[1][1] = -2.9937;
cbCoefficients[1][2] = 2.9875;
cbCoefficients[1][3] = -0.9938;
break;
case 360:
cbCoefficients[0][0] = 0,9974;
cbCoefficients[0][1] = -2,9921;
cbCoefficients[0][2] = 2,9921;
cbCoefficients[0][3] = -0,9974;
cbCoefficients[1][0] = 1.0000;
cbCoefficients[1][1] = -2.9947;
cbCoefficients[1][2] = 2.9895;
cbCoefficients[1][3] = -0.9948;
break;
case 500:
cbCoefficients[0][0] = 0.9981;
cbCoefficients[0][1] = -2.9944;
cbCoefficients[0][2] = 2.9944;
cbCoefficients[0][3] = -0.9969;
cbCoefficients[1][0] = 1.0000;
cbCoefficients[1][1] = -2.9962;
cbCoefficients[1][2] = 2.9925;
cbCoefficients[1][3] = -0.9938;
break;
}
return cbCoefficients;
}