tomwalters@0: % method of class @signal tomwalters@0: % function sig=getpart(sig,from,[to]) tomwalters@0: % tomwalters@0: % INPUT VALUES: tomwalters@0: % @sig: original signal tomwalters@0: % from: from this time in seconds tomwalters@0: % to: to this time in seconds (default: end of signal) tomwalters@0: % RETURN VALUE: tomwalters@0: % returns a signal-object that is a copy of the original signal in the tomwalters@0: % range from-to tomwalters@0: % bleeck@3: % This external file is included as part of the 'aim-mat' distribution package bleeck@3: % (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: function sig=getpart(a,from,to) tomwalters@0: tomwalters@0: sr=getsr(a); tomwalters@0: tomwalters@0: if nargin<3 tomwalters@0: to=getlength(a); tomwalters@0: end tomwalters@0: tomwalters@0: if from < getminimumtime(a) tomwalters@0: error('error: negative beginning in getpart'); tomwalters@0: end tomwalters@0: tomwalters@0: if to > getmaximumtime(a)+sr tomwalters@0: error('error: getpart wants part behind signal'); tomwalters@0: end tomwalters@0: tomwalters@0: duration=to-from; tomwalters@0: sig=signal(duration,sr); tomwalters@0: tomwalters@0: target_nr_point=getnrpoints(sig); tomwalters@0: tomwalters@0: start=time2bin(a,from)+1; tomwalters@0: stop=time2bin(a,to); tomwalters@0: tomwalters@0: % realtarget=stop-start+1; tomwalters@0: % if realtarget~=target_nr_point tomwalters@0: % % seems to happen when sr=44100 tomwalters@0: % target_nr_point=realtarget; tomwalters@0: % end tomwalters@0: tomwalters@0: len=length(a.werte); tomwalters@0: if start+target_nr_point-1 > len tomwalters@0: target_nr_point=len-start+1; tomwalters@0: % seems to happen when sr=44100 tomwalters@0: sig.werte(1:target_nr_point)=a.werte(start:start+target_nr_point-1); tomwalters@0: else tomwalters@0: sig.werte(1:end)=a.werte(start:start+target_nr_point-1); tomwalters@0: end tomwalters@0: % sig.werte(1:end)=a.werte(start:stop); tomwalters@0: tomwalters@0: sig=setstarttime(sig,from); tomwalters@0: sig=setname(sig,sprintf('Part of Signal: %s',getname(a))); tomwalters@0: tomwalters@0: tomwalters@0: