/* Process the 8 frequency filters */
for (k = 0; k < NDTMFCOEFF; k++)
{
/* Goertzel processing */
sk = sk1 = sk2 = 0;
for (n = 0; n < DTMF_NPOINTS; n++)
{
sk = DTMFsamples[n] + ((DTMFCoeff[k] * sk1) >> 15) - sk2;
sk2 = sk1;
sk1 = sk;
}
/* Prevent overflows */
sk >>= 1;
sk2 >>= 1;
/* compute |X(k)|**2 */
power = ((sk * sk) >> AMP_BITS) -
((((DTMFCoeff[k] * sk) >> 15) * sk2) >> AMP_BITS) +
((sk2 * sk2) >> AMP_BITS);
result = result >> 1;
if (power > DTMF_TRESH)
{
result += 0x80;
}
}
Listing 1—In this Goertzel
routine, the loop calculates the energy in each of eight filters (the four low
plus the four high frequencies).