function varargout = xitong8(varargin)
% XITONG8 MATLAB code for xitong8.fig
% XITONG8, by itself, creates a new XITONG8 or raises the existing
% singleton*.
%
% H = XITONG8 returns the handle to a new XITONG8 or the handle to
% the existing singleton*.
%
% XITONG8('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in XITONG8.M with the given input arguments.
%
% XITONG8('Property','Value',...) creates a new XITONG8 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before xitong8_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to xitong8_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 xitong8
% Last Modified by GUIDE v2.5 04-Dec-2019 11:04:18
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @xitong8_OpeningFcn, ...
'gui_OutputFcn', @xitong8_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 xitong8 is made visible.
function xitong8_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 xitong8 (see VARARGIN)
% Choose default command line output for xitong8
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes xitong8 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = xitong8_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;
global fs t s T
% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
try
fs=1;
[s,fs]=audioread('nansheng.wav');
sound(s,fs);
L=length(s);
T=1/fs;
t=(0:L-1)*T;
t=t';
end
% hObject handle to Untitled_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_2_Callback(hObject, eventdata, handles)
try
fs=1;
[s,fs]=audioread('nansheng.wav');
L=length(s);
T=1/fs;
t=(0:L-1)*T;
t=t';
d=randn(length(t),1);
x=s+d;
sound(x,fs);
end
% hObject handle to Untitled_2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_3_Callback(hObject, eventdata, handles)
try
[x1,fs]=audioread('nansheng.wav'); %读取语音信号的数据,赋给变量x1
d=randn(length(t),1);
x=x1+d;
plot(handles.axes2,0);
sound(x,fs)
t=(0:length(x)-1)/22050;
f=fs*(0:1023)/2048;
wp=0.1*pi;
ws=0.15*pi;
Rp=5;
Rs=50;
Fs=50000;
Ts=1/Fs;
wp1=2/Ts*tan(wp/2); %将模拟指标转换成数字指标
ws1=2/Ts*tan(ws/2);
[N,Wn]=buttord(wp1,ws1,Rp,Rs,'s'); %选择滤波器的最小阶数
[Z,P,K]=buttap(N); %创建butterworth模拟滤波器
[Bap,Aap]=zp2tf(Z,P,K);
[b,a]=lp2lp(Bap,Aap,Wn);
[bz,az]=bilinear(b,a,Fs); %用双线性变换法实现模拟滤波器到数字滤波器的转换
[H,W]=freqz(bz,az); %绘制频率响应曲线.
axes(handles.axes1)
plot(W*Fs/(2*pi),abs(H))
grid on;axis tight;
xlabel('频率(Hz)')
ylabel('频率响应')
end
% hObject handle to Untitled_3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_4_Callback(hObject, eventdata, hayndles)
try
[x1,fs]=audioread('nansheng.wav'); %读取语音信号的数据,赋给变量x1
d=randn(length(t),1);
x=x1+d;
t=(0:length(x)-1)/22050;
f=fs*(0:1023)/2048;
wp=0.1*pi; %通带的截止频率
ws=0.15*pi; %阻带的截止频率
Rp=5; %最大衰减
Rs=50; %最小衰减
Fs=50000; %采样频率
Ts=1/Fs;
wp1=2/Ts*tan(wp/2);
ws1=2/Ts*tan(ws/2); %将模拟指标转换成数字指标
[N,Wn]=buttord(wp1,ws1,Rp,Rs,'s'); %选择滤波器的最小阶数
[Z,P,K]=buttap(N); %创建butterworth模拟滤波器(N阶)零点z,极点p和增益
[Bap,Aap]=zp2tf(Z,P,K); %将系统函数的零极点转化为系统函数一般形式的系数
[b,a]=lp2lp(Bap,Aap,Wn);%改变低通模拟滤波器的截止频率,将Bap,Aap改为Wn
[bz,az]=bilinear(b,a,Fs);%用双线性变换法实现模拟滤波器到数字滤波器的转换
[H,W]=freqz(bz,az); %绘制频率响应曲线.
plot(W*Fs/(2*pi),abs(H))
f1 =filter(bz,az,x1);
sound(f1,Fs);
end
% hObject handle to Untitled_4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% -------------------------------------------------------------
function Untitled_5_Callback(hObject, eventdata, handles)
try
feature jit off
[y,fs]=audioread('nansheng.wav'); %读取声音文件
d=randn(length(t),1);
x=y+d;
x1=x(:,1); %读入的x矩阵有两列,取第1列
t=(0:length(x)-1)/22050;
f=fs*(0:1023)/2048;
wp=0.1*pi; %通带的截止频率
ws=0.15*pi; %阻带的截止频率
Rp=5; %最大衰减
Rs=50; %最小衰减
Fs=50000; %采样频率
Ts=1/Fs;
wp1=2/Ts*tan(wp/2);
ws1=2/Ts*tan(ws/2); %将模拟指标转换成数字指标
% wp2=wp1/fs/pi;
% ws2=ws1/fs/pi;
[N,Wn]=buttord(wp1,ws1,Rp,Rs,'s'); %选择滤波器的最小阶数
[Z,P,K]=buttap(N); %创建butterworth模拟滤波器(N阶)零点z,极点p和增益
[Bap,Aap]=zp2tf(Z,P,K); %将系统函数的零极点转化为系统函数一般形式的系数
[b,a]=lp2lp(Bap,Aap,Wn);%改变低通模拟滤波器的截止频率,将Bap,Aap改为Wn
[bz,az]=bilinear(b,a,Fs); %用双线性变换法实现模拟滤波器到数字滤波器的转换
f1 =filter(bz,az,x1);
sound(voice(f1,0.5),fs);
end
% hObject handle to Untitled_5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_12_Callback(hObject, eventdata, handles)
try
[y,fs]=audioread('nansheng.wav'); %读取语音信号的数据,赋给变量x1
d=randn(length(t),1);
x=y+d;
x1=x(:,1); %读入的y矩阵有两列,取第1列
plot(handles.axes2,0);
t=(0:length(x1)-1)/22050;
f=fs*(0:1023)/2048;
wp=0.1*pi; %通带的截止频率
ws=0.15*pi; %阻带的截止频率
Rp=5; %最大衰减
Rs=50; %最小衰减
Fs=50000; %采样频率
Ts=1/Fs;
wp1=2/Ts*tan(wp/2);
ws1=2/Ts*tan(ws/2); %将模拟指标转换成数字指标
[N,Wn]=buttord(wp1,ws1,Rp,Rs,'s'); %选择滤波器的最小阶数
[Z,P,K]=buttap(N); %创建butterworth模拟滤波器(N阶�
评论4