課設論文matlabgui 界面設計_第1頁
課設論文matlabgui 界面設計_第2頁
課設論文matlabgui 界面設計_第3頁
課設論文matlabgui 界面設計_第4頁
課設論文matlabgui 界面設計_第5頁
已閱讀5頁,還剩12頁未讀 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論