tomwalters@0: % procedure for 'aim-mat' tomwalters@0: % tomwalters@0: % INPUT VALUES: tomwalters@0: % tomwalters@0: % RETURN VALUE: tomwalters@0: % tomwalters@0: % load the signal file and all files, that are in this directory tomwalters@0: % set the project variables accordingly. tomwalters@0: % bleeck@3: % tomwalters@0: % (c) 2011, University of Southampton bleeck@3: % Maintained by Stefan Bleeck (bleeck@gmail.com) bleeck@3: % download of current version is on the soundsoftware site: bleeck@3: % http://code.soundsoftware.ac.uk/projects/aimmat bleeck@3: % documentation and everything is on http://www.acousticscale.org tomwalters@0: tomwalters@0: tomwalters@0: bleeck@3: bleeck@3: bleeck@3: function handles=aim_loadproject(handles) tomwalters@0: tomwalters@0: tomwalters@0: signalname=handles.info.signalname; tomwalters@0: signalwavename=handles.info.signalwavename; tomwalters@0: oldsignalwavename=handles.info.oldsignalwavename; tomwalters@0: pcpname=handles.info.pcpname; tomwalters@0: bmmname=handles.info.bmmname; tomwalters@0: napname=handles.info.napname; tomwalters@0: strobesname=handles.info.strobesname; tomwalters@0: thresholdsname=handles.info.thresholdsname; tomwalters@0: sainame=handles.info.sainame; tomwalters@0: usermodulename=handles.info.usermodulename; tomwalters@0: tomwalters@0: tomwalters@0: was_conflict=0; tomwalters@0: % load the parameterfile (and apply the parameters) tomwalters@0: if exist(handles.info.parameterfilename,'file') tomwalters@0: workdir=pwd; tomwalters@0: cd(handles.info.directoryname); bleeck@3: [~,parfile,~]=fileparts(handles.info.parameterfilename); tomwalters@0: clear all_options; tomwalters@0: new_options=handles.all_options; tomwalters@0: tomwalters@0: try % desperate... tomwalters@0: eval(parfile); % this produces all_options as 'all_options' tomwalters@0: [new_options,conflicts]=aim_mixstruct(all_options,new_options); tomwalters@0: tomwalters@0: handles.info.conflicts=conflicts; tomwalters@0: handles.all_options=new_options; tomwalters@0: cd(workdir); tomwalters@0: if ~structisequal(new_options,all_options) tomwalters@0: aim_saveparameters(handles,handles.info.parameterfilename); tomwalters@0: end tomwalters@0: catch tomwalters@0: %lasterror tomwalters@0: disp('problems with reading in old parameter file. Check parameters manually!'); tomwalters@0: disp('A common reason for this error is that you have included a new module without a ''revision'' parameter:'); tomwalters@0: disp('See the parameters file of one of the distributed modules for a template'); tomwalters@0: % new_options=all_options; tomwalters@0: conflicts='problem reading in parameter file. Check parameters!'; tomwalters@0: cd(workdir); tomwalters@0: was_conflict=1; tomwalters@0: end tomwalters@0: else tomwalters@0: was_conflict=1; tomwalters@0: end tomwalters@0: bleeck@3: try bleeck@3: % if exist(signalname,'var') tomwalters@0: [sig,type,sigoptions]=aim_loadfile(signalname); tomwalters@0: handles.data.signal=sig; tomwalters@0: if ~isempty(sigoptions) tomwalters@0: handles.all_options.signal=sigoptions; tomwalters@0: handles.data.original_signal=loadwavefile(signal,handles.info.signalwavename); tomwalters@0: else tomwalters@0: handles.all_options.signal.start_time=0; tomwalters@0: handles.all_options.signal.duration=getlength(sig); tomwalters@0: handles.all_options.signal.samplerate=getsr(sig); tomwalters@0: handles.all_options.signal.original_start_time=0; tomwalters@0: handles.all_options.signal.original_duration=getlength(sig); tomwalters@0: handles.all_options.signal.original_samplerate=getsr(sig); tomwalters@0: % for old projects tomwalters@0: if exist(handles.info.originalwavename) tomwalters@0: handles.data.original_signal=loadwavefile(signal,handles.info.originalwavename); tomwalters@0: else tomwalters@0: handles.data.original_signal=loadwavefile(signal,handles.info.signalwavename); tomwalters@0: end tomwalters@0: end tomwalters@0: tomwalters@0: % put the original signal in its place: bleeck@3: % else bleeck@3: catch tomwalters@0: % cant continue without signal! bleeck@3: str=sprintf('Problem while executing parameter file %s',signalname); tomwalters@0: er=errordlg(str,'File Error'); tomwalters@0: set(er,'WindowStyle','modal'); tomwalters@0: handles.error=1; tomwalters@0: return tomwalters@0: end tomwalters@0: tomwalters@0: if fexist(pcpname) tomwalters@0: [pcp,type,options]=aim_loadfile(pcpname); tomwalters@0: handles.data.pcp=pcp; tomwalters@0: handles.info.pcp_loaded=1; tomwalters@0: handles.info.calculated_pcp_module=type; % this one is really calculated tomwalters@0: % select(handles.listbox0,type); tomwalters@0: if ~isempty(type) tomwalters@0: str=sprintf('handles.all_options.pcpoptions.%s=options;',type); tomwalters@0: eval(str); tomwalters@0: else % old style tomwalters@0: type='ELC'; tomwalters@0: handles.all_options.pcpoptions=options; tomwalters@0: sai_savefile(pcp,pcpname,type,options,handles.all_options); tomwalters@0: end tomwalters@0: handles.info.init.calculated_pcp_module=type; tomwalters@0: else tomwalters@0: handles.info.pcp_loaded=0; tomwalters@0: end tomwalters@0: tomwalters@0: if fexist(bmmname) tomwalters@0: [bmm,type,options]=aim_loadfile(bmmname); tomwalters@0: handles.data.bmm=bmm; tomwalters@0: handles.info.bmm_loaded=1; tomwalters@0: handles.info.calculated_bmm_module=type; % this one is really calculated tomwalters@0: tomwalters@0: % select(handles.listbox1,type); tomwalters@0: handles.info.init.calculated_bmm_module=type; tomwalters@0: tomwalters@0: else tomwalters@0: handles.info.bmm_loaded=0; tomwalters@0: end tomwalters@0: if fexist(napname) tomwalters@0: [nap,type,options]=aim_loadfile(napname); tomwalters@0: handles.data.nap=nap; tomwalters@0: handles.info.nap_loaded=1; tomwalters@0: % select(handles.listbox2,type); tomwalters@0: handles.info.init.calculated_nap_module=type; tomwalters@0: tomwalters@0: else tomwalters@0: handles.info.nap_loaded=0; tomwalters@0: end tomwalters@0: if fexist(strobesname) tomwalters@0: [strobes,type,options]=aim_loadfile(strobesname); tomwalters@0: if fexist(thresholdsname) tomwalters@0: thresholds=aim_loadfile(thresholdsname); tomwalters@0: handles.data.thresholds=thresholds; tomwalters@0: end tomwalters@0: handles.data.strobes=strobes; tomwalters@0: handles.info.strobes_loaded=1; tomwalters@0: handles.info.calculated_strobes_module=type; % this one is really calculated tomwalters@0: % select(handles.listbox3,type); tomwalters@0: handles.info.init.calculated_strobes_module=type; tomwalters@0: else tomwalters@0: handles.info.strobes_loaded=0; tomwalters@0: end tomwalters@0: tomwalters@0: if fexist(sainame) tomwalters@0: [sai,type,options]=aim_loadfile(sainame); tomwalters@0: handles.data.sai=sai; tomwalters@0: handles.info.sai_loaded=1; tomwalters@0: handles.info.calculated_sai_module=type; % this one is really calculated tomwalters@0: % select(handles.listbox4,type); tomwalters@0: handles.info.init.calculated_sai_module=type; tomwalters@0: tomwalters@0: nr_frames=length(sai); tomwalters@0: handles.slideredit_frames.minvalue=1; tomwalters@0: handles.slideredit_frames.maxvalue=nr_frames; tomwalters@0: % set the framecounter tomwalters@0: % handles.slideredit_frames=slidereditcontrol_set_value(handles.slideredit_frames,nr_frames); % set to the end tomwalters@0: % handles.slideredit_frames=slidereditcontrol_set_range(handles.slideredit_frames,nr_frames); % the duration tomwalters@0: tomwalters@0: else tomwalters@0: handles.info.sai_loaded=0; tomwalters@0: end tomwalters@0: tomwalters@0: if fexist(usermodulename) tomwalters@0: [usermodule,type,options]=aim_loadfile(usermodulename); tomwalters@0: handles.data.usermodule=usermodule; tomwalters@0: handles.info.usermodule_loaded=1; tomwalters@0: handles.info.calculated_usermodule_module=type; % this one is really calculated tomwalters@0: handles.info.init.calculated_usermodule_module=type; tomwalters@0: tomwalters@0: % select(handles.listbox6,type); tomwalters@0: handles.info.usermodule_loaded=1; tomwalters@0: else tomwalters@0: handles.info.usermodule_loaded=0; tomwalters@0: end tomwalters@0: tomwalters@0: % TODO: only the first available movie is loaded. The others not tomwalters@0: handles.info.movie_loaded=0; tomwalters@0: % if length(moviename)>1 tomwalters@0: % for i=1:length(moviename) tomwalters@0: % cname=moviename{i}; tomwalters@0: % if fexist(cname) tomwalters@0: % handles.info.movie_loaded=1; tomwalters@0: % handles.info.calculated_movie_module=cname; % this one is really calculated tomwalters@0: % handles.info.init.calculated_movie_module=type; tomwalters@0: % break tomwalters@0: % end tomwalters@0: % end tomwalters@0: % end tomwalters@0: tomwalters@0: tomwalters@0: if was_conflict==1 tomwalters@0: disp('parameter file does not exist. Taking standart parameters. Check parameters manually!'); tomwalters@0: disp('saving standart parameters as new parameter file'); tomwalters@0: handles=aim_saveparameters(handles,handles.info.parameterfilename,1); tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: function select(hand,what) tomwalters@0: str=get(hand,'String'); tomwalters@0: for i=1:length(str) tomwalters@0: if strcmp(str,what) tomwalters@0: set(hand,'Value',i); tomwalters@0: return tomwalters@0: end tomwalters@0: end tomwalters@0: return tomwalters@0: