annotate aim-mat/gui/aim_loadsignalfile.m @ 4:537f939baef0 tip

various bug fixes and changed copyright message
author Stefan Bleeck <bleeck@gmail.com>
date Tue, 16 Aug 2011 14:37:17 +0100
parents 20ada0af3d7d
children
rev   line source
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
bleeck@3 16
bleeck@3 17
tomwalters@0 18
tomwalters@0 19
tomwalters@0 20 function handles=aim_loadsignalfile(handles,signalwavename)
tomwalters@0 21
tomwalters@0 22 % load the signal file (we know, that it is there
tomwalters@0 23 sig=loadwavefile(signal,signalwavename);
tomwalters@0 24
tomwalters@0 25 % first save the original signal as a copy
tomwalters@0 26 savewave(sig,handles.info.originalwavename,0);
tomwalters@0 27
tomwalters@0 28
tomwalters@0 29 len=getlength(sig);
tomwalters@0 30 if len<0.04
tomwalters@0 31 disp('Signal is too short (<40ms)! padding it with zeros automatically');
tomwalters@0 32 sig=expand(sig,0.04,0)
tomwalters@0 33 end
tomwalters@0 34
tomwalters@0 35
tomwalters@0 36 handles.info.signal_loaded=1; % it is now loaded!
tomwalters@0 37
tomwalters@0 38 if handles.autorun==0 % only, when not called with a data structure
tomwalters@0 39 % we add these parameters to the parameter file
tomwalters@0 40 handles.all_options.signal.signal_filename=handles.info.oldsignalwavename;
tomwalters@0 41 handles.all_options.signal.start_time=0;
tomwalters@0 42 handles.all_options.signal.duration=getlength(sig);
tomwalters@0 43 handles.all_options.signal.samplerate=getsr(sig);
tomwalters@0 44
tomwalters@0 45 % % prevent user to choose too long singals, because they are too slow
tomwalters@0 46 % % usually we only want a part of the signal
tomwalters@0 47 % max_allowed_duration=0.2;
tomwalters@0 48 % if getlength(sig) > max_allowed_duration
tomwalters@0 49 % text{1}='The signal is longer then 200 ms';
tomwalters@0 50 % text{2}='So the model will run rather slowly.';
tomwalters@0 51 % current_start=0;
tomwalters@0 52 % current_duration=getlength(sig);
tomwalters@0 53 % allowed_duration=getlength(sig);
tomwalters@0 54 % [new_start_time,new_duration]=length_questionbox(current_start,current_duration,allowed_duration,text);
tomwalters@0 55 % if new_start_time~=0;
tomwalters@0 56 % handles.all_options.signal.start_time=new_start_time;
tomwalters@0 57 % end
tomwalters@0 58 % if new_duration~=getlength(sig);
tomwalters@0 59 % handles.all_options.signal.duration=new_duration;
tomwalters@0 60 % end
tomwalters@0 61 % end
tomwalters@0 62 %
tomwalters@0 63
tomwalters@0 64 handles.all_options.signal.original_start_time=0;
tomwalters@0 65 handles.all_options.signal.original_duration=getlength(sig);
tomwalters@0 66 handles.all_options.signal.original_samplerate=getsr(sig);
tomwalters@0 67
tomwalters@0 68 end
tomwalters@0 69
tomwalters@0 70 % save it to the data structure
tomwalters@0 71 name=handles.info.signalname;
tomwalters@0 72 aim_savefile(handles,sig,name,'signal','signal',handles.all_options.signal,handles.all_options)
tomwalters@0 73 handles.data.original_signal=sig;
tomwalters@0 74 handles.data.signal=sig;
tomwalters@0 75
tomwalters@0 76
tomwalters@0 77 if handles.autorun==0 % only, when not called with a data structure
tomwalters@0 78 % if the samplerate is too high, sample it down per default
tomwalters@0 79 max_allowed_sr=25000;
tomwalters@0 80 if getsr(sig) > max_allowed_sr
tomwalters@0 81 new_sr=sr_questionbox(getsr(sig));
tomwalters@0 82 if new_sr~=getsr(sig);
tomwalters@0 83 sig=changesr(sig,new_sr); % this does the resampling
tomwalters@0 84 handles.all_options.signal.samplerate=new_sr;
tomwalters@0 85 signalstruct.data=sig;
tomwalters@0 86 handles.data.original_signal=sig;
tomwalters@0 87 handles.data.signal=sig;
tomwalters@0 88 end
tomwalters@0 89
tomwalters@0 90 % % ask user if he wants that hi sample rate
tomwalters@0 91 % 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 92 % if ~isempty(srneu)
tomwalters@0 93 % end
tomwalters@0 94 end
tomwalters@0 95 end
tomwalters@0 96
tomwalters@0 97 % the signal must not be changed at the moment
tomwalters@0 98 handles.info.calculate_signal=0;
tomwalters@0 99
tomwalters@0 100 % and save the signal in the new directory
tomwalters@0 101 savewave(sig,handles.info.signalwavename,0);
tomwalters@0 102
tomwalters@0 103
tomwalters@0 104