1
/*******************************************/
2
/* Two Zero Filter Class, */
3
/* by Perry R. Cook, 1995-96 */
4
/* See books on filters to understand */
5
/* more about how this works. Nothing */
6
/* out of the ordinary in this version. */
7
/*******************************************/
11
TwoZero :: TwoZero() : Filter()
13
inputs = (MY_FLOAT *) malloc(2 * sizeof(MY_FLOAT));
14
zeroCoeffs[0] = (MY_FLOAT) 0.0;
15
zeroCoeffs[1] = (MY_FLOAT) 0.0;
16
gain = (MY_FLOAT) 1.0;
25
void TwoZero :: clear()
27
inputs[0] = (MY_FLOAT) 0.0;
28
inputs[1] = (MY_FLOAT) 0.0;
29
lastOutput = (MY_FLOAT) 0.0;
32
void TwoZero :: setZeroCoeffs(MY_FLOAT *coeffs)
34
zeroCoeffs[0] = coeffs[0];
35
zeroCoeffs[1] = coeffs[1];
38
void TwoZero :: setGain(MY_FLOAT aValue)
43
MY_FLOAT TwoZero :: tick(MY_FLOAT sample) // Perform Filter Operation
44
{ // TwoZero is a two zero filter (duh!)
45
// Look it up in your favorite DSP text
46
lastOutput = zeroCoeffs[0] * inputs[0];
47
lastOutput += zeroCoeffs[1] * inputs[1];
48
inputs[1] = inputs[0];
49
inputs[0] = gain * sample;
50
lastOutput += inputs[0];