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

📄 m1.m

📁 这是一个用于语音信号处理的工具箱
💻 M
字号:
disp(' ');
disp('SCRIPT: m1.m *********************************************************');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%	%
%	m1.m
%	
%	jmw
%	6/04/94
%
%	This is the main parent program for time modification of speech.
%  modified by D. G. Childers 2/13/98
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%close all;
%clear;

if  exist('signal_gci_win_h')
   eval('close(signal_gci_win_h);',catch1);
   clear signal_gci_win_h;
end;

clc;

path(path,'./analysis');
path(path,'./data');
path(path,'./modify_anal');
path(path,'./seg_label');
path(path,'./temp');
path(path,'./time_mod');
path(path,'./utilities');


genflag = 0;     %Flags that indicate whether the corresponding analysis was done
srcflag = 0;    
frmflag = 0;

Srate = 10000;    %Unless changed, this is the fixed value for sampling rate

% Define some character strings
o_fname='';
o_pname='';

% Define some global variables

global Ts;        %Sampling period in seconds
Ts = 1e-4;

%global name;

%color_flag=0;		% Black background and white text
color_flag=1;		% White background and black text

global BACK_COLOR TEXT_COLOR LINE_COLOR;	

if color_flag == 1
   BACK_COLOR=[1 1 1]; %white
	TEXT_COLOR=[0 0 0]; %black
   LINE_COLOR=[0 0 1]; %blue
else
   BACK_COLOR=[0 0 0];
   TEXT_COLOR=[1 1 1];
   LINE_COLOR=[0 0 1];
end

check = 1;        %Variable used for proper closing and opening of windows
catch2 = 'check = 0;';
catch1 = 'break;';



% load signal
cwd=pwd;

[fname pathname]=uigetfile('*.dat','Load input file(ASCII)');
   
S=sprintf('cd %s',cwd);
eval(S);

if fname ~= 0
   S=sprintf('Loading data .....');
   disp(S);
   S=sprintf('load %s%s',pathname,fname);
   eval(S);
   
   o_fname=fname;
   o_pname=pathname;
   name=basename(fname);
   
else
   fname=o_fname;
   pathname=o_pname;
end

% If an input file is not loaded ( fname ), return to main menu
if exist('fname') ~= 1 | length(fname) == 0
   disp('Input file is not loaded. Please load an input file first.');
   return;
end

s=sprintf('signal=%s;', name);
eval(s);
signal_store=signal;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% load Data

file_string=sprintf('./temp/%s_Data',name);
s=sprintf('loading LPC analysis results from %s',file_string);
disp(s);
s=sprintf('load %s.mat',file_string);
eval(s);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% load segmentation data 

file_string=sprintf('./temp/%s_SegNLabels.mat',name);
s=sprintf('loading segmentation & labeling results from %s',file_string);
disp(s);
s=sprintf('load %s',file_string);
eval(s);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% initialization for w1 (scale factors window)

% set default values (or load from disk)

% load SF, if exists.  Otherwise, create.


file_string=sprintf('./temp/%s_SF',name);
if exist(file_string)==2	
	s=sprintf('loading previous values from %s',file_string);
	disp(s);
	s=sprintf('load %s',file_string);
	eval(s);
else
	s=sprintf('%s_SF does not exist... Creating one from defaults...',...
		name);
   disp(s);
   
	bar_sf = 1.0;
   nas_sf = 1.0;
   sil_sf = 1.0;
	smv_sf = 1.0;
   ufr_sf = 1.0;
   ust_sf = 1.0;
  	vfr_sf = 1.0;
  	vwl_sf = 1.0;

end;

SF = [bar_sf nas_sf sil_sf smv_sf ufr_sf ust_sf vfr_sf vwl_sf];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% initialization for w2 (minimum durations window)

% set default values (or load from disk)

% load MD, if exists.  Otherwise, create.

file_string=sprintf('./temp/%s_MD',name);
if exist(file_string)==2
	s=sprintf('loading previous values from %s',file_string);
	disp(s);
	s=sprintf('load %s',file_string);
	eval(s);
else
	s=sprintf('%s_MD does not exist... Creating one from defaults...',...
		name);
	disp(s);

	vwl_md = 100;
	nas_md = 100;
	smv_md = 100;
	bar_md = 100;
	vfr_md = 100;
	ust_md = 100;
	ufr_md = 100;
	sil_md = 100;
end;

MD = [vwl_md nas_md smv_md bar_md vfr_md ust_md ufr_md sil_md];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% initialization for window 4 (Manual Scale Factors window)

% set maximum number of Radio Buttons (determines size of w4)
MAXRB = 17;

if (seg_cnt < MAXRB),
        MAXRB = seg_cnt - 1;
end;

% set initial Radio Button (RB) state to off for all segments
% W4RBSTATE = zeros(1,MAXRB+1);

% load MSF, if exists.  Otherwise, create.
% also, check to see if the loaded version is the correct size
% because changes may have been made in the number of segments
% since the last time the MSF file was saved ...


file_string=sprintf('./temp/%s_MSF',name);
if exist(file_string)==2
	s=sprintf('loading previous values from %s',file_string);
	disp(s);
	s=sprintf('load %s',file_string);
	eval(s);
else
	s=sprintf('%s_MSF does not exist... Creating one from defaults...',...
		name);
	disp(s);

	% vector to hold manual scale factors
	man_sf = ones(1,MAXRB+1);	% vector to hold manual scale factors
	
	% vector to hold manual override flags
   man_override_flag = zeros(1,MAXRB+1);
   MSF=[man_override_flag man_sf];
end;

% check size of loaded man_sf

if exist(file_string)==2
	if(length(man_sf) ~= seg_cnt)
		% make new man_sf and man_override_flag;
	       disp('discrepency in MSF file. Creating new one from defaults.');
		man_sf = ones(1,MAXRB+1);
		man_override_flag = zeros(1,MAXRB+1);
	end;
end;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% initialization for window 5 (Map window)

% initialize window size

w5_width = 150 + (MAXRB * 90);     % width dependent upon number of segments
if (w5_width < 450)		   % minimum window width
	w5_width = 450;
end;

w5_ht = 500;
w5_left = 1100 - w5_width;

% load User Maps, if they exist.  Otherwise, create one.


fixed1  = 0.01 * [100:-1:1];
fixed2  = 0.01 * [1:1:100];
fixed3  = (1 - hamming(100))';
fixed4  = (hamming(100))';
ranm   = rand(1,100);
	
file_string=sprintf('./temp/%s_Maps',name);
if exist(file_string)==2
	s=sprintf('loading previous values from %s',file_string);
	disp(s);
	s=sprintf('load %s',file_string);
	eval(s);
else
	s=sprintf('%s_Maps does not exist... Creating one from defaults...',...
		name);
	disp(s);

	user1 = 0.01 * [1:1:100];
	user2 = 0.01 * [1:1:100];
	user3 = 0.01 * [1:1:100];
	
	target1 = [1 0.01; 100 1];
	target2 = [1 0.01; 100 1];
	target3 = [1 0.01; 100 1];

	smooth1 = 1;
	smooth2 = 1;
	smooth3 = 1;

	for i=2:MAXRB,
		W5PUSEGSTATE(i) = 4;	% set all methods (initially) to random
	end;

	% make MASTER map

	for i=1:MAXRB+1,
		tmp_frm = seg_frame(i,:);
		tmp_range = seg_range(i,:);
		tmp_map = ranm;	

		% if changed, MUST also change initial menu value below
		tmp_map = ranm;	

		tmp_master_map=fun_warp(tmp_frm,tmp_range,range,tmp_map);
		MASTERMAP(tmp_frm(1):tmp_frm(2))=tmp_master_map(:);
	end;
   smaps1=sprintf(' user1 user2 user3 target1 target2 target3');
   smaps2=sprintf('smooth1 smooth2 smooth3 MASTERMAP W5PUSEGSTATE');
   smaps=[smaps1 smaps2]; %create vector smaps, but do not save yet
   disp(smaps);  %display smaps, but do not save yet

end;

map_method(1,:) = user1;
map_method(2,:) = user2;
map_method(3,:) = user3;
map_method(4,:) = ranm;
map_method(5,:) = fixed1;
map_method(6,:) = fixed2;
map_method(7,:) = fixed3;
map_method(8,:) = fixed4;


% adjust for beginning and ending silent segments
MASTERMAP(seg_frame(1,1):seg_frame(1,2))=...
	zeros(1,seg_frame(1,2)-seg_frame(1,1)+1);

MASTERMAP(seg_frame(MAXRB+1,1):seg_frame(MAXRB+1,2))=...
	zeros(1,seg_frame(MAXRB+1,2)-seg_frame(MAXRB+1,1)+1);

MAX_NUM_METHODS = 8;

% misc stuff for the DISPLAY buttons and DISPLAY window

MAXDISPLAYS = 4;
W5DISPLAY = zeros(1,MAXDISPLAYS);
W5DISPLAY(3) = 1;
SEGFLAG = 0;
DISPLAYSEG = 2;
DISPLAYMODE = 3;
DISPLAYMAP = 1;

%display_ht = w5_ht - 190;
display_ht = w5_ht - 160;
display_L2 = 80;
display_L1 = 330;

% stuff for the USER MAP editing window

USERMAPCHANGED = 0;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%	end of initialization for windows 
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% make main user-interface window


m1_height = 350;
m1_width = 600;
m1_h = figure('Position', [100 100  m1_width m1_height ], 'Resize', 'on',...
	'NumberTitle', 'off','Name','Main','resize','on',...
	'Color', BACK_COLOR);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% add functional pushbutton(s) to m1

% add text and line
s1=sprintf('---------------------------------------------------------------');
s2=sprintf('---------------------------------------------------------------');
s1=[s1 s2];
text('Units','pixels','Position',[-50 m1_height-130],'String',s1,...
	'Color',TEXT_COLOR);
ax =axis;
axis(ax);
axis off;

m1_pb_quit_h = uicontrol('Style','Pushbutton','Position',...
	[30 m1_height-80  80 30],...
	'String','Quit','Callback','m1_quit');

m1_pb_save_h = uicontrol('Style','Pushbutton','Position',...
	[30 m1_height-180 80 30],...
	'String','Save','Callback','m1_save');

m1_pb_map_h = uicontrol('Style','Pushbutton','Position',...
	[120 m1_height-180 80 30],...
	'String','Map','Callback','fun_nm1');

m1_pb_synth_h = uicontrol('Style','Pushbutton','Position',...
	[210  m1_height-180 80 30],...
	'String','Synth','Callback','syn1aexp3');

m1_pb_play_h = uicontrol('Style','Pushbutton','Position',...
	[300 m1_height-160 80 30],...
	'String','Play','Callback','playsyn1');

% pushbutton to invoke window (Postview Method)
w6_h = [];
w6_saved_position = [];
m1_pb_w6_h = uicontrol('Style','Pushbutton','Position',...
	[300 m1_height-200 80 30],...
	'String','Postview','Callback','m1_w6');


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% add window-display pushbutton(s)

% add text and line
s1=sprintf('---------------------------------------------------------------');
s2=sprintf('---------------------------------------------------------------');
s1=[s1 s2];
text('Units','pixels','Position',[-50 m1_height-260],'String',s1,...
	'Color',TEXT_COLOR);
axis(ax);
axis off;

% pushbutton to invoke window 1 (Preview of Seg. & Labeling Results)
w3_h = [];
w3_saved_position = [];
m1_pb_w3_h = uicontrol('Style','Pushbutton','Position',...
	[30 m1_height-300 70 30],...
	'String','Preview','Callback','fun_prev');

% pushbutton to invoke window 2 (SF's)
w1_h = [];
w1_saved_position = [];
m1_pb_w1_h = uicontrol('Style','Pushbutton','Position',...
	[120 m1_height-300 70 30],...
	'String','SF''s','Callback','m1_w1');

% pushbutton to invoke window 3 (MD's)
w2_h = [];
w2_saved_position = [];
m1_pb_w2_h = uicontrol('Style','Pushbutton','Position',...
	[210 m1_height-300 70 30],...
	'String','MD''s','Callback','m1_w2');

% pushbutton to invoke window 4 (Manual Scale Factors)
w4_h = [];
w4_saved_position = [];
m1_pb_w4_h = uicontrol('Style','Pushbutton','Position',...
	[300 m1_height-300 70 30],...
	'String','Man SF''s','Callback','m1_w4');

% pushbutton to invoke window 5 (Mapping Method)
w5_h = [];
w5_saved_position = [];
w5_display_saved_position = [];
w5_edit_saved_position = [];
m1_pb_w5_h = uicontrol('Style','Pushbutton','Position',...
	[390 m1_height-300 70 30],...
	'String','Maps','Callback','m1_w5');


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% add name of file to m1

s=sprintf('Signal Name:  %s',name);
text('Units','pixels','Position',[-50 285],'String', s,...
	'Color', TEXT_COLOR);

% add captions to main window

s=sprintf('Functions');
text('Units','pixels','Position',[-50 m1_height-150],'String', s,...
	'Color',TEXT_COLOR);

s=sprintf('Parameter Windows');
text('Units','pixels','Position',[-50 m1_height-280],'String', s,...
	'Color',TEXT_COLOR);


%return;


⌨️ 快捷键说明

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