Contentsavailable here, or which is included with my NCM App, demonstrates both these aspects of DTMF.
fr = [697 770 852 941]; fc = [1209 1336 1477];These frequencies were chosen so that none is an integer multiple of any other. In fact the ratios are 21/19. This avoids interfering overtones. If s is a character that labels one of the buttons on the keypad, the corresponding row index k and column index j can be found with
switch s case '*', k = 4; j = 1; case '0', k = 4; j = 2; case '#', k = 4; j = 3; otherwise, d = s-'0'; j = mod(d-1,3)+1; k = (d-j)/3+1; endAn important parameter in digital sound is the sampling rate.
Fs = 32768A vector of points in one-fourth of a second at this sampling rate is
t = 0:1/Fs:0.25The tone generated by the button in position (k,j) is obtained by superimposing the two fundamental tones with frequencies fr(k) and fc(j).
y1 = sin(2*pi*fr(k)*t); y2 = sin(2*pi*fc(j)*t); y = (y1 + y2)/2;If your computer is equipped with a sound card, the statement
sound(y,Fs)plays the tone.
https://www.mathworks.com/moler.htmlncm/touchtone.matGo to the Home tab above the MATLAB command window, click on the Open tab and insert this URL into the File name slot. This will load a structure y into your MATLAB workspace. Then the statement
y = sig: [1x74800 int8] fs: 8192This shows that y has two fields, an integer vector y.sig, of length 74800, containing the signal, and a scalar y.fs, with the value 8192, which is the sample rate.
max(abs(y.sig))reveals that the elements of the signal are bounded in absolute value by 127. So the statements
Fs = y.fs; y = double(y.sig)/128;save the sample rate, rescale the vector and convert it to double precision. The statements
n = length(y); t = (0:n-1)/Fsreproduce the sample times of the recording. The last component of t is 9.1307, indicating that the recording lasts a little over 9 seconds. The next figure is a plot of the entire signal. This recording is noisy. You can even see small spikes on the graph at the times the buttons were clicked. It is easy to see that 11 digits were dialed, but, on this scale, it is impossible to determine the specific digits. Here is the magnitude of the FFT of the signal, which is the key to determining the individual digits.
p = abs(fft(y)); f = (0:n-1)*(Fs/n); plot(f,p); axis([500 1700 0 600])The x -axis corresponds to frequency. The axis settings limit the display to the range of the DTMF frequencies. There are seven peaks, corresponding to the seven basic frequencies. This overall FFT shows that all seven frequencies are present someplace in the signal, but it does not help determine the individual digits. The touchtone program also lets you break the signal into 11 equal segments and analyze each segment separately. The next figure is the display from the first segment. For this segment, there are only two peaks, indicating that only two of the basic frequencies are present in this portion of the signal. These two frequencies come from the "1" button. You can also see that the waveform of a short portion of the first segment is similar to the waveform that our synthesizer produces for the "1" button. So we can conclude that the number being dialed in touchtone starts with a 1. We leave it as an exercise to continue the analysis with touchtone and identify the complete phone number. <https://www.mathworks.com/moler/index_ncm.html>, Print Edition, SIAM Revised Reprint, SIAM, 2008, 334 pp., <http://bookstore.siam.org/ot87> .
Get the MATLAB code Published with MATLAB® R2014a
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.