tomwalters@0: % procedure for 'aim-mat' tomwalters@0: % tomwalters@0: % INPUT VALUES: tomwalters@0: % the new soundfilename tomwalters@0: % RETURN VALUE: tomwalters@0: % the updated handles tomwalters@0: % tomwalters@0: % changes the soundfile and updates 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 bleeck@3: bleeck@3: tomwalters@0: tomwalters@0: tomwalters@0: function handles=aim_exchange_sound_file(handles,signame) tomwalters@0: % exchanges the sound file and keeps the parameters tomwalters@0: % this works by deleting the directory tomwalters@0: % saving the parameter file under new name tomwalters@0: % recalculation of all stages up to the chosen one tomwalters@0: tomwalters@0: % save some old values tomwalters@0: oldhandles=handles; tomwalters@0: slider_start=handles.slideredit_start; tomwalters@0: slider_duration=handles.slideredit_duration; tomwalters@0: slider_scale=handles.slideredit_scale; tomwalters@0: slider_combi=handles.currentslidereditcombi; tomwalters@0: slider_frames=handles.slideredit_frames; tomwalters@0: tomwalters@0: tomwalters@0: handles=setupnames(handles,signame); tomwalters@0: dirname=handles.info.directoryname; tomwalters@0: tomwalters@0: tomwalters@0: loadswitch=0; tomwalters@0: if exist(dirname)~=7 % is not a directory so far tomwalters@0: % load the project tomwalters@0: handles=init_aim_parameters(handles,signame); tomwalters@0: loadswitch=1; tomwalters@0: end tomwalters@0: tomwalters@0: % if exist(dirname)==7 % is a directory with a project in (hopefully) tomwalters@0: wave_switch=get(handles.checkbox10,'Value'); tomwalters@0: spectral_switch=get(handles.checkbox6,'Value'); tomwalters@0: temporal_switch=get(handles.checkbox7,'Value'); tomwalters@0: tomwalters@0: % copy the project-file to the new directory: tomwalters@0: oldpfile=fullfile(pwd,oldhandles.info.projectfilename); tomwalters@0: newpfile=fullfile(pwd,handles.info.projectfilename); tomwalters@0: try tomwalters@0: copyfile(oldpfile,newpfile); tomwalters@0: catch tomwalters@0: what=0; tomwalters@0: end tomwalters@0: tomwalters@0: if loadswitch==0 tomwalters@0: % load the project tomwalters@0: handles=init_aim_parameters(handles,signame); tomwalters@0: end tomwalters@0: tomwalters@0: tempinfo=handles.info; tomwalters@0: % the signal options have been overwritten, so set them back: tomwalters@0: handles.all_options.signal.start_time=oldhandles.all_options.signal.start_time; tomwalters@0: handles.all_options.signal.duration=oldhandles.all_options.signal.duration; tomwalters@0: handles.all_options.signal.samplerate=oldhandles.all_options.signal.samplerate; tomwalters@0: handles=init_aim_gui(handles); tomwalters@0: tomwalters@0: tempoptions=handles.all_options; tomwalters@0: % tempinfo=handles.info; tomwalters@0: tomwalters@0: % copy the parameter file to the new directory tomwalters@0: oldpfile=fullfile(pwd,oldhandles.info.parameterfilename); tomwalters@0: newpfile=fullfile(pwd,handles.info.parameterfilename); tomwalters@0: try tomwalters@0: copyfile(oldpfile,newpfile); tomwalters@0: catch tomwalters@0: disp('error in aim_exchange_sound_file: parameter file could not be copied'); tomwalters@0: end tomwalters@0: tomwalters@0: % handles.info.current_pcp_module= tomwalters@0: handles=do_aim_updateparameters(handles); tomwalters@0: tomwalters@0: % set the current modules to the new ones, and set ticks if neccessary: tomwalters@0: handles=setselection(handles,'pcp',oldhandles.info.current_pcp_module); tomwalters@0: handles=setselection(handles,'bmm',oldhandles.info.current_bmm_module); tomwalters@0: handles=setselection(handles,'nap',oldhandles.info.current_nap_module); tomwalters@0: handles=setselection(handles,'strobes',oldhandles.info.current_strobes_module); tomwalters@0: handles=setselection(handles,'sai',oldhandles.info.current_sai_module); tomwalters@0: handles=setselection(handles,'usermodule',oldhandles.info.current_usermodule_module); tomwalters@0: handles=setselection(handles,'movie',oldhandles.info.current_movie_module); tomwalters@0: tomwalters@0: % handles=init_aim_gui(handles); tomwalters@0: tomwalters@0: changepcp=get(handles.checkbox0,'Value') || handles.info.calculate_pcp; tomwalters@0: changebmm=get(handles.checkbox1,'Value')|| handles.info.calculate_bmm; tomwalters@0: changenap=get(handles.checkbox2,'Value')|| handles.info.calculate_nap; tomwalters@0: changestrobes=get(handles.checkbox3,'Value')|| handles.info.calculate_strobes; tomwalters@0: changesai=get(handles.checkbox4,'Value')|| handles.info.calculate_sai; tomwalters@0: changeusermodule=get(handles.checkbox8,'Value')|| handles.info.calculate_usermodule; tomwalters@0: changemovie=get(handles.checkbox5,'Value')|| handles.info.calculate_movie; tomwalters@0: if oldhandles.info.pcp_loaded==1 && (handles.info.pcp_loaded==0 || changepcp==1) tomwalters@0: handles.info.calculate_pcp=1; tomwalters@0: changepcp=1; tomwalters@0: set(handles.checkbox0,'Value',1); tomwalters@0: end tomwalters@0: if oldhandles.info.bmm_loaded==1 && (handles.info.bmm_loaded==0 || changebmm==1 || (handles.info.bmm_loaded==1 && changepcp==1)) tomwalters@0: handles.info.calculate_bmm=1; tomwalters@0: changebmm=1; tomwalters@0: set(handles.checkbox1,'Value',1); tomwalters@0: end tomwalters@0: if oldhandles.info.nap_loaded==1 && (handles.info.nap_loaded==0 || changenap==1 || (handles.info.nap_loaded==1 && changebmm==1)) tomwalters@0: handles.info.calculate_nap=1; tomwalters@0: changenap=1; tomwalters@0: set(handles.checkbox2,'Value',1); tomwalters@0: end tomwalters@0: if oldhandles.info.strobes_loaded==1 && (handles.info.strobes_loaded==0 || changestrobes==1|| (handles.info.strobes_loaded==1 && changenap==1)) tomwalters@0: handles.info.calculate_strobes=1; tomwalters@0: changestrobes=1; tomwalters@0: set(handles.checkbox3,'Value',1); tomwalters@0: end tomwalters@0: if oldhandles.info.sai_loaded==1 && (handles.info.sai_loaded==0 || changesai==1|| (handles.info.sai_loaded==1 && changestrobes==1)) tomwalters@0: handles.info.calculate_sai=1; tomwalters@0: changesai=1; tomwalters@0: set(handles.checkbox4,'Value',1); tomwalters@0: end tomwalters@0: if oldhandles.info.usermodule_loaded==1 && (handles.info.usermodule_loaded==0 || changeusermodule==1 || (handles.info.usermodule_loaded==1 && changesai==1)) tomwalters@0: handles.info.calculate_usermodule=1; tomwalters@0: changeusermodule=1; tomwalters@0: set(handles.checkbox8,'Value',1); tomwalters@0: end tomwalters@0: if oldhandles.info.movie_loaded==1 && (handles.info.movie_loaded==0 || changemovie==1 || (handles.info.movie_loaded==1 && changesai==1)) tomwalters@0: handles.info.calculate_movie=1; tomwalters@0: changemovie=1; tomwalters@0: set(handles.checkbox5,'Value',1); tomwalters@0: end tomwalters@0: tomwalters@0: % if the new project has more columns active then the old one, then tomwalters@0: % delete the surplus tomwalters@0: if oldhandles.info.pcp_loaded ==0 tomwalters@0: handles=aim_deletefile(handles,'pcp'); tomwalters@0: end tomwalters@0: if oldhandles.info.bmm_loaded ==0 tomwalters@0: handles=aim_deletefile(handles,'bmm'); tomwalters@0: end tomwalters@0: if oldhandles.info.nap_loaded ==0 tomwalters@0: handles=aim_deletefile(handles,'nap'); tomwalters@0: end tomwalters@0: if oldhandles.info.strobes_loaded==0 tomwalters@0: handles=aim_deletefile(handles,'strobes'); tomwalters@0: end tomwalters@0: if oldhandles.info.sai_loaded==0 tomwalters@0: handles=aim_deletefile(handles,'sai'); tomwalters@0: end tomwalters@0: if oldhandles.info.usermodule_loaded==0 tomwalters@0: handles=aim_deletefile(handles,'usermodule'); tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: handles=do_aim_calculate(handles); tomwalters@0: tomwalters@0: % reset the signal options to the new ones: tomwalters@0: handles.all_options.signal=tempoptions.signal; tomwalters@0: handles=aim_saveparameters(handles,handles.info.parameterfilename,1); tomwalters@0: tomwalters@0: tomwalters@0: % force the sliders to the same values as before: tomwalters@0: handles.slideredit_start=slider_start; tomwalters@0: handles.slideredit_duration=slider_duration; tomwalters@0: handles.slideredit_scale=slider_scale; tomwalters@0: handles.currentslidereditcombi=slider_combi; tomwalters@0: handles.slideredit_frames=slider_frames; tomwalters@0: tomwalters@0: set(handles.checkbox10,'Value',wave_switch); tomwalters@0: set(handles.checkbox6,'Value',spectral_switch); tomwalters@0: set(handles.checkbox7,'Value',temporal_switch); tomwalters@0: tomwalters@0: return tomwalters@0: tomwalters@0: tomwalters@0: function handles=setselection(handles,selstr,curmod) tomwalters@0: switch selstr tomwalters@0: case('pcp') tomwalters@0: hand=handles.listbox0; tomwalters@0: hand2=handles.checkbox0; tomwalters@0: oldnam=handles.info.current_pcp_module; tomwalters@0: handles.info.current_pcp_module=curmod; tomwalters@0: case('bmm') tomwalters@0: hand=handles.listbox1; tomwalters@0: hand2=handles.checkbox1; tomwalters@0: oldnam=handles.info.current_bmm_module; tomwalters@0: handles.info.current_bmm_module=curmod; tomwalters@0: case('nap') tomwalters@0: hand=handles.listbox2; tomwalters@0: hand2=handles.checkbox2; tomwalters@0: oldnam=handles.info.current_nap_module; tomwalters@0: handles.info.current_nap_module=curmod; tomwalters@0: case('strobes') tomwalters@0: hand=handles.listbox3; tomwalters@0: hand2=handles.checkbox3; tomwalters@0: oldnam=handles.info.current_strobes_module; tomwalters@0: handles.info.current_strobes_module=curmod; tomwalters@0: case('sai') tomwalters@0: hand=handles.listbox4; tomwalters@0: hand2=handles.checkbox4; tomwalters@0: oldnam=handles.info.current_sai_module; tomwalters@0: handles.info.current_sai_module=curmod; tomwalters@0: case('usermodule') tomwalters@0: hand=handles.listbox6; tomwalters@0: hand2=handles.checkbox8; tomwalters@0: oldnam=handles.info.current_usermodule_module; tomwalters@0: handles.info.current_usermodule_module=curmod; tomwalters@0: case('movie') tomwalters@0: hand=handles.listbox5; tomwalters@0: hand2=handles.checkbox5; tomwalters@0: oldnam=handles.info.current_movie_module; tomwalters@0: handles.info.current_movie_module=curmod; tomwalters@0: end tomwalters@0: % it the new module is different from the old one, then set the tick tomwalters@0: if ~strcmp(oldnam,curmod) tomwalters@0: set(hand2,'Value',1); tomwalters@0: end tomwalters@0: tomwalters@0: names=get(hand,'String'); tomwalters@0: for i=1:length(names) tomwalters@0: if strcmp(names{i},curmod) tomwalters@0: set(hand,'Value',i); tomwalters@0: return tomwalters@0: end tomwalters@0: end tomwalters@0: return