tomwalters@0
|
1 % procedure for 'aim-mat'
|
tomwalters@0
|
2 %
|
tomwalters@0
|
3 % INPUT VALUES:
|
tomwalters@0
|
4 %
|
tomwalters@0
|
5 % RETURN VALUE:
|
tomwalters@0
|
6 %
|
tomwalters@0
|
7 % load the signal file and all files, that are in this directory
|
tomwalters@0
|
8 % set the project variables accordingly.
|
tomwalters@0
|
9 %
|
bleeck@3
|
10 %
|
tomwalters@0
|
11 % (c) 2011, University of Southampton
|
bleeck@3
|
12 % Maintained by Stefan Bleeck (bleeck@gmail.com)
|
bleeck@3
|
13 % download of current version is on the soundsoftware site:
|
bleeck@3
|
14 % http://code.soundsoftware.ac.uk/projects/aimmat
|
bleeck@3
|
15 % documentation and everything is on http://www.acousticscale.org
|
tomwalters@0
|
16
|
tomwalters@0
|
17
|
tomwalters@0
|
18
|
bleeck@3
|
19
|
bleeck@3
|
20
|
bleeck@3
|
21 function handles=aim_loadproject(handles)
|
tomwalters@0
|
22
|
tomwalters@0
|
23
|
tomwalters@0
|
24 signalname=handles.info.signalname;
|
tomwalters@0
|
25 signalwavename=handles.info.signalwavename;
|
tomwalters@0
|
26 oldsignalwavename=handles.info.oldsignalwavename;
|
tomwalters@0
|
27 pcpname=handles.info.pcpname;
|
tomwalters@0
|
28 bmmname=handles.info.bmmname;
|
tomwalters@0
|
29 napname=handles.info.napname;
|
tomwalters@0
|
30 strobesname=handles.info.strobesname;
|
tomwalters@0
|
31 thresholdsname=handles.info.thresholdsname;
|
tomwalters@0
|
32 sainame=handles.info.sainame;
|
tomwalters@0
|
33 usermodulename=handles.info.usermodulename;
|
tomwalters@0
|
34
|
tomwalters@0
|
35
|
tomwalters@0
|
36 was_conflict=0;
|
tomwalters@0
|
37 % load the parameterfile (and apply the parameters)
|
tomwalters@0
|
38 if exist(handles.info.parameterfilename,'file')
|
tomwalters@0
|
39 workdir=pwd;
|
tomwalters@0
|
40 cd(handles.info.directoryname);
|
bleeck@3
|
41 [~,parfile,~]=fileparts(handles.info.parameterfilename);
|
tomwalters@0
|
42 clear all_options;
|
tomwalters@0
|
43 new_options=handles.all_options;
|
tomwalters@0
|
44
|
tomwalters@0
|
45 try % desperate...
|
tomwalters@0
|
46 eval(parfile); % this produces all_options as 'all_options'
|
tomwalters@0
|
47 [new_options,conflicts]=aim_mixstruct(all_options,new_options);
|
tomwalters@0
|
48
|
tomwalters@0
|
49 handles.info.conflicts=conflicts;
|
tomwalters@0
|
50 handles.all_options=new_options;
|
tomwalters@0
|
51 cd(workdir);
|
tomwalters@0
|
52 if ~structisequal(new_options,all_options)
|
tomwalters@0
|
53 aim_saveparameters(handles,handles.info.parameterfilename);
|
tomwalters@0
|
54 end
|
tomwalters@0
|
55 catch
|
tomwalters@0
|
56 %lasterror
|
tomwalters@0
|
57 disp('problems with reading in old parameter file. Check parameters manually!');
|
tomwalters@0
|
58 disp('A common reason for this error is that you have included a new module without a ''revision'' parameter:');
|
tomwalters@0
|
59 disp('See the parameters file of one of the distributed modules for a template');
|
tomwalters@0
|
60 % new_options=all_options;
|
tomwalters@0
|
61 conflicts='problem reading in parameter file. Check parameters!';
|
tomwalters@0
|
62 cd(workdir);
|
tomwalters@0
|
63 was_conflict=1;
|
tomwalters@0
|
64 end
|
tomwalters@0
|
65 else
|
tomwalters@0
|
66 was_conflict=1;
|
tomwalters@0
|
67 end
|
tomwalters@0
|
68
|
bleeck@3
|
69 try
|
bleeck@3
|
70 % if exist(signalname,'var')
|
tomwalters@0
|
71 [sig,type,sigoptions]=aim_loadfile(signalname);
|
tomwalters@0
|
72 handles.data.signal=sig;
|
tomwalters@0
|
73 if ~isempty(sigoptions)
|
tomwalters@0
|
74 handles.all_options.signal=sigoptions;
|
tomwalters@0
|
75 handles.data.original_signal=loadwavefile(signal,handles.info.signalwavename);
|
tomwalters@0
|
76 else
|
tomwalters@0
|
77 handles.all_options.signal.start_time=0;
|
tomwalters@0
|
78 handles.all_options.signal.duration=getlength(sig);
|
tomwalters@0
|
79 handles.all_options.signal.samplerate=getsr(sig);
|
tomwalters@0
|
80 handles.all_options.signal.original_start_time=0;
|
tomwalters@0
|
81 handles.all_options.signal.original_duration=getlength(sig);
|
tomwalters@0
|
82 handles.all_options.signal.original_samplerate=getsr(sig);
|
tomwalters@0
|
83 % for old projects
|
tomwalters@0
|
84 if exist(handles.info.originalwavename)
|
tomwalters@0
|
85 handles.data.original_signal=loadwavefile(signal,handles.info.originalwavename);
|
tomwalters@0
|
86 else
|
tomwalters@0
|
87 handles.data.original_signal=loadwavefile(signal,handles.info.signalwavename);
|
tomwalters@0
|
88 end
|
tomwalters@0
|
89 end
|
tomwalters@0
|
90
|
tomwalters@0
|
91 % put the original signal in its place:
|
bleeck@3
|
92 % else
|
bleeck@3
|
93 catch
|
tomwalters@0
|
94 % cant continue without signal!
|
bleeck@3
|
95 str=sprintf('Problem while executing parameter file %s',signalname);
|
tomwalters@0
|
96 er=errordlg(str,'File Error');
|
tomwalters@0
|
97 set(er,'WindowStyle','modal');
|
tomwalters@0
|
98 handles.error=1;
|
tomwalters@0
|
99 return
|
tomwalters@0
|
100 end
|
tomwalters@0
|
101
|
tomwalters@0
|
102 if fexist(pcpname)
|
tomwalters@0
|
103 [pcp,type,options]=aim_loadfile(pcpname);
|
tomwalters@0
|
104 handles.data.pcp=pcp;
|
tomwalters@0
|
105 handles.info.pcp_loaded=1;
|
tomwalters@0
|
106 handles.info.calculated_pcp_module=type; % this one is really calculated
|
tomwalters@0
|
107 % select(handles.listbox0,type);
|
tomwalters@0
|
108 if ~isempty(type)
|
tomwalters@0
|
109 str=sprintf('handles.all_options.pcpoptions.%s=options;',type);
|
tomwalters@0
|
110 eval(str);
|
tomwalters@0
|
111 else % old style
|
tomwalters@0
|
112 type='ELC';
|
tomwalters@0
|
113 handles.all_options.pcpoptions=options;
|
tomwalters@0
|
114 sai_savefile(pcp,pcpname,type,options,handles.all_options);
|
tomwalters@0
|
115 end
|
tomwalters@0
|
116 handles.info.init.calculated_pcp_module=type;
|
tomwalters@0
|
117 else
|
tomwalters@0
|
118 handles.info.pcp_loaded=0;
|
tomwalters@0
|
119 end
|
tomwalters@0
|
120
|
tomwalters@0
|
121 if fexist(bmmname)
|
tomwalters@0
|
122 [bmm,type,options]=aim_loadfile(bmmname);
|
tomwalters@0
|
123 handles.data.bmm=bmm;
|
tomwalters@0
|
124 handles.info.bmm_loaded=1;
|
tomwalters@0
|
125 handles.info.calculated_bmm_module=type; % this one is really calculated
|
tomwalters@0
|
126
|
tomwalters@0
|
127 % select(handles.listbox1,type);
|
tomwalters@0
|
128 handles.info.init.calculated_bmm_module=type;
|
tomwalters@0
|
129
|
tomwalters@0
|
130 else
|
tomwalters@0
|
131 handles.info.bmm_loaded=0;
|
tomwalters@0
|
132 end
|
tomwalters@0
|
133 if fexist(napname)
|
tomwalters@0
|
134 [nap,type,options]=aim_loadfile(napname);
|
tomwalters@0
|
135 handles.data.nap=nap;
|
tomwalters@0
|
136 handles.info.nap_loaded=1;
|
tomwalters@0
|
137 % select(handles.listbox2,type);
|
tomwalters@0
|
138 handles.info.init.calculated_nap_module=type;
|
tomwalters@0
|
139
|
tomwalters@0
|
140 else
|
tomwalters@0
|
141 handles.info.nap_loaded=0;
|
tomwalters@0
|
142 end
|
tomwalters@0
|
143 if fexist(strobesname)
|
tomwalters@0
|
144 [strobes,type,options]=aim_loadfile(strobesname);
|
tomwalters@0
|
145 if fexist(thresholdsname)
|
tomwalters@0
|
146 thresholds=aim_loadfile(thresholdsname);
|
tomwalters@0
|
147 handles.data.thresholds=thresholds;
|
tomwalters@0
|
148 end
|
tomwalters@0
|
149 handles.data.strobes=strobes;
|
tomwalters@0
|
150 handles.info.strobes_loaded=1;
|
tomwalters@0
|
151 handles.info.calculated_strobes_module=type; % this one is really calculated
|
tomwalters@0
|
152 % select(handles.listbox3,type);
|
tomwalters@0
|
153 handles.info.init.calculated_strobes_module=type;
|
tomwalters@0
|
154 else
|
tomwalters@0
|
155 handles.info.strobes_loaded=0;
|
tomwalters@0
|
156 end
|
tomwalters@0
|
157
|
tomwalters@0
|
158 if fexist(sainame)
|
tomwalters@0
|
159 [sai,type,options]=aim_loadfile(sainame);
|
tomwalters@0
|
160 handles.data.sai=sai;
|
tomwalters@0
|
161 handles.info.sai_loaded=1;
|
tomwalters@0
|
162 handles.info.calculated_sai_module=type; % this one is really calculated
|
tomwalters@0
|
163 % select(handles.listbox4,type);
|
tomwalters@0
|
164 handles.info.init.calculated_sai_module=type;
|
tomwalters@0
|
165
|
tomwalters@0
|
166 nr_frames=length(sai);
|
tomwalters@0
|
167 handles.slideredit_frames.minvalue=1;
|
tomwalters@0
|
168 handles.slideredit_frames.maxvalue=nr_frames;
|
tomwalters@0
|
169 % set the framecounter
|
tomwalters@0
|
170 % handles.slideredit_frames=slidereditcontrol_set_value(handles.slideredit_frames,nr_frames); % set to the end
|
tomwalters@0
|
171 % handles.slideredit_frames=slidereditcontrol_set_range(handles.slideredit_frames,nr_frames); % the duration
|
tomwalters@0
|
172
|
tomwalters@0
|
173 else
|
tomwalters@0
|
174 handles.info.sai_loaded=0;
|
tomwalters@0
|
175 end
|
tomwalters@0
|
176
|
tomwalters@0
|
177 if fexist(usermodulename)
|
tomwalters@0
|
178 [usermodule,type,options]=aim_loadfile(usermodulename);
|
tomwalters@0
|
179 handles.data.usermodule=usermodule;
|
tomwalters@0
|
180 handles.info.usermodule_loaded=1;
|
tomwalters@0
|
181 handles.info.calculated_usermodule_module=type; % this one is really calculated
|
tomwalters@0
|
182 handles.info.init.calculated_usermodule_module=type;
|
tomwalters@0
|
183
|
tomwalters@0
|
184 % select(handles.listbox6,type);
|
tomwalters@0
|
185 handles.info.usermodule_loaded=1;
|
tomwalters@0
|
186 else
|
tomwalters@0
|
187 handles.info.usermodule_loaded=0;
|
tomwalters@0
|
188 end
|
tomwalters@0
|
189
|
tomwalters@0
|
190 % TODO: only the first available movie is loaded. The others not
|
tomwalters@0
|
191 handles.info.movie_loaded=0;
|
tomwalters@0
|
192 % if length(moviename)>1
|
tomwalters@0
|
193 % for i=1:length(moviename)
|
tomwalters@0
|
194 % cname=moviename{i};
|
tomwalters@0
|
195 % if fexist(cname)
|
tomwalters@0
|
196 % handles.info.movie_loaded=1;
|
tomwalters@0
|
197 % handles.info.calculated_movie_module=cname; % this one is really calculated
|
tomwalters@0
|
198 % handles.info.init.calculated_movie_module=type;
|
tomwalters@0
|
199 % break
|
tomwalters@0
|
200 % end
|
tomwalters@0
|
201 % end
|
tomwalters@0
|
202 % end
|
tomwalters@0
|
203
|
tomwalters@0
|
204
|
tomwalters@0
|
205 if was_conflict==1
|
tomwalters@0
|
206 disp('parameter file does not exist. Taking standart parameters. Check parameters manually!');
|
tomwalters@0
|
207 disp('saving standart parameters as new parameter file');
|
tomwalters@0
|
208 handles=aim_saveparameters(handles,handles.info.parameterfilename,1);
|
tomwalters@0
|
209 end
|
tomwalters@0
|
210
|
tomwalters@0
|
211
|
tomwalters@0
|
212 function select(hand,what)
|
tomwalters@0
|
213 str=get(hand,'String');
|
tomwalters@0
|
214 for i=1:length(str)
|
tomwalters@0
|
215 if strcmp(str,what)
|
tomwalters@0
|
216 set(hand,'Value',i);
|
tomwalters@0
|
217 return
|
tomwalters@0
|
218 end
|
tomwalters@0
|
219 end
|
tomwalters@0
|
220 return
|
tomwalters@0
|
221
|