Kindly help me for question of DTMF decoding, i am stuck in it

2 次查看(过去 30 天)
This is question. The next objective is decoding - a process that requires a binary decision on the presence or absence of the individual frequencies. In order to make the signal detection an automated process, we need a score function that rates the different possibilities. (a) Complete the dtmfscor function based on the skeleton given in Table 2. Assume that the input signal xx to the dtmfscor function is actually a short segment from the DTMF signal. The task of breaking up the signal so that each segment corresponds to one key will be done by another function prior to calling dtmfscor. The implementation of the FIR bandpass filter is done with the conv function. The running time of the convolution function is proportional to the filter length L. Therefore, the filter length L must satisfy two competing constraints: L should be large so that the bandwidth of the band pass filter is narrow enough to isolate individual DTMF frequencies, but making it too large will cause the program to run slowly.
Table 2: Skeleton of the dtmfscor.m function
function ss = dtmfscor(xx, freq, L, fs)
%DTMFSCOR
% ss = dtmfscor(xx, freq, L, [fs])
% returns 1 (TRUE) if freq is present in xx
% 0 (FALSE) if freq is not present in xx
%
% xx = input DTMF signal
% freq = test frequency
% L = length of FIR bandpass filter
% fs = sampling freq (DEFAULT is 8000)
%
% The signal detection is done by filtering xx with a length L
% BPF, hh, squaring the output, and comparing with an arbitrary
% setpoint based on the average power of xx.
%
if (nargin < 4), fs = 8000; end;
hh = % define the bandpass filter coeffs here
ss = (mean(conv(xx,hh).^2) > mean(xx.^2)/5);
Plz help me how to go about it Thanks a lot

回答(1 个)

moonman
moonman 2011-10-17
Uptill now i have written code for DTMF generation which is working absolutely fine. I have also cross checked the tones through the software
function [dtmf]=dtmfdial(x);
%This function produces DTMF Tone corresponding to given
%key number
low_fg = [697 770 852 941]; % Low frequency group
high_fg = [1209 1336 1477]; % High frequency group
f = [];
for a=1:4,
for b=1:3,
f = [ f [low_fg(a);high_fg(b)] ];
end
end
disp('Table of Frequencies is shown')
table=f'
dur=.5; %Duration for each tone is .5 sec
fs=8000; % Sampling Freq is 8000 Hz for tones
tt=0:(1/fs):dur;
n=length(x);
D=cell(1,n);
for k=1:n % This loop will continue for number of keys
if x(k)==1
freqa=table(1,1); %Freq is picked from table(row1,col1)
freqb=table(1,2); %Freq is picked from table(row1,col2)
else if x(k)==2
freqa=table(2,1);
freqb=table(2,2);
else if x(k)==3
freqa=table(3,1);
freqb=table(3,2);
else if x(k)==4
freqa=table(4,1);
freqb=table(4,2);
else if x(k)==5
freqa=table(5,1);
freqb=table(5,2);
else if x(k)==6
freqa=table(6,1);
freqb=table(6,2);
else if x(k)==7
freqa=table(7,1);
freqb=table(7,2);
else if x(k)==8
freqa=table(8,1);
freqb=table(8,2);
else if x(k)==9
freqa=table(9,1);
freqb=table(9,2);
else if x(k)=='*'
freqa=table(10,1);
freqb=table(10,2);
else if x(k)==0
freqa=table(11,1);
freqb=table(11,2);
else x(k)='#';
freqa=table(12,1);
freqb=table(12,2);
end
end
end
end
end
end
end
end
end
end
end
tone1=sin(2*pi*freqa*tt); % Tone of First Frequency
tone2=sin(2*pi*freqb*tt); % Tone of Second Frequency
tone=tone1+tone2; % Now both tones are added
sil_dur=.1; % Defining silence duration between tones
sil_freq=0; % Since we want to keep silence,
sil_tt=0:(1/fs):sil_dur;
sil_tone=sin(2*pi*sil_freq*sil_tt); % Generating silence tone
D{k} = [tone,sil_tone]; % Concatinatiing tones and then silence
end %end of for loop
dtmf = cat(2, D{:}); %Concatinatiing all tones( e.g tone+Silence,Tone+silence....)
wavwrite(dtmf,8000,'alpha'); % Will Writte the wave file

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by