Daniel@0: function y=rasta(x,fs,low,high) Daniel@0: % function y=rasta(x,fs) where x is the input data (rows of time data), Daniel@0: % and fs is the frame rate (sampling rate) in Hz. This is a modified Daniel@0: % version of the original filter. Here the RASTA filter is approximated Daniel@0: % by a simple fourth order Butterworth bandpass filter. See pages 50-51 Daniel@0: % of my second IRC logbook for the derivation. Daniel@0: % Daniel@0: % Hermansky and Morgan, "RASTA Processing of Speech." IEEE Transactions Daniel@0: % on Speech and Audio Processing. vol. 2, no. 4, October 1994 Daniel@0: % Daniel@0: Daniel@0: % (c) 1998 Interval Research Corporation Daniel@0: % Malcolm Slaney, January 30, 1996, Interval Research Corporation Daniel@0: Daniel@0: if (nargin < 2); fs=100; end Daniel@0: if (nargin < 3); low=.9; end Daniel@0: if (nargin < 4); high=12.8; end Daniel@0: Daniel@0: if (low == 0 & high == 0) % Original Filter Daniel@0: num = .1*[2 1 0 -1 -2]; Daniel@0: denum = [1 -.94]; Daniel@0: else % New fourth order Daniel@0: % Butterworth BP filter Daniel@0: w1=low/fs*2*pi; Daniel@0: w2=high/fs*2*pi; Daniel@0: theta=1; Daniel@0: Daniel@0: a=cos((w1+w2)/2)/cos((w2-w1)/2); Daniel@0: k=cot((w2-w1)/2)*tan(theta/2); Daniel@0: Daniel@0: num = [1 0 -2 0 1]; Daniel@0: denum = [(1 + 2*2^(1/2)*k + 4*k^2) ... Daniel@0: (-4*2^(1/2)*a*k - 16*a*k^2) ... Daniel@0: (-2 + 8*k^2 + 16*a^2*k^2) ... Daniel@0: (4*2^(1/2)*a*k - 16*a*k^2) ... Daniel@0: (1 - 2*2^(1/2)*k + 4*k^2)]; Daniel@0: scale = denum(1); % Scale by a(1) component Daniel@0: num = num/scale; Daniel@0: denum = denum/scale; Daniel@0: end Daniel@0: Daniel@0: if (0) Daniel@0: len = 1024; Daniel@0: impulse = zeros(1,len); Daniel@0: impulse(1) = 1; Daniel@0: Daniel@0: y=filter(num,denum,impulse); Daniel@0: ym = abs(fft(y)); Daniel@0: ym=20*log10(ym); Daniel@0: f=(0:(len-1))/len*fs; Daniel@0: semilogx(f(1:len/2),ym(1:len/2)); Daniel@0: drawnow; Daniel@0: end Daniel@0: Daniel@0: if (length(x) == size(x,1)*size(x,2)) Daniel@0: y = filter(num,denum,x,x(1)*[-1 -1 1 1]); Daniel@0: else Daniel@0: y = zeros(size(x)); Daniel@0: for i=1:size(x,1) Daniel@0: y(i,:) = filter(num,denum,x(i,:),x(i,1)*[-1 -1 1 1]/scale); Daniel@0: end Daniel@0: end