annotate aim-mat/tools/@signal/leakyintegrator.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
bleeck@3 2 % This external file is included as part of the 'aim-mat' distribution package
bleeck@3 3 % (c) 2011, University of Southampton
bleeck@3 4 % Maintained by Stefan Bleeck (bleeck@gmail.com)
bleeck@3 5 % download of current version is on the soundsoftware site:
bleeck@3 6 % http://code.soundsoftware.ac.uk/projects/aimmat
bleeck@3 7 % documentation and everything is on http://www.acousticscale.org
bleeck@3 8
tomwalters@0 9 %
tomwalters@0 10
tomwalters@0 11 function nvals=leakyintegrator(sig,lowpass_cutoff_frequency,order)
tomwalters@0 12
tomwalters@0 13
tomwalters@0 14 time_constant=1/(2.*pi.*lowpass_cutoff_frequency);
tomwalters@0 15 sr=getsr(sig);
tomwalters@0 16 vals=getvalues(sig);
tomwalters@0 17 b=exp(-1/(sr.*time_constant));
tomwalters@0 18 gain=1./(1-b);
tomwalters@0 19
tomwalters@0 20
tomwalters@0 21 nvals=zeros(size(vals));
tomwalters@0 22 for dothis=1:order
tomwalters@0 23 xn_1=0;
tomwalters@0 24 yn_1=0;
tomwalters@0 25 for i=1:length(vals)
tomwalters@0 26 xn=vals(i);
tomwalters@0 27 yn= xn + b*yn_1 ;
tomwalters@0 28 xn_1=xn;
tomwalters@0 29 yn_1=yn;
tomwalters@0 30 nvals(i)=yn;
tomwalters@0 31 end
tomwalters@0 32 vals=nvals./gain;
tomwalters@0 33 end
tomwalters@0 34
tomwalters@0 35 nvals=vals;