24 std::complex<double> compexp = exp(
25 std::complex<double>(0.0, 2 * PI * f));
26 return -((-compexp + 1.0) / (compexp + 1.0)).imag();
35 class SimpleLp:
public std::unary_function<double, double>
39 double filtervalues[3];
47 filtervalues[0] = -b / (1.0 + b);
48 filtervalues[1] = -b / (1.0 + b);
49 filtervalues[2] = (1.0 - b) / (1.0 + b);
51 std::fill_n(tsvalues, 2, 0.0);
57 tsvalues[1] = filtervalues[0] * currvalue + filtervalues[1]
58 * tsvalues[0] + filtervalues[2] * tsvalues[1];
60 tsvalues[0] = currvalue;
69 class SimpleBp:
public std::unary_function<double, double>
73 double filtervalues[4];
76 SimpleBp(
const double lowercornerfreq,
const double uppercornerfreq)
79 double b =
FreqToW(uppercornerfreq);
80 double a =
FreqToW(lowercornerfreq);
82 filtervalues[0] = -b / ((1.0 + a) * (1.0 + b));
83 filtervalues[1] = b / ((1.0 + a) * (1.0 + b));
84 filtervalues[2] = ((1.0 + a) * (1.0 - b) + (1.0 - a) * (1.0 + b))
85 / ((1.0 + a) * (1.0 + b));
86 filtervalues[3] = -(1.0 - a) * (1.0 - b) / ((1.0 + a) * (1.0 + b));
88 std::fill_n(tsvalues, 4, 0.0);
91 double operator()(
const double currvalue)
94 double tmp = tsvalues[2];
96 tsvalues[2] = filtervalues[0] * currvalue + filtervalues[1]
97 * tsvalues[1] + filtervalues[2] * tsvalues[2] + filtervalues[3]
101 tsvalues[1] = tsvalues[0];
102 tsvalues[0] = currvalue;
void f(vector< double > &v1, vector< double > &v2, vector< double > &v3, vector< double > &v4)