%dtmfrun.m function keys = dtmfrun(xx,L,fs) %DTMFRUN keys = dtmfrun(xx,L,fs) % returns the list of key names found in xx. % keys = array of characters, i.e., the decoded key names % xx = DTMF waveform % L = filter length % fs = sampling freq % dtmf.keys = ... ['1','2','3','A'; '4','5','6','B'; '7','8','9','C'; '*','0','#','D']; dtmf.colTones = ones(4,1)*[1209,1336,1477,1633]; % defines col matrix dtmf.rowTones = [697;770;852;941]*ones(1,4); % defines row matrix center_freqs = [dtmf.rowTones(:,1)' , dtmf.colTones(1,:)]; % defines 1X8 vector of freqs hh = dtmfdesign( center_freqs,L,fs ); % calls dtmfdesign to form matrix of filters % hh = L by 8 MATRIX of all the filters. Each column contains the % impulse response of one BPF (bandpass filter) % [nstart,nstop] = dtmfcut(xx,fs); %<--Find the tone bursts keys = []; %initializes keys ansset=[]; %initializes ansset for kk=1:length(nstart) %cycle through each tone ansset = []; %clears ansset from previous itterations x_seg = xx(nstart(kk):nstop(kk)); %<--Extract one DTMF tone for jj=1:length(center_freqs) %cycle through each filter ansset = [ansset, dtmfscore(x_seg,hh(:,jj))]; %creates a vector of ones and zeros repersenting where %the frequency components lie. end aa = find(ansset==1); %creates a vector of indicies where ones occur if length(aa) ~= 2 | aa(1) > 4 | aa(2) < 5 %cheks for impossible scores and skips if they are found keys = [keys,'e']; continue end row = aa(1); % decodes row position from aa col = aa(2)-4; %decodes col position from aa keys = [keys, dtmf.keys(row,col)]; %sets keys equal to the current keys %and the key found in this itteration. end