双音多频信号的产生与识别代码

双音多频信号的产生与识别代码

function varargout = untitled333(varargin)
% UNTITLED333 MATLAB code for untitled333.fig
% UNTITLED333, by itself, creates a new UNTITLED333 or raises the existing
% singleton*.
%
% H = UNTITLED333 returns the handle to a new UNTITLED333 or the handle to
% the existing singleton*.
%
% UNTITLED333(‘CALLBACK’,hObject,eventData,handles,…) calls the local
% function named CALLBACK in UNTITLED333.M with the given input arguments.
%
% UNTITLED333(‘Property’,‘Value’,…) creates a new UNTITLED333 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled333_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled333_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE’s Tools menu. Choose “GUI allows only one
% instance to run (singleton)”.
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help untitled333

% Last Modified by GUIDE v2.5 16-Mar-2019 17:45:25

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct(‘gui_Name’, mfilename, …
‘gui_Singleton’, gui_Singleton, …
‘gui_OpeningFcn’, @untitled333_OpeningFcn, …
‘gui_OutputFcn’, @untitled333_OutputFcn, …
‘gui_LayoutFcn’, [] , …
‘gui_Callback’, []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

% — Executes just before untitled333 is made visible.
function untitled333_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to untitled333 (see VARARGIN)

% Choose default command line output for untitled333
handles.output = hObject;

handles.fs=8192;
handles.DTMFsum=820;
handles.DTMFnum=410;
% Update handles structure
guidata(hObject, handles);
handles.NUM=[ ];

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes untitled333 wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% — Outputs from this function are returned to the command line.
function varargout = untitled333_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;

% — Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:410]; % 每个数字 410 个采样点表示
d1=sin(2pi697/handles.fsn)+sin(2pi1209/handles.fsn); % 对应行频列频叠加
n1=strcat(get(handles.edit1,‘string’),‘1’); % 获取数字号码
set(handles.edit1,‘string’,n1); % 显示号码
space=zeros(1,410); %410 个 0 模拟静音信号
handles.NUM=[ handles.NUM, d1,space]; % 存储连续的拨号音信号
guidata(hObject, handles);
sound(d1,8192); % 产生拨号音

% — Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:410]; % 每个数字 410 个采样点表示
d2=sin(2pi697/handles.fsn)+sin(2pi1336/handles.fsn); % 对应行频列频叠加
n2=strcat(get(handles.edit1,‘string’),‘2’); % 获取数字号码
set(handles.edit1,‘string’,n2); % 显示号码
space=zeros(1,410); %410 个 0 模拟静音信号
handles.NUM=[handles.NUM,d2,space]; % 存储连续的拨号音信号
guidata(hObject, handles);
sound(d2,8192); % 产生拨号音

% — Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:410]; % 每个数字 410 个采样点表示
d3=sin(2pi697/handles.fsn)+sin(2pi1477/handles.fsn); % 对应行频列频叠加
n3=strcat(get(handles.edit1,‘string’),‘3’); % 获取数字号码
set(handles.edit1,‘string’,n3); % 显示号码
space=zeros(1,410); %410 个 0 模拟静音信号
handles.NUM=[ handles.NUM, d3,space]; % 存储连续的拨号音信号
guidata(hObject, handles);
sound(d3,8192); % 产生拨号音

% — Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:410]; % 每个数字 410 个采样点表示
d4=sin(2pi770/handles.fsn)+sin(2pi1209/handles.fsn); % 对应行频列频叠加
n4=strcat(get(handles.edit1,‘string’),‘4’); % 获取数字号码
set(handles.edit1,‘string’,n4); % 显示号码
space=zeros(1,410); %410 个 0 模拟静音信号
handles.NUM=[ handles.NUM, d4,space]; % 存储连续的拨号音信号
guidata(hObject, handles);
sound(d4,8192); % 产生拨号音

% — Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:410]; % 每个数字 410 个采样点表示
d5=sin(2pi770/handles.fsn)+sin(2pi1336/handles.fsn); % 对应行频列频叠加
n5=strcat(get(handles.edit1,‘string’),‘5’); % 获取数字号码
set(handles.edit1,‘string’,n5); % 显示号码
space=zeros(1,410); %410 个 0 模拟静音信号
handles.NUM=[ handles.NUM, d5,space]; % 存储连续的拨号音信号
guidata(hObject, handles);
sound(d5,8192); % 产生拨号音

% — Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:410]; % 每个数字 410 个采样点表示
d6=sin(2pi770/handles.fsn)+sin(2pi1477/handles.fsn); % 对应行频列频叠加
n6=strcat(get(handles.edit1,‘string’),‘6’); % 获取数字号码
set(handles.edit1,‘string’,n6); % 显示号码
space=zeros(1,410); %410 个 0 模拟静音信号
handles.NUM=[ handles.NUM, d6,space]; % 存储连续的拨号音信号
guidata(hObject, handles);
sound(d6,8192); % 产生拨号音

% — Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:410]; % 每个数字 410 个采样点表示
d7=sin(2pi852/handles.fsn)+sin(2pi1209/handles.fsn); % 对应行频列频叠加
n7=strcat(get(handles.edit1,‘string’),‘7’); % 获取数字号码
set(handles.edit1,‘string’,n7); % 显示号码
space=zeros(1,410); %410 个 0 模拟静音信号
handles.NUM=[ handles.NUM, d7,space]; % 存储连续的拨号音信号
guidata(hObject, handles);
sound(d7,8192); % 产生拨号音

% — Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:410]; % 每个数字 410 个采样点表示
d8=sin(2pi852/handles.fsn)+sin(2pi1336/handles.fsn); % 对应行频列频叠加
n8=strcat(get(handles.edit1,‘string’),‘8’); % 获取数字号码
set(handles.edit1,‘string’,n8); % 显示号码
space=zeros(1,410); %410 个 0 模拟静音信号
handles.NUM=[ handles.NUM, d8,space]; % 存储连续的拨号音信号
guidata(hObject, handles);
sound(d8,8192); % 产生拨号音

% — Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:410]; % 每个数字 410 个采样点表示
d9=sin(2pi852/handles.fsn)+sin(2pi1477/handles.fsn); % 对应行频列频叠加
n9=strcat(get(handles.edit1,‘string’),‘9’); % 获取数字号码
set(handles.edit1,‘string’,n9); % 显示号码
space=zeros(1,410); %410 个 0 模拟静音信号
handles.NUM=[ handles.NUM, d9,space]; % 存储连续的拨号音信号
guidata(hObject, handles);
sound(d9,8192); % 产生拨号音

% — Executes on button press in pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:410];
num=get(handles.edit1,‘string’);
l=length(num);
n10=strrep(num,num,num(1:l-1));
d10=sin(0.7217n)+sin(0.9273n);
set(handles.edit1,‘string’,n10);
L=length(handles.NUM);
handles.NUM=handles.NUM(1:L-820);
guidata(hObject, handles);
sound(d10,8192);

% — Executes on button press in pushbutton13.
function pushbutton13_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:410]; % 每个数字 410 个采样点表示
d0=sin(0.7217n)+sin(1.0247n); % 对应行频列频叠加
n0=strcat(get(handles.edit1,‘string’),‘0’); % 获取数字号码
set(handles.edit1,‘string’,n0); % 显示号码
space=zeros(1,410); %410 个 0 模拟静音信号
handles.NUM=[ handles.NUM, d0,space]; % 存储连续的拨号音信号
guidata(hObject, handles);
sound(d0,8192); % 产生拨号音

% — Executes on button press in pushbutton14.
function pushbutton14_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton14 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
tic
L=length(handles.NUM);
n=L/820;
number=’’;
for i=1:n
j=(i-1)*820+1;
d=handles.NUM(j:j+819); %截取出每个数字
f=fft(d,8192); %以N=8192作FFT变换
a=abs(f);
p=a.*a/8192; %计算功率谱
num(1)=find(p(1:1000)max(p(1:1000))); % 找行频
num(2)=1000+find(p(1000:1700)max(p(1000:1700))); % 找列频
if (num(1) < 730) row=1; % 确定行数
elseif (num(1) < 810) row=2;
elseif (num(1) < 900) row=3;
else row=4;
end
if (num(2) < 1272.5) column=1; %确定列数
elseif (num(2) < 1406.5) column=2;
else column=3;
end
z=[row,column]; % 确定数字
if z
[4,2] tel=0; %0在4行2列
elseif z
[1,1] tel=1; %1在1行1列
elseif z==[1,2] tel=2; %2在1行2列
elseif z==[1,3] tel=3; %3在1行3列
elseif z==[2,1] tel=4; %4在2行1列
elseif z==[2,2] tel=5; %5在2行2列
elseif z==[2,3] tel=6; %6在2行3列
elseif z==[3,1] tel=7; %7在3行1列
elseif z==[3,2] tel=8; %8在3行2列
elseif z==[3,3] tel=9; %9在3行3列
end
t(i)=tel;
c=strcat(number,int2str(tel));
number=c;
i=i+1;
end
set(handles.edit2,‘string’,number);
toc

function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,‘String’) returns contents of edit1 as text
% str2double(get(hObject,‘String’)) returns contents of edit1 as a double

% — Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,‘BackgroundColor’), get(0,‘defaultUicontrolBackgroundColor’))
set(hObject,‘BackgroundColor’,‘white’);
end

% — Executes on button press in pushbutton15.
function pushbutton15_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton15 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.NUM=[];
set(handles.edit1,‘string’,[]);
set(handles.edit2,‘string’,[]);
guidata(hObject,handles);

% — Executes on button press in pushbutton16.
function pushbutton16_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton16 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% — Executes on button press in pushbutton17.
function pushbutton17_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton17 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename,filepath]=uigetfile(‘E13.m4a’,‘选择音频文件’);
if(filename0)
return;
end
audiofile=strcat(filepath,filename);
[handles.tdata,fs]=audioread(audiofile);
sound(handles.tdata,fs);
set(handles.filepathname,‘string’,audiofile);
tic
L=length(handles.tdata);
n=L/28000;
number=’’;
for i=1:n
j=(i-1)*28000+1;
d=handles.tdata(j:j+27999); %截取出每个数字
f=fft(d,fs); %以N=2048作FFT变换
a=abs(f);
p=a.*a/fs; %计算功率谱
num(1)=find(p(1:1000)max(p(1:1000))); % 找行频
num(2)=1000+find(p(1000:1700)max(p(1000:1700))); % 找列频
if (num(1) < 730) row=1; % 确定行数
elseif (num(1) < 810) row=2;
elseif (num(1) < 900) row=3;
else row=4;
end
if (num(2) < 1272.5) column=1; %确定列数
elseif (num(2) < 1406.5) column=2;
else column=3;
end
z=[row,column]; % 确定数字
if z
[4,2] tel=0; %0在4行2列
elseif z
[1,1] tel=1; %1在1行1列
elseif z
[1,2] tel=2; %2在1行2列
elseif z==[1,3] tel=3; %3在1行3列
elseif z==[2,1] tel=4; %4在2行1列
elseif z==[2,2] tel=5; %5在2行2列
elseif z==[2,3] tel=6; %6在2行3列
elseif z==[3,1] tel=7; %7在3行1列
elseif z==[3,2] tel=8; %8在3行2列
elseif z==[3,3] tel=9; %9在3行3列
end
t(i)=tel;
c=strcat(number,int2str(tel));
number=c;
i=i+1;
end
set(handles.edit2,‘string’,number);
toc
guidata(hObject,handles);

  • 11
    点赞
  • 54
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qq_38621899

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值