mgif_pas.m

来自「这是一个用于语音信号处理的工具箱」· M 代码 · 共 363 行

M
363
字号
%
% Manuall glottal inverse filtering algorithm
% The inverse filter can be adjusted by hand using formant frequency 
% and bandwidths.
% Author : Minkyu Lee
% Date 10-Oct-1994
%

%Modified by Karthik May 31 1997
mgif_ps_flag=0;
clear dg_final g_final;

GVV=zeros(size(SPEECH));
DGVV=zeros(size(SPEECH));
RESIDUE=zeros(size(SPEECH));

if exist('SPEECH') ~=1
	disp('Please load a speech file for analysis first');
	return;
end
ext_left = NEW_LEFT -1;
ext_right = 0;

ydata_m=SPEECH;
	
% Crude estimation of gain and formant frequencies and bandwidths.
% Here, the gain, ff1, ff2, ff3, ff4, fb1, fb2, fb3 and fb4 will be 
% estimated roughly in this script.

mgif_es;

% Define some character strings for future use

S_g  =sprintf('Filter Gain. [dB] :');
S_ff1=sprintf('1st fmt freq.[Hz] :');
S_fb1=sprintf('        bwd. [Hz] :');
S_ff2=sprintf('2nd fmt freq.[Hz] :');
S_fb2=sprintf('        bwd. [Hz] :');
S_ff3=sprintf('3rd fmt freq.[Hz] :');
S_fb3=sprintf('        bwd. [Hz] :');
S_ff4=sprintf('4th fmt freq.[Hz] :');
S_fb4=sprintf('        bwd. [Hz] :');
S_ff5=sprintf('5th fmt freq.[Hz] :');
S_fb5=sprintf('        bwd. [Hz] :');

% Open control box for manual inverse filtering
PV=[2 22 290 400];
s2 = 'Manual GIF control box';

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

if exist('mgif_con_win_h')~=1;
   mgif_con_win_h=figure('Position',PV,...
      'Resize','on',...
      'Numbertitle','off',...
      'color',BACK_COLOR,...
      'Name',s2);
   % Design the control box 
    
   % for gain slide bar
   
   mgif_warning_display = uicontrol('Style','text',...
      'BackgroundColor','white',...
      'ForegroundColor','red',...
      'Position',[10 380 250 10],...
      'String','Warning:Once you are finished use Save or Cancel to Quit.');
   mgif_txt_gain_h=uicontrol('Style','Pushbutton',...
      'Position',[10 350 120 20],...
      'String',S_g);
   
   S1=sprintf('gain=mgif_e2s(mgif_sl_gain_h, mgif_ed_gain_h);'); 
   mgif_ed_gain_h=uicontrol('Style','edit',...
      'Position',[140 350 40 20],...
      'Callback',S1,...
      'String',gain);
   
   S1=sprintf('gain=mgif_s2e(mgif_ed_gain_h, mgif_sl_gain_h);'); 
   mgif_sl_gain_h=uicontrol('Style','slider',...
      'Position',[190 350 90 20],...
      'Callback',S1,...
      'Max',200,...
      'Min',1,...
      'Value',gain);
   
   % for ff1 slide bar
   mgif_txt_ff1_h=uicontrol('Style','Pushbutton',...
      'Position',[10 320 120 20],...
      'String',S_ff1);
   
   S1=sprintf('ff(1)=mgif_e2s(mgif_sl_ff1_h, mgif_ed_ff1_h);'); 
   mgif_ed_ff1_h=uicontrol('Style','edit',...
      'Position',[140 320 40 20],...
      'Callback',S1,...
      'String',ff(1));
   
   S1=sprintf('ff(1)=mgif_s2e(mgif_ed_ff1_h, mgif_sl_ff1_h);'); 
   mgif_sl_ff1_h=uicontrol('Style','slider',...
      'Position',[190 320 90 20],...
      'Callback',S1,...
      'Max',2000,...
      'Min',0,...
      'Value',ff(1));
   % for fb1 slide bar
   mgif_txt_fb1_h=uicontrol('Style','Pushbutton',...
      'Position',[10 290 120 20],...
      'String',S_fb1);
   
   S1=sprintf('fb(1)=mgif_e2s(mgif_sl_fb1_h, mgif_ed_fb1_h);'); 
   mgif_ed_fb1_h=uicontrol('Style','edit',...
      'Position',[140 290 40 20],...
      'Callback',S1,...
      'String',fb(1));
   
   S1=sprintf('fb(1)=mgif_s2e(mgif_ed_fb1_h, mgif_sl_fb1_h);'); 
   mgif_sl_fb1_h=uicontrol('Style','slider',...
      'Position',[190 290 90 20],...
      'Callback',S1,...
      'Max',5000,...
      'Min',30,...
      'Value',fb(1));
   % for ff2 slide bar
   mgif_txt_ff2_h=uicontrol('Style','Pushbutton',...
      'Position',[10 260 120 20],...
      'String',S_ff2);
   
   S1=sprintf('ff(2)=mgif_e2s(mgif_sl_ff2_h, mgif_ed_ff2_h);'); 
   mgif_ed_ff2_h=uicontrol('Style','edit',...
      'Position',[140 260 40 20],...
      'Callback',S1,...
      'String',ff(2));
   
   S1=sprintf('ff(2)=mgif_s2e(mgif_ed_ff2_h, mgif_sl_ff2_h);'); 
   mgif_sl_ff2_h=uicontrol('Style','slider',...
      'Position',[190 260 90 20],...
      'Callback',S1,...
      'Max',2500,...
      'Min',500,...
      'Value',ff(2));
   
   % for fb2 slide bar
   mgif_txt_fb2_h=uicontrol('Style','Pushbutton',...
      'Position',[10 230 120 20],...
      'String',S_fb2);
   
   S1=sprintf('fb(2)=mgif_e2s(mgif_sl_fb2_h, mgif_ed_fb2_h);'); 
   mgif_ed_fb2_h=uicontrol('Style','edit',...
      'Position',[140 230 40 20],...
      'Callback',S1,...
      'String',fb(2));
   
   S1=sprintf('fb(2)=mgif_s2e(mgif_ed_fb2_h, mgif_sl_fb2_h);'); 
   mgif_sl_fb2_h=uicontrol('Style','slider',...
      'Position',[190 230 90 20],...
      'Callback',S1,...
      'Max',5000,...
      'Min',30,...
      'Value',fb(2));
   
   % for ff3 slide bar
   mgif_txt_ff3_h=uicontrol('Style','Pushbutton',...
      'Position',[10 200 120 20],...
      'String',S_ff3);
   
   S1=sprintf('ff(3)=mgif_e2s(mgif_sl_ff3_h, mgif_ed_ff3_h);'); 
   mgif_ed_ff3_h=uicontrol('Style','edit',...
      'Position',[140 200 40 20],...
      'Callback',S1,...
      'String',ff(3));
   
   S1=sprintf('ff(3)=mgif_s2e(mgif_ed_ff3_h, mgif_sl_ff3_h);'); 
   mgif_sl_ff3_h=uicontrol('Style','slider',...
      'Position',[190 200 90 20],...
      'Callback',S1,...
      'Max',5000,...
      'Min',1300,...
      'Value',ff(3));
   
   % for fb3 slide bar
   mgif_txt_fb3_h=uicontrol('Style','Pushbutton',...
      'Position',[10 170 120 20],...
      'String',S_fb3);
   
   S1=sprintf('fb(3)=mgif_e2s(mgif_sl_fb3_h, mgif_ed_fb3_h);'); 
   mgif_ed_fb3_h=uicontrol('Style','edit',...
      'Position',[140 170 40 20],...
      'Callback',S1,...
      'String',fb(3));
   
   S1=sprintf('fb(3)=mgif_s2e(mgif_ed_fb3_h, mgif_sl_fb3_h);'); 
   mgif_sl_fb3_h=uicontrol('Style','slider',...
      'Position',[190 170 90 20],...
      'Callback',S1,...
      'Max',5000,...
      'Min',40,...
      'Value',fb(3));
   
   % for ff4 slide bar
   mgif_txt_ff4_h=uicontrol('Style','Pushbutton',...
      'Position',[10 140 120 20],...
      'String',S_ff4);
   
   S1=sprintf('ff(4)=mgif_e2s(mgif_sl_ff4_h, mgif_ed_ff4_h);'); 
   mgif_ed_ff4_h=uicontrol('Style','edit',...
      'Position',[140 140 40 20],...
      'Callback',S1,...
      'String',ff(4));
   
   S1=sprintf('ff(4)=mgif_s2e(mgif_ed_ff4_h, mgif_sl_ff4_h);'); 
   mgif_sl_ff4_h=uicontrol('Style','slider',...
      'Position',[190 140 90 20],...
      'Callback',S1,...
      'Max',5000,...
      'Min',2500,...
      'Value',ff(4));
   
   % for fb4 slide bar
   mgif_txt_fb4_h=uicontrol('Style','Pushbutton',...
      'Position',[10 110 120 20],...
      'String',S_fb4);
   
   S1=sprintf('fb(4)=mgif_e2s(mgif_sl_fb4_h, mgif_ed_fb4_h);'); 
   mgif_ed_fb4_h=uicontrol('Style','edit',...
      'Position',[140 110 40 20],...
      'Callback',S1,...
      'String',fb(4));
   
   S1=sprintf('fb(4)=mgif_s2e(mgif_ed_fb4_h, mgif_sl_fb4_h);'); 
   mgif_sl_fb4_h=uicontrol('Style','slider',...
      'Position',[190 110 90 20],...
      'Callback',S1,...
      'Max',5000,...
      'Min',40,...
      'Value',fb(4));
   
   % for ff5 slide bar
   mgif_txt_ff5_h=uicontrol('Style','Pushbutton',...
      'Position',[10 80 120 20],...
      'String',S_ff5);
   
   S1=sprintf('ff(5)=mgif_e2s(mgif_sl_ff5_h, mgif_ed_ff5_h);'); 
   mgif_ed_ff5_h=uicontrol('Style','edit',...
      'Position',[140 80 40 20],...
      'Callback',S1,...
      'String',ff(5));
   
   S1=sprintf('ff(5)=mgif_s2e(mgif_ed_ff5_h, mgif_sl_ff5_h);'); 
   mgif_sl_ff5_h=uicontrol('Style','slider',...
      'Position',[190 80 90 20],...
      'Callback',S1,...
      'Max',5000,...
      'Min',2500,...
      'Value',ff(5));
   
   % for fb5 slide bar
   mgif_txt_fb5_h=uicontrol('Style','Pushbutton',...
      'Position',[10 50 120 20],...
      'String',S_fb5);
   
   S1=sprintf('fb(5)=mgif_e2s(mgif_sl_fb5_h, mgif_ed_fb5_h);'); 
   mgif_ed_fb5_h=uicontrol('Style','edit',...
      'Position',[140 50 40 20],...
      'Callback',S1,...
      'String',fb(5));
   
   S1=sprintf('fb(5)=mgif_s2e(mgif_ed_fb5_h, mgif_sl_fb5_h);'); 
   mgif_sl_fb5_h=uicontrol('Style','slider',...
      'Position',[190 50 90 20],...
      'Callback',S1,...
      'Max',5000,...
      'Min',40,...
      'Value',fb(5));
   
   mgif_pb_go_h=uicontrol('Style','pushbutton',...
      'Position',[10 10 80 30],...
      'Callback','mgif_go',...
      'String','Go');
   
   
   mgif_pb_can_h=uicontrol('Style','pushbutton',...
      'Position',[100 10 80 30],...
      'Callback','mgif_as_save',...
      'String','Save(dgvv)');
   
        
   mgif_pb_re_h=uicontrol('Style','pushbutton',...
      'Position',[200 10 80 30],...
      'Callback','mgif_ca',...
      'String','Cancel');
   
else
   set(mgif_sl_gain_h,'Value',gain);
   set(mgif_sl_ff1_h,'Value',ff(1));
   set(mgif_sl_fb1_h,'Value',fb(1));
   set(mgif_sl_ff2_h,'Value',ff(2));
   set(mgif_sl_fb2_h,'Value',fb(2));
   set(mgif_sl_ff3_h,'Value',ff(3));
   set(mgif_sl_fb3_h,'Value',fb(3));
   set(mgif_sl_ff4_h,'Value',ff(4));
   set(mgif_sl_fb4_h,'Value',fb(4));
   set(mgif_sl_ff5_h,'Value',ff(5));
   set(mgif_sl_fb5_h,'Value',fb(5));
   set(mgif_ed_gain_h,'String',gain);
   set(mgif_ed_ff1_h,'String',ff(1));			
   set(mgif_ed_fb1_h,'String',fb(1));
   set(mgif_ed_ff2_h,'String',ff(2));	
   set(mgif_ed_fb2_h,'String',fb(2));
   set(mgif_ed_ff3_h,'String',ff(3));	
   set(mgif_ed_fb3_h,'String',fb(3));
   set(mgif_ed_fb4_h,'String',fb(4));
   set(mgif_ed_ff4_h,'String',ff(4));
   set(mgif_ed_fb5_h,'String',fb(5));
   set(mgif_ed_ff5_h,'String',ff(5));
end

% Open the plotting window for manual inverse filtering

PV=[270 302 515 268];
s2 = 'MGIF - Filter Characteristic';

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

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

mgif_go;

⌨️ 快捷键说明

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