function varargout = gui_5(varargin)
% GUI_5 MATLAB code for gui_5.fig
% GUI_5, by itself, creates a new GUI_5 or raises the existing
% singleton*.
%
% H = GUI_5 returns the handle to a new GUI_5 or the handle to
% the existing singleton*.
%
% GUI_5('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI_5.M with the given input arguments.
%
% GUI_5('Property','Value',...) creates a new GUI_5 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before gui_5_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to gui_5_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 gui_5
% Last Modified by GUIDE v2.5 25-May-2020 23:28:24
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @gui_5_OpeningFcn, ...
'gui_OutputFcn', @gui_5_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 gui_5 is made visible.
function gui_5_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 gui_5 (see VARARGIN)
% Choose default command line output for gui_5
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes gui_5 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = gui_5_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 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)
close(gcf);
% --- 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)
global Voicedata;
global Fs;
datapro=filter([1 -0.98],1,Voicedata);%预加重
p=14;%设定LPC预测器阶
al=lpc(datapro,p);%求LPC系数
freq1=(0:511)*Fs/512;%还原真实频率
pf=abs(fft(al.',512).').^(-2);%声道模型功率谱响应曲线
U=10*log10(pf);%求功率谱衰减
[pks,locs]=findpeaks(U);%寻找功率谱峰值点
delete(allchild(handles.axes8));
axes(handles.axes8);
plot(freq1(1:256),U(1:256),'b')%蓝色线条绘图
hold on;grid on;%开启网格线
Ax=freq1(locs(1:0.5*length(locs)));%找到峰值对应的频率点
Bx=freq1(locs(1:0.5*length(locs)));
Ay=zeros(1,length(Ax))-40;%划线起始点纵坐标
By=pks(1:0.5*length(locs));%划线终点纵坐标
X=[Ax;Bx];%标定划线起始点,终点横坐标集合
Y=[Ay;By];%标定划线起始点。终点纵坐标集合
line(X,Y,'linestyle',':','linewidth',1,'color','r')%划线
xlabel({'频率/Hz','电信1705 金锡斌 0121714680406'});
ylabel('衰减/dB');
title('LPC系数标定语音共振峰位置');
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global Fs;
global Voicedata;
Rp =1; Rs =40 ; %设置通带波纹小于3db ,阻带衰减为30db
Wp =2 *[60 900]/Fs; %滤波器通带
Ws =2 *[40 2000]/Fs; %滤波器阻带
[n,Wn] = ellipord(Wp,Ws,Rp,Rs);
[b,a] = ellip(n,Rp,Rs,Wn);
[H w]=freqz(b,a,512);
delete(allchild(handles.axes5));
axes(handles.axes5);
plot(w*Fs/(2*pi),20*log10(abs(H)));grid on;hold on
line([60,60],[-120,0],'linestyle',':','color','k');
line([900,900],[-120,0],'linestyle',':','color','k')
xlabel({'频率/Hz','电信1705 金锡斌 0121714680406'})
ylabel('衰减/dB');
title('椭圆滤波器幅频响应曲线')
dataOut = filter(b,a,Voicedata);%对采样后的语音数据序列进行滤波处理
handles.dataOut=dataOut;
guidata(hObject, handles);
delete(allchild(handles.axes6));
axes(handles.axes6);
plot(Voicedata,'r');hold on;
plot(dataOut,'b');legend('滤波前','滤波后');title(['滤波前后语音信号时域波形对比图 采样率-',num2str(Fs)]);
xlabel({'样本点','电信1705 金锡斌 0121714680406'});ylabel('幅值');
% --- 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)
global Fs;
u2=handles.xn_frames(:,handles.frame_num);
max1=max(abs(u2(1:100)));
max2=max(abs(u2(length(u2)-99:length(u2))));
cl=min(max1,max2)*0.68;
for j=1:size(handles.xn_frames,1) %三电平削波处理
if u2(j)>cl;
u2(j)=u2(j)-cl;
three(j)=1;
elseif u2(j)<-cl;
u2(j)=u2(j)+cl;
three(j)=-1;
else
u2(j)=0;
three(j)=0;
end
end
r=xcorr(three,u2,'coeff');%对三电平削波后的数据进行自相关计算
r=r(size(u2,1):end);%取适当范围内的延迟
k=max(r(50:end));
index=find(r==k);
basic=Fs/index;
set(handles.edit4,'String',basic);
delete(allchild(handles.axes7));
axes(handles.axes7);
plot(r);grid on;
xlabel({'延时/k','电信1705 金锡斌 0121714680406'});
ylabel('幅值');title('三电平削波后自相关函数计算');
function edit4_Callback(hObject, eventdata, handles)
% hObject handle to edit4 (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 edit4 as text
% str2double(get(hObject,'String')) returns contents of edit4 as a double
% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit4 (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
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
str1=get(handles.edit1,'string');
handles.frame_time=str2num(str1);
guidata(hObject,handles);
% --- 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 futur