comparison Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/vs_OutputToEMU.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_OutputToEMU(varargin)
2 % VS_OUTPUTTOEMU M-file for vs_OutputToEMU.fig
3 % VS_OUTPUTTOEMU, by itself, creates a new VS_OUTPUTTOEMU or raises the existing
4 % singleton*.
5 %
6 % H = VS_OUTPUTTOEMU returns the handle to a new VS_OUTPUTTOEMU or the handle to
7 % the existing singleton*.
8 %
9 % VS_OUTPUTTOEMU('CALLBACK',hObject,eventData,handles,...) calls the local
10 % function named CALLBACK in VS_OUTPUTTOEMU.M with the given input arguments.
11 %
12 % VS_OUTPUTTOEMU('Property','Value',...) creates a new VS_OUTPUTTOEMU or raises the
13 % existing singleton*. Starting from the left, property value pairs are
14 % applied to the GUI before vs_OutputToEMU_OpeningFcn gets called. An
15 % unrecognized property name or invalid value makes property application
16 % stop. All inputs are passed to vs_OutputToEMU_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_OutputToEMU
24
25 % Last Modified by GUIDE v2.5 15-Oct-2009 12:44:26
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_OutputToEMU_OpeningFcn, ...
32 'gui_OutputFcn', @vs_OutputToEMU_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_OutputToEMU is made visible.
48 function vs_OutputToEMU_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_OutputToEMU (see VARARGIN)
54
55 % Choose default command line output for vs_OutputToEMU
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 % Update handles structure
65 guidata(hObject, handles);
66
67 VSData = guidata(handles.VSHandle);
68 set(handles.edit_matdir, 'String', VSData.vars.OTE_matdir);
69 set(handles.edit_outputdir, 'String', VSData.vars.OTE_outputdir);
70
71 if (VSData.vars.recursedir)
72 func_setlistbox(handles.listbox_matfilelist, VSData.vars.OTE_matdir, 'recurse', VSData.vars, '*.mat');
73 else
74 func_setlistbox(handles.listbox_matfilelist, VSData.vars.OTE_matdir, 'none', VSData.vars, '*.mat');
75 end
76
77 paramlist = func_getoutputparameterlist();
78
79 % default is everything selected
80 if (isempty(VSData.vars.OTE_paramselection))
81 VSData.vars.OTE_paramselection = 1:length(paramlist);
82 guidata(handles.VSHandle, VSData);
83 end
84
85 set(handles.listbox_paramlist, 'String', paramlist, 'Value', VSData.vars.OTE_paramselection);
86
87 set(handles.checkbox_saveEMUwithmat, 'Value', VSData.vars.OTE_saveEMUwithmat);
88
89 if (VSData.vars.OTE_saveEMUwithmat)
90 set(handles.edit_outputdir, 'Enable', 'Off');
91 set(handles.pushbutton_outputdir_browse, 'Enable', 'Off');
92 else
93 set(handles.edit_outputdir, 'Enable', 'On');
94 set(handles.pushbutton_outputdir_browse, 'Enable', 'On');
95 end
96
97 set(handles.listbox_matfilelist, 'KeyPressFcn', @filelist_listbox_KeyPressFcn);
98
99
100
101 % UIWAIT makes vs_OutputToEMU wait for user response (see UIRESUME)
102 % uiwait(handles.figure_OutputToEMU);
103
104
105 % --- Outputs from this function are returned to the command line.
106 function varargout = vs_OutputToEMU_OutputFcn(hObject, eventdata, handles)
107 % varargout cell array for returning output args (see VARARGOUT);
108 % hObject handle to figure
109 % eventdata reserved - to be defined in a future version of MATLAB
110 % handles structure with handles and user data (see GUIDATA)
111
112 % Get default command line output from handles structure
113 varargout{1} = handles.output;
114
115
116
117 function edit_matdir_Callback(hObject, eventdata, handles)
118 % hObject handle to edit_matdir (see GCBO)
119 % eventdata reserved - to be defined in a future version of MATLAB
120 % handles structure with handles and user data (see GUIDATA)
121 new_dir = get(handles.edit_matdir, 'String');
122 VSData = guidata(handles.VSHandle);
123
124 if (exist(new_dir, 'dir') == 7)
125 VSData = func_setmatdir('OTE_matdir', new_dir, VSData);
126 set(handles.edit_matdir, 'String', new_dir);
127
128 if (VSData.vars.recursedir)
129 func_setlistbox(handles.listbox_matfilelist, VSData.vars.OTE_matdir, 'recurse', VSData.vars, '*.mat');
130 else
131 func_setlistbox(handles.listbox_matfilelist, VSData.vars.OTE_matdir, 'none', VSData.vars, '*.mat');
132 end
133
134 if (VSData.vars.OTE_saveEMUwithmat)
135 set(handles.edit_outputdir, 'String', new_dir);
136 VSData.vars.OTE_outputdir = new_dir;
137 end
138
139 guidata(handles.VSHandle, VSData);
140 else
141 msgbox('Error: directory not found.', 'Error', 'error', 'modal');
142 set(hObject, 'String', VSData.vars.OTE_matdir);
143 end
144
145 % --- Executes during object creation, after setting all properties.
146 function edit_matdir_CreateFcn(hObject, eventdata, handles)
147 % hObject handle to edit_matdir (see GCBO)
148 % eventdata reserved - to be defined in a future version of MATLAB
149 % handles empty - handles not created until after all CreateFcns called
150
151 % Hint: edit controls usually have a white background on Windows.
152 % See ISPC and COMPUTER.
153 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
154 set(hObject,'BackgroundColor','white');
155 end
156
157
158 % --- Executes on button press in pushbutton_matdir_browse.
159 function pushbutton_matdir_browse_Callback(hObject, eventdata, handles)
160 % hObject handle to pushbutton_matdir_browse (see GCBO)
161 % eventdata reserved - to be defined in a future version of MATLAB
162 % handles structure with handles and user data (see GUIDATA)
163 current_dir = get(handles.edit_matdir, 'String');
164 new_dir = uigetdir(current_dir);
165 VSData = guidata(handles.VSHandle);
166
167 if (ischar(new_dir))
168 VSData = func_setmatdir('OTE_matdir', new_dir, VSData);
169 set(handles.edit_matdir, 'String', new_dir);
170
171 if (VSData.vars.recursedir)
172 func_setlistbox(handles.listbox_matfilelist, VSData.vars.OTE_matdir, 'recurse', VSData.vars, '*.mat');
173 else
174 func_setlistbox(handles.listbox_matfilelist, VSData.vars.OTE_matdir, 'none', VSData.vars, '*.mat');
175 end
176
177 if (VSData.vars.OTE_saveEMUwithmat)
178 set(handles.edit_outputdir, 'String', new_dir);
179 VSData.vars.OTE_outputdir = new_dir;
180 end
181
182 guidata(handles.VSHandle, VSData);
183 end
184
185
186
187 % --- Executes on selection change in listbox_matfilelist.
188 function listbox_matfilelist_Callback(hObject, eventdata, handles)
189 % hObject handle to listbox_matfilelist (see GCBO)
190 % eventdata reserved - to be defined in a future version of MATLAB
191 % handles structure with handles and user data (see GUIDATA)
192
193 % Hints: contents = get(hObject,'String') returns listbox_matfilelist contents as cell array
194 % contents{get(hObject,'Value')} returns selected item from listbox_matfilelist
195
196
197 % --- Executes during object creation, after setting all properties.
198 function listbox_matfilelist_CreateFcn(hObject, eventdata, handles)
199 % hObject handle to listbox_matfilelist (see GCBO)
200 % eventdata reserved - to be defined in a future version of MATLAB
201 % handles empty - handles not created until after all CreateFcns called
202
203 % Hint: listbox controls usually have a white background on Windows.
204 % See ISPC and COMPUTER.
205 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
206 set(hObject,'BackgroundColor','white');
207 end
208
209
210 % --- Executes on selection change in listbox_paramlist.
211 function listbox_paramlist_Callback(hObject, eventdata, handles)
212 % hObject handle to listbox_paramlist (see GCBO)
213 % eventdata reserved - to be defined in a future version of MATLAB
214 % handles structure with handles and user data (see GUIDATA)
215 VSData = guidata(handles.VSHandle);
216
217 inx = get(hObject, 'Value');
218 VSData.vars.OTE_paramselection = setxor(VSData.vars.OTE_paramselection, inx);
219 set(hObject, 'Value', [VSData.vars.OTE_paramselection]);
220 guidata(handles.VSHandle, VSData);
221
222
223 % --- Executes during object creation, after setting all properties.
224 function listbox_paramlist_CreateFcn(hObject, eventdata, handles)
225 % hObject handle to listbox_paramlist (see GCBO)
226 % eventdata reserved - to be defined in a future version of MATLAB
227 % handles empty - handles not created until after all CreateFcns called
228
229 % Hint: listbox controls usually have a white background on Windows.
230 % See ISPC and COMPUTER.
231 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
232 set(hObject,'BackgroundColor','white');
233 end
234
235
236
237 function edit_outputdir_Callback(hObject, eventdata, handles)
238 % hObject handle to edit_outputdir (see GCBO)
239 % eventdata reserved - to be defined in a future version of MATLAB
240 % handles structure with handles and user data (see GUIDATA)
241 new_dir = get(handles.edit_outputdir, 'String');
242 VSData = guidata(handles.VSHandle);
243
244 if (exist(new_dir, 'dir') == 7)
245 VSData.vars.OTE_outputdir = new_dir;
246 set(handles.edit_outputdir, 'String', new_dir);
247 guidata(handles.VSHandle, VSData);
248 else
249 msgbox('Error: directory not found.', 'Error', 'error', 'modal');
250 end
251
252 % --- Executes during object creation, after setting all properties.
253 function edit_outputdir_CreateFcn(hObject, eventdata, handles)
254 % hObject handle to edit_outputdir (see GCBO)
255 % eventdata reserved - to be defined in a future version of MATLAB
256 % handles empty - handles not created until after all CreateFcns called
257
258 % Hint: edit controls usually have a white background on Windows.
259 % See ISPC and COMPUTER.
260 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
261 set(hObject,'BackgroundColor','white');
262 end
263
264
265 % --- Executes on button press in pushbutton_outputdir_browse.
266 function pushbutton_outputdir_browse_Callback(hObject, eventdata, handles)
267 % hObject handle to pushbutton_outputdir_browse (see GCBO)
268 % eventdata reserved - to be defined in a future version of MATLAB
269 % handles structure with handles and user data (see GUIDATA)
270 current_dir = get(handles.edit_outputdir, 'String');
271 new_dir = uigetdir(current_dir);
272 VSData = guidata(handles.VSHandle);
273
274 if (ischar(new_dir))
275 VSData.vars.OTE_outputdir = new_dir;
276 set(handles.edit_outputdir, 'String', new_dir);
277
278 guidata(handles.VSHandle, VSData);
279 end
280
281
282 % --- Executes on button press in togglebutton_start.
283 function togglebutton_start_Callback(hObject, eventdata, handles)
284 % hObject handle to togglebutton_start (see GCBO)
285 % eventdata reserved - to be defined in a future version of MATLAB
286 % handles structure with handles and user data (see GUIDATA)
287
288 VSData = guidata(handles.VSHandle);
289 matfilelist = get(handles.listbox_matfilelist, 'String');
290 if (isempty(matfilelist))
291 msgbox('Error: no mat files found.', 'Error', 'error', 'modal');
292 return;
293 end
294
295 if (isempty(VSData.vars.OTE_paramselection))
296 msgbox('Error: no parameters selected.', 'Error', 'error', 'modal');
297 return;
298 end
299
300 if (get(hObject, 'Value') == 1) % start the process
301 set(hObject, 'String', 'Processing...', 'ForegroundColor', 'red');
302
303 WriteEMUfiles(handles);
304
305 set(hObject, 'String', 'Start!', 'ForegroundColor', 'black', 'Value', 0);
306 end
307
308
309
310
311 function filelist_listbox_KeyPressFcn(hObject, eventdata)
312 handles = guidata(hObject);
313
314 key = double(get(gcbf, 'CurrentCharacter'));
315 if (gcbo == handles.listbox_matfilelist)
316 if (key == 127) % delete key
317
318 inx = get(handles.listbox_matfilelist, 'Value');
319 contents = get(handles.listbox_matfilelist, 'String');
320
321 %nothing to do
322 if (isempty(contents))
323 return;
324 end
325
326 newinx = setxor(inx, [1:length(contents)]);
327
328 newcontents = contents(newinx);
329 set(handles.listbox_matfilelist, 'String', newcontents);
330
331 if (inx(end) > length(newcontents))
332 set(handles.listbox_matfilelist, 'Value', length(newcontents));
333 else
334 set(handles.listbox_matfilelist, 'Value', inx(end));
335 end
336 end
337 end
338
339
340 % --- Executes on button press in checkbox_saveEMUwithmat.
341 function checkbox_saveEMUwithmat_Callback(hObject, eventdata, handles)
342 % hObject handle to checkbox_saveEMUwithmat (see GCBO)
343 % eventdata reserved - to be defined in a future version of MATLAB
344 % handles structure with handles and user data (see GUIDATA)
345
346 % Hint: get(hObject,'Value') returns toggle state of checkbox_saveEMUwithmat
347 VSData = guidata(handles.VSHandle);
348 VSData.vars.OTE_saveEMUwithmat = get(hObject, 'Value');
349
350 if (VSData.vars.OTE_saveEMUwithmat)
351 set(handles.edit_outputdir, 'Enable', 'Off');
352 set(handles.pushbutton_outputdir_browse, 'Enable', 'Off');
353
354 set(handles.edit_outputdir, 'String', VSData.vars.OTE_matdir);
355 VSData.vars.OTE_outputdir = VSData.vars.OTE_matdir;
356
357 else
358 set(handles.edit_outputdir, 'Enable', 'On');
359 set(handles.pushbutton_outputdir_browse, 'Enable', 'On');
360 end
361
362 guidata(handles.VSHandle, VSData);
363
364
365 % -- main outputting function
366 function WriteEMUfiles(handles)
367
368 VSData = guidata(handles.VSHandle);
369 MBox = MessageBox;
370 MBoxHandles = guidata(MBox);
371
372 matfilelist = get(handles.listbox_matfilelist, 'String');
373 messages = cell(length(matfilelist) + 1, 1);
374
375 paramlist = get(handles.listbox_paramlist, 'String');
376 params = paramlist(VSData.vars.OTE_paramselection);
377
378 errcnt = 0;
379
380 for k=1:length(matfilelist)
381 messages{k} = sprintf('%d/%d. %s: ', k, length(matfilelist), matfilelist{k});
382 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
383 set(handles.listbox_matfilelist, 'Value', k);
384 drawnow;
385
386 matfile = [VSData.vars.OTE_matdir VSData.vars.dirdelimiter matfilelist{k}];
387 mdata = func_buildMData(matfile, VSData.vars.O_smoothwinsize);
388
389 for n=1:length(params)
390 C = textscan(params{n}, '%s %s', 'delimiter', '(');
391 param = C{2}{1}(1:end-1);
392
393 if (~isfield(mdata, param))
394 messages{k} = [messages{k} param ' not found, '];
395 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
396 set(handles.listbox_matfilelist, 'Value', k);
397 drawnow;
398 errcnt = errcnt + 1;
399 continue;
400 end
401
402 messages{k} = [messages{k} param ', '];
403 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
404 set(handles.listbox_matfilelist, 'Value', k);
405 drawnow;
406
407 outfile = [VSData.vars.OTE_outputdir VSData.vars.dirdelimiter matfilelist{k}(1:end-3) param];
408
409 % check that the outputdir exists
410 pathname = fileparts(outfile);
411 if (exist(pathname, 'dir') ~= 7)
412 mkdir(pathname);
413 end
414
415 func_VS2ssff(mdata.(param), param, outfile, VSData.vars);
416
417 % check if user has requested a halt
418 if (get(MBoxHandles.figure_MessageBox, 'UserData') == 1)
419 messages{k+1} = 'Stop button pressed.';
420 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k+1);
421 break;
422 end
423
424 end
425
426 if (get(MBoxHandles.figure_MessageBox, 'UserData') == 1)
427 break;
428 end
429
430 end
431
432 messages{length(matfilelist)+1} = sprintf('Completed. %d errors found.', errcnt);
433 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
434 set(handles.listbox_matfilelist, 'Value', k);
435 drawnow;
436
437 set(MBoxHandles.pushbutton_close, 'Enable', 'On');
438 set(MBoxHandles.pushbutton_stop, 'Enable', 'Off');