Commit a899d5fa authored by Marina Kreme's avatar Marina Kreme
Browse files

fix bugs

parent e63e159e
Pipeline #5964 passed with stage
in 5 minutes and 16 seconds
clc; clear; close all;
%%
% This script executes algorithm 1 (TFF-1: filtering out one TF region)
% This script executes algorithm 1 (TFF-1: filtering out one TF region)
% proposed in paper [1] on multiple datasets.
%
% [1] Time-frequency fading algorithms based on Gabor multipliers,
% A. Marina Kreme Valentin Emiya, Caroline Chaux, and Bruno Torresani
%%
wb_list ={'car','plane','train'};
loc_list = {'beeps','bird','clicks','finger_snaps','modulations'};
win_list = {'gauss 256', 'hann 512'};
wideband_name ={'car','plane','train'};
localized_name = {'beeps','bird','chirps','clicks','finger_snaps',...,
'modulations'};
wins_params = struct('Gauss256', struct('win_type','gauss','win_len',...,
256,'hop_ratio',1/4,'nbins_ratio', 4, 'win_dur',256/8000),...,
'Hann512', struct('win_type','hann','win_len', 512,...,
'hop_ratio',1/8,'nbins_ratio', 2, 'win_dur',512/8000));
keys = fieldnames(wins_params);
%%
tol_subregions = 0;
gamma=0.7;
fs = 8000;
sig_len =16384;
signal_params = generate_signal_parameters(fs, sig_len);
%%
f = fopen('exp_1area_cuicui.csv', 'w');
f = fopen('exp_tff1_car_bird.csv', 'w');
fprintf(f, '%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s \n','loc_src', 'wb_src',...,
'win_type','win_len','t_oracle','t_true_energy','t_est','t_arrf',...,
't_evdn','t_ut_x','sdr_mix','sdr_interp', 'sdr_zero','sdr_est',...,
......@@ -25,37 +37,53 @@ fprintf(f, '%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s \n','l
%%
for win =1:length(win_list)
for win_param = 1 :length(keys)
[win_type, win_dur, win_len, hop_ratio, nbins_ratio] = get_win_params(win_list{win});
win_len = wins_params.(keys{win_param}).win_len;
win_type = wins_params.(keys{win_param}).win_type;
win_dur = wins_params.(keys{win_param}).win_dur;
hop_ratio = wins_params.(keys{win_param}).hop_ratio;
nbins_ratio = wins_params.(keys{win_param}).nbins_ratio;
params = get_params(win_len, win_type);
fprintf("window %s:\n\n",win_type);
fprintf("window: %s - length: %.f\n", win_type, win_len);
for wb = 1:1%length(wb_list)
wideband_src = wb_list{wb};
% DGT parameters
dgt_params = generate_dgt_parameters(win_type, win_len, params.hop,...,
params.nbins, sig_len);
%DGT operators
[dgt, idgt] = get_stft_operators(dgt_params, signal_params);
for wb = 1: length(wideband_name)
wideband_src =wideband_name{wb};
fprintf("**************************************\n\n")
fprintf("This is the %.f ieme run. wideband source is:%s \n",wb ,wb_list{wb});
fprintf("This is the %.f ieme run. wideband source is:%s \n", wb , wideband_src);
fprintf("**************************************\n\n")
for loc=1:1%length(loc_list)
pwd;
fig_dir =['fig_', wb_list{wb},'_',loc_list{loc},'_', win_type,'_',num2str(win_len)];
for loc=1:length(localized_name)
loc_source = localized_name{loc};
fprintf("loalized source number %.f : %s \n",loc,loc_source) ;
fprintf("**************************************\n\n")
%%
fig_dir =['fig_', wideband_src,'_',loc_source,'_', win_type,'_',num2str(win_len)];
if ~exist(fig_dir,'dir')
mkdir(fig_dir);
end
addpath(fig_dir)
%%
fprintf("loalized source number %.f : %s \n",loc,loc_list{loc}) ;
fprintf("**************************************\n\n")
loc_source=loc_list{loc};
%%
[alpha, seuil, radius] = set_smooth_mask_params(wideband_src, loc_source, win_type);
[alpha, thres, radius] = set_smooth_mask_params(wideband_src, loc_source, win_type);
[signals, dgt_params, signal_params, mask, mask_area, dgt,...,
idgt] = get_mix(loc_source, wideband_src, gamma, win_dur, hop_ratio,...,
nbins_ratio, win_type, alpha, seuil, radius, fig_dir);
nbins_ratio, win_type, alpha, thres, radius, fig_dir);
fprintf('win_len:%.f\n', length(dgt_params.win));
fprintf('hop:%.f\n', dgt_params.hop);
......@@ -179,7 +207,7 @@ for win =1:length(win_list)
plot(lambda_est,sdr_wideband(lambda_est),'o','MarkerSize',12)
plot(lambda_true_energy,sdr_wideband(lambda_true_energy),'*','MarkerSize',12)
plot(1,sdr_wideband(1),'o','MarkerSize',12)
legend('SDR', 'TFF-O','TFF-1', 'TFF-E','Zero fill');
legend('SDR', 'TFF-O','TFF-1', 'TFF-P','Zero fill');
xlabel('$\lambda$','Interpreter','latex')
ylabel('SDR(dB)')
......@@ -207,7 +235,7 @@ for win =1:length(win_list)
ylabel('IS (dB)')
set(gca,'XScale','log');
grid()
legend('SDR','TFF-O','TFF-1','TFF-E','Zero fill')
legend('SDR','TFF-O','TFF-1','TFF-P','Zero fill')
axis tight;
saveas(gcf,fullfile(fig_dir, 'tuning_lambda_IS.pdf'));
......@@ -237,7 +265,7 @@ for win =1:length(win_list)
axis tight;
legend('SDR','TFF-1','TFF-E','TFF-O','Zero fill','Location','northwest');
legend('SDR','TFF-1','TFF-P','TFF-O','Zero fill','Location','northwest');
xlabel('$\lambda$','Interpreter','latex')
ylabel('IS divergence')
set(gca, 'FontSize', 20, 'fontName','Times');
......@@ -247,7 +275,7 @@ for win =1:length(win_list)
%% 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);
......@@ -259,10 +287,12 @@ for win =1:length(win_list)
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);
......@@ -352,9 +382,9 @@ for win =1:length(win_list)
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) ])
title(['TFF-P 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'));
saveas(gcf,fullfile(fig_dir, 'spectrogram_TFF-P.pdf'));
%%
......@@ -366,14 +396,11 @@ for win =1:length(win_list)
%% save in csv
fprintf(f,'%s %s %s %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f \n',...,
wb_list{wb},loc_list{loc},win_list{win},win_len,t_oracle,t_true_energy,...,
wideband_src,loc_source,win_type ,win_len,t_oracle,t_true_energy,...,
t_est,t_arrf,t_evdn,t_ut_x,sdr_mix, sdr_interp,...,
sdr_zero,sdr_est,sdr_oracle, is_interp, is_mix, is_est, is_zero, is_oracle);
end
end
......
Markdown is supported
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