Also, the goertzel algorithm is supposed to compensate for magnitude on its own.
This can be done without changing the library.
The dtmf_test sketch originally had this code:
dtmf.detect(d_mags,512);
thischar = dtmf.button(d_mags,1800);
Change it to this:
dtmf.detect(d_mags,512);
for(int i = 0;i < 8;i++) {
d_mags[i] /= n;
}
thischar = dtmf.button(d_mags,20.);
The "for" loop normalizes the magnitudes. I determined the threshold value of 20 empirically but it works for values of n from 55 up to 160 when using either of the sample audio files.
I prefer to leave this outside the library but if you want to build it in, in the method DTMF::detect change this statement:
dtmf_mag[i] = sqrt(Q1[i]*Q1[i] + Q2[i]*Q2[i] - coeff[i]*Q1[i]*Q2[i]);
to this:
dtmf_mag[i] = sqrt(Q1[i]*Q1[i] + Q2[i]*Q2[i] - coeff[i]*Q1[i]*Q2[i])/N;
Pete