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: tomwalters@0: function handles=loadsignalfile(handles,signame); 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: moviename=handles.info.moviename; tomwalters@0: tomwalters@0: tomwalters@0: % load the parameterfile: tomwalters@0: if fexist(handles.info.parameterfilename) tomwalters@0: workdir=pwd; tomwalters@0: cd(handles.info.directoryname); tomwalters@0: [a,parfile,c,d]=fileparts(handles.info.parameterfilename); tomwalters@0: clear all_options; tomwalters@0: eval(parfile); tomwalters@0: cd(workdir); tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: if fexist(signalname) tomwalters@0: [sig,sigoptions]=aim_loadfile(signalname); tomwalters@0: else tomwalters@0: if fexist(signalwavename) tomwalters@0: sig=loadwavefile(signal,signalwavename); tomwalters@0: % and save the wavefile hinterher: tomwalters@0: % nsf=sprintf('%s\\%s',handles.info.directoryname,signalwavename); tomwalters@0: % copyfile(signalwavename,nsf); tomwalters@0: % delete(signalwavename); tomwalters@0: % signalwavename=nsf; tomwalters@0: elseif fexist(oldsignalwavename) tomwalters@0: sig=loadwavefile(signal,oldsignalwavename); tomwalters@0: % and save the wavefile hinterher: tomwalters@0: nsf=sprintf('%s\\%s',handles.info.directoryname,oldsignalwavename); tomwalters@0: copyfile(oldsignalwavename,nsf); tomwalters@0: % delete(oldsignalwavename); tomwalters@0: signalwavename=nsf; tomwalters@0: else tomwalters@0: % handles=0; tomwalters@0: return tomwalters@0: end tomwalters@0: end tomwalters@0: handles.data.sig=sig; tomwalters@0: len=getlength(sig); tomwalters@0: if len<0.04 tomwalters@0: str=sprintf('Signal %s too short',signame); tomwalters@0: er=errordlg(str,'File Error'); tomwalters@0: set(er,'WindowStyle','modal'); tomwalters@0: pause; tomwalters@0: handles=0; tomwalters@0: return tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: handles.info.signal_loaded=1; tomwalters@0: % we add these parameters to the parameter file (for the future) tomwalters@0: handles.all_options.signal.signal_filename=handles.info.oldsignalwavename; 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: signalstruct.data=sig; tomwalters@0: signalstruct.options=handles.all_options.signal; tomwalters@0: tomwalters@0: % if the samplerate is too high, sample it down per default tomwalters@0: sr=22050; tomwalters@0: if handles.all_options.signal.samplerate>sr tomwalters@0: % ask user if he wants that hi sample rate tomwalters@0: srneu=input('The samplerate of the specified signal \nis higher then 22050 Hz. \nPlease insert a smaller samperate \n(or return for keeping the old one): '); tomwalters@0: if ~isempty(srneu) tomwalters@0: sig=changesr(sig,srneu); tomwalters@0: handles.all_options.signal.samplerate=srneu; tomwalters@0: signalstruct.data=sig; tomwalters@0: handles.data.sig=sig; tomwalters@0: end tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: save(signalname,'signalstruct'); tomwalters@0: savewave(sig,signalwavename,0); 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: 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: 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: 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: 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: 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: 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: break tomwalters@0: end tomwalters@0: end tomwalters@0: end tomwalters@0: tomwalters@0: % change the sliders according to the new signal: tomwalters@0: % combi_start=handles.slideredit_start; tomwalters@0: % combi_duration=handles.slideredit_start; tomwalters@0: tomwalters@0: duration=0.04; tomwalters@0: start_time=getminimumtime(sig); tomwalters@0: tomwalters@0: handles.slideredit_duration.maxvalue=getlength(sig); tomwalters@0: handles.slideredit_duration.minvalue=0.005; tomwalters@0: handles.slideredit_start.minvalue=start_time; tomwalters@0: handles.slideredit_start.maxvalue=getlength(sig); tomwalters@0: tomwalters@0: handles.slideredit_start=slidereditcontrol_set_range(handles.slideredit_start,duration); % the duration tomwalters@0: % handles.slideredit_duration=slidereditcontrol_set_range(handles.slideredit_duration,duration); % the duration tomwalters@0: handles.slideredit_start=slidereditcontrol_set_value(handles.slideredit_start,start_time); % set to the beginning of the signal tomwalters@0: handles.slideredit_duration=slidereditcontrol_set_value(handles.slideredit_duration,duration); % set to the beginning of the signal tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: set(handles.displayduration,'String',num2str(fround(getlength(sig)*1000,1))); tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: % % start_time=offset; tomwalters@0: % set(handles.edit2,'String',num2str(start_time*1000)); tomwalters@0: % set(handles.edit3,'String',num2str(duration*1000)); tomwalters@0: % tomwalters@0: % tomwalters@0: % set(handles.slider3,'Value',0); tomwalters@0: % set(handles.slider3,'Value',duration/max_duration); tomwalters@0: % tomwalters@0: % handles.data.min_duration=min_duration; tomwalters@0: % handles.data.max_duration=max_duration; tomwalters@0: % handles.data.max_start_time=max_start_time; tomwalters@0: % handles.data.min_start_time=min_start_time; tomwalters@0: % tomwalters@0: % set(handles.edit1,'String',num2str(1)); tomwalters@0: % handles.data.min_scale=0.001; tomwalters@0: % handles.data.max_scale=1000; tomwalters@0: % set(handles.slider1,'Value',f2f(1,handles.data.min_scale,handles.data.max_scale,0,1,'loglin')); tomwalters@0: tomwalters@0: % set(handles.pushbutton8,'Enable','on'); tomwalters@0: % set(handles.pushbutton9,'Enable','on'); tomwalters@0: % set(handles.pushbutton10,'Enable','on'); tomwalters@0: set(handles.edit1,'Enable','on'); tomwalters@0: set(handles.slider1,'Enable','on'); tomwalters@0: set(handles.edit2,'Enable','on'); tomwalters@0: set(handles.slider2,'Enable','on'); tomwalters@0: set(handles.edit3,'Enable','on'); tomwalters@0: set(handles.slider3,'Enable','on'); tomwalters@0: tomwalters@0: tomwalters@0: % aim_saveparameters(handles); 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: