Analysis number from dtmf sound

hello, i have a wav file, which use dtmf i do spectrogram on the file and i receive 10 amplitude peak how can i return the 2 frequency of each peak (high and low frequency)

2 件のコメント

Stephen23
Stephen23 2014 年 9 月 17 日
編集済み: Stephen23 2014 年 9 月 17 日
MATLAB provides this DTMF example , and you can also find some DTMF submissions on FEX.
rafi
rafi 2014 年 9 月 17 日
i understand this, but i don't know how to extract the frequency peak amplitude

サインインしてコメントする。

 採用された回答

Star Strider
Star Strider 2014 年 9 月 17 日

0 投票

You did not post your data so I cannot be specific. You can get the frequency and time output as vectors from spectrogram:
  • [S,F,T] = spectrogram(...) returns a vector of frequencies, F , and a vector of times, T , at which the spectrogram is computed. F has length equal to the number of rows of S . T has length k (defined above) and the values in T correspond to the center of each segment.
There is probably no neat and efficient way to do what you want. I would loop through S at each time, sort and threshold the amplitudes to find the indices of the values >-35dB or so, then use the indices returned by sort to determine the frequencies. (Using the find function is also a possibility, but I am not certain it would make this more efficient.)

9 件のコメント

Star Strider
Star Strider 2014 年 9 月 17 日
The S (spectrogram) output does have the amplitudes, but you have to take the absolute value of it to get them (the plot is the spectrogram):
[x,fs] = audioread('phonecall.wav');
[S,F,T] = spectrogram(x, 1024, 3/4*1024, [], fs, 'yaxis');
Sa = abs(S);
[r, c] = find(Sa >= 40);
Fr = F(r);
Tc = T(c)';
FT = [Tc Fr];
figure(1)
mesh(Sa)
view([0 90])
xlabel('Time (s)')
ylabel('Frequency (Hz)')
The ‘Sa’ variable are the absolute values of the spectrogram. The ‘find’ call returns the row and column indices of the elements that are >40dB. The ‘Fr’ and ‘Tc’ variables are the frequencies and times respectively of the occurrences of the tones that are >40dB. The ‘FT’ matrix combines them so you can see that there are two tones for each time. This is not exact, there are sometimes three frequencies listed for every time, but in all cases two of them are close to each other. You will have to determine the tolerances and then classify the two tones at each time.
Experiment with the threshold in the find call (40dB here) to get the accuracy you need.
You have the frequencies and the times they occurred in the ‘FT’ matrix. This should be everything you need to get started.
rafi
rafi 2014 年 9 月 17 日
the phone number contain 10 symbol so FT should contain 20 frequency (10 high and 10 low)
but my FT contain 32 frequency
Star Strider
Star Strider 2014 年 9 月 17 日
編集済み: Star Strider 2014 年 9 月 17 日
I changed your spectrogram call and changed the threshold, and added assignments creating a cell array that isolates the times and frequencies. You will have to characterise the frequencies and decode them.
I actually detected 12 unique times with this code, so there are actually 12 symbols and 24 frequencies.
Note that ‘FrqTime’ elements are all either (2x2) or (3x2), so while the discrimination with these changes is about as good as it is possible to expect, you will have to sort through them to distinguish the frequencies. As with the ‘FT’ matrix, the first column of each element is time and the second is frequency.
------------------------------------------------
The full, revised code:
[x,fs] = audioread('phonecall.wav');
[S,F,T] = spectrogram(x, 1024, 512, 256*3, fs, 'yaxis');
Sa = abs(S);
[r, c] = find(Sa >= 30);
Fr = F(r);
Tc = T(c)';
FT = [Tc Fr];
[C, ia, ic] = unique(FT(:,1)); % Find Unique Times
for k1 = 1:size(C,1) % Create Cell Array By Time
FrqTime{k1} = FT(FT(:,1) == C(k1),:);
end
FrqTime{4:6} % Display ‘FreqTime’ Sample
rafi
rafi 2014 年 9 月 17 日
the resolve is : 0546427316 so there are 10 symbol and 20 frequencies :(
Star Strider
Star Strider 2014 年 9 月 17 日
Change the spectrogram call to:
[S,F,T] = spectrogram(x, 1024, 512*3/4, 256*3, fs, 'yaxis');
That should produce the result you want.
Do not change anything else in my code!
I don’t know how robust my code is (how well it would work in other situations), but it works essentially perfectly here.
rafi
rafi 2014 年 9 月 17 日
thank very very much! this real answer
only one thing, if you can explain me why you did you coose these parameters in spectrogram
Star Strider
Star Strider 2014 年 9 月 17 日
My pleasure!
I simply experimented until I get the result I needed, first with the length of the fft, then with noverlap. That is frequently necessary in real-world situations, and is the only way to solve some problems. Signal processing analysis and filtering frequently depends on the signals being processed, including sampling rate, noise, and desired output.
rafi
rafi 2014 年 10 月 6 日
hi again, i need a liitle help: 1. the function spctrogram is IIR or FIR fillter? 2.i try to learn from the help about spectrogram, but who can explain me better than help?
Star Strider
Star Strider 2014 年 10 月 6 日
To the best of my knowledge, there are no filters at all involved in spectrogram. It uses a fft with windowing.

サインインしてコメントする。

その他の回答 (1 件)

rafi
rafi 2014 年 9 月 17 日

0 投票

hello Star Strider,
i attach my audio+ code that i write
i don't understand from your answer how can i find threshold amplitudes because vector S contain fft, no amplitudes

タグ

質問済み:

2014 年 9 月 17 日

コメント済み:

2014 年 10 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by