-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsbpca_inv_subbands.m
40 lines (34 loc) · 1.14 KB
/
sbpca_inv_subbands.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function [d, sr] = sbpca_inv_subbands(subbands, params)
% [d, sr] = sbpca_inv_subbands(subbands, params)
% Invert mapping to subbands for SBPCA.
% 2013-05-27 Dan Ellis [email protected]
%d = ifilterbank(params.fbank.b, params.fbank.a, subbands, 1, params.fbank.t);
%function X = ifilterbank(B,A,M,N,T)
% X = ifilterbank(B,A,M,N,T) Invert IIR filterbank output to single channel.
% recover number of filters
[bands, flena] = size(params.fbank.a);
[sbbands, mcols] = size(subbands);
if sbbands ~= bands
error('Rows of data different from number of filter definitions')
end
% columns in output may be interpolated
xcols = 1+(mcols-1);
% initialize output
d = zeros(xcols,1);
% calculate each row
for filt = 1:bands
% get filter parameters
a = params.fbank.a(filt, :);
b = params.fbank.b(filt, :);
% extract data row & interpolate with zeros
interp = zeros(xcols,1);
interp(1:xcols) = subbands(filt,:)';
% time shift
t = round(params.fbank.t(filt)); % samples to shift must be an integer
interp = [zeros(t,1); interp(1:end-t)];
% filter
y = filter(b,a,flipud(interp));
% accumulate in output
d = d+flipud(y);
end
sr = params.sr;