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