1024programmer Java Inverse DTFT transformation (DemonstratetheDFTbasedDTMFdetectionalgorithm.)

Inverse DTFT transformation (DemonstratetheDFTbasedDTMFdetectionalgorithm.)

一,Inverse DTFT description is the idea

The method of DTFT,The idea is the code has been mentioned above

DTFTmatlab implementation

As can be seen from the above& #xff0c; A key contains signals of two frequencies. In order to distinguish the keys, you can perform fft on the sound of the key, which is the Fourier transform. It is not rigorous and should be called dft transform. ),Comparing the transformed result with the presets in the table can determine the type of key.

The implementation of the code “segments the sound data” and #xff0c; performs IFFT transformation on a piece of sound when the duration and interval time of the key are known in advance. Due to the DTFT line The frequency and column frequency are bounded by 1000Hz. After performing the IFFT transformation, the spectrum can be divided into two parts by 1000Hz and compared with the preset frequency.

When obtaining the IFFT frequency ,due to the existence of noise and spectrum leakage phenomenon,the ideal spectrum cannot be obtained,so you can use the Max function,to find the spectrum range The maximum value of the internal frequency.

2,Code

1,Read sound file

First determine the sound sequence, key duration and blank time

[h,Fs ]=audioread('my_phone_number_sound_test.wav');% read signal,sampling rate and number of sampling bits.
keytime=0.5;% key duration
zerotime=0.5;% the time with zero in the middle
n=keytime*Fs;% the number of points when the key is pressed
n1& #61;zerotime*Fs;% points when there is no button

2,IFFT transformation of the data

y=h(1+n1 *(i-1)+n*(i-1):n+n1*(i-1)+n*(i-1));% determine the interval of sound processing
H=fft(y);% Fast Fourier Transform
h_d=abs(H/n);% Find the amplitude of fft, and convert it into the amplitude of the bilateral spectrum (fft The amplitude is related to the number of input points,divided by n to ensure the original amplitude)
h_d1= h_d(1:n/2+1);% turns the double-sided spectrum into a single-sided spectrum
h_d1(2:end-1)=2*h_d1(2:end-1);% bilateral spectrum becomes single-sided spectrum amplitude multiplied by 2
f=Fs*(0:n /2)/n;% Find the normalized frequency

3,Frequency acquisition

f=Fs*(0:n/2) /n;% Find the normalized frequency h_d2=h_d1(1:n/8);% From f, we can know that the range of f is 0 to 4000, The range of n/8 is 0 to 1000[M,I] = max(h_d2);I=Fs*I/n;% Find the frequency corresponding to the maximum value h_d3=h_d1(n/8:n/4-1) ;% frequency range is 1000 to 2000[A,B] = max(h_d3);B=Fs*B/n+1000;

 Note :The maximum value or data position does not represent the corresponding frequency,Fs*(0:n/2)/n needs to be processed.

4,Very simple but very cumbersomeFrequency judgment

if I>=690&&I =690&&I=1400&&B=690&&I=1600&&B=700&&I=1200&&B=700&&I =700&&I=1600&&B=800&&I=1200&&B=800&&I=1300&&B=800&&I =900&&I=1200&&B=900&&I =1300&&B=900&&I=1400&&B=900&&I=1600&&B<=1700disp(D);end

5,Total code

%——————————————— —————————–
%clc
[h,Fs]=audioread(&# 39;my_phone_number_sound_test.wav');% read signal,sampling rate and number of sampling bits.
keytime=0.5;% key duration
zerotime=0.5;% the time with zero in the middle
n=keytime*Fs;% the number of points when the key is pressed
n1& #61;zerotime*Fs;% points when no key is pressed
for i=1:11y=h(1+n1*(i-1)+n*(i-1 ):n+n1*(i-1)+n*(i-1));% determine the interval of sound processing H=fft(y);% fast Fourier transform h_d&#61 ;abs(H/n);% Find the amplitude of fft, and convert it into the amplitude of the bilateral spectrum (the amplitude of fft is related to the number of input points,divided by n to ensure the original amplitude)h_d1& #61; h_d(1:n/2+1);% Change the bilateral spectrum into a unilateral spectrum h_d1(2:end-1)=2*h_d1(2:end-1);% Bilateral The spectrum becomes a single-sided spectrum amplitude multiplied by 2f=Fs*(0:n/2)/n;% to find the normalized frequency h_d2=h_d1(1:n/8);%. It can be known from f& #xff0c;f ranges from 0 to 4000,n/8 ranges from 0 to 1000[M,I] = max(h_d2);I=Fs*I/n;% to find the maximum The frequency corresponding to the value h_d3=h_d1(n/8:n/4-1);% frequency range is 1000 to 2000[A,B] = max(h_d3);B=Fs*B /n+1000;if I>=690&&I=1200&&B=690&&I=1300&&B=690&&I=1400&&B=690&&I1600&&B=700&&I=1200&&B=700&&I=1300&&B=700&&I=1400&&B=700&&I=1600&&B=800&&I1200&&B=800&&I=1300&&B=800&&I=1400&&B=800&&I=1600&&B=900&&I=1200&&B=900&&I=1300&&B=900&&I=1400&&B&# 61;900&&I=1600&&B<=1700disp(D);end
end

Just compare each frequency and it’s done&# xff0c;Giving each frequency a range – the range I gave above is wide – can be appropriately compressed.

Three,Result Analysis

Use the audio generated in the previous article,The key duration is 0.5s,The blank time is 0.5s

produces the same result.

Four,Function Usage

audioread

Redirect: https://www.cnblogs.com/BugsCreator/p/10273092.html

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/724845

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索