[b6ad1a]: testing / test_erbfilters.m Maximize Restore History

Download this file

test_erbfilters.m    106 lines (85 with data), 3.2 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
 96
 97
 98
 99
100
101
102
103
104
105
106
function test_failed=test_erbfilters
%TEST_ERBFILTERS Test the erbfilters filter generator
warpname={'warped','symmetric'};
%warpname={'symmetric'};
test_failed=0;
for realcomplexidx=1:2
if realcomplexidx==1
realcomplex='real';
isreal=1;
else
realcomplex='complex';
isreal=0;
end;
for warpidx=1:2
warping=warpname{warpidx};
for fracidx=2:-1:1
if fracidx==1
fractional={'regsampling'};
fracname='regsamp';
else
fractional={'fractional','L',10000};
fracname='fractional';
end;
for uniformidx=1:2
if uniformidx==1
isuniform=0;
uniform='nonuniform';
else
isuniform=1;
uniform='uniform';
end;
[g,a]=erbfilters(16000,fractional{:},warping,uniform,'redmul',1,realcomplex);
L=filterbanklength(5000,a);
f=randn(L,1);
% Test it
if 0
f=[1;zeros(L-1,1)];
ff=fft(f);
ff(1999:2003)=0;
f=ifft(ff);
end;
if 0
% Inspect it: Dual windows, frame bounds and the response
disp('Frame bounds:')
[A,B]=filterbankrealbounds(g,a,L);
A
B
B/A
filterbankresponse(g,a,L,'real','plot');
end;
if isreal
gd=filterbankrealdual(g,a,L);
else
gd=filterbankdual(g,a,L);
end;
if isuniform
c=ufilterbank(f,g,a);
else
c=filterbank(f,g,a);
end;
r=ifilterbank(c,gd,a);
if isreal
r=2*real(r);
end;
res=norm(f-r);
[test_failed,fail]=ltfatdiditfail(res,test_failed);
s=sprintf(['ERBFILTER DUAL %s %s %s %s L:%3i %0.5g %s'],realcomplex,warping,fracname,uniform,L,res,fail);
disp(s);
if isreal
gt=filterbankrealtight(g,a,L);
else
gt=filterbanktight(g,a,L);
end;
rt=ifilterbank(c,gt,a);
if isreal
rt=2*real(rt);
end;
res=norm(f-rt);
[test_failed,fail]=ltfatdiditfail(res,test_failed);
s=sprintf(['ERBFILTER TIGHT %s %s %s %s L:%3i %0.5g %s'],realcomplex,warping,fracname,uniform,L,res,fail);
disp(s);
end;
end;
end;
end;