Commit 9a1e4f45 authored by Marina Kreme's avatar Marina Kreme
Browse files

update - fix bugs

parent 84c7a6d4
Pipeline #5968 passed with stage
in 5 minutes and 16 seconds
......@@ -397,3 +397,4 @@ title(['Interp SDR= ', num2str(sdr_interp,4),'dB ','IS=',num2str(is_interp)])
set(gca, 'FontSize', 20, 'fontName','Times');
saveas(gcf,fullfile(fig_dir,'spectrogram_interp.pdf'));
%%
save('exp_tff1_car_bird.mat')
......@@ -11,7 +11,7 @@ dbstack;
%%
loc_source='bird';
wideband_src='car';
setting = 7;
setting = 6;
if setting == 1
......@@ -22,98 +22,45 @@ if setting == 1
tol_subregions = 1e-5;
[alpha, seuil, radius] = set_smooth_mask_params(wideband_src, loc_source, win_type);
elseif setting == 1.2
win_type = 'hann';
win_dur = 128/8000;
hop_ratio = 1/4;
nbins_ratio = 4;
tol_subregions = 1e-5;
[alpha, seuil, radius] = set_smooth_mask_params(wideband_src, loc_source, win_type);
elseif setting == 1.3
win_type = 'hann';
win_dur = 128/8000;
hop_ratio = 1/4;
nbins_ratio = 4;
tol_subregions = 1e-5;
[alpha, seuil, radius] = set_smooth_mask_params(wideband_src, loc_source, win_type);
elseif setting == 1.5
elseif setting == 2
win_type = 'hann';
win_dur = 128/8000;
hop_ratio = 1/4;
nbins_ratio = 4;
win_dur = 256/8000;
hop_ratio = 1/8;
nbins_ratio = 2;
tol_subregions = 1e-5;
[alpha, seuil, radius] = set_smooth_mask_params(wideband_src, loc_source, win_type);
elseif setting == 2
win_type = 'gauss';
win_dur = 128 / 8000;
hop_ratio = 1 / 4;
nbins_ratio = 4;
tol_subregions = 1e-5;
[alpha, seuil, radius] = set_smooth_mask_params(wideband_src, loc_source, win_type);
elseif setting == 3
win_type = 'hann';
win_dur = 128 / 8000;
hop_ratio = 1 / 4;
win_dur = 512/8000;
hop_ratio = 1/4;
nbins_ratio = 4;
tol_subregions = 1e-5;
[alpha, seuil, radius] = set_smooth_mask_params(wideband_src, loc_source, win_type);
elseif setting == 4
win_type = 'hann';
win_dur = 256 / 8000;
hop_ratio = 1 / 8;
nbins_ratio = 2;
tol_subregions = 1e-5;
[alpha, seuil, radius] = set_smooth_mask_params(wideband_src, loc_source, win_type);
elseif setting == 5
win_type = 'hann';
win_dur = 512 / 8000;
hop_ratio = 1 / 4;
nbins_ratio = 4;
tol_subregions = 1e-5;
[alpha, seuil, radius] = set_smooth_mask_params(wideband_src, loc_source, win_type);
elseif setting == 6
win_type = 'hann';
win_dur = 512 / 8000;
hop_ratio = 1 / 8;
win_dur = 512/8000;
hop_ratio = 1/8;
nbins_ratio = 2;
tol_subregions = 1e-5;
[alpha, seuil, radius] = set_smooth_mask_params(wideband_src, loc_source, win_type);
elseif setting == 7
win_type = 'gauss';
win_dur = 256/8000;
hop_ratio = 1 / 4;
nbins_ratio = 4;
tol_subregions = 1e-5;
[alpha, seuil, radius] = set_smooth_mask_params(wideband_src, loc_source, win_type);
elseif setting == 7.1
elseif setting == 5
win_type = 'gauss';
win_dur = 256 / 8000;
win_dur = 128 / 8000;
hop_ratio = 1 / 4;
nbins_ratio = 4;
tol_subregions = 1e-5;
[alpha, seuil, radius] = set_smooth_mask_params(wideband_src, loc_source, win_type);
elseif setting == 8
elseif setting == 6
win_type = 'gauss';
win_dur = 256 / 8000;
......@@ -122,32 +69,23 @@ elseif setting == 8
tol_subregions = 1e-5;
[alpha, seuil, radius] = set_smooth_mask_params(wideband_src, loc_source, win_type);
elseif setting == 9
elseif setting == 7
win_type = 'gauss';
win_dur = 256 / 8000;
hop_ratio = 1 / 4;
nbins_ratio = 4;
hop_ratio = 1 / 8;
nbins_ratio = 2;
tol_subregions = 1e-5;
[alpha, seuil, radius] = set_smooth_mask_params(wideband_src, loc_source, win_type);
elseif setting == 10
win_type = 'gauss';
win_dur = 256 / 8000;
hop_ratio = 1 / 4;
nbins_ratio = 4;
tol_subregions = 1e-5;
[alpha, seuil, radius] = set_smooth_mask_params(wideband_src, loc_source, win_type);
end
%%
nb_areas ='Paeras';
pwd;
fig_dir =['fig_solve_', nb_areas,'_car_cuicui_', win_type];
fig_dir =['fig_solve_', nb_areas,'_car_bird_', win_type];
if ~exist(fig_dir,'dir')
mkdir(fig_dir);
end
......@@ -217,9 +155,7 @@ x_rec = @(lambda_coef)compute_estimate(lambda_coef, x_mix, s_vec_list,...,
[lambda_oracle, t_oracle] = compute_lambda_oracle_sdr(n_areas,x_wideband, x_rec);
fprintf("Running time to tune lambda (oracle): %f \n")
disp("Running time to tune lambda (oracle): %f \n")
disp(t_oracle);
%% Estimate energy and lambda
......@@ -232,24 +168,6 @@ disp(t_oracle);
fprintf("Running time to tune lambda (est): \n")
disp(t_lambda_est);
%% Estimate lambda from true energy
e_wideband_true_energy = zeros(n_areas,1);
x_wideband_tf_mat = dgt(gabmul_list{1}(signals.wideband));
for k_area =1:n_areas
mask_k = (mask_labeled==k_area);
x_wideband_tf_masked = mask_k .* x_wideband_tf_mat;
e_wideband_true_energy(k_area) =norm(x_wideband_tf_masked, 'fro').^2;
end
e_wideband = e_wideband_true_energy;
[lambda_true_energy, t_true_energy] = compute_lambda(x_mix, mask_labeled, dgt_params,...,
signal_params, dgt, s_vec_list, u_mat_list, ut_x_list,...,
gabmul_list, fig_dir,e_wideband);
%%
fprintf("Running time to tune lambda (True):\n")
disp(t_true_energy);
%% Results
......@@ -257,11 +175,11 @@ disp(t_true_energy);
x_wideband = signals.wideband;
sdr_wideband = @(lambda_coef)sdr(x_wideband, x_rec(lambda_coef));
sdr_wideband_1area = @(lambda_coef, k_area)sdr_engine_1area(lambda_coef, k_area, x_rec, x_wideband, n_areas);
sdr_wideband_1area = @(lambda_coef, k_area)sdr_1region(lambda_coef, k_area, x_rec, x_wideband, n_areas);
is_wideband = @(lambda_coef) itakura_saito_dist_spectrum(x_wideband, x_rec(lambda_coef));
is_wideband_1area = @(lambda_coef,k_area)is_spectrum_engine_1aera(x_wideband, k_area,lambda_coef, n_areas,x_rec);
is_wideband_1area = @(lambda_coef,k_area)is_spectrum_1region(x_wideband, k_area,lambda_coef, n_areas,x_rec);
%% SDR for each area
......@@ -270,77 +188,89 @@ l_range = 10.^linspace(-10,10,100);
sdr_engine1area_l = zeros(length(l_range),1);
figure;
for k_area =1: n_areas
figure;
for k=1:length(l_range)
sdr_engine1area_l(k) = sdr_wideband_1area(l_range(k), k_area);
end
txt = ['SDR sub-reg =' num2str(k_area)];
plot(l_range, sdr_engine1area_l,'DisplayName',txt)
end
txt = 'SDR';
plot(l_range, sdr_engine1area_l,'LineWidth',3,'DisplayName',txt)
hold on;
for k_area =1:n_areas
txt1 = ['TFF-O ',num2str(k_area)];
txt1 = 'TFF-O ';
plot(lambda_oracle(k_area), sdr_wideband_1area(lambda_oracle(k_area), k_area),...,
'*','LineWidth',3,'DisplayName',txt1);
txt2 = ['TFF-P',num2str(k_area)];
txt2 = 'TFF-P';
plot(lambda_est(k_area),sdr_wideband_1area(lambda_est(k_area), k_area),...,
'o','LineWidth',3,'DisplayName',txt2);
txt3 = ['TFF-E',num2str(k_area)];
plot(lambda_true_energy(k_area),sdr_wideband_1area(lambda_true_energy(k_area), k_area),...,
'o','LineWidth',3,'DisplayName',txt3);
txt4 = ['Zero fill',num2str(k_area)];
plot(1, sdr_wideband_1area(1, k_area), 'o','LineWidth',3,'DisplayName',txt4);
txt3 = 'Zero fill';
plot(1, sdr_wideband_1area(1, k_area), 'o','LineWidth',3,'DisplayName',txt3);
end
legend show;
xlabel('$\lambda$','Interpreter','latex')
ylabel('SDR(dB)')
title(['SDR sub-region:' num2str(k_area)])
set(gca,'XScale','log');
grid on;
set(gca, 'FontSize', 20, 'fontName','Times');
saveas(gcf,fullfile(fig_dir, 'tuning_lambda.pdf'));
saveas(gcf,fullfile(fig_dir, ['tuning_lambda_area_',num2str(k_area),'.pdf']));
end
%% Itakura saito for each aera
is_engine1area_l = zeros(length(l_range),1);
figure;
for k_area =1: n_areas
figure;
for k=1:length(l_range)
is_engine1area_l(k) = is_wideband_1area(l_range(k), k_area);
end
txt = ['SDR sub-reg =' num2str(k_area)];
txt ='IS';
plot(l_range, is_engine1area_l,'LineWidth',3,'DisplayName',txt)
end
hold on;
for k_area=1:n_areas
plot(lambda_oracle(k_area), is_wideband_1area(lambda_oracle(k_area),k_area), 'o','LineWidth',3)
plot(lambda_est(k_area), is_wideband_1area(lambda_est(k_area),k_area), 'o')
plot(lambda_true_energy(k_area), is_wideband_1area(lambda_true_energy(k_area),k_area),'o','LineWidth',3)
plot(1, is_wideband_1area(1,k_area), 'o','LineWidth',3)
end
xlabel('$\lambda$','Interpreter','latex')
ylabel('IS (dB)')
set(gca,'XScale','log');
title(['IS sub-region:' num2str(k_area)])
grid()
legend('IS','TFF-O','TFF-P','TFF-E','Zero fill')
legend('IS','TFF-O','TFF-P','Zero fill')
axis tight;
saveas(gcf,fullfile(fig_dir, 'tuning_lambda_IS.pdf'));
%%
figure;
set(gca, 'FontSize', 20, 'fontName','Times');
saveas(gcf,fullfile(fig_dir, ['tuning_IS_',num2str(k_area),'.pdf']));
end
%% plot both sdr and itakura saito in the same axis
sdr_engine1area_l = zeros(length(l_range),1);
is_engine1area_l = zeros(length(l_range),1);
for k_area =1:n_areas
figure;
for k=1:length(l_range)
sdr_engine1area_l(k) = sdr_wideband_1area(l_range(k), k_area);
is_engine1area_l(k) = is_wideband_1area(l_range(k), k_area);
end
txt = ['SDR sub-reg =' num2str(k_area)];
yyaxis left;
plot(l_range, sdr_engine1area_l, '-','LineWidth',3); hold on;
plot(lambda_oracle(k_area), sdr_wideband_1area(lambda_oracle(k_area), k_area), ...,
'o','LineWidth',3)
plot(lambda_est(k_area),sdr_wideband_1area(lambda_est(k_area), k_area),...,
'bo','LineWidth',3)
plot(1, sdr_wideband_1area(1, k_area), 'mo', 'LineWidth',3);
grid on;
xlabel('$\lambda$','Interpreter','latex')
ylabel('SDR (dB)')
......@@ -350,20 +280,24 @@ set(gca,'XScale','log');
yyaxis right;
plot(l_range,is_engine1area_l,'-','LineWidth',3); hold on;
plot(lambda_oracle(k_area), is_wideband_1area(lambda_oracle(k_area),k_area),...,
'o','LineWidth',3)
plot(lambda_est(k_area), is_wideband_1area(lambda_est(k_area),k_area), 'bo',...,
'LineWidth',3)
plot(1, is_wideband_1area(1,k_area), 'mo','LineWidth',3)
axis tight;
legend('SDR TFF-P','IS TFF-P','Location','northwest');
legend('SDR','TFF-O','TFF-P','Zero fill','Location','northwest');
xlabel('$\lambda$','Interpreter','latex')
ylabel('IS divergence')
title(['SDR-IS sub-reg:' num2str(k_area)])
set(gca, 'FontSize', 20, 'fontName','Times');
saveas(gcf,fullfile(fig_dir, 'tuning_lambda_SDR_IS.pdf'));
saveas(gcf,fullfile(fig_dir, ['tuning_lambda_SDR_IS',num2str(k_area),'.pdf']));
end
%% Reconstructed signals
tf_mat_mix = compute_dgt(signals.mix, dgt );
x_oracle = x_rec(lambda_oracle);
wav_write('x_oracle.wav', x_oracle, signal_params.fs);
......@@ -375,16 +309,17 @@ x_true_energy = x_rec(lambda_true_energy);
wav_write('x_true_energy.wav', x_true_energy, signal_params.fs);
x_zero = solver_tfgm_zero(tf_mat_mix, mask, idgt);
x_zero = zero_fill_solver(x_mix, mask, dgt, idgt, dgt_params,...,
signal_params, fig_dir);
wav_write('x_zero_fill.wav', x_zero, signal_params.fs);
x_interp= solver_tfgm_interp(tf_mat_mix, mask, idgt);
x_interp= interpolation_solver(x_mix, mask, dgt, idgt, dgt_params,...,
signal_params, fig_dir);
wav_write('x_interp.wav', x_zero, signal_params.fs);
%% Sdr
sdr_oracle = sdr(x_wideband, x_oracle);
sdr_est = sdr(x_wideband, x_est);
sdr_true_energy = sdr(x_wideband, x_true_energy);
......@@ -403,8 +338,6 @@ is_interp= itakura_saito_dist_spectrum(x_wideband,x_interp);
%%
fprintf('Oracle lambda: %f\n', lambda_oracle);
fprintf('SDR for oracle lambda: %f dB\n',sdr_oracle);
......@@ -452,10 +385,6 @@ set(gca, 'FontSize', 20, 'fontName','Times');
axis tight;
saveas(gcf,fullfile(fig_dir,'spectrogram_TFF-O.pdf'));
%%
figure;
plot_spectrogram(x_est, dgt_params, signal_params, dgt)
title(['TFF-P - SDR= ',num2str(sdr_est,4),'dB ','IS=',num2str(is_est)])
......@@ -463,19 +392,10 @@ set(gca, 'FontSize', 20, 'fontName','Times');
axis tight;
saveas(gcf,fullfile(fig_dir, 'spectrogram_TFF-P.pdf'));
%%
figure;
plot_spectrogram(x_true_energy, dgt_params, signal_params,dgt)
title(['TFF-E SDR= ', num2str(sdr_true_energy,4),'dB ','IS=',num2str(is_true_energy) ])
set(gca, 'FontSize', 20, 'fontName','Times');
saveas(gcf,fullfile(fig_dir, 'spectrogram_TFF-E.pdf'));
%%
figure;
plot_spectrogram(x_interp, dgt_params, signal_params,dgt)
title(['Interp SDR= ', num2str(sdr_interp,4),'dB ','IS=',num2str(is_interp)])
set(gca, 'FontSize', 20, 'fontName','Times');
saveas(gcf,fullfile(fig_dir,'spectrogram_interp.pdf'));
%%
save('exp_tffP_car_bird.mat');
function is_engine_1area = is_spectrum_engine_1aera(x_engine, k_area,lambda_coef, n_areas,x_rec)
function is_1region = is_spectrum_1region(x_engine, k_area,lambda_coef, n_areas,x_rec)
lambda_vec = ones(n_areas,1);
lambda_vec(k_area) = lambda_coef;
is_engine_1area = itakura_saito_dist_spectrum(x_engine, x_rec(lambda_vec)) ;
is_1region = itakura_saito_dist_spectrum(x_engine, x_rec(lambda_vec)) ;
......
function sdr_engine1area =sdr_engine_1area(lambda_coef, k_area, x_rec, x_engine, n_areas)
function sdr_1region =sdr_1region(lambda_coef, k_area, x_rec, x_engine, n_areas)
lambda_vec = ones(n_areas,1);
lambda_vec(k_area) = lambda_coef;
sdr_engine1area = sdr(x_engine, x_rec(lambda_vec));
sdr_1region = sdr(x_engine, x_rec(lambda_vec));
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment