Better Filtering
The filter we have identified so far for identifying the answer tone was developed intuitively. We can do much better. Matlab's filter design facilities in the DSP toolbox provide some well-known algorithms for filter design. For example,
h = remez(100,[0,2000,2090,2110,2200,4000]/4000,[0,0,1,1,0,0])
The second argument gives the edges of the three frequency bands of interest, zero to 2000, 2090 to 2110, and 2200 to the Nyquist frequency (4000 Hz). The third argument gives the desired gain in these bands. This returns the impulse response of an FIR filter with 101 coefficients that is designed using the Parks-McLellan algorithm, which is based on the Remez exchange algorithm. This algorithm ensures that the sidelobes are of equal size, as seen in the following plot of the magnitude frequency response of this new filter.
Notice that the new filter performs about as well as our naive filter in terms of selecting the frequencies in the vicinity of 2100 Hz, but frequencies close to 2100 Hz are attenuated significantly more.
The impulse response of this filter still has the intuitive 2100 Hz component, but unlike the naive filter, it decays somewhat more gradually towards the ends: