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 bleeck@3: tomwalters@0: % tomwalters@0: tomwalters@0: function nvals=leakyintegrator(sig,lowpass_cutoff_frequency,order) tomwalters@0: tomwalters@0: tomwalters@0: time_constant=1/(2.*pi.*lowpass_cutoff_frequency); tomwalters@0: sr=getsr(sig); tomwalters@0: vals=getvalues(sig); tomwalters@0: b=exp(-1/(sr.*time_constant)); tomwalters@0: gain=1./(1-b); tomwalters@0: tomwalters@0: tomwalters@0: nvals=zeros(size(vals)); tomwalters@0: for dothis=1:order tomwalters@0: xn_1=0; tomwalters@0: yn_1=0; tomwalters@0: for i=1:length(vals) tomwalters@0: xn=vals(i); tomwalters@0: yn= xn + b*yn_1 ; tomwalters@0: xn_1=xn; tomwalters@0: yn_1=yn; tomwalters@0: nvals(i)=yn; tomwalters@0: end tomwalters@0: vals=nvals./gain; tomwalters@0: end tomwalters@0: tomwalters@0: nvals=vals;