Dawn@4
|
1 function varargout = vs_ParameterEstimation(varargin)
|
Dawn@4
|
2 % VS_PARAMETERESTIMATION M-file for vs_ParameterEstimation.fig
|
Dawn@4
|
3 % VS_PARAMETERESTIMATION, by itself, creates a new VS_PARAMETERESTIMATION or raises the existing
|
Dawn@4
|
4 % singleton*.
|
Dawn@4
|
5 %
|
Dawn@4
|
6 % H = VS_PARAMETERESTIMATION returns the handle to a new VS_PARAMETERESTIMATION or the handle to
|
Dawn@4
|
7 % the existing singleton*.
|
Dawn@4
|
8 %
|
Dawn@4
|
9 % VS_PARAMETERESTIMATION('CALLBACK',hObject,eventData,handles,...) calls the local
|
Dawn@4
|
10 % function named CALLBACK in VS_PARAMETERESTIMATION.M with the given input arguments.
|
Dawn@4
|
11 %
|
Dawn@4
|
12 % VS_PARAMETERESTIMATION('Property','Value',...) creates a new VS_PARAMETERESTIMATION 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_ParameterEstimation_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_ParameterEstimation_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_ParameterEstimation
|
Dawn@4
|
24
|
Dawn@4
|
25 % Last Modified by GUIDE v2.5 19-Oct-2009 11:55:41
|
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_ParameterEstimation_OpeningFcn, ...
|
Dawn@4
|
32 'gui_OutputFcn', @vs_ParameterEstimation_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_ParameterEstimation is made visible.
|
Dawn@4
|
48 function vs_ParameterEstimation_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_ParameterEstimation (see VARARGIN)
|
Dawn@4
|
54
|
Dawn@4
|
55 % Choose default command line output for vs_ParameterEstimation
|
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 % set up the text fields with default values
|
Dawn@4
|
65 setGUIVariables(handles);
|
Dawn@4
|
66
|
Dawn@4
|
67 set(handles.listbox_filelist, 'KeyPressFcn', @filelist_listbox_KeyPressFcn);
|
Dawn@4
|
68
|
Dawn@4
|
69 % Update handles structure
|
Dawn@4
|
70 guidata(hObject, handles);
|
Dawn@4
|
71
|
Dawn@4
|
72 % UIWAIT makes vs_ParameterEstimation wait for user response (see UIRESUME)
|
Dawn@4
|
73 % uiwait(handles.figure_ParameterEstimation);
|
Dawn@4
|
74
|
Dawn@4
|
75
|
Dawn@4
|
76 function setGUIVariables(handles)
|
Dawn@4
|
77 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
78
|
Dawn@4
|
79 set(handles.edit_inputdirectory, 'String', VSData.vars.wavdir);
|
Dawn@4
|
80 set(handles.edit_outputdirectory, 'String', VSData.vars.matdir);
|
Dawn@4
|
81
|
Dawn@4
|
82 set(handles.checkbox_savematwithwav, 'Value', VSData.vars.PE_savematwithwav);
|
Dawn@4
|
83 set(handles.checkbox_process16khz, 'Value', VSData.vars.PE_processwith16k);
|
Dawn@4
|
84 set(handles.checkbox_useTextgrid, 'Value', VSData.vars.PE_useTextgrid);
|
Dawn@4
|
85 set(handles.checkbox_showwaveform, 'Value', VSData.vars.PE_showwaveforms); % turn this off at startup
|
Dawn@4
|
86
|
Dawn@4
|
87
|
Dawn@4
|
88 if (VSData.vars.recursedir)
|
Dawn@4
|
89 func_setlistbox(handles.listbox_filelist, VSData.vars.wavdir, 'recurse', VSData.vars, VSData.vars.I_searchstring);
|
Dawn@4
|
90 else
|
Dawn@4
|
91 func_setlistbox(handles.listbox_filelist, VSData.vars.wavdir, 'none', VSData.vars, VSData.vars.I_searchstring);
|
Dawn@4
|
92 end
|
Dawn@4
|
93
|
Dawn@4
|
94 if (VSData.vars.PE_savematwithwav == 1)
|
Dawn@4
|
95 set(handles.edit_outputdirectory, 'Enable', 'Off');
|
Dawn@4
|
96 set(handles.pushbutton_outputBrowse, 'Enable', 'Off');
|
Dawn@4
|
97 else
|
Dawn@4
|
98 set(handles.edit_outputdirectory, 'Enable', 'On');
|
Dawn@4
|
99 set(handles.pushbutton_outputBrowse, 'Enable', 'On');
|
Dawn@4
|
100 end
|
Dawn@4
|
101
|
Dawn@4
|
102 if (length(VSData.vars.PE_params) == 0)
|
Dawn@4
|
103 set(handles.edit_parameterselection, 'String', 'None');
|
Dawn@4
|
104 elseif (length(VSData.vars.PE_params) == length(func_getparameterlist()))
|
Dawn@4
|
105 set(handles.edit_parameterselection, 'String', 'All');
|
Dawn@4
|
106 else
|
Dawn@4
|
107 set(handles.edit_parameterselection, 'String', 'Custom');
|
Dawn@4
|
108 end
|
Dawn@4
|
109
|
Dawn@4
|
110
|
Dawn@4
|
111
|
Dawn@4
|
112 function filelist_listbox_KeyPressFcn(hObject, eventdata)
|
Dawn@4
|
113 handles = guidata(hObject);
|
Dawn@4
|
114
|
Dawn@4
|
115 key = double(get(gcbf, 'CurrentCharacter'));
|
Dawn@4
|
116 if (gcbo == handles.listbox_filelist)
|
Dawn@4
|
117 if (key == 127) % delete key
|
Dawn@4
|
118
|
Dawn@4
|
119 inx = get(handles.listbox_filelist, 'Value');
|
Dawn@4
|
120 contents = get(handles.listbox_filelist, 'String');
|
Dawn@4
|
121
|
Dawn@4
|
122 %nothing to do
|
Dawn@4
|
123 if (isempty(contents))
|
Dawn@4
|
124 return;
|
Dawn@4
|
125 end
|
Dawn@4
|
126
|
Dawn@4
|
127 newinx = setxor(inx, [1:length(contents)]);
|
Dawn@4
|
128
|
Dawn@4
|
129 newcontents = contents(newinx);
|
Dawn@4
|
130 set(handles.listbox_filelist, 'String', newcontents);
|
Dawn@4
|
131
|
Dawn@4
|
132 if (inx(end) > length(newcontents))
|
Dawn@4
|
133 set(handles.listbox_filelist, 'Value', length(newcontents));
|
Dawn@4
|
134 else
|
Dawn@4
|
135 set(handles.listbox_filelist, 'Value', inx(end));
|
Dawn@4
|
136 end
|
Dawn@4
|
137 end
|
Dawn@4
|
138 end
|
Dawn@4
|
139
|
Dawn@4
|
140
|
Dawn@4
|
141
|
Dawn@4
|
142 % --- Outputs from this function are returned to the command line.
|
Dawn@4
|
143 function varargout = vs_ParameterEstimation_OutputFcn(hObject, eventdata, handles)
|
Dawn@4
|
144 % varargout cell array for returning output args (see VARARGOUT);
|
Dawn@4
|
145 % hObject handle to figure
|
Dawn@4
|
146 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
147 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
148
|
Dawn@4
|
149 % Get default command line output from handles structure
|
Dawn@4
|
150 varargout{1} = handles.output;
|
Dawn@4
|
151
|
Dawn@4
|
152
|
Dawn@4
|
153 % --- Executes on selection change in listbox_filelist.
|
Dawn@4
|
154 function listbox_filelist_Callback(hObject, eventdata, handles)
|
Dawn@4
|
155 % hObject handle to listbox_filelist (see GCBO)
|
Dawn@4
|
156 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
157 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
158
|
Dawn@4
|
159 if (get(handles.checkbox_showwaveform, 'Value') == 1)
|
Dawn@4
|
160 plotCurrentWav(handles);
|
Dawn@4
|
161 end
|
Dawn@4
|
162
|
Dawn@4
|
163
|
Dawn@4
|
164 % --- Executes during object creation, after setting all properties.
|
Dawn@4
|
165 function listbox_filelist_CreateFcn(hObject, eventdata, handles)
|
Dawn@4
|
166 % hObject handle to listbox_filelist (see GCBO)
|
Dawn@4
|
167 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
168 % handles empty - handles not created until after all CreateFcns called
|
Dawn@4
|
169
|
Dawn@4
|
170 % Hint: listbox controls usually have a white background on Windows.
|
Dawn@4
|
171 % See ISPC and COMPUTER.
|
Dawn@4
|
172 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
|
Dawn@4
|
173 set(hObject,'BackgroundColor','white');
|
Dawn@4
|
174 end
|
Dawn@4
|
175
|
Dawn@4
|
176
|
Dawn@4
|
177
|
Dawn@4
|
178 function edit_inputdirectory_Callback(hObject, eventdata, handles)
|
Dawn@4
|
179 % hObject handle to edit_inputdirectory (see GCBO)
|
Dawn@4
|
180 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
181 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
182 new_dir = get(handles.edit_inputdirectory, 'String');
|
Dawn@4
|
183
|
Dawn@4
|
184 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
185
|
Dawn@4
|
186 if (exist(new_dir, 'dir') == 7) % check if new_dir exists
|
Dawn@4
|
187 VSData.vars.wavdir = new_dir;
|
Dawn@4
|
188 set(handles.edit_inputdirectory, 'String', new_dir);
|
Dawn@4
|
189
|
Dawn@4
|
190 if (get(handles.checkbox_savematwithwav, 'Value') == 1) % change output dir too
|
Dawn@4
|
191 set(handles.edit_outputdirectory, 'String', new_dir);
|
Dawn@4
|
192
|
Dawn@4
|
193 VSData = func_setmatdir('matdir', new_dir, VSData);
|
Dawn@4
|
194 end
|
Dawn@4
|
195
|
Dawn@4
|
196 % update the listbox
|
Dawn@4
|
197 if (VSData.vars.recursedir == 1)
|
Dawn@4
|
198 func_setlistbox(handles.listbox_filelist, new_dir, 'recurse', VSData.vars, VSData.vars.I_searchstring);
|
Dawn@4
|
199 else
|
Dawn@4
|
200 func_setlistbox(handles.listbox_filelist, new_dir, 'none', VSData.vars, VSData.vars.I_searchstring);
|
Dawn@4
|
201 end
|
Dawn@4
|
202
|
Dawn@4
|
203 VSData = func_setwavdir('wavdir', new_dir, VSData);
|
Dawn@4
|
204
|
Dawn@4
|
205 % update the variables
|
Dawn@4
|
206 guidata(handles.VSHandle, VSData);
|
Dawn@4
|
207 else
|
Dawn@4
|
208 msgbox('Error: directory not found.', 'Error', 'error', 'modal');
|
Dawn@4
|
209 set(hObject, 'String', VSData.vars.wavdir);
|
Dawn@4
|
210 end
|
Dawn@4
|
211
|
Dawn@4
|
212
|
Dawn@4
|
213 % --- Executes during object creation, after setting all properties.
|
Dawn@4
|
214 function edit_inputdirectory_CreateFcn(hObject, eventdata, handles)
|
Dawn@4
|
215 % hObject handle to edit_inputdirectory (see GCBO)
|
Dawn@4
|
216 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
217 % handles empty - handles not created until after all CreateFcns called
|
Dawn@4
|
218
|
Dawn@4
|
219 % Hint: edit controls usually have a white background on Windows.
|
Dawn@4
|
220 % See ISPC and COMPUTER.
|
Dawn@4
|
221 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
|
Dawn@4
|
222 set(hObject,'BackgroundColor','white');
|
Dawn@4
|
223 end
|
Dawn@4
|
224
|
Dawn@4
|
225
|
Dawn@4
|
226 % --- Executes on button press in pushbutton_inputBrowse.
|
Dawn@4
|
227 function pushbutton_inputBrowse_Callback(hObject, eventdata, handles)
|
Dawn@4
|
228 % hObject handle to pushbutton_inputBrowse (see GCBO)
|
Dawn@4
|
229 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
230 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
231 current_dir = get(handles.edit_inputdirectory, 'String');
|
Dawn@4
|
232 new_dir = uigetdir(current_dir);
|
Dawn@4
|
233
|
Dawn@4
|
234 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
235
|
Dawn@4
|
236 if (ischar(new_dir)) % check if a new dir was returned
|
Dawn@4
|
237 VSData.vars.wavdir = new_dir;
|
Dawn@4
|
238 set(handles.edit_inputdirectory, 'String', new_dir);
|
Dawn@4
|
239
|
Dawn@4
|
240 if (get(handles.checkbox_savematwithwav, 'Value') == 1) % change output dir too
|
Dawn@4
|
241 set(handles.edit_outputdirectory, 'String', new_dir);
|
Dawn@4
|
242
|
Dawn@4
|
243 VSData = func_setmatdir('matdir', new_dir, VSData);
|
Dawn@4
|
244 end
|
Dawn@4
|
245
|
Dawn@4
|
246 % update the listbox
|
Dawn@4
|
247 if (VSData.vars.recursedir == 1)
|
Dawn@4
|
248 func_setlistbox(handles.listbox_filelist, new_dir, 'recurse', VSData.vars, VSData.vars.I_searchstring);
|
Dawn@4
|
249 else
|
Dawn@4
|
250 func_setlistbox(handles.listbox_filelist, new_dir, 'none', VSData.vars, VSData.vars.I_searchstring);
|
Dawn@4
|
251 end
|
Dawn@4
|
252
|
Dawn@4
|
253 VSData = func_setwavdir('wavdir', new_dir, VSData);
|
Dawn@4
|
254
|
Dawn@4
|
255 % update the variables
|
Dawn@4
|
256 guidata(handles.VSHandle, VSData);
|
Dawn@4
|
257 end
|
Dawn@4
|
258
|
Dawn@4
|
259
|
Dawn@4
|
260
|
Dawn@4
|
261 function edit_outputdirectory_Callback(hObject, eventdata, handles)
|
Dawn@4
|
262 % hObject handle to edit_outputdirectory (see GCBO)
|
Dawn@4
|
263 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
264 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
265
|
Dawn@4
|
266 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
267
|
Dawn@4
|
268 if (strcmp(get(hObject, 'Enable'), 'on'))
|
Dawn@4
|
269 new_dir = get(handles.edit_outputdirectory, 'String');
|
Dawn@4
|
270
|
Dawn@4
|
271 if (exist(new_dir, 'dir') == 7)
|
Dawn@4
|
272 set(handles.edit_outputdirectory, 'String', new_dir);
|
Dawn@4
|
273
|
Dawn@4
|
274 VSData = func_setmatdir('matdir', new_dir, VSData);
|
Dawn@4
|
275
|
Dawn@4
|
276 guidata(handles.VSHandle, VSData);
|
Dawn@4
|
277 else
|
Dawn@4
|
278 msgbox('Error: Directory not found.', 'Error', 'error', 'modal');
|
Dawn@4
|
279 set(hObject, 'String', VSData.vars.matdir);
|
Dawn@4
|
280 end
|
Dawn@4
|
281 end
|
Dawn@4
|
282
|
Dawn@4
|
283 % --- Executes during object creation, after setting all properties.
|
Dawn@4
|
284 function edit_outputdirectory_CreateFcn(hObject, eventdata, handles)
|
Dawn@4
|
285 % hObject handle to edit_outputdirectory (see GCBO)
|
Dawn@4
|
286 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
287 % handles empty - handles not created until after all CreateFcns called
|
Dawn@4
|
288
|
Dawn@4
|
289 % Hint: edit controls usually have a white background on Windows.
|
Dawn@4
|
290 % See ISPC and COMPUTER.
|
Dawn@4
|
291 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
|
Dawn@4
|
292 set(hObject,'BackgroundColor','white');
|
Dawn@4
|
293 end
|
Dawn@4
|
294
|
Dawn@4
|
295
|
Dawn@4
|
296 % --- Executes on button press in pushbutton_outputBrowse.
|
Dawn@4
|
297 function pushbutton_outputBrowse_Callback(hObject, eventdata, handles)
|
Dawn@4
|
298 % hObject handle to pushbutton_outputBrowse (see GCBO)
|
Dawn@4
|
299 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
300 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
301
|
Dawn@4
|
302 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
303
|
Dawn@4
|
304 if (strcmp(get(hObject, 'Enable'), 'on'))
|
Dawn@4
|
305 curr_dir = get(handles.edit_outputdirectory, 'String');
|
Dawn@4
|
306 new_dir = uigetdir(curr_dir);
|
Dawn@4
|
307
|
Dawn@4
|
308 if (ischar(new_dir))
|
Dawn@4
|
309 set(handles.edit_outputdirectory, 'String', new_dir);
|
Dawn@4
|
310
|
Dawn@4
|
311 VSData = func_setmatdir('matdir', new_dir, VSData);
|
Dawn@4
|
312
|
Dawn@4
|
313 guidata(handles.VSHandle, VSData);
|
Dawn@4
|
314 end
|
Dawn@4
|
315 end
|
Dawn@4
|
316
|
Dawn@4
|
317
|
Dawn@4
|
318 % --- Executes on button press in checkbox_savematwithwav.
|
Dawn@4
|
319 function checkbox_savematwithwav_Callback(hObject, eventdata, handles)
|
Dawn@4
|
320 % hObject handle to checkbox_savematwithwav (see GCBO)
|
Dawn@4
|
321 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
322 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
323
|
Dawn@4
|
324 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
325 VSData.vars.PE_savematwithwav = get(hObject, 'Value');
|
Dawn@4
|
326
|
Dawn@4
|
327 if (get(hObject, 'Value') == 1) % link input with output directory
|
Dawn@4
|
328 VSData = func_setmatdir('matdir', VSData.vars.wavdir, VSData);
|
Dawn@4
|
329
|
Dawn@4
|
330 set(handles.edit_outputdirectory, 'String', VSData.vars.matdir);
|
Dawn@4
|
331 set(handles.edit_outputdirectory, 'Enable', 'off');
|
Dawn@4
|
332 set(handles.pushbutton_outputBrowse, 'Enable', 'off');
|
Dawn@4
|
333 else
|
Dawn@4
|
334 %enable user to pick output directory
|
Dawn@4
|
335 set(handles.edit_outputdirectory, 'Enable', 'on');
|
Dawn@4
|
336 set(handles.pushbutton_outputBrowse, 'Enable', 'on');
|
Dawn@4
|
337 end
|
Dawn@4
|
338
|
Dawn@4
|
339 guidata(handles.VSHandle, VSData);
|
Dawn@4
|
340
|
Dawn@4
|
341
|
Dawn@4
|
342
|
Dawn@4
|
343
|
Dawn@4
|
344
|
Dawn@4
|
345 % --- Executes on button press in pushbutton_ParameterSelection.
|
Dawn@4
|
346 function pushbutton_ParameterSelection_Callback(hObject, eventdata, handles)
|
Dawn@4
|
347 % hObject handle to pushbutton_ParameterSelection (see GCBO)
|
Dawn@4
|
348 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
349 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
350
|
Dawn@4
|
351 % save the old file list
|
Dawn@4
|
352 filelist = get(handles.listbox_filelist, 'String');
|
Dawn@4
|
353 fileinx = get(handles.listbox_filelist, 'Value');
|
Dawn@4
|
354 vs_SelectParameters();
|
Dawn@4
|
355 set(handles.listbox_filelist, 'String', filelist, 'Value', fileinx);
|
Dawn@4
|
356
|
Dawn@4
|
357
|
Dawn@4
|
358
|
Dawn@4
|
359 function edit_parameterselection_Callback(hObject, eventdata, handles)
|
Dawn@4
|
360 % hObject handle to edit_parameterselection (see GCBO)
|
Dawn@4
|
361 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
362 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
363
|
Dawn@4
|
364 % Hints: get(hObject,'String') returns contents of edit_parameterselection as text
|
Dawn@4
|
365 % str2double(get(hObject,'String')) returns contents of edit_parameterselection as a double
|
Dawn@4
|
366
|
Dawn@4
|
367
|
Dawn@4
|
368 % --- Executes during object creation, after setting all properties.
|
Dawn@4
|
369 function edit_parameterselection_CreateFcn(hObject, eventdata, handles)
|
Dawn@4
|
370 % hObject handle to edit_parameterselection (see GCBO)
|
Dawn@4
|
371 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
372 % handles empty - handles not created until after all CreateFcns called
|
Dawn@4
|
373
|
Dawn@4
|
374 % Hint: edit controls usually have a white background on Windows.
|
Dawn@4
|
375 % See ISPC and COMPUTER.
|
Dawn@4
|
376 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
|
Dawn@4
|
377 set(hObject,'BackgroundColor','white');
|
Dawn@4
|
378 end
|
Dawn@4
|
379
|
Dawn@4
|
380
|
Dawn@4
|
381 % --- Executes on button press in checkbox_process16khz.
|
Dawn@4
|
382 function checkbox_process16khz_Callback(hObject, eventdata, handles)
|
Dawn@4
|
383 % hObject handle to checkbox_process16khz (see GCBO)
|
Dawn@4
|
384 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
385 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
386
|
Dawn@4
|
387 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
388 VSData.vars.PE_processwith16k = get(hObject, 'Value');
|
Dawn@4
|
389 guidata(handles.VSHandle, VSData);
|
Dawn@4
|
390
|
Dawn@4
|
391
|
Dawn@4
|
392 % --- Executes on button press in checkbox_useTextgrid.
|
Dawn@4
|
393 function checkbox_useTextgrid_Callback(hObject, eventdata, handles)
|
Dawn@4
|
394 % hObject handle to checkbox_useTextgrid (see GCBO)
|
Dawn@4
|
395 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
396 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
397 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
398 VSData.vars.PE_useTextgrid = get(hObject, 'Value');
|
Dawn@4
|
399 guidata(handles.VSHandle, VSData);
|
Dawn@4
|
400
|
Dawn@4
|
401
|
Dawn@4
|
402 % --- Executes on button press in checkbox_showwaveform.
|
Dawn@4
|
403 function checkbox_showwaveform_Callback(hObject, eventdata, handles)
|
Dawn@4
|
404 % hObject handle to checkbox_showwaveform (see GCBO)
|
Dawn@4
|
405 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
406 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
407 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
408 VSData.vars.PE_showwaveforms = get(hObject, 'Value');
|
Dawn@4
|
409 guidata(handles.VSHandle, VSData);
|
Dawn@4
|
410
|
Dawn@4
|
411 if (get(hObject, 'Value') == 1)
|
Dawn@4
|
412 SWfig = vs_ShowWaveform;
|
Dawn@4
|
413 SWhandle = guidata(SWfig);
|
Dawn@4
|
414
|
Dawn@4
|
415 handles.SWfig = SWfig;
|
Dawn@4
|
416 handles.SWhandle = SWhandle;
|
Dawn@4
|
417 guidata(hObject, handles);
|
Dawn@4
|
418
|
Dawn@4
|
419 plotCurrentWav(handles);
|
Dawn@4
|
420 else
|
Dawn@4
|
421 if (isfield(handles, 'SWfig'))
|
Dawn@4
|
422 delete(handles.SWfig);
|
Dawn@4
|
423 handles = rmfield(handles, 'SWfig');
|
Dawn@4
|
424 guidata(hObject, handles);
|
Dawn@4
|
425 end
|
Dawn@4
|
426 end
|
Dawn@4
|
427
|
Dawn@4
|
428
|
Dawn@4
|
429 % --- plots the current wavfile into handles.SWhandle.axes_main
|
Dawn@4
|
430 function plotCurrentWav(handles)
|
Dawn@4
|
431 % get the present file selected
|
Dawn@4
|
432 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
433
|
Dawn@4
|
434 contents = get(handles.listbox_filelist, 'String');
|
Dawn@4
|
435 if (isempty(contents))
|
Dawn@4
|
436 return; % do nothing
|
Dawn@4
|
437 end
|
Dawn@4
|
438 inx = get(handles.listbox_filelist, 'Value');
|
Dawn@4
|
439 filename = contents{inx};
|
Dawn@4
|
440 directory = get(handles.edit_inputdirectory, 'String');
|
Dawn@4
|
441 wavfile = [directory VSData.vars.dirdelimiter filename];
|
Dawn@4
|
442
|
Dawn@4
|
443 [y,Fs] = wavread(wavfile);
|
Dawn@4
|
444 t = linspace(0,length(y)/Fs*1000, length(y));
|
Dawn@4
|
445 plot(handles.SWhandle.axes_main, t, y);
|
Dawn@4
|
446 ylabel(handles.SWhandle.axes_main, 'Amplitude');
|
Dawn@4
|
447 xlabel(handles.SWhandle.axes_main, 'Time (ms)');
|
Dawn@4
|
448 axis(handles.SWhandle.axes_main, 'tight');
|
Dawn@4
|
449 set(handles.SWhandle.figure_ShowWaveform, 'Name', filename);
|
Dawn@4
|
450
|
Dawn@4
|
451
|
Dawn@4
|
452 % --- Executes on button press in togglebutton_start.
|
Dawn@4
|
453 function togglebutton_start_Callback(hObject, eventdata, handles)
|
Dawn@4
|
454 % hObject handle to togglebutton_start (see GCBO)
|
Dawn@4
|
455 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
456 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
457
|
Dawn@4
|
458 if (get(hObject, 'Value') == 1) % start the process
|
Dawn@4
|
459 set(hObject, 'String', 'Processing...', 'ForegroundColor', 'red');
|
Dawn@4
|
460
|
Dawn@4
|
461 BatchProcess(handles);
|
Dawn@4
|
462 set(hObject, 'String', 'Start!', 'ForegroundColor', 'black', 'Value', 0);
|
Dawn@4
|
463
|
Dawn@4
|
464 end
|
Dawn@4
|
465
|
Dawn@4
|
466
|
Dawn@4
|
467
|
Dawn@4
|
468 % this is the main parameter estimation function
|
Dawn@4
|
469 function BatchProcess(handles)
|
Dawn@4
|
470 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
471 filelist = get(handles.listbox_filelist, 'String');
|
Dawn@4
|
472 paramlist = VSData.vars.PE_params;
|
Dawn@4
|
473
|
Dawn@4
|
474 if (isempty(filelist))
|
Dawn@4
|
475 msgbox('No input files.', 'Error', 'warn', 'modal');
|
Dawn@4
|
476 return;
|
Dawn@4
|
477 end
|
Dawn@4
|
478
|
Dawn@4
|
479 if (isempty(paramlist))
|
Dawn@4
|
480 msgbox('No parameters selected.', 'Error', 'warn', 'modal');
|
Dawn@4
|
481 return;
|
Dawn@4
|
482 end
|
Dawn@4
|
483
|
Dawn@4
|
484 MBox = MessageBox;
|
Dawn@4
|
485 MBoxHandles = guidata(MBox);
|
Dawn@4
|
486
|
Dawn@4
|
487 messages = cell(length(filelist)+1, 1); % allocate some memory for messages
|
Dawn@4
|
488
|
Dawn@4
|
489 % get the variables from settings
|
Dawn@4
|
490 windowsize = VSData.vars.windowsize;
|
Dawn@4
|
491 frameshift = VSData.vars.frameshift;
|
Dawn@4
|
492 preemphasis = VSData.vars.preemphasis;
|
Dawn@4
|
493 F0algorithm = VSData.vars.F0algorithm;
|
Dawn@4
|
494 FMTalgorithm = VSData.vars.FMTalgorithm;
|
Dawn@4
|
495 maxF0 = VSData.vars.maxF0;
|
Dawn@4
|
496 minF0 = VSData.vars.minF0;
|
Dawn@4
|
497 frame_precision = VSData.vars.frame_precision; % used for Praat f0/formant
|
Dawn@4
|
498 % estimation, SHR algorithm
|
Dawn@4
|
499 % to set precision for time
|
Dawn@4
|
500 % alignment of data
|
Dawn@4
|
501 % vectors, in terms of frames
|
Dawn@4
|
502
|
Dawn@4
|
503 inputdir = get(handles.edit_inputdirectory, 'String');
|
Dawn@4
|
504 outputdir = get(handles.edit_outputdirectory, 'String');
|
Dawn@4
|
505
|
Dawn@4
|
506 % start the processing of each file
|
Dawn@4
|
507 for k=1:length(filelist)
|
Dawn@4
|
508 % check if 'stop' button has been pressed
|
Dawn@4
|
509 if (~ishandle(MBoxHandles.figure_MessageBox) || get(MBoxHandles.figure_MessageBox, 'UserData') == 1)
|
Dawn@4
|
510 messages{k} = 'Stop button pressed by user.';
|
Dawn@4
|
511 if (ishandle(MBoxHandles.figure_MessageBox))
|
Dawn@4
|
512 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
513 end
|
Dawn@4
|
514 return;
|
Dawn@4
|
515 end
|
Dawn@4
|
516
|
Dawn@4
|
517 messages{k} = sprintf('%d/%d. %s: ', k, length(filelist), filelist{k});
|
Dawn@4
|
518 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
519 set(handles.listbox_filelist, 'Value', k);
|
Dawn@4
|
520 drawnow;
|
Dawn@4
|
521
|
Dawn@4
|
522 wavfile = [inputdir VSData.vars.dirdelimiter filelist{k}];
|
Dawn@4
|
523 matfile = [outputdir VSData.vars.dirdelimiter filelist{k}(1:end-3) 'mat'];
|
Dawn@4
|
524 textgridfile = [wavfile(1:end-3) 'Textgrid'];
|
Dawn@4
|
525
|
Dawn@4
|
526 % strip down the matfile and check if the directory exists
|
Dawn@4
|
527 mdir = fileparts(matfile);
|
Dawn@4
|
528 if (exist(mdir, 'dir') ~= 7)
|
Dawn@4
|
529 mkdir(mdir);
|
Dawn@4
|
530 end
|
Dawn@4
|
531
|
Dawn@4
|
532 % check if we are showing the waveforms
|
Dawn@4
|
533 if (get(handles.checkbox_showwaveform, 'Value') == 1)
|
Dawn@4
|
534 plotCurrentWav(handles);
|
Dawn@4
|
535 end
|
Dawn@4
|
536
|
Dawn@4
|
537 % check to see if we're using textgrids
|
Dawn@4
|
538 useTextgrid = get(handles.checkbox_useTextgrid, 'Value');
|
Dawn@4
|
539 if (useTextgrid == 1)
|
Dawn@4
|
540 if (exist(textgridfile, 'file') == 0)
|
Dawn@4
|
541 useTextgrid = 0;
|
Dawn@4
|
542 end
|
Dawn@4
|
543 end
|
Dawn@4
|
544
|
Dawn@4
|
545 % read in the wav file
|
Dawn@4
|
546 [y, Fs, nbits] = wavread(wavfile);
|
Dawn@4
|
547
|
Dawn@4
|
548 if (size(y, 2) > 1)
|
Dawn@4
|
549 messages{k} = [messages{k} ' Multi-channel wav file - using first channel only: '];
|
Dawn@4
|
550 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
551 drawnow;
|
Dawn@4
|
552 y = y(:,1);
|
Dawn@4
|
553 end
|
Dawn@4
|
554
|
Dawn@4
|
555 % see if we need to resample to 16 kHz (faster for Straight)
|
Dawn@4
|
556 resampled = 0;
|
Dawn@4
|
557 if (get(handles.checkbox_process16khz, 'Value') == 1)
|
Dawn@4
|
558 if (Fs ~= 16000)
|
Dawn@4
|
559 y = resample(y, 16000, Fs);
|
Dawn@4
|
560 wavfile = generateRandomFile(wavfile, handles);
|
Dawn@4
|
561 wavfile = [wavfile(1:end-4) '_16kHz.wav'];
|
Dawn@4
|
562 warning off; % stop clipping messages
|
Dawn@4
|
563 wavwrite(y, 16000, nbits, wavfile);
|
Dawn@4
|
564 warning on;
|
Dawn@4
|
565 resampled = 1;
|
Dawn@4
|
566 end
|
Dawn@4
|
567 [y, Fs] = wavread(wavfile); % reread the resampled file
|
Dawn@4
|
568 end
|
Dawn@4
|
569
|
Dawn@4
|
570 % calculate the length of data vectors - all measures will have this
|
Dawn@4
|
571 % length - important!!
|
Dawn@4
|
572 data_len = floor(length(y) / Fs * 1000 / frameshift);
|
Dawn@4
|
573
|
Dawn@4
|
574 % parse the parameter list to get proper ordering
|
Dawn@4
|
575 paramlist = func_parseParameters(paramlist, handles, matfile, data_len);
|
Dawn@4
|
576
|
Dawn@4
|
577 for n=1:length(paramlist)
|
Dawn@4
|
578
|
Dawn@4
|
579 % check if 'stop' button has been pressed
|
Dawn@4
|
580 if (~ishandle(MBoxHandles.figure_MessageBox) || get(MBoxHandles.figure_MessageBox, 'UserData') == 1)
|
Dawn@4
|
581 break;
|
Dawn@4
|
582 end
|
Dawn@4
|
583
|
Dawn@4
|
584
|
Dawn@4
|
585 % F0 straight
|
Dawn@4
|
586 if (strcmp(paramlist{n}, 'F0 (Straight)'))
|
Dawn@4
|
587 messages{k} = [messages{k} 'strF0 '];
|
Dawn@4
|
588 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
589 drawnow;
|
Dawn@4
|
590 err = 0;
|
Dawn@4
|
591
|
Dawn@4
|
592 if (useTextgrid)
|
Dawn@4
|
593 try
|
Dawn@4
|
594 [strF0, V] = func_StraightPitch(y, Fs, VSData.vars, textgridfile);
|
Dawn@4
|
595 catch
|
Dawn@4
|
596 err = 1;
|
Dawn@4
|
597 end
|
Dawn@4
|
598 else
|
Dawn@4
|
599 try
|
Dawn@4
|
600 [strF0, V] = func_StraightPitch(y, Fs, VSData.vars);
|
Dawn@4
|
601 catch
|
Dawn@4
|
602 err = 1;
|
Dawn@4
|
603 end
|
Dawn@4
|
604 end
|
Dawn@4
|
605
|
Dawn@4
|
606 if (strcmp(VSData.vars.F0algorithm, 'F0 (Straight)') && err == 1)
|
Dawn@4
|
607 messages{k+1} = 'Error: Problem with STRAIGHT - please check settings';
|
Dawn@4
|
608 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k+1);
|
Dawn@4
|
609 set(MBoxHandles.pushbutton_close, 'Enable', 'on');
|
Dawn@4
|
610 set(MBoxHandles.pushbutton_stop, 'Enable', 'off');
|
Dawn@4
|
611
|
Dawn@4
|
612 msgbox({'Error: Unable to proceed.', 'Problem with STRAIGHT - please check settings'}, 'Error', 'error', 'modal');
|
Dawn@4
|
613 if (resampled) % delete the temporary file if it exists
|
Dawn@4
|
614 delete(wavfile);
|
Dawn@4
|
615 end
|
Dawn@4
|
616 return;
|
Dawn@4
|
617 end
|
Dawn@4
|
618
|
Dawn@4
|
619 strF0 = strF0(1:frameshift:end); % drop samples if necessary
|
Dawn@4
|
620
|
Dawn@4
|
621 if (length(strF0) > data_len)
|
Dawn@4
|
622 strF0 = strF0(1:data_len);
|
Dawn@4
|
623 elseif (length(strF0) < data_len)
|
Dawn@4
|
624 strF0 = [strF0; ones(data_len - length(strF0), 1) * NaN];
|
Dawn@4
|
625 end
|
Dawn@4
|
626
|
Dawn@4
|
627 if (exist(matfile, 'file'))
|
Dawn@4
|
628 save(matfile, 'strF0', 'Fs', '-append');
|
Dawn@4
|
629 else
|
Dawn@4
|
630 save(matfile, 'strF0', 'Fs');
|
Dawn@4
|
631 end
|
Dawn@4
|
632
|
Dawn@4
|
633
|
Dawn@4
|
634 % F0 (Snack)
|
Dawn@4
|
635 elseif (strcmp(paramlist{n}, 'F0 (Snack)'))
|
Dawn@4
|
636 messages{k} = [messages{k} 'sF0 '];
|
Dawn@4
|
637 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
638 drawnow;
|
Dawn@4
|
639
|
Dawn@4
|
640 % guard case for 32-bit precision files - some version of snack
|
Dawn@4
|
641 % on a 64-bit machine causes pitch estimation to fail
|
Dawn@4
|
642 use_alt_file = 0;
|
Dawn@4
|
643 if (nbits ~= 16)
|
Dawn@4
|
644 snackwavfile = [wavfile(1:end-4) '_16b.wav'];
|
Dawn@4
|
645 use_alt_file = 1;
|
Dawn@4
|
646 wavwrite(y, Fs, 16, snackwavfile);
|
Dawn@4
|
647 else
|
Dawn@4
|
648 snackwavfile = wavfile;
|
Dawn@4
|
649 end
|
Dawn@4
|
650
|
Dawn@4
|
651 err = 0;
|
Dawn@4
|
652 try
|
Dawn@4
|
653 [sF0, sV, err] = func_SnackPitch(snackwavfile, windowsize/1000, frameshift/1000, maxF0, minF0);
|
Dawn@4
|
654 catch
|
Dawn@4
|
655 err = 1;
|
Dawn@4
|
656 end
|
Dawn@4
|
657
|
Dawn@4
|
658 % check for fatal errors
|
Dawn@4
|
659 if (strcmp(VSData.vars.F0algorithm, 'F0 (Snack)') && err == 1)
|
Dawn@4
|
660 messages{k+1} = 'Error: Problem with snack - please check settings';
|
Dawn@4
|
661 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k+1);
|
Dawn@4
|
662 set(MBoxHandles.pushbutton_close, 'Enable', 'on');
|
Dawn@4
|
663 set(MBoxHandles.pushbutton_stop, 'Enable', 'off');
|
Dawn@4
|
664
|
Dawn@4
|
665 msgbox({'Error: Unable to proceed.', 'Problem with snack - please check settings'}, 'Error', 'error', 'modal');
|
Dawn@4
|
666 if (resampled) % delete the temporary file if it exists
|
Dawn@4
|
667 delete(wavfile);
|
Dawn@4
|
668 end
|
Dawn@4
|
669 if (use_alt_file)
|
Dawn@4
|
670 delete(snackwavfile);
|
Dawn@4
|
671 end
|
Dawn@4
|
672 return;
|
Dawn@4
|
673 end
|
Dawn@4
|
674
|
Dawn@4
|
675 sF0 = [zeros(floor(windowsize/frameshift/2),1)*NaN; sF0]; sF0 = [sF0; ones(data_len-length(sF0), 1)*NaN];
|
Dawn@4
|
676 sV = [zeros(floor(windowsize/frameshift/2),1)*NaN; sV]; sV = [sV; ones(data_len-length(sV), 1)* NaN];
|
Dawn@4
|
677
|
Dawn@4
|
678 if (exist(matfile, 'file'))
|
Dawn@4
|
679 save(matfile, 'sF0', 'sV', 'Fs', '-append');
|
Dawn@4
|
680 else
|
Dawn@4
|
681 save(matfile, 'sF0', 'sV', 'Fs');
|
Dawn@4
|
682 end
|
Dawn@4
|
683
|
Dawn@4
|
684 if (use_alt_file)
|
Dawn@4
|
685 delete(snackwavfile);
|
Dawn@4
|
686 end
|
Dawn@4
|
687
|
Dawn@4
|
688 % F0 (Praat)
|
Dawn@4
|
689 elseif (strcmp(paramlist{n}, 'F0 (Praat)'))
|
Dawn@4
|
690 messages{k} = [messages{k} 'pF0 '];
|
Dawn@4
|
691 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
692 drawnow;
|
Dawn@4
|
693
|
Dawn@4
|
694 % guard case for 32-bit precision files - some version of snack
|
Dawn@4
|
695 % on a 64-bit machine causes pitch estimation to fail
|
Dawn@4
|
696 err = 0;
|
Dawn@4
|
697 try
|
Dawn@4
|
698 [pF0, err] = func_PraatPitch(wavfile, frameshift/1000, frame_precision, ...
|
Dawn@4
|
699 VSData.vars.F0Praatmin, ...
|
Dawn@4
|
700 VSData.vars.F0Praatmax, ...
|
Dawn@4
|
701 VSData.vars.F0PraatSilenceThreshold, ...
|
Dawn@4
|
702 VSData.vars.F0PraatVoiceThreshold, ...
|
Dawn@4
|
703 VSData.vars.F0PraatOctaveCost, ...
|
Dawn@4
|
704 VSData.vars.F0PraatOctaveJumpCost, ...
|
Dawn@4
|
705 VSData.vars.F0PraatVoicedUnvoicedCost, ...
|
Dawn@4
|
706 VSData.vars.F0PraatKillOctaveJumps, ...
|
Dawn@4
|
707 VSData.vars.F0PraatSmooth, ...
|
Dawn@4
|
708 VSData.vars.F0PraatSmoothingBandwidth, ...
|
Dawn@4
|
709 VSData.vars.F0PraatInterpolate, ...
|
Dawn@4
|
710 VSData.vars.F0Praatmethod, ...
|
Dawn@4
|
711 data_len);
|
Dawn@4
|
712 catch
|
Dawn@4
|
713 err = 1;
|
Dawn@4
|
714 end
|
Dawn@4
|
715
|
Dawn@4
|
716 % check for fatal errors
|
Dawn@4
|
717 if (strcmp(VSData.vars.F0algorithm, 'F0 (Praat)') && err ~= 0)
|
Dawn@4
|
718 messages{k+1} = 'Error: Problem with Praat - please check settings';
|
Dawn@4
|
719 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k+1);
|
Dawn@4
|
720 set(MBoxHandles.pushbutton_close, 'Enable', 'on');
|
Dawn@4
|
721 set(MBoxHandles.pushbutton_stop, 'Enable', 'off');
|
Dawn@4
|
722
|
Dawn@4
|
723 msgbox({'Error: Unable to proceed.', 'Problem with Praat - please check settings'}, 'Error', 'error', 'modal');
|
Dawn@4
|
724 if (resampled) % delete the temporary file if it exists
|
Dawn@4
|
725 delete(wavfile);
|
Dawn@4
|
726 end
|
Dawn@4
|
727
|
Dawn@4
|
728 return;
|
Dawn@4
|
729 elseif (err ~= 0)
|
Dawn@4
|
730 messages{k} = [messages{k} '(error) '];
|
Dawn@4
|
731 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
732 end
|
Dawn@4
|
733
|
Dawn@4
|
734 if (exist(matfile, 'file'))
|
Dawn@4
|
735 save(matfile, 'pF0', 'Fs', '-append');
|
Dawn@4
|
736 else
|
Dawn@4
|
737 save(matfile, 'pF0', 'Fs');
|
Dawn@4
|
738 end
|
Dawn@4
|
739
|
Dawn@4
|
740 % F0 (Other)
|
Dawn@4
|
741 elseif (strcmp(paramlist{n}, 'F0 (Other)'))
|
Dawn@4
|
742 messages{k} = [messages{k} 'oF0 '];
|
Dawn@4
|
743 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
744 drawnow;
|
Dawn@4
|
745
|
Dawn@4
|
746 oF0 = zeros(data_len, 1) * NaN; % allocate some memory
|
Dawn@4
|
747
|
Dawn@4
|
748 err = 0;
|
Dawn@4
|
749 try
|
Dawn@4
|
750 [F0, errmsg] = func_OtherPitch(wavfile, handles);
|
Dawn@4
|
751 catch
|
Dawn@4
|
752 err = 1;
|
Dawn@4
|
753 end
|
Dawn@4
|
754
|
Dawn@4
|
755 if ((length(F0)==1 && isnan(F0)) || isempty(F0))
|
Dawn@4
|
756 err = 1;
|
Dawn@4
|
757 end
|
Dawn@4
|
758
|
Dawn@4
|
759 % check for fatal errors
|
Dawn@4
|
760 if (err == 1)
|
Dawn@4
|
761 messages{k} = [messages{k} '- error: ' errmsg ' '];
|
Dawn@4
|
762 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
763
|
Dawn@4
|
764 if (strcmp(VSData.vars.F0algorithm, 'F0 (Other)'))
|
Dawn@4
|
765 set(MBoxHandles.pushbutton_close, 'Enable', 'on');
|
Dawn@4
|
766 set(MBoxHandles.pushbutton_stop, 'Enable', 'off');
|
Dawn@4
|
767 msgbox({['Error: ' errmsg], 'Problem with F0 estimation - please check settings'}, 'Error', 'error', 'modal');
|
Dawn@4
|
768 if (resampled) % delete the temporary file if it exists
|
Dawn@4
|
769 delete(wavfile);
|
Dawn@4
|
770 end
|
Dawn@4
|
771 return;
|
Dawn@4
|
772 end
|
Dawn@4
|
773 elseif (err ~= 0)
|
Dawn@4
|
774 messages{k} = [messages{k} '(error) '];
|
Dawn@4
|
775 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
776 end
|
Dawn@4
|
777
|
Dawn@4
|
778
|
Dawn@4
|
779 if (VSData.vars.F0OtherOffset + length(F0) <= data_len)
|
Dawn@4
|
780 oF0(VSData.vars.F0OtherOffset+1:VSData.vars.F0OtherOffset + length(F0)) = F0;
|
Dawn@4
|
781 else % need to trim F0
|
Dawn@4
|
782 oF0(VSData.vars.F0OtherOffset+1:end) = F0(1:data_len - VSData.vars.F0OtherOffset);
|
Dawn@4
|
783 end
|
Dawn@4
|
784
|
Dawn@4
|
785 if (exist(matfile, 'file'))
|
Dawn@4
|
786 save(matfile, 'oF0', 'Fs', '-append');
|
Dawn@4
|
787 else
|
Dawn@4
|
788 save(matfile, 'oF0', 'Fs');
|
Dawn@4
|
789 end
|
Dawn@4
|
790
|
Dawn@4
|
791
|
Dawn@4
|
792 % F1, F2, F3, F4 (Snack)
|
Dawn@4
|
793 elseif (strcmp(paramlist{n}, 'F1, F2, F3, F4 (Snack)'))
|
Dawn@4
|
794 messages{k} = [messages{k} 'FMTs '];
|
Dawn@4
|
795 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
796 drawnow;
|
Dawn@4
|
797
|
Dawn@4
|
798 % guard case for 32-bit files - some version of snack on a
|
Dawn@4
|
799 % 64-bit machine causes formant estimation to fail
|
Dawn@4
|
800 use_alt_file = 0;
|
Dawn@4
|
801 if (nbits ~= 16)
|
Dawn@4
|
802 snackwavfile = [wavfile(1:end-4) '_16b.wav'];
|
Dawn@4
|
803 wavwrite(y, Fs, 16, snackwavfile);
|
Dawn@4
|
804 use_alt_file = 1;
|
Dawn@4
|
805 else
|
Dawn@4
|
806 snackwavfile = wavfile;
|
Dawn@4
|
807 end
|
Dawn@4
|
808
|
Dawn@4
|
809 [sF1, sF2, sF3, sF4, sB1, sB2, sB3, sB4, err] = func_SnackFormants(snackwavfile, windowsize/1000, frameshift/1000, preemphasis);
|
Dawn@4
|
810
|
Dawn@4
|
811 if (strcmp(VSData.vars.FMTalgorithm, 'F1, F2, F3, F4 (Snack)') && err == 1)
|
Dawn@4
|
812 messages{k+1} = 'Error: Problem with snack - please check settings';
|
Dawn@4
|
813 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k+1);
|
Dawn@4
|
814 set(MBoxHandles.pushbutton_close, 'Enable', 'on');
|
Dawn@4
|
815 set(MBoxHandles.pushbutton_stop, 'Enable', 'off');
|
Dawn@4
|
816
|
Dawn@4
|
817 msgbox({'Error: Unable to proceed.', 'Problem with snack - please check settings'}, 'Error', 'error', 'modal');
|
Dawn@4
|
818 if (resampled) % delete the temporary file if it exists
|
Dawn@4
|
819 delete(wavfile);
|
Dawn@4
|
820 end
|
Dawn@4
|
821 if (use_alt_file)
|
Dawn@4
|
822 delete(snackwavfile);
|
Dawn@4
|
823 end
|
Dawn@4
|
824
|
Dawn@4
|
825 return;
|
Dawn@4
|
826 end
|
Dawn@4
|
827
|
Dawn@4
|
828 sF1 = [zeros(floor(windowsize/frameshift/2),1) * NaN; sF1]; sF1 = [sF1; ones(data_len-length(sF1), 1)*NaN];
|
Dawn@4
|
829 sF2 = [zeros(floor(windowsize/frameshift/2),1) * NaN; sF2]; sF2 = [sF2; ones(data_len-length(sF2), 1)*NaN];
|
Dawn@4
|
830 sF3 = [zeros(floor(windowsize/frameshift/2),1) * NaN; sF3]; sF3 = [sF3; ones(data_len-length(sF3), 1)*NaN];
|
Dawn@4
|
831 sF4 = [zeros(floor(windowsize/frameshift/2),1) * NaN; sF4]; sF4 = [sF4; ones(data_len-length(sF4), 1)*NaN];
|
Dawn@4
|
832 sB1 = [zeros(floor(windowsize/frameshift/2),1) * NaN; sB1]; sB1 = [sB1; ones(data_len-length(sB1), 1)*NaN];
|
Dawn@4
|
833 sB2 = [zeros(floor(windowsize/frameshift/2),1) * NaN; sB2]; sB2 = [sB2; ones(data_len-length(sB2), 1)*NaN];
|
Dawn@4
|
834 sB3 = [zeros(floor(windowsize/frameshift/2),1) * NaN; sB3]; sB3 = [sB3; ones(data_len-length(sB3), 1)*NaN];
|
Dawn@4
|
835 sB4 = [zeros(floor(windowsize/frameshift/2),1) * NaN; sB4]; sB4 = [sB4; ones(data_len-length(sB4), 1)*NaN];
|
Dawn@4
|
836
|
Dawn@4
|
837 if (exist(matfile, 'file'))
|
Dawn@4
|
838 save(matfile, 'sF1', 'sF2', 'sF3', 'sF4', 'sB1', 'sB2', 'sB3', 'sB4', '-append');
|
Dawn@4
|
839 save(matfile, 'windowsize', 'frameshift', 'preemphasis', '-append');
|
Dawn@4
|
840 else
|
Dawn@4
|
841 save(matfile, 'sF1', 'sF2', 'sF3', 'sF4', 'sB1', 'sB2', 'sB3', 'sB4');
|
Dawn@4
|
842 save(matfile, 'windowsize', 'frameshift', 'preemphasis', '-append');
|
Dawn@4
|
843 end
|
Dawn@4
|
844
|
Dawn@4
|
845 if (use_alt_file)
|
Dawn@4
|
846 delete(snackwavfile);
|
Dawn@4
|
847 end
|
Dawn@4
|
848
|
Dawn@4
|
849 % F1, F2, F3, F4 (Praat)
|
Dawn@4
|
850 elseif (strcmp(paramlist{n}, 'F1, F2, F3, F4 (Praat)'))
|
Dawn@4
|
851 messages{k} = [messages{k} 'FMTp '];
|
Dawn@4
|
852 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
853 drawnow;
|
Dawn@4
|
854
|
Dawn@4
|
855 [pF1, pF2, pF3, pF4, pB1, pB2, pB3, pB4, err] = ...
|
Dawn@4
|
856 func_PraatFormants(wavfile, windowsize/1000, frameshift/1000, frame_precision, data_len);
|
Dawn@4
|
857
|
Dawn@4
|
858 if (strcmp(VSData.vars.FMTalgorithm, 'F1, F2, F3, F4 (Praat)') && err ~= 0)
|
Dawn@4
|
859 messages{k+1} = 'Error: Problem with Praat - please check settings';
|
Dawn@4
|
860 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k+1);
|
Dawn@4
|
861 set(MBoxHandles.pushbutton_close, 'Enable', 'on');
|
Dawn@4
|
862 set(MBoxHandles.pushbutton_stop, 'Enable', 'off');
|
Dawn@4
|
863
|
Dawn@4
|
864 msgbox({'Error: Unable to proceed.', 'Problem with Praat - please check settings'}, 'Error', 'error', 'modal');
|
Dawn@4
|
865 if (resampled) % delete the temporary file if it exists
|
Dawn@4
|
866 delete(wavfile);
|
Dawn@4
|
867 end
|
Dawn@4
|
868
|
Dawn@4
|
869 return;
|
Dawn@4
|
870 end
|
Dawn@4
|
871
|
Dawn@4
|
872 if (exist(matfile, 'file'))
|
Dawn@4
|
873 save(matfile, 'pF1', 'pF2', 'pF3', 'pF4', 'pB1', 'pB2', 'pB3', 'pB4', '-append');
|
Dawn@4
|
874 save(matfile, 'windowsize', 'frameshift', 'preemphasis', '-append');
|
Dawn@4
|
875 else
|
Dawn@4
|
876 save(matfile, 'pF1', 'pF2', 'pF3', 'pF4', 'pB1', 'pB2', 'pB3', 'pB4');
|
Dawn@4
|
877 save(matfile, 'windowsize', 'frameshift', 'preemphasis', '-append');
|
Dawn@4
|
878 end
|
Dawn@4
|
879
|
Dawn@4
|
880 % F1, F2, F3, F4 (Other)
|
Dawn@4
|
881 elseif (strcmp(paramlist{n}, 'F1, F2, F3, F4 (Other)'))
|
Dawn@4
|
882 messages{k} = [messages{k} 'oFMTs '];
|
Dawn@4
|
883 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
884 drawnow;
|
Dawn@4
|
885
|
Dawn@4
|
886 oF1 = zeros(data_len, 1) * NaN; % allocate some memory
|
Dawn@4
|
887 oF2 = zeros(data_len, 1) * NaN;
|
Dawn@4
|
888 oF3 = zeros(data_len, 1) * NaN;
|
Dawn@4
|
889 oF4 = zeros(data_len, 1) * NaN;
|
Dawn@4
|
890 oB1 = zeros(data_len, 1) * NaN;
|
Dawn@4
|
891 oB2 = zeros(data_len, 1) * NaN;
|
Dawn@4
|
892 oB3 = zeros(data_len, 1) * NaN;
|
Dawn@4
|
893 oB4 = zeros(data_len, 1) * NaN;
|
Dawn@4
|
894
|
Dawn@4
|
895 err = 0;
|
Dawn@4
|
896 try
|
Dawn@4
|
897 [F1, F2, F3, F4, B1, B2, B3, B4, errmsg] = func_OtherFormants(wavfile, handles);
|
Dawn@4
|
898 catch
|
Dawn@4
|
899 err = 1;
|
Dawn@4
|
900 end
|
Dawn@4
|
901
|
Dawn@4
|
902 if ((length(F1) == 1 && isnan(F1)) || isempty(F1))
|
Dawn@4
|
903 err = 1;
|
Dawn@4
|
904 end
|
Dawn@4
|
905
|
Dawn@4
|
906 if (err == 1)
|
Dawn@4
|
907 messages{k} = [messages{k} '-error: ' errmsg];
|
Dawn@4
|
908 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
909
|
Dawn@4
|
910 if (strcmp(VSData.vars.FMTalgorithm, 'F1, F2, F3, F4 (Other)'))
|
Dawn@4
|
911 set(MBoxHandles.pushbutton_close, 'Enable', 'on');
|
Dawn@4
|
912 set(MBoxHandles.pushbutton_stop, 'Enable', 'off');
|
Dawn@4
|
913
|
Dawn@4
|
914 msgbox({'Error: Unable to proceed.', 'Problem with formant tracker - please check settings'}, 'Error', 'error', 'modal');
|
Dawn@4
|
915 if (resampled) % delete the temporary file if it exists
|
Dawn@4
|
916 delete(wavfile);
|
Dawn@4
|
917 end
|
Dawn@4
|
918
|
Dawn@4
|
919 return;
|
Dawn@4
|
920 end
|
Dawn@4
|
921 end
|
Dawn@4
|
922
|
Dawn@4
|
923 % build up the actual vector
|
Dawn@4
|
924 if (VSData.vars.FormantsOtherOffset + length(F1) <= data_len)
|
Dawn@4
|
925 oF1(VSData.vars.FormantsOtherOffset+1:VSData.vars.FormantsOtherOffset + length(F1)) = F1;
|
Dawn@4
|
926 oF2(VSData.vars.FormantsOtherOffset+1:VSData.vars.FormantsOtherOffset + length(F2)) = F2;
|
Dawn@4
|
927 oF3(VSData.vars.FormantsOtherOffset+1:VSData.vars.FormantsOtherOffset + length(F3)) = F3;
|
Dawn@4
|
928 oF4(VSData.vars.FormantsOtherOffset+1:VSData.vars.FormantsOtherOffset + length(F4)) = F4;
|
Dawn@4
|
929 oB1(VSData.vars.FormantsOtherOffset+1:VSData.vars.FormantsOtherOffset + length(B1)) = B1;
|
Dawn@4
|
930 oB2(VSData.vars.FormantsOtherOffset+1:VSData.vars.FormantsOtherOffset + length(B2)) = B2;
|
Dawn@4
|
931 oB3(VSData.vars.FormantsOtherOffset+1:VSData.vars.FormantsOtherOffset + length(B3)) = B3;
|
Dawn@4
|
932 oB4(VSData.vars.FormantsOtherOffset+1:VSData.vars.FormantsOtherOffset + length(B4)) = B4;
|
Dawn@4
|
933 else % need to trim
|
Dawn@4
|
934 oF1(VSData.vars.FormantsOtherOffset+1:end) = F1(1:data_len - VSData.vars.FormantsOtherOffset);
|
Dawn@4
|
935 oF2(VSData.vars.FormantsOtherOffset+1:end) = F2(1:data_len - VSData.vars.FormantsOtherOffset);
|
Dawn@4
|
936 oF3(VSData.vars.FormantsOtherOffset+1:end) = F3(1:data_len - VSData.vars.FormantsOtherOffset);
|
Dawn@4
|
937 oF4(VSData.vars.FormantsOtherOffset+1:end) = F4(1:data_len - VSData.vars.FormantsOtherOffset);
|
Dawn@4
|
938 oB1(VSData.vars.FormantsOtherOffset+1:end) = B1(1:data_len - VSData.vars.FormantsOtherOffset);
|
Dawn@4
|
939 oB2(VSData.vars.FormantsOtherOffset+1:end) = B2(1:data_len - VSData.vars.FormantsOtherOffset);
|
Dawn@4
|
940 oB3(VSData.vars.FormantsOtherOffset+1:end) = B3(1:data_len - VSData.vars.FormantsOtherOffset);
|
Dawn@4
|
941 oB4(VSData.vars.FormantsOtherOffset+1:end) = B4(1:data_len - VSData.vars.FormantsOtherOffset);
|
Dawn@4
|
942 end
|
Dawn@4
|
943
|
Dawn@4
|
944 if (exist(matfile, 'file'))
|
Dawn@4
|
945 save(matfile, 'oF1', 'oF2', 'oF3', 'oF4', 'oB1', 'oB2', 'oB3', 'oB4', '-append');
|
Dawn@4
|
946 else
|
Dawn@4
|
947 save(matfile, 'oF1', 'oF2', 'oF3', 'oF4', 'oB1', 'oB2', 'oB3', 'oB4');
|
Dawn@4
|
948 end
|
Dawn@4
|
949
|
Dawn@4
|
950
|
Dawn@4
|
951
|
Dawn@4
|
952 % H1, H2, H4
|
Dawn@4
|
953 elseif (strcmp(paramlist{n}, 'H1, H2, H4'))
|
Dawn@4
|
954 messages{k} = [messages{k} 'Hx '];
|
Dawn@4
|
955 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
956 drawnow;
|
Dawn@4
|
957
|
Dawn@4
|
958 matdata = load(matfile);
|
Dawn@4
|
959
|
Dawn@4
|
960 F0 = func_parseF0(matdata, F0algorithm);
|
Dawn@4
|
961
|
Dawn@4
|
962 if (useTextgrid)
|
Dawn@4
|
963 [H1, H2, H4, isComplete] = func_GetH1_H2_H4(y, Fs, F0, MBoxHandles, VSData.vars, textgridfile);
|
Dawn@4
|
964 else
|
Dawn@4
|
965 [H1, H2, H4, isComplete] = func_GetH1_H2_H4(y, Fs, F0, MBoxHandles, VSData.vars);
|
Dawn@4
|
966 end
|
Dawn@4
|
967
|
Dawn@4
|
968 HF0algorithm = F0algorithm;
|
Dawn@4
|
969
|
Dawn@4
|
970 % check if the process was completed
|
Dawn@4
|
971 if (isComplete==0)
|
Dawn@4
|
972 messages{k+1} = 'Stop button pressed by user.';
|
Dawn@4
|
973 if (ishandle(MBoxHandles.figure_MessageBox))
|
Dawn@4
|
974 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k+1);
|
Dawn@4
|
975 end
|
Dawn@4
|
976 if (resampled) % delete the temporary file if it exists
|
Dawn@4
|
977 delete(wavfile);
|
Dawn@4
|
978 end
|
Dawn@4
|
979
|
Dawn@4
|
980 return;
|
Dawn@4
|
981 end
|
Dawn@4
|
982
|
Dawn@4
|
983 if (exist(matfile, 'file'))
|
Dawn@4
|
984 save(matfile, 'H1', 'H2', 'H4', 'HF0algorithm', '-append');
|
Dawn@4
|
985 else
|
Dawn@4
|
986 save(matfile, 'H1', 'H2', 'H4', 'HF0algorithm');
|
Dawn@4
|
987 end
|
Dawn@4
|
988
|
Dawn@4
|
989
|
Dawn@4
|
990
|
Dawn@4
|
991 % A1, A2, A3
|
Dawn@4
|
992 elseif (strcmp(paramlist{n}, 'A1, A2, A3'))
|
Dawn@4
|
993 messages{k} = [messages{k} 'Ax '];
|
Dawn@4
|
994 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
995 drawnow;
|
Dawn@4
|
996
|
Dawn@4
|
997 matdata = load(matfile); % file has to exist at this point - dependency checking should make sure of this
|
Dawn@4
|
998
|
Dawn@4
|
999 F0 = func_parseF0(matdata, F0algorithm);
|
Dawn@4
|
1000 [F1, F2, F3] = func_parseFMT(matdata, FMTalgorithm);
|
Dawn@4
|
1001
|
Dawn@4
|
1002 if (useTextgrid)
|
Dawn@4
|
1003 [A1, A2, A3] = func_GetA1A2A3(y, Fs, F0, F1, F2, F3, VSData.vars, textgridfile);
|
Dawn@4
|
1004 else
|
Dawn@4
|
1005 [A1, A2, A3] = func_GetA1A2A3(y, Fs, F0, F1, F2, F3, VSData.vars);
|
Dawn@4
|
1006 end
|
Dawn@4
|
1007
|
Dawn@4
|
1008 AFMTalgorithm = FMTalgorithm;
|
Dawn@4
|
1009
|
Dawn@4
|
1010 save(matfile, 'A1', 'A2', 'A3', 'AFMTalgorithm', '-append');
|
Dawn@4
|
1011
|
Dawn@4
|
1012
|
Dawn@4
|
1013 % H1*-H2* and H2*-H4*
|
Dawn@4
|
1014 elseif (strcmp(paramlist{n}, 'H1*-H2*, H2*-H4*'))
|
Dawn@4
|
1015 messages{k} = [messages{k} 'H1H2c H2H4c '];
|
Dawn@4
|
1016 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
1017 drawnow;
|
Dawn@4
|
1018
|
Dawn@4
|
1019 matdata = load(matfile);
|
Dawn@4
|
1020 F0 = func_parseF0(matdata, F0algorithm);
|
Dawn@4
|
1021 [F1, F2, F3] = func_parseFMT(matdata, FMTalgorithm);
|
Dawn@4
|
1022
|
Dawn@4
|
1023 [H1H2c, H2H4c] = func_GetH1H2_H2H4(matdata.H1, matdata.H2, matdata.H4, Fs, F0, F1, F2);
|
Dawn@4
|
1024 save(matfile, 'H1H2c', 'H2H4c', '-append');
|
Dawn@4
|
1025
|
Dawn@4
|
1026
|
Dawn@4
|
1027 % H1*-A1*, H1*-A2*, and H1*-A3*
|
Dawn@4
|
1028 elseif (strcmp(paramlist{n}, 'H1*-A1*, H1*-A2*, H1*-A3*'))
|
Dawn@4
|
1029 messages{k} = [messages{k} 'H1A1c H1A2c H1A3c '];
|
Dawn@4
|
1030 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
1031 drawnow;
|
Dawn@4
|
1032
|
Dawn@4
|
1033 matdata = load(matfile);
|
Dawn@4
|
1034 F0 = func_parseF0(matdata, F0algorithm);
|
Dawn@4
|
1035 [F1, F2, F3] = func_parseFMT(matdata, FMTalgorithm);
|
Dawn@4
|
1036
|
Dawn@4
|
1037 [H1A1c, H1A2c, H1A3c] = func_GetH1A1_H1A2_H1A3(matdata.H1, matdata.A1, matdata.A2, matdata.A3, Fs, F0, F1, F2, F3);
|
Dawn@4
|
1038 save(matfile, 'H1A1c', 'H1A2c', 'H1A3c', '-append');
|
Dawn@4
|
1039
|
Dawn@4
|
1040
|
Dawn@4
|
1041 % Energy
|
Dawn@4
|
1042 elseif (strcmp(paramlist{n}, 'Energy'))
|
Dawn@4
|
1043 messages{k} = [messages{k} 'E '];
|
Dawn@4
|
1044 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
1045 drawnow;
|
Dawn@4
|
1046
|
Dawn@4
|
1047 matdata = load(matfile);
|
Dawn@4
|
1048 F0 = func_parseF0(matdata, F0algorithm);
|
Dawn@4
|
1049
|
Dawn@4
|
1050 Energy = func_GetEnergy(y, F0, Fs, VSData.vars);
|
Dawn@4
|
1051 save(matfile, 'Energy', '-append');
|
Dawn@4
|
1052
|
Dawn@4
|
1053
|
Dawn@4
|
1054 % CPP
|
Dawn@4
|
1055 elseif (strcmp(paramlist{n}, 'CPP'))
|
Dawn@4
|
1056 messages{k} = [messages{k} 'CPP '];
|
Dawn@4
|
1057 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
1058 drawnow;
|
Dawn@4
|
1059
|
Dawn@4
|
1060 matdata = load(matfile);
|
Dawn@4
|
1061 F0 = func_parseF0(matdata, F0algorithm);
|
Dawn@4
|
1062
|
Dawn@4
|
1063 CPP = func_GetCPP(y, Fs, F0, VSData.vars);
|
Dawn@4
|
1064 save(matfile, 'CPP', '-append');
|
Dawn@4
|
1065
|
Dawn@4
|
1066
|
Dawn@4
|
1067 % HNR
|
Dawn@4
|
1068 elseif (strcmp(paramlist{n}, 'Harmonic to Noise Ratios - HNR'))
|
Dawn@4
|
1069 messages{k} = [messages{k} 'HNR '];
|
Dawn@4
|
1070 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
1071 drawnow;
|
Dawn@4
|
1072
|
Dawn@4
|
1073 matdata = load(matfile);
|
Dawn@4
|
1074 F0 = func_parseF0(matdata, F0algorithm);
|
Dawn@4
|
1075
|
Dawn@4
|
1076 [HNR05, HNR15, HNR25, HNR35] = func_GetHNR(y, Fs, F0, VSData.vars);
|
Dawn@4
|
1077 save(matfile, 'HNR05', 'HNR15', 'HNR25', 'HNR35', '-append');
|
Dawn@4
|
1078
|
Dawn@4
|
1079
|
Dawn@4
|
1080 % SHR
|
Dawn@4
|
1081 elseif (strcmp(paramlist{n}, 'Subharmonic to Harmonic Ratio/F0 - SHR, (shr)F0'))
|
Dawn@4
|
1082 messages{k} = [messages{k} 'SHR, shrF0 '];
|
Dawn@4
|
1083 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', k);
|
Dawn@4
|
1084 drawnow;
|
Dawn@4
|
1085
|
Dawn@4
|
1086 matdata = load(matfile);
|
Dawn@4
|
1087
|
Dawn@4
|
1088 [SHR, shrF0] = func_GetSHRP(y, Fs, VSData.vars, data_len);
|
Dawn@4
|
1089 save(matfile, 'SHR', 'shrF0', '-append');
|
Dawn@4
|
1090 end
|
Dawn@4
|
1091
|
Dawn@4
|
1092 end
|
Dawn@4
|
1093
|
Dawn@4
|
1094 if (resampled) % delete the temporary file if it exists
|
Dawn@4
|
1095 delete(wavfile);
|
Dawn@4
|
1096 end
|
Dawn@4
|
1097
|
Dawn@4
|
1098 end
|
Dawn@4
|
1099
|
Dawn@4
|
1100 messages{length(filelist)+1} = 'Processing complete.';
|
Dawn@4
|
1101 set(MBoxHandles.listbox_messages, 'String', messages, 'Value', length(filelist)+1);
|
Dawn@4
|
1102 set(MBoxHandles.pushbutton_close, 'Enable', 'on');
|
Dawn@4
|
1103 set(MBoxHandles.pushbutton_stop, 'Enable', 'off');
|
Dawn@4
|
1104
|
Dawn@4
|
1105
|
Dawn@4
|
1106 % Function to generate random file names
|
Dawn@4
|
1107 function filename = generateRandomFile(fname, handles)
|
Dawn@4
|
1108 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
1109 N = 8; % this many random digits/characters
|
Dawn@4
|
1110 [pathstr, name, ext] = fileparts(fname);
|
Dawn@4
|
1111 randstr = '00000000';
|
Dawn@4
|
1112
|
Dawn@4
|
1113 isok = 0;
|
Dawn@4
|
1114
|
Dawn@4
|
1115 while(isok == 0)
|
Dawn@4
|
1116 for k=1:N
|
Dawn@4
|
1117 randstr(k) = floor(rand() * 25) + 65;
|
Dawn@4
|
1118 end
|
Dawn@4
|
1119 filename = [pathstr VSData.vars.dirdelimiter 'tmp_' name randstr ext];
|
Dawn@4
|
1120
|
Dawn@4
|
1121 if (exist(filename, 'file') == 0)
|
Dawn@4
|
1122 isok = 1;
|
Dawn@4
|
1123 end
|
Dawn@4
|
1124 end
|
Dawn@4
|
1125
|
Dawn@4
|
1126
|
Dawn@4
|
1127 % --- Executes when user attempts to close figure_ParameterEstimation.
|
Dawn@4
|
1128 function figure_ParameterEstimation_CloseRequestFcn(hObject, eventdata, handles)
|
Dawn@4
|
1129 % hObject handle to figure_ParameterEstimation (see GCBO)
|
Dawn@4
|
1130 % eventdata reserved - to be defined in a future version of MATLAB
|
Dawn@4
|
1131 % handles structure with handles and user data (see GUIDATA)
|
Dawn@4
|
1132
|
Dawn@4
|
1133 % Hint: delete(hObject) closes the figure
|
Dawn@4
|
1134 if (isfield(handles, 'SWfig'))
|
Dawn@4
|
1135 delete(handles.SWfig);
|
Dawn@4
|
1136 end
|
Dawn@4
|
1137
|
Dawn@4
|
1138 VSData = guidata(handles.VSHandle);
|
Dawn@4
|
1139 VSData.vars.PE_showwaveforms = 0;
|
Dawn@4
|
1140 guidata(handles.VSHandle, VSData);
|
Dawn@4
|
1141
|
Dawn@4
|
1142 delete(hObject);
|
Dawn@4
|
1143
|
Dawn@4
|
1144
|