-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathmain_offline_bss_separation.m
265 lines (216 loc) · 9.28 KB
/
main_offline_bss_separation.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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Sample program to compare several blind source separation techniques: %
% 1 - AIRES %
% 2 - TRINICON %
% 3 - AuxIVA %
% 4 - Independent Low-Rank Matrix Analysis (ILRMA) %
% %
% Coded by O. Golokolenko (oleg.golokolenko@tu-ilmenau.de) on July, 2019 %
% Copyright 2019 Golokolenko Oleg %
% %
% These programs are distributed only for academic research at %
% universities and research institutions. %
% It is not allowed to use or modify these programs for commercial or %
% industrial purpose without our permission. %
% When you use or modify these programs and write research articles, %
% cite the following references: %
% %
% 1 - O. Golokolenko and G. Schuller, "Fast time domain %
% stereo audio source separation using fractional delay filters," %
% in AES 147th Convention, 2019 %
% %
% 2 - H. Buchner, R. Aichner, and W. Kellermann, "Trinicon: A versatile %
% framework for multichannel blind signal processing," in %
% IEEE International Conference on Acoustics, Speech, and Signal %
% Processing, Montreal, Que., Canada, 2004. %
% %
% 3 - Ono, Nobutaka. "Stable and fast update rules for independent %
% vector analysis based on auxiliary function technique." WASPAA 2011. %
% %
% 4 - D. Kitamura, N. Ono, H. Sawada, H. Kameoka, H. Saruwatari, %
% "Determined blind source separation unifying independent vector %
% analysis and nonnegative matrix factorization," IEEE/ACM Trans. ASLP, %
% vol. 24,no. 9, pp. 1626-1641, September 2016. %
% %
% 5 - D. Kitamura, N. Ono, H. Sawada, H. Kameoka, "Determined %
% blind source separation with independent low-rank matrix analysis," %
% Audio Source Separation. Signals and Communication Technology., %
% S. Makino, Ed. Springer, Cham, pp. 125-155, March 2018. %
% %
% Audio sample files are taken from TIMIT database: J. Garofolo %
% et al., ???Timit acoustic-phonetic continuous speech corpus,??? 1993 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear; close all; clc;
fs_ = 16000;
%% Load simulated dataset
fs = 16000;
addpath('convolutive_datasets')
%% RT60 = 0.05s and distance from sound sources to mics = 1m
%fname = 'stationary_ss_rt60-0.05_TIMIT_dist-1.0m.mat';
%% RT60 = 0.05s and distance from sound sources to mics = 2.5m
fname = 'stationary_ss_rt60-0.05_TIMIT_dist-2.5m.mat';
%% RT60 = 0.1s and distance from sound sources to mics = 1m
%fname = 'stationary_ss_rt60-0.1_TIMIT_dist-1.0m.mat';
%% RT60 = 0.1s and distance from sound sources to mics = 2.5m
%fname = 'stationary_ss_rt60-0.1_TIMIT_dist-2.5m.mat';
%% RT60 = 0.2s and distance from sound sources to mics = 1m
%fname = 'stationary_ss_rt60-0.2_TIMIT_dist-1.0m.mat';
%% RT60 = 0.2s and distance from sound sources to mics = 2.5m
%fname = 'stationary_ss_rt60-0.2_TIMIT_dist-2.5m.mat';
loadedData = load(fname);
% Load mixed audio
x = loadedData.mixed_ss;
% Load original audio (not mixed)
x_original = loadedData.original_rir_ss;
%% Resample, if necessary
%{
if isempty(fs)
fs = fs_;
else
if fs_ ~= fs
warning('Sampling rates do not match. The sampling rate will be changed');
x = resample(x,fs,fs_);
end
end
%}
%% Play loaded audio file
%soundsc(x(:,1), fs_);
%soundsc(x(:,2), fs_);
%% Normilize input signal
x_mixed = x./(max(abs(x(:))));
%% Apply AIRES BSS
disp("****************");
disp("AIRES BSS");
startTrinc = tic;
% AIRES configuration
aires = aires_class_offline;
% Number of unmixing iteretions
aires.num_iterations = 20;
% Search stepsize
aires.alpha = 0.6;
aires_x_demixed = aires.separate_signals(x_mixed);
runtimeAlg = toc(startTrinc);
fprintf('\tRuntime: %5.3f s\n', runtimeAlg);
[SDR,SIR,SAR,perm]=bss_eval_sources(aires_x_demixed.',x_original.');
disp('AIRES BSS SDR measure Original VS Unmixed, [dB]');
disp(SDR);
disp('AIRES BSS SIR measure Original VS Unmixed, [dB]');
disp(SIR);
audiowrite('resulting_wav/aires_stationary_ss_unmixed_channel_1.wav',aires_x_demixed(:,1), fs_);
audiowrite('resulting_wav/aires_stationary_ss_unmixed_channel_2.wav',aires_x_demixed(:,2), fs_);
audiowrite('resulting_wav/stationary_ss_mixed_channel_1.wav',x_mixed(:,1), fs_);
audiowrite('resulting_wav/stationary_ss_mixed_channel_2.wav',x_mixed(:,2), fs_);
% Play AIRES separated sound sources
disp('Play AIRES separated sound sources');
soundsc(aires_x_demixed(:,1), fs_);
pause(5);
soundsc(aires_x_demixed(:,2), fs_);
pause(5);
%% Apply TRINICON BSS
disp("****************");
disp("TRINICON BSS");
startTrinc = tic;
% TRINICON configuration
trinicon_x_demixed = trinicon_bss_fnc(x_mixed);
runtimeAlg = toc(startTrinc);
fprintf('\tRuntime: %5.3f s\n', runtimeAlg);
[SDR,SIR,SAR,perm]=bss_eval_sources(trinicon_x_demixed.',x_original.');
disp('TRINICON BSS SDR measure Original VS Unmixed, [dB]');
disp(SDR);
disp('TRINICON BSS SIR measure Original VS Unmixed, [dB]');
disp(SIR);
% Play separated sound sources
%soundsc(trinicon_x_demixed(:,1), fs_);
%pause(5);
%soundsc(trinicon_x_demixed(:,2), fs_);
%pause(5);
%% Apply AuxIVA BSS
disp("****************");
disp("AuxIVA BSS");
addpath('AuxIVA')
startTrinc = tic;
epochs=30;
auxiva_x_demixed = auxiva_bss(x_mixed, epochs);
runtimeAlg = toc(startTrinc);
fprintf('\tRuntime: %5.3f s\n', runtimeAlg);
[SDR,SIR,SAR,perm]=bss_eval_sources(auxiva_x_demixed.',x_original.');
disp('AuxIVA BSS SDR measure Original VS Unmixed, [dB]');
disp(SDR);
disp('AuxIVA BSS SIR measure Original VS Unmixed, [dB]');
disp(SIR);
% Play separated sound sources
%soundsc(auxiva_x_demixed(:,1), fs_);
%pause(5);
%soundsc(auxiva_x_demixed(:,2), fs_);
%pause(5);
%% Apply ILRMA BSS
disp("****************");
disp("ILRMA BSS");
addpath('ILRMA')
startTrinc = tic;
epochs=30;
ilrma_x_demixed = ilrma_bss(x_mixed, epochs);
runtimeAlg = toc(startTrinc);
fprintf('\tRuntime: %5.3f s\n', runtimeAlg);
[SDR,SIR,SAR,perm]=bss_eval_sources(ilrma_x_demixed.',x_original.');
disp('ILRMA BSS SDR measure Original VS Unmixed, [dB]');
disp(SDR);
disp('ILRMA BSS SIR measure Original VS Unmixed, [dB]');
disp(SIR);
% Play separated sound sources
%soundsc(ilrma_x_demixed(:,1), fs_);
%pause(5);
%soundsc(ilrma_x_demixed(:,2), fs_);
%pause(5);
%%
function x_unmixed_trinicon = trinicon_bss_fnc(x_mixed)
%% TRINICON configuration
% number of microphones (= input channels)
cfg_trinicon.nMic = 2;
% number of sources (= output channels)
cfg_trinicon.nSrc = 2;
% length of unmixing filter w (in samples)
cfg_trinicon.L = 1024;
% number of maximum delays for calculation of correlation
cfg_trinicon.D = cfg_trinicon.L-1;
% off-line block length (in samples)
cfg_trinicon.blockLen = 2 * cfg_trinicon.L;
% Sylvester constraint: 'SCC': column SC, 'SCR': row SC
cfg_trinicon.SC = 'SCR';
% shift of unit impulse at initialization (in samples); should be chosen
% large enough to cover the intermicrophone distance
cfg_trinicon.initShift = 20;
% adaptation step size
cfg_trinicon.stepSize = 0.01;
% number of iterations
cfg_trinicon.numIter = 600;
% --- Inverses
% inversion method:
% one of 'efficient_broadband', 'inv_narrowband'
cfg_trinicon.compCorrInv = 'inv_narrowband';
% -- efficient broadband inverse
% value of regularization for sigma^2=0
cfg_trinicon.effBroadPar.delta = 1;
% --- narrowband inverse
% regularization constant
cfg_trinicon.invNrbPar.delta = eps;
% DFT length for inversion
cfg_trinicon.invNrbPar.NBR = 10 * cfg_trinicon.blockLen;
% weighting factor between narrowband and broadband inverse, extremal values:
% 0: narrowband, 1: broadband
cfg_trinicon.invNrbPar.NBrho = 0.5;
% - run offline TRINICON
% inputs:
% cfg_trinicon: configuration structure; see above
% x: acoustic mixture (two channels);
% dimension <nSamples x 2>
%
% outputs:
% y: separated signals; same length as input;
% dimension <nSamples x 2>
% W: demixing system; dimension <L x nMic x nSrc>;
% i.e., W(:,p,q) denotes the impulse response from
% the p-th input to the q-th output
offlTrinc = CLASS_offlineTRINICON(cfg_trinicon);
[x_unmixed_trinicon, W] = offlTrinc.sepSignals(x_mixed);
end