-
Notifications
You must be signed in to change notification settings - Fork 0
/
sep_ctpcp.m
37 lines (30 loc) · 1.53 KB
/
sep_ctpcp.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
function sep_ctpcp(mixture,sisec,k,outDir)
% sep_ctpcp: Separation using Complex Tensor PCP. For SMARD, requires
% soprano which contains the first six channels of "44_soprano".
% Tak-Shing Chan, 20160505
global soprano;
if sisec
% 2-channel SiSEC
[~,name] = fileparts(mixture);
x = load_audio(mixture,sisec,false,false);
% Perform short-time Fourier transforms
X = cat(3,stft1411(x(:,1)'),stft1411(x(:,2)'));
% Complex Tensor PCP
[A,E] = ialm_ctpcp(X,k/sqrt(length(X)),1e-7,1000);
a = [istft1411(A(:,:,1))' istft1411(A(:,:,2))'];
audiowrite(fullfile(outDir,[name '_A.wav']),wavnormalize(a),22050);
e = [istft1411(E(:,:,1))' istft1411(E(:,:,2))'];
audiowrite(fullfile(outDir,[name '_E.wav']),wavnormalize(e),22050);
else
% 6-channel SMARD
[~,name,ext] = fileparts(mixture);
x = load_audio(mixture,sisec,true,false)+soprano;
% Perform short-time Fourier transforms
X = cat(3,stft1411(x(:,1)'),stft1411(x(:,2)'),stft1411(x(:,3)'),stft1411(x(:,4)'),stft1411(x(:,5)'),stft1411(x(:,6)'));
% Complex Tensor PCP
[A,E] = ialm_ctpcp(X,k/sqrt(length(X)),1e-7,1000);
a = [istft1411(A(:,:,1))' istft1411(A(:,:,2))' istft1411(A(:,:,3))' istft1411(A(:,:,4))' istft1411(A(:,:,5))' istft1411(A(:,:,6))'];
audiowrite(fullfile(outDir,[name ext '_A.wav']),wavnormalize(a),22050);
e = [istft1411(E(:,:,1))' istft1411(E(:,:,2))' istft1411(E(:,:,3))' istft1411(E(:,:,4))' istft1411(E(:,:,5))' istft1411(E(:,:,6))'];
audiowrite(fullfile(outDir,[name ext '_E.wav']),wavnormalize(e),22050);
end