annotate Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/vs_ParameterDisplay.m @ 4:92ca03a8fa99 tip

Update to ICASSP 2013 benchmark
author Dawn Black
date Wed, 13 Feb 2013 11:02:39 +0000
parents
children
rev   line source
Dawn@4 1 function varargout = vs_ParameterDisplay(varargin)
Dawn@4 2 % VS_PARAMETERDISPLAY M-file for vs_ParameterDisplay.fig
Dawn@4 3 % VS_PARAMETERDISPLAY, by itself, creates a new VS_PARAMETERDISPLAY or raises the existing
Dawn@4 4 % singleton*.
Dawn@4 5 %
Dawn@4 6 % H = VS_PARAMETERDISPLAY returns the handle to a new VS_PARAMETERDISPLAY or the handle to
Dawn@4 7 % the existing singleton*.
Dawn@4 8 %
Dawn@4 9 % VS_PARAMETERDISPLAY('CALLBACK',hObject,eventData,handles,...) calls the local
Dawn@4 10 % function named CALLBACK in VS_PARAMETERDISPLAY.M with the given input arguments.
Dawn@4 11 %
Dawn@4 12 % VS_PARAMETERDISPLAY('Property','Value',...) creates a new VS_PARAMETERDISPLAY or raises the
Dawn@4 13 % existing singleton*. Starting from the left, property value pairs are
Dawn@4 14 % applied to the GUI before vs_ParameterDisplay_OpeningFcn gets called. An
Dawn@4 15 % unrecognized property name or invalid value makes property application
Dawn@4 16 % stop. All inputs are passed to vs_ParameterDisplay_OpeningFcn via varargin.
Dawn@4 17 %
Dawn@4 18 % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
Dawn@4 19 % instance to run (singleton)".
Dawn@4 20 %
Dawn@4 21 % See also: GUIDE, GUIDATA, GUIHANDLES
Dawn@4 22
Dawn@4 23 % Edit the above text to modify the response to help vs_ParameterDisplay
Dawn@4 24
Dawn@4 25 % Last Modified by GUIDE v2.5 13-Oct-2009 22:52:31
Dawn@4 26
Dawn@4 27 % Begin initialization code - DO NOT EDIT
Dawn@4 28 gui_Singleton = 1;
Dawn@4 29 gui_State = struct('gui_Name', mfilename, ...
Dawn@4 30 'gui_Singleton', gui_Singleton, ...
Dawn@4 31 'gui_OpeningFcn', @vs_ParameterDisplay_OpeningFcn, ...
Dawn@4 32 'gui_OutputFcn', @vs_ParameterDisplay_OutputFcn, ...
Dawn@4 33 'gui_LayoutFcn', [] , ...
Dawn@4 34 'gui_Callback', []);
Dawn@4 35 if nargin && ischar(varargin{1})
Dawn@4 36 gui_State.gui_Callback = str2func(varargin{1});
Dawn@4 37 end
Dawn@4 38
Dawn@4 39 if nargout
Dawn@4 40 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
Dawn@4 41 else
Dawn@4 42 gui_mainfcn(gui_State, varargin{:});
Dawn@4 43 end
Dawn@4 44 % End initialization code - DO NOT EDIT
Dawn@4 45
Dawn@4 46
Dawn@4 47 % --- Executes just before vs_ParameterDisplay is made visible.
Dawn@4 48 function vs_ParameterDisplay_OpeningFcn(hObject, eventdata, handles, varargin)
Dawn@4 49 % This function has no output args, see OutputFcn.
Dawn@4 50 % hObject handle to figure
Dawn@4 51 % eventdata reserved - to be defined in a future version of MATLAB
Dawn@4 52 % handles structure with handles and user data (see GUIDATA)
Dawn@4 53 % varargin command line arguments to vs_ParameterDisplay (see VARARGIN)
Dawn@4 54
Dawn@4 55 % Choose default command line output for vs_ParameterDisplay
Dawn@4 56 handles.output = hObject;
Dawn@4 57
Dawn@4 58 % YS: get the settings from the main figure
Dawn@4 59 if (~isfield(handles, 'VSHandle'))
Dawn@4 60 VSHandle = VoiceSauce;
Dawn@4 61 handles.VSHandle = VSHandle;
Dawn@4 62 end
Dawn@4 63
Dawn@4 64 VSData = guidata(handles.VSHandle);
Dawn@4 65 set(handles.edit_wavdir, 'String', VSData.vars.PD_wavdir);
Dawn@4 66 set(handles.edit_matdir, 'String', VSData.vars.PD_matdir);
Dawn@4 67
Dawn@4 68 if (VSData.vars.recursedir)
Dawn@4 69 func_setlistbox(handles.listbox_wavfilelist, VSData.vars.PD_wavdir, 'recurse', VSData.vars, VSData.vars.I_searchstring);
Dawn@4 70 else
Dawn@4 71 func_setlistbox(handles.listbox_wavfilelist, VSData.vars.PD_wavdir, 'none', VSData.vars, VSData.vars.I_searchstring);
Dawn@4 72 end
Dawn@4 73
Dawn@4 74 set(handles.listbox_wavfilelist, 'Value', 1);
Dawn@4 75
Dawn@4 76 % Update handles structure
Dawn@4 77 guidata(hObject, handles);
Dawn@4 78
Dawn@4 79 checkParameters(handles);
Dawn@4 80 plotData(handles);
Dawn@4 81
Dawn@4 82 % UIWAIT makes vs_ParameterDisplay wait for user response (see UIRESUME)
Dawn@4 83 % uiwait(handles.figure_ParameterDisplay);
Dawn@4 84
Dawn@4 85
Dawn@4 86 % --- Outputs from this function are returned to the command line.
Dawn@4 87 function varargout = vs_ParameterDisplay_OutputFcn(hObject, eventdata, handles)
Dawn@4 88 % varargout cell array for returning output args (see VARARGOUT);
Dawn@4 89 % hObject handle to figure
Dawn@4 90 % eventdata reserved - to be defined in a future version of MATLAB
Dawn@4 91 % handles structure with handles and user data (see GUIDATA)
Dawn@4 92
Dawn@4 93 % Get default command line output from handles structure
Dawn@4 94 varargout{1} = handles.output;
Dawn@4 95
Dawn@4 96
Dawn@4 97
Dawn@4 98 % displays the waveform based on the selected parameters
Dawn@4 99 function plotData(handles)
Dawn@4 100 VSData = guidata(handles.VSHandle);
Dawn@4 101 contents = get(handles.listbox_wavfilelist, 'String');
Dawn@4 102 paramlist = get(handles.listbox_paramlist, 'String');
Dawn@4 103
Dawn@4 104 if (isempty(contents))
Dawn@4 105 return;
Dawn@4 106 end
Dawn@4 107
Dawn@4 108 shortwavfile = contents{get(handles.listbox_wavfilelist, 'Value')};
Dawn@4 109 wavfile = [VSData.vars.PD_wavdir VSData.vars.dirdelimiter, shortwavfile];
Dawn@4 110 figdata = guidata(handles.figure_ParameterDisplay);
Dawn@4 111 mdata = figdata.mdata;
Dawn@4 112
Dawn@4 113 [y,Fs] = wavread(wavfile);
Dawn@4 114
Dawn@4 115 if (isempty(VSData.vars.PD_paramselection) || isempty(paramlist))
Dawn@4 116 position = [0.05 0.05 0.9 0.9];
Dawn@4 117 else
Dawn@4 118 position = [0.05 0.7 0.9 0.295];
Dawn@4 119 end
Dawn@4 120
Dawn@4 121 % top plot is always the wav
Dawn@4 122 subp = subplot('Position', position, 'Parent', handles.uipanel_figure);
Dawn@4 123 t = linspace(0, length(y) / Fs * 1000, length(y));
Dawn@4 124 plot(subp, t, y);
Dawn@4 125 axis(subp, 'tight');
Dawn@4 126
Dawn@4 127 if (isempty(VSData.vars.PD_paramselection) || isempty(paramlist)) % nothing else to do
Dawn@4 128 return;
Dawn@4 129 end
Dawn@4 130
Dawn@4 131 %set(subp, 'XTick', []);
Dawn@4 132 set(subp, 'XTickLabel', []);
Dawn@4 133
Dawn@4 134 subp2 = subplot('Position', [0.05 0.1 0.9 0.595], 'Parent', handles.uipanel_figure);
Dawn@4 135 cla(subp2);
Dawn@4 136
Dawn@4 137 hold(subp2, 'on');
Dawn@4 138 labels = cell(length(VSData.vars.PD_paramselection), 1);
Dawn@4 139 for k=1:length(VSData.vars.PD_paramselection)
Dawn@4 140 C = textscan(paramlist{VSData.vars.PD_paramselection(k)}, '%s %s', 'delimiter', '(');
Dawn@4 141 param = C{2}{1}(1:end-1);
Dawn@4 142 labels{k} = param;
Dawn@4 143 t = [1:length(mdata.(param))] * mdata.frameshift;
Dawn@4 144 plot(subp2, t, mdata.(param), VSData.vars.PD_plottype{mod(k-1, VSData.vars.PD_maxplots)+1});
Dawn@4 145 end
Dawn@4 146
Dawn@4 147 axis(subp2, 'tight');
Dawn@4 148 legend(subp2, labels);
Dawn@4 149 xlabel(subp2, 'Time (ms)');
Dawn@4 150
Dawn@4 151
Dawn@4 152 % fill in the parameter listbox
Dawn@4 153 function checkParameters(handles)
Dawn@4 154 VSData = guidata(handles.VSHandle);
Dawn@4 155 contents = get(handles.listbox_wavfilelist, 'String');
Dawn@4 156
Dawn@4 157 if (isempty(contents))
Dawn@4 158 return;
Dawn@4 159 end
Dawn@4 160
Dawn@4 161 shortwavfile = contents{get(handles.listbox_wavfilelist, 'Value')};
Dawn@4 162 matfile = [VSData.vars.PD_matdir VSData.vars.dirdelimiter, shortwavfile(1:end-3) 'mat'];
Dawn@4 163
Dawn@4 164 figdata = guidata(handles.figure_ParameterDisplay); % store it so we don't have to recreate the mat data
Dawn@4 165
Dawn@4 166 if (exist(matfile, 'file') == 0)
Dawn@4 167 set(handles.listbox_paramlist, 'String', []);
Dawn@4 168 mdata = [];
Dawn@4 169 paramlist = [];
Dawn@4 170 else
Dawn@4 171
Dawn@4 172 %load it up and check available parameters
Dawn@4 173 mdata = func_buildMData(matfile, VSData.vars.O_smoothwinsize);
Dawn@4 174
Dawn@4 175 paramlist = func_getoutputparameterlist();
Dawn@4 176 paraminx = 1:length(paramlist);
Dawn@4 177
Dawn@4 178 for k=1:length(paramlist)
Dawn@4 179 C = textscan(paramlist{k}, '%s %s', 'delimiter', '(');
Dawn@4 180 param = C{2}{1}(1:end-1);
Dawn@4 181 if (~isfield(mdata, param))
Dawn@4 182 paraminx(k) = 0;
Dawn@4 183 end
Dawn@4 184 end
Dawn@4 185
Dawn@4 186 paraminx(paraminx == 0) = [];
Dawn@4 187 paramlist = paramlist(paraminx);
Dawn@4 188
Dawn@4 189 end
Dawn@4 190
Dawn@4 191 figdata.mdata = mdata;
Dawn@4 192 guidata(handles.figure_ParameterDisplay, figdata);
Dawn@4 193
Dawn@4 194 set(handles.listbox_paramlist, 'String', paramlist, 'Value', VSData.vars.PD_paramselection);
Dawn@4 195
Dawn@4 196
Dawn@4 197
Dawn@4 198 function edit_wavdir_Callback(hObject, eventdata, handles)
Dawn@4 199 % hObject handle to edit_wavdir (see GCBO)
Dawn@4 200 % eventdata reserved - to be defined in a future version of MATLAB
Dawn@4 201 % handles structure with handles and user data (see GUIDATA)
Dawn@4 202
Dawn@4 203 % Hints: get(hObject,'String') returns contents of edit_wavdir as text
Dawn@4 204 % str2double(get(hObject,'String')) returns contents of edit_wavdir as a double
Dawn@4 205 new_dir = get(hObject, 'String');
Dawn@4 206
Dawn@4 207 VSData = guidata(handles.VSHandle);
Dawn@4 208
Dawn@4 209 if (exist(new_dir, 'dir') == 7)
Dawn@4 210 VSData = func_setwavdir('PD_wavdir', new_dir, VSData);
Dawn@4 211
Dawn@4 212 if (VSData.vars.recursedir)
Dawn@4 213 func_setlistbox(handles.listbox_wavfilelist, new_dir, 'recurse', VSData.vars, VSData.vars.I_searchstring);
Dawn@4 214 else
Dawn@4 215 func_setlistbox(handles.listbox_wavfilelist, new_dir, 'none', VSData.vars, VSData.vars.I_searchstring);
Dawn@4 216 end
Dawn@4 217
Dawn@4 218 if (VSData.vars.PE_savematwithwav)
Dawn@4 219 set(handles.edit_matdir, 'String', new_dir);
Dawn@4 220 VSData = func_setmatdir('PD_matdir', new_dir, VSData);
Dawn@4 221 end
Dawn@4 222
Dawn@4 223 guidata(handles.VSHandle, VSData);
Dawn@4 224 checkParameters(handles);
Dawn@4 225 plotData(handles);
Dawn@4 226 else
Dawn@4 227 msgbox('Error: directory not found.', 'Error', 'error', 'modal');
Dawn@4 228 set(hObject, 'String', VSData.vars.PD_wavdir);
Dawn@4 229 end
Dawn@4 230
Dawn@4 231 % --- Executes during object creation, after setting all properties.
Dawn@4 232 function edit_wavdir_CreateFcn(hObject, eventdata, handles)
Dawn@4 233 % hObject handle to edit_wavdir (see GCBO)
Dawn@4 234 % eventdata reserved - to be defined in a future version of MATLAB
Dawn@4 235 % handles empty - handles not created until after all CreateFcns called
Dawn@4 236
Dawn@4 237 % Hint: edit controls usually have a white background on Windows.
Dawn@4 238 % See ISPC and COMPUTER.
Dawn@4 239 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
Dawn@4 240 set(hObject,'BackgroundColor','white');
Dawn@4 241 end
Dawn@4 242
Dawn@4 243
Dawn@4 244 % --- Executes on button press in pushbutton_wavdir_browse.
Dawn@4 245 function pushbutton_wavdir_browse_Callback(hObject, eventdata, handles)
Dawn@4 246 % hObject handle to pushbutton_wavdir_browse (see GCBO)
Dawn@4 247 % eventdata reserved - to be defined in a future version of MATLAB
Dawn@4 248 % handles structure with handles and user data (see GUIDATA)
Dawn@4 249 current_dir = get(handles.edit_wavdir, 'String');
Dawn@4 250 new_dir = uigetdir(current_dir);
Dawn@4 251
Dawn@4 252 VSData = guidata(handles.VSHandle);
Dawn@4 253
Dawn@4 254 if (ischar(new_dir))
Dawn@4 255
Dawn@4 256 set(handles.edit_wavdir, 'String', new_dir);
Dawn@4 257 func_setlistbox(handles.listbox_wavfilelist, new_dir, 'recurse', VSData.vars, VSData.vars.I_searchstring);
Dawn@4 258 VSData = func_setwavdir('PD_wavdir', new_dir, VSData);
Dawn@4 259
Dawn@4 260 if (VSData.vars.PE_savematwithwav)
Dawn@4 261 set(handles.edit_matdir, 'String', new_dir);
Dawn@4 262 VSData = func_setmatdir('PD_matdir', new_dir, VSData);
Dawn@4 263 end
Dawn@4 264
Dawn@4 265 guidata(handles.VSHandle, VSData);
Dawn@4 266
Dawn@4 267 checkParameters(handles);
Dawn@4 268 plotData(handles);
Dawn@4 269 end
Dawn@4 270
Dawn@4 271
Dawn@4 272
Dawn@4 273 % --- Executes on selection change in listbox_wavfilelist.
Dawn@4 274 function listbox_wavfilelist_Callback(hObject, eventdata, handles)
Dawn@4 275 % hObject handle to listbox_wavfilelist (see GCBO)
Dawn@4 276 % eventdata reserved - to be defined in a future version of MATLAB
Dawn@4 277 % handles structure with handles and user data (see GUIDATA)
Dawn@4 278
Dawn@4 279 % Hints: contents = get(hObject,'String') returns listbox_wavfilelist contents as cell array
Dawn@4 280 % contents{get(hObject,'Value')} returns selected item from listbox_wavfilelist
Dawn@4 281 checkParameters(handles);
Dawn@4 282 plotData(handles);
Dawn@4 283
Dawn@4 284
Dawn@4 285 % --- Executes during object creation, after setting all properties.
Dawn@4 286 function listbox_wavfilelist_CreateFcn(hObject, eventdata, handles)
Dawn@4 287 % hObject handle to listbox_wavfilelist (see GCBO)
Dawn@4 288 % eventdata reserved - to be defined in a future version of MATLAB
Dawn@4 289 % handles empty - handles not created until after all CreateFcns called
Dawn@4 290
Dawn@4 291 % Hint: listbox controls usually have a white background on Windows.
Dawn@4 292 % See ISPC and COMPUTER.
Dawn@4 293 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
Dawn@4 294 set(hObject,'BackgroundColor','white');
Dawn@4 295 end
Dawn@4 296
Dawn@4 297
Dawn@4 298
Dawn@4 299 function edit_matdir_Callback(hObject, eventdata, handles)
Dawn@4 300 % hObject handle to edit_matdir (see GCBO)
Dawn@4 301 % eventdata reserved - to be defined in a future version of MATLAB
Dawn@4 302 % handles structure with handles and user data (see GUIDATA)
Dawn@4 303
Dawn@4 304 new_dir = get(hObject, 'String');
Dawn@4 305
Dawn@4 306 VSData = guidata(handles.VSHandle);
Dawn@4 307
Dawn@4 308 if (exist(new_dir, 'dir') == 7)
Dawn@4 309 VSData = func_setmatdir('PD_matdir', newdir, VSData);
Dawn@4 310 set(handles.edit_matdir, 'String', new_dir);
Dawn@4 311
Dawn@4 312 guidata(handles.VSHandle, VSData);
Dawn@4 313
Dawn@4 314 checkParameters(handles);
Dawn@4 315 plotData(handles);
Dawn@4 316 else
Dawn@4 317 msgbox('Error: directory not found.', 'Error', 'error', 'modal');
Dawn@4 318 set(hObject, 'String', VSData.vars.PD_matdir);
Dawn@4 319 end
Dawn@4 320
Dawn@4 321
Dawn@4 322 % --- Executes during object creation, after setting all properties.
Dawn@4 323 function edit_matdir_CreateFcn(hObject, eventdata, handles)
Dawn@4 324 % hObject handle to edit_matdir (see GCBO)
Dawn@4 325 % eventdata reserved - to be defined in a future version of MATLAB
Dawn@4 326 % handles empty - handles not created until after all CreateFcns called
Dawn@4 327
Dawn@4 328 % Hint: edit controls usually have a white background on Windows.
Dawn@4 329 % See ISPC and COMPUTER.
Dawn@4 330 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
Dawn@4 331 set(hObject,'BackgroundColor','white');
Dawn@4 332 end
Dawn@4 333
Dawn@4 334
Dawn@4 335 % --- Executes on button press in pushbutton_matdir_browse.
Dawn@4 336 function pushbutton_matdir_browse_Callback(hObject, eventdata, handles)
Dawn@4 337 % hObject handle to pushbutton_matdir_browse (see GCBO)
Dawn@4 338 % eventdata reserved - to be defined in a future version of MATLAB
Dawn@4 339 % handles structure with handles and user data (see GUIDATA)
Dawn@4 340 current_dir = get(handles.edit_matdir, 'String');
Dawn@4 341 new_dir = uigetdir(current_dir);
Dawn@4 342
Dawn@4 343 VSData = guidata(handles.VSHandle);
Dawn@4 344
Dawn@4 345 if (ischar(new_dir))
Dawn@4 346 VSData = func_setmatdir('PD_matdir', new_dir, VSData);
Dawn@4 347 set(handles.edit_matdir, 'String', new_dir);
Dawn@4 348
Dawn@4 349 guidata(handles.VSHandle, VSData);
Dawn@4 350
Dawn@4 351 checkParameters(handles);
Dawn@4 352 plotData(handles);
Dawn@4 353
Dawn@4 354 end
Dawn@4 355
Dawn@4 356
Dawn@4 357
Dawn@4 358
Dawn@4 359 % --- Executes on selection change in listbox_paramlist.
Dawn@4 360 function listbox_paramlist_Callback(hObject, eventdata, handles)
Dawn@4 361 % hObject handle to listbox_paramlist (see GCBO)
Dawn@4 362 % eventdata reserved - to be defined in a future version of MATLAB
Dawn@4 363 % handles structure with handles and user data (see GUIDATA)
Dawn@4 364 contents = get(hObject, 'String');
Dawn@4 365
Dawn@4 366 if (isempty(contents))
Dawn@4 367 return;
Dawn@4 368 end
Dawn@4 369
Dawn@4 370 VSData = guidata(handles.VSHandle);
Dawn@4 371 inx = get(hObject, 'Value');
Dawn@4 372 VSData.vars.PD_paramselection = setxor(VSData.vars.PD_paramselection, inx);
Dawn@4 373 VSData.vars.PD_paramselection(VSData.vars.PD_paramselection > length(contents)) = [];
Dawn@4 374
Dawn@4 375 set(hObject, 'Value', VSData.vars.PD_paramselection);
Dawn@4 376 guidata(handles.VSHandle, VSData);
Dawn@4 377
Dawn@4 378 figdata = guidata(handles.figure_ParameterDisplay);
Dawn@4 379 if (~isfield(figdata, 'mdata'))
Dawn@4 380 checkParameters(handles);
Dawn@4 381 end
Dawn@4 382
Dawn@4 383 plotData(handles);
Dawn@4 384
Dawn@4 385
Dawn@4 386 % --- Executes during object creation, after setting all properties.
Dawn@4 387 function listbox_paramlist_CreateFcn(hObject, eventdata, handles)
Dawn@4 388 % hObject handle to listbox_paramlist (see GCBO)
Dawn@4 389 % eventdata reserved - to be defined in a future version of MATLAB
Dawn@4 390 % handles empty - handles not created until after all CreateFcns called
Dawn@4 391
Dawn@4 392 % Hint: listbox controls usually have a white background on Windows.
Dawn@4 393 % See ISPC and COMPUTER.
Dawn@4 394 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
Dawn@4 395 set(hObject,'BackgroundColor','white');
Dawn@4 396 end
Dawn@4 397
Dawn@4 398
Dawn@4 399 % --- Executes on button press in pushbutton_OK.
Dawn@4 400 function pushbutton_OK_Callback(hObject, eventdata, handles)
Dawn@4 401 % hObject handle to pushbutton_OK (see GCBO)
Dawn@4 402 % eventdata reserved - to be defined in a future version of MATLAB
Dawn@4 403 % handles structure with handles and user data (see GUIDATA)
Dawn@4 404
Dawn@4 405 delete(gcf);