comparison toolboxes/MIRtoolbox1.3.2/AuditoryToolbox/rasta.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function y=rasta(x,fs,low,high)
2 % function y=rasta(x,fs) where x is the input data (rows of time data),
3 % and fs is the frame rate (sampling rate) in Hz. This is a modified
4 % version of the original filter. Here the RASTA filter is approximated
5 % by a simple fourth order Butterworth bandpass filter. See pages 50-51
6 % of my second IRC logbook for the derivation.
7 %
8 % Hermansky and Morgan, "RASTA Processing of Speech." IEEE Transactions
9 % on Speech and Audio Processing. vol. 2, no. 4, October 1994
10 %
11
12 % (c) 1998 Interval Research Corporation
13 % Malcolm Slaney, January 30, 1996, Interval Research Corporation
14
15 if (nargin < 2); fs=100; end
16 if (nargin < 3); low=.9; end
17 if (nargin < 4); high=12.8; end
18
19 if (low == 0 & high == 0) % Original Filter
20 num = .1*[2 1 0 -1 -2];
21 denum = [1 -.94];
22 else % New fourth order
23 % Butterworth BP filter
24 w1=low/fs*2*pi;
25 w2=high/fs*2*pi;
26 theta=1;
27
28 a=cos((w1+w2)/2)/cos((w2-w1)/2);
29 k=cot((w2-w1)/2)*tan(theta/2);
30
31 num = [1 0 -2 0 1];
32 denum = [(1 + 2*2^(1/2)*k + 4*k^2) ...
33 (-4*2^(1/2)*a*k - 16*a*k^2) ...
34 (-2 + 8*k^2 + 16*a^2*k^2) ...
35 (4*2^(1/2)*a*k - 16*a*k^2) ...
36 (1 - 2*2^(1/2)*k + 4*k^2)];
37 scale = denum(1); % Scale by a(1) component
38 num = num/scale;
39 denum = denum/scale;
40 end
41
42 if (0)
43 len = 1024;
44 impulse = zeros(1,len);
45 impulse(1) = 1;
46
47 y=filter(num,denum,impulse);
48 ym = abs(fft(y));
49 ym=20*log10(ym);
50 f=(0:(len-1))/len*fs;
51 semilogx(f(1:len/2),ym(1:len/2));
52 drawnow;
53 end
54
55 if (length(x) == size(x,1)*size(x,2))
56 y = filter(num,denum,x,x(1)*[-1 -1 1 1]);
57 else
58 y = zeros(size(x));
59 for i=1:size(x,1)
60 y(i,:) = filter(num,denum,x(i,:),x(i,1)*[-1 -1 1 1]/scale);
61 end
62 end