tomwalters@0: % method of class @signal tomwalters@0: % function sigresult=smooth(org_sig,sigma) tomwalters@0: % INPUT VALUES: tomwalters@0: % org_sig: orgiginal @signal tomwalters@0: % sigma: smooth width tomwalters@0: % type: 'gauss' gauss average, sigma is sigma of gauss function (default) tomwalters@0: % 'rect' rectangle window, width = 2*sigma+1 tomwalters@0: % mirrow signal at border tomwalters@0: % tomwalters@0: % RETURN VALUE: tomwalters@0: % sigresult: smoothed @signal tomwalters@0: % tomwalters@0: % smoothes the signal by multipliing it with gaussian filters of tomwalters@0: % the width "sigma" in ms 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=smooth(org_sig,sigma, type) tomwalters@0: tomwalters@0: % vals=getvalues(org_sig); tomwalters@0: % % check sigma tomwalters@0: % if sigma<3 tomwalters@0: % sigma==3 tomwalters@0: % end tomwalters@0: % if mod(sigma, 2)==0 tomwalters@0: % sigma=sigma+1 tomwalters@0: % end tomwalters@0: % % Generate Kernel tomwalters@0: % t = (-2*sigma):(2*sigma); tomwalters@0: % kernel = 1/(sqrt(2*pi)*sigma)*exp(-(t).^2/(2*sigma.^2)); tomwalters@0: % tomwalters@0: if (nargin<3) tomwalters@0: type='gauss'; tomwalters@0: end tomwalters@0: tomwalters@0: vals=getvalues(org_sig); tomwalters@0: new_vals=vals; tomwalters@0: % Stefans's version tomwalters@0: if strcmp(type,'gauss') tomwalters@0: nr_points=getnrpoints(org_sig); tomwalters@0: smooth_base=1:nr_points; tomwalters@0: smooth_frame = zeros(nr_points,1); tomwalters@0: for ii = 1:nr_points tomwalters@0: % kernel = exp(-(smooth_base-ii).^2/(2*sigma^2)); tomwalters@0: kernel = exp(-(((smooth_base-ii).*(smooth_base-ii))/(2*sigma*sigma))); tomwalters@0: kernel = kernel / sum(kernel); tomwalters@0: new_vals(ii) = sum(vals.*kernel'); tomwalters@0: end tomwalters@0: end tomwalters@0: if strcmp(type, 'rect') tomwalters@0: nr_points=getnrpoints(org_sig); tomwalters@0: % mirroring the border tomwalters@0: sigma=round(sigma); tomwalters@0: vals=vals'; tomwalters@0: if (length(vals)