一个简单的RASTA matlab CODE

 

function y=rasta(x,fs,low,high)
% function y=rasta(x,fs) where x is the input data (rows of time data),
% and fs is the frame rate (sampling rate) in Hz.  This is a modified
% version of the original filter. Here the RASTA filter is approximated
% by a simple fourth order Butterworth bandpass filter.  See pages 50-51
% of my second IRC logbook for the derivation.
%
% Hermansky and Morgan, "RASTA Processing of Speech."  IEEE Transactions
% on Speech and Audio Processing.  vol. 2, no. 4, October 1994
%

% (c) 1998 Interval Research Corporation 
% Malcolm Slaney, January 30, 1996, Interval Research Corporation

if (nargin < 2); fs=100; end
if (nargin < 3); low=.9; end
if (nargin < 4); high=12.8; end

if (low == 0 & high == 0)   % Original Filter
 num = .1*[2 1 0 -1 -2];
 denum = [1 -.94];
else      % New fourth order
      % Butterworth BP filter
 w1=low/fs*2*pi;
 w2=high/fs*2*pi;
 theta=1;
 
 a=cos((w1+w2)/2)/cos((w2-w1)/2);
 k=cot((w2-w1)/2)*tan(theta/2);
 
 num = [1 0 -2 0 1];
 denum = [(1 + 2*2^(1/2)*k + 4*k^2) ...
   (-4*2^(1/2)*a*k - 16*a*k^2) ...
   (-2 + 8*k^2 + 16*a^2*k^2) ...
   (4*2^(1/2)*a*k - 16*a*k^2) ...
   (1 - 2*2^(1/2)*k + 4*k^2)];
 scale = denum(1);   % Scale by a(1) component
 num = num/scale;
 denum = denum/scale;
end

if (0)
 len = 1024;
 impulse = zeros(1,len);
 impulse(1) = 1;
 
 y=filter(num,denum,impulse);
 ym = abs(fft(y));
 ym=20*log10(ym);
 f=(0:(len-1))/len*fs;
 semilogx(f(1:len/2),ym(1:len/2));
 drawnow;
end

if (length(x) == size(x,1)*size(x,2))
 y = filter(num,denum,x,x(1)*[-1 -1 1 1]);
else
 y = zeros(size(x));
 for i=1:size(x,1)
  y(i,:) = filter(num,denum,x(i,:),x(i,1)*[-1 -1 1 1]/scale);
 end
end

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值