-
Notifications
You must be signed in to change notification settings - Fork 6
/
sbpca_inv_autoco.m
50 lines (34 loc) · 1.13 KB
/
sbpca_inv_autoco.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
function subbands = sbpca_inv_autoco(autocos, params)
% subbands = sbpca_inv_autoco(autocos, params)
% Invert the short-time autocorrelation in sbpca
% autocos is nlag x nchs x nframes
% subbands is nchs x ntime
% 2013-05-27 Dan Ellis [email protected]
% This is the hard bit. We lost the phase...
[nlag, nchs, nframes] = size(autocos);
dur = nframes*params.hoptime;
nframes = size(autocos,3);
hoppts = round(params.hoptime * params.sr);
winpts = round(params.wintime * params.sr);
win2pts = 2*nlag;
ywin = [hann(win2pts-1)',0];
alen = round(params.sr * dur) + win2pts;
subbands = zeros(nchs, alen);
for ch = 1:nchs
% Convert autocos into STFTs
ac = squeeze(autocos(:,ch,:));
ffts = fft([ac;zeros(1, size(ac,2));ac(end:-1:2,:)]);
% incrementally reconstruct each window based on the phase of the overlap
out = zeros(1,alen);
for j = 1:nframes
xx = (j-1)*hoppts + [1:win2pts];
yi = out(xx);
YI = fft(yi);
YO = abs(ffts(:,j)') .* exp(sqrt(-1)*angle(YI));
yo = real(ifft(YO));
% cross fade
yo = ywin .* yo;
out(xx) = out(xx) + yo;
end
subbands(ch, :) = out;
end