forked from ltfat/ltfat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathufilterbank.m
68 lines (55 loc) · 1.79 KB
/
ufilterbank.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
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
function c=ufilterbank(f,g,a,varargin)
%UFILTERBANK Apply Uniform filterbank
% Usage: c=ufilterbank(f,g,a);
%
% `ufilterbank(f,g,a)` applies the filter given in *g* to the signal
% *f*. Each subband will be subsampled by a factor of *a* (the
% hop-size). If *f* is a matrix, the transformation is applied to each
% column.
%
% The filters *g* must be a cell-array, where each entry in the cell
% array corresponds to a filter.
%
% If *f* is a single vector, then the output will be a matrix, where each
% column in *f* is filtered by the corresponding filter in *g*. If *f* is
% a matrix, the output will be 3-dimensional, and the third dimension will
% correspond to the columns of the input signal.
%
% The coefficients *c* computed from the signal *f* and the filterbank
% with windows *g_m* are defined by
%
% .. L-1
% c(n+1,m+1) = sum f(l+1) * g_m (an-l+1)
% l=0
%
% .. math:: c\left(n+1,m+1\right)=\sum_{l=0}^{L-1}f\left(l+1\right)g\left(an-l+1\right)
%
% See also: ifilterbank, filterbankdual
%
% References: bohlfe02
if nargin<3
error('%s: Too few input parameters.',upper(mfilename));
end;
if isempty(a) || ~all(a(:,1)==a(1)) ...
|| ~isnumeric(a) || any(rem(a(:),1)~=0)
error(['%s: a has to be either scalar or a numel(g) vector of equal',...
' integers.'], upper(mfilename));
end
definput.import={'pfilt'};
definput.keyvals.L=[];
[~,kv,L]=ltfatarghelper({'L'},definput,varargin);
[f,Ls,W]=comp_sigreshape_pre(f,'UFILTERBANK',0);
a=a(1);
if isempty(L)
L=filterbanklength(Ls,a);
end;
[g,asan]=filterbankwin(g,a,L,'normal');
M=numel(g);
N=L/a;
f=postpad(f,L);
g = comp_filterbank_pre(g,asan,L,kv.crossover);
ctmp=comp_filterbank(f,g,asan);
c=zeros(N,M,W,assert_classname(f));
for m=1:M
c(:,m,:)=ctmp{m};
end;