📄 guiinit.m
字号:
% MATLAB SIMULATION OF NSA FS-1016 CELP v3.2
% COPYRIGHT (C) 1995-99 ANDREAS SPANIAS AND TED PAINTER
%
% This Copyright applies only to this particular MATLAB implementation
% of the FS-1016 CELP coder. The MATLAB software is intended only for educational
% purposes. No other use is intended or authorized. This is not a public
% domain program and distribution to individuals or networks is strictly
% prohibited. Be aware that use of the standard in any form is goverened
% by rules of the US DoD. Therefore patents and royalties may apply to
% authors, companies, or committees associated with this standard, FS-1016.
% For questions on rules,% royalties, or patents associated with the standard,
% please contact the DoD.
%
% ALL DERIVATIVE WORKS MUST INCLUDE THIS COPYRIGHT NOTICE.
%
% ******************************************************************
% GUIINIT
%
% NSA CELP 3.2a SPEECH CODER GRAPHICAL USER INTERFACE (GUI)
% 6-7-94
%
% ******************************************************************
%
% DESCRIPTION
%
% Create base window for current GUI phase.
%
% DESIGN NOTES
%
% This function switches on the value of guiPhase:
% 0 = Startup configuration window - Y/N query for runtime graphical output
% 1 = Runtime output window - either graphical plots or text status
% 2 = Termination window with OK button
% 3 = Options window
%
% VARIABLES
%
% INPUTS
% guiPhase - Current phase of GUI operation (start, runtime, termination, options)
%
% OUTPUTS
% Creates output window with text and axes, ready for data.
%
% INTERNALS
% NameStr - Output window title string
% FileStr - Output window filename string
% StatStr - Output window status string - frame number
% EndStr - Simulation termination string
% WSstr - White space string for screen formatting
% L1STR - Output window title string
% L2STR - Output window subtitle string
% PSTR - Percent complete string
% f1 - Object handle for startup window
% hh - Object handle for miscellaneous window objects
% ss - Screen size vector for host machine
% xorg - Host machine screen X axis origin for output window
% yorg - Host machine screen Y axis origin for output window
% x - X coordinates for percentage complete rectangle
% y - Y coordinates for percentage complete rectangle
% F1POS - Output window location in screen pixels
% cFIG - Background color, graphical output window
% OKButton - Object handle, OK to exit options window
%
% GLOBALS
% guiState - Graphical output or status output mode
% 0 = status mode (non-interactive), 1 = graphics mode
% guiF1 - Output window object handle
% guiSline - Status output text object handle
% FrameCnt - Number of frames processed so far
%
% CONSTANTS
% L1POS - Text line 1 position in output window (pixels)
% L2POS - Text line 2 position in output window (pixels)
% L3POS - Text line 3 position in output window (pixels)
% PPOS - Percent complete bar graph position
% FILEPOS - File name message position
% ENDPOS - Termination message position
% OKPOS - OK button position in termination window
% RUNPOS - Run button position in startup window
% OPTPOS - Option button position in startup window
% EXITPOS - Exit button position in startup window
%
% ******************************************************************
function guiinit( guiPhase )
% DECLARE GLOBALS
global guiState guiF1 guiSline FrameCnt guiOpt guiColors
global guiIfile guiOfile guiNPFfile guiHPFfile
global fnInput fnNPFile fnHPFile fnPFile
% DECLARE GLOBAL CONSTANTS
global ANALYSIS
% DEFINE COLORS
if strcmp( guiColors, 'white' ) == 1
cFIG = 'w';
else
cFIG = 'k';
end
PCOL = 'k';
% INITIALIZE GRAPHICAL OBJECT POSITIONS
L1POS = [110,330,400,50];
L2POS = [110,300,400,50];
L3POS = [100,210,400,20];
X1POS = [100,300,400,20];
X2POS = [100,270,450,20];
PPOS = [0.15,0.35,0.7,0.05];
FILEPOS = [5,30,600,20];
ENDPOS = [110,150,400,20];
OKPOS = [285,100,50,30];
% COMPUTE WINDOW POSITIONS BASED ON SCREEN DIMENSIONS
ss = get( 0, 'ScreenSize' );
xorg = ( ss(3) - 600 ) / 2;
yorg = ( ss(4) - 400 ) / 2;
F1POS = [ xorg yorg 600 400 ];
% DETERMINE COLOR DISPLAY CAPABILITY FOR MOVIE ENABLE/DISABLE
guiDepth = get( 0, 'ScreenDepth' );
% INITIALIZE TEXT OBJECTS
NameStr = 'NSA CELP v3.2 SIMULATION ';
WSstr = ' ';
EndStr = sprintf( 'CELP Simulation Complete. Processed %3d Frames.', FrameCnt );
FileStr = sprintf( 'Input File: %12s%sOutput File: %12s', guiIfile, WSstr, guiOfile );
StatStr = sprintf( 'Processing Frame #%4d', FrameCnt );
L1STR = NameStr;
L2STR = 'FEDERAL STANDARD 1016';
X1STR = 'DEVELOPED BY TED PAINTER AND ANDREAS SPANIAS';
X2STR = 'COPYRIGHT (C) 1994-99 ANDREAS SPANIAS AND TED PAINTER';
PSTR = 'Percent Complete (%)';
% CREATE BASE WINDOW FOR CURRENT PHASE
% 0 : STARTUP PHASE - RUN/OPTIONS/EXIT WINDOW
if guiPhase == 0
cr;
% 1 : RUNTIME PHASE - EITHER TEXTUAL STATUS OR GRAPHICAL DATA DISPLAY
elseif guiPhase == 1
% CREATE WINDOW AND TEXT OBJECTS
guiF1 = figure( 'Position', F1POS, 'number', 'off', 'name', ...
NameStr, 'resize', 'off', 'Menubar', 'none', 'color', PCOL );
clf;
hh=uicontrol('style','text','string',L1STR,'position', L1POS);
set(hh,'backg',get(gcf,'color'),'foreg',[1,1,1]-get(gcf,'color'));
hh=uicontrol('style','text','string',L2STR,'position',L2POS);
set(hh,'backg',get(gcf,'color'),'foreg',[1,1,1]-get(gcf,'color'));
hh=uicontrol('style','text','string',X1STR,'position', X1POS);
set(hh,'backg',get(gcf,'color'),'foreg',[1,1,1]-get(gcf,'color'));
hh=uicontrol('style','text','string',X2STR,'position', X2POS);
set(hh,'backg',get(gcf,'color'),'foreg',[1,1,1]-get(gcf,'color'));
hh=uicontrol('style','text','string',FileStr,'position',FILEPOS);
set(hh,'backg',get(gcf,'color'),'foreg',[1,1,1]-get(gcf,'color'));
guiSline=uicontrol('style','text','string',StatStr,'position',L3POS);
set(guiSline,'backg',get(gcf,'color'),'foreg',[1,1,1]-get(gcf,'color'));
% CREATE COMPLETION BAR GRAPH
guiPax = axes('position',PPOS);
x=[ 0,0,0,0 ];
y=[ 0,1,1,0];
fill(x,y,'b');
axis([0,100,0,1.0]);
% Won't work with both v.4 and v.5 - "labels" for v4, "label" for v5
%set(guiPax,'box','off','yticklabel','');
set(guiPax,'box','off');
xlabel(PSTR);
hold on
drawnow;
% 2 : TERMINATION PHASE - INDICATE NUMBER OF FRAMES PROCESSED AND OK BUTTON
elseif guiPhase == 2
% FIRST, CLOSE RUNTIME WINDOW
close;
% CREATE TERMINATION WINDOW
guiF1 = figure( 'Position', F1POS, 'number', 'off', 'name', NameStr, ...
'resize', 'off', 'Menubar', 'none', 'color', PCOL );
clf;
% DISPLAY STANDARD VOCODER TEXT MESSAGES
hh=uicontrol('style','text','string',L1STR,'position', L1POS);
set(hh,'backg',get(gcf,'color'),'foreg',[1,1,1]-get(gcf,'color'));
hh=uicontrol('style','text','string',L2STR,'position',L2POS);
set(hh,'backg',get(gcf,'color'),'foreg',[1,1,1]-get(gcf,'color'));
hh=uicontrol('style','text','string',X1STR,'position', X1POS);
set(hh,'backg',get(gcf,'color'),'foreg',[1,1,1]-get(gcf,'color'));
hh=uicontrol('style','text','string',X2STR,'position', X2POS);
set(hh,'backg',get(gcf,'color'),'foreg',[1,1,1]-get(gcf,'color'));
hh=uicontrol('style','text','string',FileStr,'position',FILEPOS);
set(hh,'backg',get(gcf,'color'),'foreg',[1,1,1]-get(gcf,'color'));
% DISPLAY TERMINATION MESSAGE AND OK BUTTON
hh=uicontrol('style','text','string',EndStr,'position',ENDPOS);
set(hh,'backg',get(gcf,'color'),'foreg',[1,1,1]-get(gcf,'color'));
OKButton = uicontrol('Style','Pushbutton','Position',OKPOS,'Callback',...
'close;','String','OK');
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -