-
Notifications
You must be signed in to change notification settings - Fork 0
/
trace.h
176 lines (131 loc) · 2.77 KB
/
trace.h
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// forward decl
class Trace;
#define _USE_MATH_DEFINES
#include<math.h>
#ifndef _trace
#define _trace
#include <complex>
class Trace {
public:
/**
* Constructor
**/
Trace();
/**
* Destructor
**/
~Trace();
/**
* Filter
**/
float filter(float value);
/**
* Calculates the coefficients from the typical traceass parameters q and f.
* The frequency is the normalized frequency in the range [0:0.5].
**/
void calcCoeffBandp(float f,float q);
/**
* Calculates the coefficients for a trace: n is the number of
* taps and tau is a decay constant.
**/
void calcCoeffTrace(int nTaps, float tau);
/**
* Calculates the coefficients from the two conjugate poles. The parameters
* are the coordinates in the s-plane (!). The transformation from the
* s-plane to the z-plane is just now the impulseinvariant transform.
**/
void calcCoeffPoles(float r,float i);
/**
* Generates an acsii file with the impulse response of the filter.
**/
void impulse(const char* name);
/**
* the transfer function
**/
std::complex<float> h(std::complex<float> s);
void calc_norm();
/**
* Generates an ASCII file with the transfer function
**/
void transfer(const char* name);
/**
* Gets the actual output of the filter. Same as the return value
* of the function "filter()".
**/
float getActualOutput() {return actualOutput;};
/**
* Gets the input signal
**/
float getInputSignal() {return inputSignal;};
/**
* Gets the derivative of the signal
**/
float getDeriv() {return diff;};
////////////////////////////////////////////////////////////////////
private:
/**
* normalization
**/
float norm;
/**
* Real part of the pole
**/
float realPart;
/**
* Imaginary part of the pole
**/
float imagPart;
/**
* The first pole
**/
std::complex<float> s1;
/**
* The second pole
**/
std::complex<float> s2;
/**
* The coefficients of the denominator of H(z)
**/
float denominator[3];
/**
* The coefficients of the enumerator of H(z)
**/
float enumerator[3];
/**
* Delay lines for the IIR-Filter
**/
float buffer[3];
/**
* Number of taps of the FIR filter for the trace
**/
int taps;
/**
* Delay line for the IIR filter
**/
float *bufferFIR;
/**
* Coefficients of the FIR filter
**/
float *coeffFIR;
/**
* The actual output of the filter (the return value of the filter()
* function).
**/
float actualOutput;
/**
* Sets the IIR delay line to zero
**/
void resetBuffer();
float oldOutput;
float diff;
float inputSignal;
float fre,qual;
float e,w;
public:
float getF() {return fre;};
float getQ() {return qual;};
float getReal() {return -e;};
float getImag() {return w;};
std::complex<float> getPole() {return std::complex<float>(-e,w);};
};
#endif