5 #define PI 3.1415926535897932384626433832795f
8 /* Convert formant freqencies and bandwidth into resonator difference equation coefficents
10 void resonator::initResonator(
11 int aFrequency, /* Frequency of resonator in Hz */
12 int aBandwidth, /* Bandwidth of resonator in Hz */
15 float arg = (-PI / aSamplerate) * aBandwidth;
16 float r = (float)exp(arg);
18 arg = (-2.0f * PI / aSamplerate) * aFrequency;
19 mB = r * (float)cos(arg) * 2.0f;
23 /* Convert formant freqencies and bandwidth into anti-resonator difference equation constants
25 void resonator::initAntiresonator(
26 int aFrequency, /* Frequency of resonator in Hz */
27 int aBandwidth, /* Bandwidth of resonator in Hz */
30 initResonator(aFrequency, aBandwidth, aSamplerate); /* First compute ordinary resonator coefficients */
31 /* Now convert to antiresonator coefficients */
32 mA = 1.0f / mA; /* a'= 1/a */
33 mB *= -mA; /* b'= -b/a */
34 mC *= -mA; /* c'= -c/a */
37 /* Generic resonator function */
38 float resonator::resonate(float input)
40 float x = mA * input + mB * mP1 + mC * mP2;
46 /* Generic anti-resonator function
47 Same as resonator except that a,b,c need to be set with initAntiresonator()
48 and we save inputs in p1/p2 rather than outputs.
49 There is currently only one of these - "mNasalZero"
51 /* Output = (mNasalZero.a * input) + (mNasalZero.b * oldin1) + (mNasalZero.c * oldin2) */
53 float resonator::antiresonate(float input)
55 float x = mA * input + mB * mP1 + mC * mP2;
61 resonator::resonator()
63 mA = mB = mC = mP1 = mP2 = 0;
66 resonator::~resonator()
70 void resonator::setGain(float aG)