⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ma_go.m

📁 这是一个用于语音信号处理的工具箱
💻 M
字号:
%
% Callback function for popup menu in the Frequency Analysis window
% Author : Minkyu Lee
% Date : 27-Feb-1995
% Modified by Karthik May 27 1997
% Modified by D. G. Childers


% Set position and size of analysis window
PV=[275 100 519 240];
s2 = 'Frequency Domain Analysis - Output';

% Open analysis window
while exist('freq_out_win_h')==1
   try1 = 'get(freq_out_win_h,''position'');';
   eval(try1,catch2);
   if check ==0
      clear freq_out_win_h;
      check = 1;
      break;
   end
   s1 = get(freq_out_win_h,'Name');
   if ~strcmp(s1,s2)
      clear freq_out_win_h;
      break;
   end
   figure(freq_out_win_h);
   break;
end;

if exist('freq_out_win_h')~=1;
	freq_out_win_h=figure('Position',PV,...
		'Resize','on',...
      'Numbertitle','off',...
      'Name',s2 );
end

if (RIGHT-LEFT+1) < ma_frame_len
	disp('The current data length is less than the analysis frame length');
	ma_frame_len=RIGHT-LEFT+1;
end

if ma_window == 1
	window = hamming(ma_frame_len);	   % Window type
elseif ma_window == 2
	window = hanning(ma_frame_len);	   % Window type
elseif ma_window == 3
	beta=0.5;
	window = kaiser(ma_frame_len,beta);	% Window type
elseif ma_window == 4
	window = triang(ma_frame_len);	   % Window type
elseif ma_window == 5
	window = bartlett(ma_frame_len);	   % Window type
elseif ma_window == 6
	window = blackman(ma_frame_len);	   % Window type
elseif ma_window == 7
	window = boxcar(ma_frame_len);	   % Window type
elseif ma_window == 8
	rdb=3;
	window = chebwin(ma_frame_len,rdb);	% Window type
end



% set parameters
button=1;
while button==1
   if freq_ma_mark_flag == 0
      if ma_frame_len > length(SPEECH)         S=sprintf('Analysis window length is longer that input data. %d of zeros are padded',ma_frame_len-LEN);
         disp(S);
         temp=zeros(ma_frame_len-LEN,1);
         speech1=[SPEECH;temp];
      else
         S=sprintf('The analysis frame is the first %d points of current data window',ma_frame_len);
         disp(S);
         speech1=SPEECH_OLD(LEFT:LEFT+ma_frame_len-1);
      end
      button=0;
   else
      disp('Please select a starting point of analysis frame');
      figure(ana_wav_win_h);
      [x,y,button]=ginput(1);
      x=round(x);
      if button ~= 1
         return;
      end
      speech1=SPEECH_OLD(x:x+ma_frame_len-1);
      figure(freq_out_win_h);
   end
   
   wait_window = figure('Numbertitle','off',...
   'Color',BACK_COLOR,...
   'Name','Please be patient...',...
   'Position',[117 248 560 150]);

   wait_window_display = uicontrol('Style','Text',...
   'Position',[50 50 410 30],...
   'Backgroundcolor','white',...
   'Foregroundcolor','blue',...
   'String','This method may take a while...please wait');

   pause(0.01);

   
   Np=length(speech1);
   epsilon=1e-15;		% A small number to test for ill-conditioning of matrix  
   FFT = fft(window.*speech1);

   % call Matlab function to calculate spectrogram from input signal
   [B sig2] = durbin(window.*speech1, Np, ma_num_zeros, round(Np/5));
   error=filter(1, [1 B],window.*speech1);
   eng=sqrt(error'*error);
   
   [H W] = freqz(eng*[1 B],1,Np/2);
   
   set(wait_window_display,'String','Thanks for being patient.  Now plotting');
   pause(0.01);
   close(wait_window);
   clear wait_window;

   
   % plot the spectrum and pole_zero plot
   vh=1:Np/2;
   vh=vh/(Np/2)*1/(2*Ts);
   subplot(121),plot(vh, 20*log10( abs(FFT(1:Np/2)) ) );
   hold on
   plot(vh,20*log10(abs(H)), ':r');
   hold off
   title('Moving Average Analysis');
   subplot(122), zplane([1 B], []);
   fsave=20*log10(abs(H));
   
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -