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 bleeck@3: bleeck@3: tomwalters@0: tomwalters@0: tomwalters@0: function handles=aim_loadsignalfile(handles,signalwavename) tomwalters@0: tomwalters@0: % load the signal file (we know, that it is there tomwalters@0: sig=loadwavefile(signal,signalwavename); tomwalters@0: tomwalters@0: % first save the original signal as a copy tomwalters@0: savewave(sig,handles.info.originalwavename,0); tomwalters@0: tomwalters@0: tomwalters@0: len=getlength(sig); tomwalters@0: if len<0.04 tomwalters@0: disp('Signal is too short (<40ms)! padding it with zeros automatically'); tomwalters@0: sig=expand(sig,0.04,0) tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: handles.info.signal_loaded=1; % it is now loaded! tomwalters@0: tomwalters@0: if handles.autorun==0 % only, when not called with a data structure tomwalters@0: % we add these parameters to the parameter file 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: tomwalters@0: % % prevent user to choose too long singals, because they are too slow tomwalters@0: % % usually we only want a part of the signal tomwalters@0: % max_allowed_duration=0.2; tomwalters@0: % if getlength(sig) > max_allowed_duration tomwalters@0: % text{1}='The signal is longer then 200 ms'; tomwalters@0: % text{2}='So the model will run rather slowly.'; tomwalters@0: % current_start=0; tomwalters@0: % current_duration=getlength(sig); tomwalters@0: % allowed_duration=getlength(sig); tomwalters@0: % [new_start_time,new_duration]=length_questionbox(current_start,current_duration,allowed_duration,text); tomwalters@0: % if new_start_time~=0; tomwalters@0: % handles.all_options.signal.start_time=new_start_time; tomwalters@0: % end tomwalters@0: % if new_duration~=getlength(sig); tomwalters@0: % handles.all_options.signal.duration=new_duration; tomwalters@0: % end tomwalters@0: % end tomwalters@0: % tomwalters@0: 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: tomwalters@0: end tomwalters@0: tomwalters@0: % save it to the data structure tomwalters@0: name=handles.info.signalname; tomwalters@0: aim_savefile(handles,sig,name,'signal','signal',handles.all_options.signal,handles.all_options) tomwalters@0: handles.data.original_signal=sig; tomwalters@0: handles.data.signal=sig; tomwalters@0: tomwalters@0: tomwalters@0: if handles.autorun==0 % only, when not called with a data structure tomwalters@0: % if the samplerate is too high, sample it down per default tomwalters@0: max_allowed_sr=25000; tomwalters@0: if getsr(sig) > max_allowed_sr tomwalters@0: new_sr=sr_questionbox(getsr(sig)); tomwalters@0: if new_sr~=getsr(sig); tomwalters@0: sig=changesr(sig,new_sr); % this does the resampling tomwalters@0: handles.all_options.signal.samplerate=new_sr; tomwalters@0: signalstruct.data=sig; tomwalters@0: handles.data.original_signal=sig; tomwalters@0: handles.data.signal=sig; tomwalters@0: end tomwalters@0: 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: % end tomwalters@0: end tomwalters@0: end tomwalters@0: tomwalters@0: % the signal must not be changed at the moment tomwalters@0: handles.info.calculate_signal=0; tomwalters@0: tomwalters@0: % and save the signal in the new directory tomwalters@0: savewave(sig,handles.info.signalwavename,0); tomwalters@0: tomwalters@0: tomwalters@0: