850 likes | 1.92k Vues
“Goertzel Algorithm". Texas Instruments University Programme Teaching Materials. Goertzel Algorithm. Introduction. Touch tone telephones use Dual Tone Multi Frequency (DTMF) for dialling numbers When a keyboard button on a telephone is pressed, pairs of audio tones are generated
E N D
“Goertzel Algorithm" Texas Instruments University Programme Teaching Materials
Introduction • Touch tone telephones use Dual Tone Multi Frequency (DTMF) for dialling numbers • When a keyboard button on a telephone is pressed, pairs of audio tones are generated • The receiver listens to the audio tones and decodes them using the Goertzel Algorithm.
Objectives • To implement Goertzel algorithm in C code • To use the Goertzel Algorithm to decode the tones generated by a touch-tone telephone • To display the key pressed on the console of Code Composer Studio.
Touch Tone Telephone A touch tone telephone works using audio. A pair of audio tones is generated for every key push. Click on the icon to hear the tones.
How the Receiver Works The receiver listens to the audio notes. Analogy: you press a key on the piano. Someone with “perfect pitch” listens and says “you played the note C”.
Keypad Frequencies 1336 Hz 1209 Hz 1477 Hz 697 Hz 770 Hz 852 Hz 941 Hz
Characteristics of Dual Tones • No frequency is a multiple (harmonic) of another • The sum of any two frequencies does not equal any of the other frequencies • The difference between any two frequencies does not equal any of the other frequencies. • The frequency must be within 2% of that specified for the receiver to accept it.
Choice of Frequencies • The tones must not be confused with musical frequencies: • Musical frequencies such as 440 Hz, 523 Hz etc are not used. • Speech can contain second order harmonics: • Ideally the detector should ignore a tone with a high second-order content.
All-Pole IIR Filters • An individual frequency can be identified using an IIR filter with poles placed on the unit circle.
Calculating Filter Values • The formula for the 2nd Order band pass IIR filter is: • Here f = frequency of tone and fs = 8000 Hz.
Filter Difference Equations • The difference equations for this IIR filter are: • Here: x(n) = filter input v(n) = filter output N = number of times filter is applied.
Power In Signal • The outputs from IIR filters have: • amplitude • phase shift • This means the filter outputs will have both real and imaginary components • To calculate the power in the signal we have: • Power = real2 x imaginary2 • In this case we can ignore the phase shift.
Calculating the Power • The power in the signal is calculated as follows: Where: N = total number of times filter is used, typically 210 v(N) = filter output after N times v(N-1) = previous filter output. • A detailed description is to be found in Ifeachor and Jervis in the References section.
Goertzel Algorithm Implementation Requires 8 IIR filters, one for each frequency. Run each filter for the input signal x(n) a total of (typically) 205 to 210 times. The final time through, calculate the power in each of the 8 frequencies. Evaluate which pairs of tones are present from the 8 calculated powers.
Twist • Ideally the two individual DTMF frequencies should have the same amplitude. • This is not always the case. • The ratio between the two individual tones is referred to as “twist”. • Tones where there is a large amount of “twist” may not be DTMF signals.
C Code Implementation The Goertzel Algorithm can be implemented using a sampling frequency of 8000 Hz Each sample takes 210 / 8 = 26.25 ms The output can be built using a sample-by-sample basis Calculation is updated on the arrival of every new input value.
Practical Goertzel Algorithm In this laboratory the keyboard button pushes will be identified by listening to the audio The first part is to test the filter frequencies using a signal generator The second part is to place the microphone near the telephone keyboard and press a keyboard button The button pressed will be displayed on the console.
Installing the Application Copy the files from Application 15 Goertzel Algorithm to the workspace Follow the steps previously given in Chapter 1 to set up the new project.
USB Stick Setup for Test USB to PC Signal Generator Headphones
Testing the IIR Filters Before testing with a telephone keypad, it is useful to test the accuracy of each IIR filter. The version using main1.c contains only single IIR filters. It is possible to test the filters using a signal generator.
USB Stick Setup for Application USB to PC Microphone Headphones
Alternate Test Setup • This requires two TMS320C5505 USB Sticks to be available • Use DTMF generator from Application 14 DTMF Generator to generate the tones • Another option is to record the DTMF tones to a .wav file and then play this back to the TMS320C5505 USB Stick.
Identifying a Telephone Number The implementation in C code only identifies single button pushes. Write your own version of main.c which can identify an entire telephone number.
Second Harmonics • Add a second series of IIR filters for 2x each of the frequencies. • For example, for 697 Hz, add a second filter at 1394 Hz. • Ignore signals where a large amount of second harmonic is present.
Twist • Add code to only accept DTMF tones only if the ratio of frequency1 : frequency2 is less than 2:1. • This prevents non-DTMF tones being accepted.
Question What sort of filters does the Goertzel Algorithm use? Why does the Goertzel Algorithm calculate the output power? How can music be distinguished from DTMF tones?
References • Digital Signal Processing, A Practical Approach by Emmanuel C. Ifeachor and Barrie W. Jervis. ISBN 0201-59619-9.