note i have a .wav file and i want to detect it
i am trying forrier then using "find function "in matlab
but the result of "find " have a lot of number
what i can do to solve this problem
here is my attempt
[y1,fs,n]=wavread('tone4.wav');
Ts=1/fs
y=fft(y1);
y=Ts*fftshift(y);
freq =find (y)
Could be a bit difficult: DTMF tones are generally -pairs- of frequencies,
not single frequencies. There are 4 "row" tones and 4 "column" tones, and
each number and other symbol (e.g., star) is assigned a place in a 4 x 4
matrix, and the DTMF for that key is the "row" tone and the "column" tone
for that location played together. (If you count the keys on most phones,
you will find 12 tones; the standard also defines four additional keys
that are not in common use.)
> then i want to know the number which
> the tone belong to
> i am trying forrier then using "find function "in matlab
> but the result of "find " have a lot of number
> what i can do to solve this problem
Remember, a recorded DTMF tone-pair has a finite start and finite stop.
So when you do the discrete fourier analysis you have to deal with the
"approximately instantaneous" start and stop. The start and stop are
similar to the rise and fall of square waves: the theoretical model
requires an infinite mix of frequencies with non-zero amplitude, so of
course you are going to see a lot of non-zero frequencies. What you
want to know is what the principle components are.
Then too, if the recording was made over a phone line, the phone line
was bandwidth limited (probably to 8000 eight-bit samples per second)
so you are going to be dealing with filtered tones rather than pure tones.
And if the sampling frequency doesn't happen to be an exact multiple of
the tone frequencies (the most probable case) then even if you had
an unfiltered sample without start and stop transients, the maxima are
going to be spread out over a couple of adjacent frequencies, rather than
there being a sharp peak at one particular frequency and the adjacent
frequencies near zero...
--
.signature note: I am now avoiding replying to unclear or ambiguous postings.
Please review questions before posting them. Be specific. Use examples of what you mean,
of what you don't mean. Specify boundary conditions, and data classes and value
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?
i have a DTMF tone as a .wav file like this
http://www.4shared.com/file/74768062/40d58422/tone4.html
and i want to know which number it is belong to by detect the frequencies
which consist of
now i want to know any simple way in order to know the frequencies
ignore my code in the first post
> and i want to know which number it is belong to by detect the frequencies
> which consist of
Okay you have adjusted from "frequency" to "frequencies", but other than
that, I don't seem to observe anything "more specific" about your response ?
> now i want to know any simple way in order to know the frequencies
There isn't any simple way. There is no dtmf decoder function in any of
the toolboxes. You are going to have to actually -think- about how to
implement this.
%
[zewave Freq]=wavread('tone4');
zewave=zewave(:)';
DTMFCell=...
{...
'Tone1/Tone2' '1209' '1336' '1477' '1633';...
'697' '1' '2' '3' 'A';...
'770' '4' '5' '6' 'B';...
'852' '7' '8' '9' 'C';...
'941' '*' '0' '#' 'D'...
};
Code=DTMFCell( 2:end,2:end)';
Tone1=cellfun(@(x) str2num(x), DTMFCell(1,2:end));
Tone2=cellfun(@(x) str2double(x), DTMFCell(2:(end-1),1)');
[ToneMat1 ToneMat2] =ndgrid(Tone1,Tone2);
k=1;
figure(1);
TD=.5; % tone duration in second
subplot(3,4,1)
k=1;
MaxAmplitude=zeros(numel(Tone1)*numel(Tone2),1);
for TonePair=[ToneMat1(:)';ToneMat2(:)']
ComplexTone=(cos(2*pi*( (0:1/Freq:TD) *TonePair(1)))+j*cos(2*pi*( (0:1/Freq:TD) *TonePair(2))));
subplot(3,4,k)
XcorrData=xcorr(zewave,ComplexTone);
Amplitude=(abs(hilbert(real(XcorrData)))+abs(hilbert(imag(XcorrData))));
plot(Amplitude)
MaxAmplitude(k)=max(Amplitude);
k=k+1;
legend([ num2str(TonePair(1)) ',' num2str(TonePair(2))])
end
[val Indx]=max(MaxAmplitude);
subplot(3,4,Indx)
text(.5,.5,'this is it', 'units', 'normalized')
disp( ['The code is ' Code{Indx}])
something
"abdo " <tothe...@hotmail.com> wrote in message <ghcd8f$bdt$1...@fred.mathworks.com>...
>> spec = abs(fft(wavread(myWav)));
you should have a spec with a lot of roundabout zeros (if timesignal is not to noisy) and four CLEAR peaks. Two of them of course are redundant for your purposes. But the other ones you can find easyly using
>> N = length(spec);
>> spec = spec(1:N/2);
>> spec(spec < certainSquelchValue) = 0; % denoise signal
now
>> help find
create a proper frequency-axis and use result of the 'find' command to adress wanted freq-bin of freq-axis
Regards, Lars
Israeli siege leaves Gaza islated and desperate
By the way
I would to thank all the member whose help me to understand and reach my goal
I want to thank Michel Bertrand for his code since he give me a complete code although I can not understand all it since I am beginner in MATLAB.
Now here is a very simple code since we do not have noise
Depend on building data base for the tones then compare the external tone
And here is the procedure
1- Generate the tones and compose it in matlab using
the wavwrite function
2-reading the tone which the user insert by using
wavread function which store the information of the tone in a variable y .
3-also I will making wavread to the tone which I store in the matlab .
4-making fourier transform to the tow type of signal
5- compare the result using if and elseif to identify the tone
Here is the code
fs=8000; %You should make fs=8000
t=(0:9999)/fs; %the time of the signal
f1=697;
f2=770;
f3=852;
f4=941;
f5=1209;
f6=1336;
f7=1477;
f8=1633;
wavwrite(sin(2*pi*f1*t)+sin(2*pi*f5*t),fs,'number1=.wav');
wavwrite(sin(2*pi*f1*t)+sin(2*pi*f6*t),fs,'number2=.wav');
wavwrite(sin(2*pi*f1*t)+sin(2*pi*f7*t),fs,'number3=.wav');
wavwrite(sin(2*pi*f1*t)+sin(2*pi*f8*t),fs,'number4=.wav');
wavwrite(sin(2*pi*f2*t)+sin(2*pi*f5*t),fs,'number5=.wav');
wavwrite(sin(2*pi*f2*t)+sin(2*pi*f6*t),fs,'number6=.wav');
wavwrite(sin(2*pi*f2*t)+sin(2*pi*f7*t),fs,'number7=.wav');
wavwrite(sin(2*pi*f2*t)+sin(2*pi*f8*t),fs,'number8=.wav');
wavwrite(sin(2*pi*f3*t)+sin(2*pi*f5*t),fs,'number9=.wav');
wavwrite(sin(2*pi*f3*t)+sin(2*pi*f6*t),fs,'number10=.wav');
wavwrite(sin(2*pi*f3*t)+sin(2*pi*f7*t),fs,'number11=.wav');
wavwrite(sin(2*pi*f3*t)+sin(2*pi*f8*t),fs,'number12=.wav');
wavwrite(sin(2*pi*f4*t)+sin(2*pi*f5*t),fs,'number13=.wav');
wavwrite(sin(2*pi*f4*t)+sin(2*pi*f6*t),fs,'number14=.wav');
wavwrite(sin(2*pi*f4*t)+sin(2*pi*f7*t),fs,'number15=.wav');
wavwrite(sin(2*pi*f4*t)+sin(2*pi*f8*t),fs,'number16=.wav');
[number1,fs,n]=wavread('number1=.wav');
[number2,fs,n]=wavread('number2=.wav');
[number3,fs,n]=wavread('number3=.wav');
[number4,fs,n]=wavread('number4=.wav');
[number5,fs,n]=wavread('number5=.wav');
[number6,fs,n]=wavread('number6=.wav');
[number7,fs,n]=wavread('number7=.wav');
[number8,fs,n]=wavread('number8=.wav');
[number9,fs,n]=wavread('number9=.wav');
[number10,fs,n]=wavread('number10=.wav');
[number11,fs,n]=wavread('number11=.wav');
[number12,fs,n]=wavread('number12=.wav');
[number13,fs,n]=wavread('number13=.wav');
[number14,fs,n]=wavread('number14=.wav');
[number15,fs,n]=wavread('number15=.wav');
[number16,fs,n]=wavread('number16=.wav');
[y1,fs,n]=wavread('tone2.wav');
y=fft(y1);
if y ==(fft(number1));
disp('the number is 1')
elseif y==(fft(number2));
disp('the number is 2')
elseif y==(fft(number3));
disp('the number is 3')
elseif y==(fft(number4));
disp('the number is 4')
elseif y==(fft(number5));
disp('the number is 5')
elseif y==(fft(number6));
disp('the number is 6')
elseif y==(fft(number7));
disp('the number is 7')
elseif y==(fft(number8));
disp('the number is 8')
elseif y==(fft(number9));
disp('the number is 9')
elseif y==(fft(number10));
disp('the number is 10')
elseif y==(fft(number11));
disp('the number is 11')
elseif y==(fft(number12));
disp('the number is 12')
elseif y==(fft(number13));
disp('the number is 13')
elseif y==(fft(number14));
disp('the number is 14')
elseif y==(fft(number15));
disp('the number is 15')
elseif y==(fft(number16));
disp('the number is 16')
elseif y==y
disp('wronge')
end
all thanks
Chances are that that will not work due to round-off error. y and fft(number1) will be
double precision complex vectors. The result of the == operation will be a vector of logical
results indicating whether the corresponding values were *exactly* equal, down to the last
bit. The 'if' statement, when given a vector of logical results, tests to see if *all* of
the logical results are true, and considers the statement true only if *all* of them are true
and considers the statement false if even one of the results is false. Thus, the result of
the == would be considered false if there is even just a single bit difference in one of the
values due to round-off.
The results of the fft(y1) can be large (complex) numbers, with magnitude up to
max(abs(y1)) * length(y1) if I calculate correctly. As you are generating your files
by summing two sin waves, the maximum magnitude before the fft is 2, and your length is
fs = 8000, so the absolute magnitude could be up to 2 * 8000 = 16000 (I think.)
A single-bit difference at that range makes a difference of up to about 1.8*10^(-12)
so be careful in your comparison function.
i write my simple code under my simple information of matlab function
and post the code in order to benefit other beginner
thanks
An amateur programmer assumes that a program will work the ideal way they
were imagining in their mind. A professional programmer, on the other hand,
lives by Finagle's law (google it) -- and assumes that vendor documentation
is amusing Science Fiction until proven otherwise.