tomwalters@0: % method of class @ tomwalters@0: % function newsig=squeeze(sig,factor) tomwalters@0: % INPUT VALUES: tomwalters@0: % sig: orginal @signal tomwalters@0: % factor: factor, by which the signal is squeezed tomwalters@0: % RETURN VALUE: tomwalters@0: % newsig: squeezed signal tomwalters@0: % tomwalters@0: % reduces the length of the signal by scaling it in time 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 newsig=squeeze(sig,factor) tomwalters@0: tomwalters@0: tomwalters@0: %%%%%%%%%%%%%%% tomwalters@0: % if squeezed it becomes shorter tomwalters@0: if factor < 1 tomwalters@0: len=getlength(sig); tomwalters@0: newlen=len*factor; tomwalters@0: sr=sig.samplerate; tomwalters@0: newsr=sr; % dont change the sr tomwalters@0: if newlen < newsr tomwalters@0: newlen=newsr; tomwalters@0: end tomwalters@0: newsig=signal(newlen,newsr); tomwalters@0: nr_points=getnrpoints(newsig); tomwalters@0: new_vals=zeros(nr_points,1); tomwalters@0: for i=1:nr_points tomwalters@0: whichstart=(i-1)*newsr/factor; tomwalters@0: whichstop=i*newsr/factor; tomwalters@0: tomwalters@0: if whichstop>len tomwalters@0: whichstop=len; tomwalters@0: end tomwalters@0: new_vals(i)=average(sig,whichstart,whichstop); tomwalters@0: end tomwalters@0: newsig=setvalues(newsig,new_vals); tomwalters@0: return tomwalters@0: end tomwalters@0: tomwalters@0: newsig=sig; tomwalters@0: tomwalters@0: