[e6709d]: filterbank / ifilterbank.m  Maximize  Restore  History

Download this file

96 lines (83 with data), 2.6 kB

 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
function f=ifilterbank(c,g,a,varargin);
%IFILTERBANK Filter bank inversion
% Usage: f=ifilterbank(c,g,a);
%
% `ifilterbank(c,g,a)` synthesizes a signal *f* from the coefficients *c*
% using the filters stored in *g* for a channel subsampling rate of *a* (the
% hop-size). The coefficients has to be in the format returned by
% either |filterbank| or |ufilterbank|.
%
% The filter format for *g* is the same as for |filterbank|.
%
% If perfect reconstruction is desired, the filters must be the duals
% of the filters used to generate the coefficients. See the help on
% |filterbankdual|.
%
% See also: filterbank, ufilterbank, filterbankdual
%
% References: bohlfe02
if nargin<3
error('%s: Too few input parameters.',upper(mfilename));
end;
definput.keyvals.Ls=[];
[flags,kv,Ls]=ltfatarghelper({'Ls'},definput,varargin);
L=filterbanklengthcoef(c,a);
[g,info]=filterbankwin(g,a,L,'normal');
M=info.M;
a=info.a;
if iscell(c)
Mcoef=numel(c);
W=size(c{1},2);
else
Mcoef=size(c,2);
W=size(c,3);
end;
if ~(M==Mcoef)
error(['Mismatch between the size of the input coefficients and the ' ...
'number of filters.']);
end;
if iscell(c)
f=zeros(L,W,assert_classname(c{1}));
else
f=zeros(L,W,assert_classname(c));
end;
% This routine must handle the following cases
%
% * Time-side or frequency-side filters (test for isfield(g,'H'))
%
% * Cell array or matrix input (test for iscell(c))
%
% * Regular or fractional subsampling (test for info.isfractional)
l=(0:L-1).'/L;
for m=1:M
conjG=conj(comp_transferfunction(g{m},L));
% Handle fractional subsampling (this implies frequency side filters)
if info.isfractional
N=size(c{m},1);
Llarge=ceil(L/N)*N;
amod=Llarge/N;
for w=1:W
% This repmat cannot be replaced by bsxfun
innerstuff=middlepad(circshift(repmat(fft(c{m}(:,w)),amod,1),-g{m}.foff),L);
f(:,w)=f(:,w)+ifft(circshift(bsxfun(@times,innerstuff,circshift(conjG,-g{m}.foff)),g{m}.foff));
end;
else
if iscell(c)
for w=1:W
% This repmat cannot be replaced by bsxfun
f(:,w)=f(:,w)+ifft(repmat(fft(c{m}(:,w)),a(m),1).*conjG);
end;
else
for w=1:W
% This repmat cannot be replaced by bsxfun
f(:,w)=f(:,w)+ifft(repmat(fft(c(:,m,w)),a(m),1).*conjG);
end;
end;
end;
end;
% Cut or extend f to the correct length, if desired.
if ~isempty(Ls)
f=postpad(f,Ls);
else
Ls=L;
end;

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks