How can I detect the number pressed from a dtmf tone (.mat) file?
조회 수: 23 (최근 30일)
이전 댓글 표시
I have a DTMF tone that is a .mat file, it just consists of one button press on a telephone and i want to be able to detect the number pressed and output it to the command line. How exactly can I do this?
I posted an example of the .mat file
댓글 수: 3
DGM
2021년 5월 1일
A mat file is just a container for any sort of variable that matlab can hold. The mat file just contains a vector and a scalar specifying the sampling frequency.
Using this FEX submission I just randomly picked:
load('dial_0.mat')
thiskey = decode(y',1,fs,numel(y)/fs)
gives
thiskey =
0
Of course, the documentation and parameterization for this function is pretty terrible, but that's some kind of tradition on the File Exchange.
채택된 답변
DGM
2021년 5월 1일
Basing off of this example:
% this loads two variables:
% fs -- sampling rate
% y -- signal vector
load('dial_0.mat');
Nt = 205;
source_tones = [697 770 852 941 1209 1336 1477]';
symbols = {'1','2','3';'4','5','6';'7','8','9';'*','0','#'};
k = round(source_tones/fs*Nt); % Indices of the DFT
estim_f = round(k*fs/Nt); % Frequencies at which the DFT is estimated
tone = y(1:205);
% Estimate DFT using Goertzel
ydft = goertzel(tone,k+1);
% find the two most powerful frequencies
[~,sourcetoneidx] = sort(abs(ydft),'descend');
sourcetoneidx = sourcetoneidx(1:2);
% sourcetoneidx should contain one index from
% each group of source tones (first four, last three)
row = min(sourcetoneidx);
col = max(sourcetoneidx)-4;
% look up the symbol in the table
thissymbol = symbols{row,col}
gives
thissymbol =
'0'
댓글 수: 4
DGM
2021년 5월 1일
편집: DGM
2021년 5월 3일
At this point, I wouldn't worry too much about using the FEX code directly. Like I said, it's a mess and requires the user input a bunch of extraneous parameters because it was probably designed only to do a particular thing (yes, probably it was just made to recycle the tones generated by the encoder).
That's why I cleaned it up and reduced it to a simplified script that takes the mat-file as given. No parameters needed, just a filename (assuming your mat-files all contain variables called fs and y).
EDIT:
I cleaned up my suggested code and made a encoder/decoder set of tools. Hopefully these will be a better resource to the next person that has the same task:
There's no special toolboxes needed, and it should be compatible back to at least R2009b.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 DTMF에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!