




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、、function varargout = jy01(varargin% JY01 M-file for jy01.fig% JY01, by itself, creates a new JY01 or raises the existing% singleton*.% H = JY01 returns the handle to a new JY01 or the handle to% the existing singleton*.% JY01('CALLBACK',hObject,eventData,handles,. calls the local% function
2、named CALLBACK in JY01.M with the given input arguments.% JY01('Property','Value',. creates a new JY01 or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before jy01_OpeningFcn gets called. An% unrecognized property name or invali
3、d value makes property application% stop. All inputs are passed to jy01_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
4、jy01% Last Modified by GUIDE v2.5 01-Jul-2005 13:30:37% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, .'gui_Singleton', gui_Singleton, .'gui_OpeningFcn', jy01_OpeningFcn, .'gui_OutputFcn', jy01_OutputFcn, .'gui_
5、LayoutFcn', , .'gui_Callback', ;if nargin && ischar(varargin1gui_State.gui_Callback = str2func(varargin1;endif nargoutvarargout1:nargout = gui_mainfcn(gui_State, varargin:;elsegui_mainfcn(gui_State, varargin:;end% End initialization code - DO NOT EDIT% - Executes just before jy01
6、 is made visible.function jy01_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 l
7、ine arguments to jy01 (see VARARGIN% Choose default command line output for jy01handles.output = hObject;% Update handles structureguidata(hObject, handles;% UIWAIT makes jy01 wait for user response (see UIRESUME% uiwait(handles.figure1;% - Outputs from this function are returned to the command line
8、.function varargout = jy01_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 comman
9、d line output from handles structurevarargout1 = handles.output;% - Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles% hObject handle to pushbutton2 (see GCBO% eventdata reserved - to be defined in a future version of MATLAB% handles structure with han
10、dles and user data (see GUIDATAx=wavread('01.wav'sound(x;subplot(4,1,1;plot(x;axis(1 length(x -1 1;ylabel('Speech'enhance=filter(1-0.9375,1,x;FrameLen=240; FrameInc=80;yframe=enframe(x,FrameLen,FrameInc;amp1=sum(abs(yframe,2;subplot(4,1,2;plot(amp1;axis(1 length(amp1 0 max(amp1;ylabe
11、l('Amp'legend('amp1=¡Æ©¦x©¦'amp2=sum(abs(yframe.*yframe,2;subplot(4,1,3;plot(amp2;axis(1 length(amp2 0 max(amp2;ylabel('Energy'legend('amp1=¡Æ©¦x*x©¦'tmp1=enframe(x(1:end-1,FrameLen,FrameInc;tmp2=enframe(x(2:
12、end,FrameLen,FrameInc;signs=(tmp1.*tmp2<0;diffs=(tmp1-tmp2>0.02;zcr=sum(signs.*diffs,2;subplot(4,1,4;plot(zcr;axis(1 length(zcr 0 max(zcr;ylabel('ZCR'legend('zcr'function f=enframe(x,win,incnx=length(x(:;nwin=length(win;if (nwin = 1len = win;elselen = nwin;endif (nargin < 3i
13、nc = len;endnf = fix(nx-len+inc/inc;f=zeros(nf,len;indf= inc*(0:(nf-1.'inds = (1:len;f(: = x(indf(:,ones(1,len+inds(ones(nf,1,:;if (nwin > 1w = win(:'f = f .* w(ones(nf,1,:;end% - Executes on button press in pushbutton3.function pushbutton3_Callback(hObject, eventdata, handles% hObject ha
14、ndle to pushbutton3 (see GCBO% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATAour=wavread('01.wav'specgram_hw3p20(our,1024,512,10000;specgram_hw3p20(our,512,256,10000;function spec = specgram_hw3p20(x, winlgh, frmlgh
15、, sampling_rate; % specgram_hw3p20(x, winlgh, frmlgh, sampling_rate% function to compute a spectrogram % x = input waveform % winlgh = window length in samples% frmlgh = frame length in samples% sampling_rate = samples/sec% PARAMETERS%sampling_rate = 10000; % sampling ratelfft = 1024; % FFT length l
16、fft2 = lfft/2;%winlgh = 200; % (128 window length (in samples%frmlgh = 10; % frame interval (in samplesnoverlap = winlgh - frmlgh;% x = x(1:4500;x = 2.0*x/max(abs(x;etime = length(x/sampling_rate;%-%spec = abs(specgram(x, lfft, sampling_rate, winlgh, noverlap;subplot(211;plot(1:length(x/sampling_rat
17、e,xxlabel('Time (s'title('SPEECH'axis(0 etime -2.5 2.5;grid;subplot(212imagesc(0:.010:etime, 0:1000:(sampling_rate/2, log10(abs(spec;axis('xy'xlabel('Time (ms',ylabel('Frequency (Hz'title('SPECTROGRAM'% - Executes on button press in pushbutton4.functio
18、n 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 GUIDATAclc; clear;tic, y,fs=wavread('01.wav' L=length(y; fw=y.*hamming(L;r=real(log
19、(fft(fw,Lpfw=cceps(fw;rpfw=rceps(fw;z=rpfw(1:30;p=pfw(31:Llogz=real(exp(fft(z,L;logp=real(fft(p;subplot(3,2,1;plot(y;title('Ôʼ²¨ÐÎ'subplot(3,2,3;plot(pfw;title('¸´µ¹Æ×'subplot(3,2,5;plot(rpfw;title('Ê
20、81;µ¹Æ×'subplot(3,2,6;plot(logz;title('µ¹Æ×ÓòÂ˲¨ºóµÄ¶ÔÊý·ù¶ÈÆ×'subplot(3,2,4;plot(r;title('¶ÔÊý·ù¶È
21、8;×'subplot(3,2,2;plot(fw;title('¼Óº£Ã÷´°ºóµÄ²¨ÐÎ'% - Executes on button press in pushbutton5.function pushbutton5_Callback(hObject, eventdata, handles% hObject handle to pushbutton5 (see GCBO% eventdata
22、 reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATAspeech1_10k=wavread('01.wav',1024 1273;%È¡250µãµÄÓïÒôÐźÅsw=speech1_10k.*hamming(250;%a¼Óº
23、86;Ã÷´° Rsw=xcorr(sw'%a×ÔÏà¹Ø t=0.1:0.1:25;subplot(1,2,1;plot(t,sw;xlabel('ms'title('¼Ó´°ºóʱÓò²¨ÐÎ' subplot(1,2,2; t=0.1:0.1:length(Rsw/10;plot(t,Rsw;xlabel(
24、39;ms'title('¼Ó´°ºó×Թز¨ÐÎ' Rsw4=Rsw(250:253;Rsw(249:252;Rsw(248:251;Rsw(247:250;%Éú³É4*4 ×ÔÏà¹ØÕó Rsw6=Rsw(250:255;Rsw(249:254;Rsw(248:253;Rsw(247:252;Rsw(2
25、46:251;Rsw(245:250;%Éú³É6*6×ÔÏà¹ØÕó rea4=inv(Rsw4*Rsw(251:254'%ÇóÔ¤²âϵÊý4 rea6=inv(Rsw6*Rsw(251:256'%ÇóÔ¤²âϵÊý6 A4=sqrt(Rsw(250-Rs
26、w(251:254*rea4;%ÇóÔöÒæ A6=sqrt(Rsw(250-Rsw(251:256*rea6;%ÇóÔöÒæ w=pi/512:pi/512:pi;%Éú³ÉÊä³öƵÂÊ·¶Î§ j=sqrt(-1; FW4=rea4'*exp(-j*w;exp(-j*w*2;exp(-j*w*3;exp
27、(-j*w*4;%ÔÚƵÂÊ·¶Î§ÇóÔ¤²âƵÏì FW6=rea6'*exp(-j*w;exp(-j*w*2;exp(-j*w*3;exp(-j*w*4;exp(-j*w*5;exp(-j*w*6;%ÔÚƵÂÊ·¶Î§ÇóÔ¤²&
28、#226;ƵÏì HW4=A4./(1-FW4;%ÓÉÔ¤²âƵÏìÇó HW6=A6./(1-FW6;%ÓÉÔ¤²âƵÏìÇó FW2=fft(sw,1024;%ÐźŸµÁ¢Ò¶±ä
29、87;» FW3=FW2(1:512; w=(1/1024:1/1024:0.5*10000; subplot(2,2,1;plot(w,log(abs(FW3;xlabel('ƵÂÊhz'title('¼Ó´°ºóÐźÅƵÆ×' subplot(2,2,2;plot(w,log(abs(HW4,'g'xlabel('Ƶ
30、194;Êhz'title('4¼«µãÄ£ÐÍƵÂÊÏìÓ¦' subplot(2,2,3;plot(w,log(abs(HW6,'r'xlabel('ƵÂÊhz'title('6¼«µãÄ£ÐÍƵÂ
31、2;ÏìÓ¦' subplot(2,2,4;plot(w,log(abs(FW3,w,log(abs(HW4,w,log(abs(HW6;xlabel('ƵÂÊhz'title('ÈýÕ߱ȽÏ'% - Executes on button press in pushbutton6.function pushbutton6_Callback(hObject, eventdata, handle
32、s% 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 GUIDATAclearY=wavread('01.wav',1 1800;x1=Y(271:510;x2=Y(271:510;x3=Y(271:510;%×ÔÏà¹Ø·¨r=zero
33、s(1,240;for k=1:240for n=1:240-kr(k=r(k+x1(n*x1(n+k;endendj=1:240;subplot(2,2,2;plot(j,r;title('×ÔÏà¹Ø·¨´¦ÀíºóµÄ²¨ÐÎ'subplot(2,2,1;plot(j,x1;title('Ôº¯Êý'
34、;%Èýµçƽ·¨for k1=1:1:240if x2(k1>0x2(k1=1;else if x2(k1=0x2(k1=0;else if x2(k1<0x2(k1=-1;endendendendj=1:240;subplot(2,2,3;plot(j,x2;title('Èýµçƽ·¨´¦ÀíºóµÄ²¨
35、208;Î'%ÖÐÐÄÏû²¨·¨for k1=1:1:240ma=abs(max(x3;tc=0.6*ma;if x3(k1>tcx3(k1=x3(k1-tc;else if x3(k1<-tcx3(k1=x3(k1+tc;elsex3(k1=0;endendendj=1:240;subplot(2,2,4;plot(j,x3;title('ÖÐÐÄÏû²¨·
36、8;´¦ÀíºóµÄ²¨ÐÎ'% - 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 str
37、ucture with handles and user data (see GUIDATAclearclcwinsize=256; % ´°³¤ winsize=256; % ´°³¤ n=0.04; % ÔëÉùˮƽ speech,fs,nbits=wavread('01.wav' % ¶ÁÈëÊý¾Ý size=length(spe
38、ech; numofwin=floor(size/winsize; % Ö¡Êý %¼Ó´° ham=hamming(winsize' %Generates Hamming Window hamwin=zeros(1,size; %Vector for window gain enhanced=zeros(1,size; %Vector for enhanced speech %²úÉú´øÔëÐź
39、;Å x=speech'+ n*randn(1,size; %Contaminates signal with white noise %ÔëÉù¹À¼Æ noisy=n*randn(1,winsize; %Sample of noise N = fft(noisy; nmag= abs(N; %Estimated noise magnitude spectrum for q=1:2*numofwin-1 frame=x(1+(q-1*winsize/2:winsize+(q-1*winsize/
40、2; %50 percent overlap hamwin(1+(q-1*winsize/2:winsize+(q-1*winsize/2=hamwin(1+(q-1*winsize/2:winsize+(q-1*winsize/2+ham; %Window gain %¶Ô´øÔëÓïÒô½øÐÐDFT y=fft(frame.*ham; mag = abs(y; %Magnitude Spectrum phase = angle(y; %Phase S
41、pectrum %·ù¶ÈÆ×¼õ for i=1:winsize if mag(i-nmag(i>0 clean(i= mag(i-nmag(i; else;clean(i=0; end end %ÔÚƵÓòÖÐÖØкϳÉÓïÒô fff=exp(j*phase;spectral=clean.*fff;
42、 %IDFT²¢ÖصþÏà¼Ó enhanced(1+(q-1*winsize/2:winsize+(q-1*winsize/2=enhanced(1+(q-1*winsize/2:winsize+(q-1*winsize/2+real(ifft(spectral; end % ³ýÈ¥Hamming´°ÒýÆðµÄÔöÒæ for i
43、=1:size if hamwin(i=0 enhanced(i=0; else enhanced(i=enhanced(i/hamwin(i; end end SNR1 = 10*log10(var(speech'/var(noisy; %¼ÓÔëÓïÒôÐÅÔë±È SNR2 = 10*log10(var(speech'/var(enhanced-speech' %ÔöÇ¿Ó
44、239;ÒôÐÅÔë±È wavwrite(x,fs,nbits,'noisy.wav' %Êä³ö´øÔëÐźŠwavwrite(enhanced,fs,nbits,'enhanced.wav' %Êä³öÔöÇ¿ÓïÒô subplot(3
45、,1,1;plot(speech' %ÔʼÓïÒô²¨ÐÎ title('Original Voice (n=',num2str(n,'' ; specgram(speech' %ÔʼÓïÒôÓïÆ× title('Original Voice (n=',num2str(n,'&
46、#39; ; subplot(3,1,2; plot(x; title('Noise Added (SNR=',num2str(SNR1,'dB' specgram(x; %¼ÓÔëÓïÒôÓïÆ× title('Noise Added (SNR=',num2str(SNR1,'dB' subplot(3,1,3;plot(enhanced; title('Improved Voice (SNR=',num2str(SNR2,'dB SNR=',num2str(SNR2-SNR1,'dB' specgram(enhanced; title('Improved Voice (SNR=',num2str(SNR2,'dB SNR=',num2str(SNR2-SNR1,'dB' pause; sound(speech;pause;sound(x;pause;sound(enhanced;% - Executes o
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 山东枣庄市薛城区2025届高考第二次模拟考试历史试题理试题含解析
- 2025年江苏省溧中、省扬中、镇江一中、江都中学高三模拟(最后一次)英语试题含解析
- 化疗科普小知识
- 船运渣土施工方案
- 2025年焊工(中级)考试题及答案
- 护士护理查房儿科
- 安全使用布洛芬
- 智能粮仓二五年防鼠防潮安防系统协议
- 德育工作总结汇报2
- 护理医疗操作的不良事件
- 艾滋病梅毒和乙肝母婴阻断知识知晓率调查问卷
- 99S203消防水泵接合器安装图集
- 平面控制点测量复核记录
- 乔木、灌木栽植方案
- 中国胸痛中心认证标准(标准版、基层版)
- 利益平衡理论及其在民事诉讼中的运用
- 《艺术学概论考研》课件艺术内涵的演变
- 三年级英语家长会发言稿15篇
- 光的折射(课堂PPT)
- 监控系统维护及方案
- 无心磨床新手
评论
0/150
提交评论