Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tff2020
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
skmad-suite
tff2020
Commits
ab062d6c
Commit
ab062d6c
authored
5 years ago
by
Marina Kreme
Browse files
Options
Downloads
Patches
Plain Diff
unnecessary file deletion
parent
5b15577c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
matlab/tfgm/scripts/solve_p1area_cuicui.m
+0
-412
0 additions, 412 deletions
matlab/tfgm/scripts/solve_p1area_cuicui.m
with
0 additions
and
412 deletions
matlab/tfgm/scripts/solve_p1area_cuicui.m
deleted
100644 → 0
+
0
−
412
View file @
5b15577c
clc
;
clear
;
close
all
;
% Algo 1
%%
pwd
;
pathname
=
'solve_1area_cuicui'
;
if
~
exist
(
'solve_1area_cuicui'
,
'dir'
)
mkdir
(
'solve_1area_cuicui'
);
end
addpath
(
'solve_1area_cuicui'
)
%%
fs
=
8000
;
% sampling frequency
sig_len
=
16384
;
% siglen
%% DGT params - signals - mask
close
all
win_len
=
512
;
win_type
=
'hann'
;
params
=
get_params
(
win_len
,
win_type
);
%Gauss
win_len
=
params
.
win_len
;
win_type
=
params
.
win_type
;
hop
=
params
.
hop
;
nbins
=
params
.
nbins
;
wideband_src
=
'car'
;
loc_source
=
'modulations'
;
win_dur
=
win_len
/
8000
;
hop_ratio
=
1
/
8
;
nbins_ratio
=
2
;
[
alpha
,
seuil
,
radius
]
=
set_smooth_mask_params
(
wideband_src
,
loc_source
,
win_type
);
gamma
=
0.7
;
fig_dir
=
pathname
;
[
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
);
%%
[
mask_area
,
mask_area_ratio
]
=
get_mask_area
(
mask
);
fprintf
(
"We work with %s window of length %.f\n"
,
win_type
,
win_len
);
fprintf
(
"Gabor transform parameters are: \n"
)
fprintf
(
'hop :%2.f\n'
,
dgt_params
.
hop
);
fprintf
(
'n_bins: %2.f\n'
,
dgt_params
.
nbins
);
fprintf
(
"The parameters for smoothing the mask are: \n"
)
fprintf
(
"alpha = %f\n"
,
alpha
);
fprintf
(
"seuil = %f\n"
,
seuil
);
fprintf
(
"radius = %f\n"
,
radius
);
figure
;
% window plot
plot_win
(
dgt_params
.
win
,
signal_params
.
fs
,
signal_params
.
sig_len
,
win_type
)
title
([
num2str
(
win_type
),
' - window'
]);
set
(
gca
,
'FontSize'
,
20
,
'fontName'
,
'Times'
);
saveas
(
gcf
,
fullfile
(
pathname
,
[
num2str
(
win_type
),
'_window.png'
]));
%% plot mask
figure
(
'name'
,
'mask'
);
plot_spectrogram
(
mask
,
dgt_params
,
signal_params
,
dgt
);
title
([
'mask : mask-area = '
,
num2str
(
mask_area
)]);
set
(
gca
,
'FontSize'
,
20
,
'fontName'
,
'Times'
);
saveas
(
gcf
,
fullfile
(
pathname
,
'gauss_mask.png'
));
%%
mask_bool
=
mask
;
tol_subregions
=
0
;
[
mask_labeled
,
n_areas
,
t_subregions
]
=
get_nareas
(
mask_bool
,
dgt
,
idgt
,
dgt_params
,
...
,
signal_params
,
fig_dir
,
tol_subregions
);
[
gabmul_list
,
mask_list
]
=
get_P_gabmul
(
mask_labeled
,
dgt
,
idgt
);
x_mix
=
signals
.
mix
;
tolerance_arrf
=
1e-3
;
proba_arrf
=
1
-
1e-4
;
[
t_arrf
,
t_evdn
,
t_ut_x
,
rank_q
,
s_vec_list
,
u_mat_list
,
...
,
ut_x_list
,
r
]
=
compute_decomposition
(
x_mix
,
mask_list
,
gabmul_list
,
...
,
tolerance_arrf
,
proba_arrf
);
%% plot mask
figure
(
'name'
,
'mask'
);
plot_mask
(
mask
,
dgt_params
.
hop
,
dgt_params
.
nbins
,
signal_params
.
fs
);
title
([
'mask : mask-area = '
,
num2str
(
mask_area
)]);
set
(
gca
,
'FontSize'
,
20
,
'fontName'
,
'Times'
);
saveas
(
gcf
,
fullfile
(
fig_dir
,
'mask.pdf'
));
%% Plot eigenvalues
figure
;
for
k_area
=
1
:
n_areas
txt
=
[
'sub-region ='
num2str
(
k_area
)];
plot
(
s_vec_list
{
k_area
},
'LineWidth'
,
3
,
'DisplayName'
,
txt
);
hold
on
;
end
xlabel
(
'$k$'
,
'Interpreter'
,
'latex'
);
ylabel
(
'$\sigma[k]$'
,
'Interpreter'
,
'latex'
);
set
(
gca
,
'YScale'
,
'log'
);
grid
;
legend
show
;
set
(
gca
,
'FontSize'
,
25
,
'fontName'
,
'Times'
);
xlabel
(
'$k$'
,
'Interpreter'
,
'latex'
);
set
(
gca
,
'FontSize'
,
25
,
'fontName'
,
'Times'
);
saveas
(
gcf
,
fullfile
(
fig_dir
,
'gabmul_eigenvalues.pdf'
));
%% find optimal lambda (best SDR)
x_wideband
=
signals
.
wideband
;
x_rec
=
@
(
lambda_coef
)
compute_estimate
(
lambda_coef
,
x_mix
,
s_vec_list
,
...
,
u_mat_list
,
ut_x_list
);
[
lambda_oracle
,
t_oracle
]
=
compute_lambda_oracle_sdr
(
n_areas
,
x_wideband
,
x_rec
);
fprintf
(
"Running time to tune lambda (oracle): %f \n"
,
t_oracle
);
%% Estimate energy and lambda
[
lambda_est
,
t_est
]
=
compute_lambda
(
x_mix
,
mask_labeled
,
dgt_params
,
...
,
signal_params
,
dgt
,
s_vec_list
,
u_mat_list
,
ut_x_list
,
...
,
gabmul_list
,
fig_dir
);
fprintf
(
"Running time to tune lambda (est): %f \n"
,
t_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): %f \n"
,
t_true_energy
);
%% Results
x_wideband
=
signals
.
wideband
;
sdr_wideband
=
@
(
lambda_coef
)
sdr
(
x_wideband
,
x_rec
(
lambda_coef
));
sdr_wideband_1area
=
@
(
lambda_coef
)
sdr_engine_1area
(
lambda_coef
,
signals
,
k_area
,
...
,
n_areas
,
s_vec_list
,
u_mat_list
,
ut_x_list
);
is_wideband
=
@
(
lambda_coef
)
itakura_saito_dist_spectrum
(
x_wideband
,
x_rec
(
lambda_coef
));
%%
l_range
=
10.
^
linspace
(
-
10
,
10
,
100
);
sdr_wideband_l
=
zeros
(
length
(
l_range
),
1
);
sdr_engine1area_l
=
zeros
(
length
(
l_range
),
1
);
if
tol_subregions
==
0
for
k
=
1
:
length
(
l_range
)
sdr_wideband_l
(
k
)
=
sdr_wideband
(
l_range
(
k
));
end
figure
;
plot
(
l_range
,
sdr_wideband_l
,
'-'
,
'LineWidth'
,
3
);
hold
on
;
plot
(
lambda_oracle
,
sdr_wideband
(
lambda_oracle
),
'gs'
,
'MarkerSize'
,
12
);
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
)
else
figure
;
for
k_area
=
1
:
n_areas
for
k
=
1
:
length
(
l_range
)
sdr_engine1area_l
(
k
)
=
sdr_engine_1area
(
k
,
k_area
);
end
txt
=
[
'SDR sub-reg ='
num2str
(
k
)];
end
plot
(
l_range
,
sdr_engine1area_l
,
'_'
,
'LineWidth'
,
3
,
'DisplayName'
,
txt
)
for
k_area
=
1
:
n_areas
txt1
=
[
'TFF-O '
,
num2str
(
k_area
)];
plot
(
lambda_oracle
(
k_area
),
sdr_engine_1area
(
lambda_oracle
(
k_area
),
k_area
),
...
,
'*'
,
'LineWidth'
,
3
,
'DisplayName'
,
txt1
);
txt2
=
[
'TFF-P'
,
num2str
(
k_area
)];
plot
(
lambda_est
(
k_area
),
sdr_engine_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_engine_1area
(
lambda_true_energy
(
k_area
),
k_area
),
...
,
'o'
,
'LineWidth'
,
3
,
'DisplayName'
,
txt3
);
txt4
=
[
'Zero fill'
,
num2str
(
k_area
)];
plot
(
1
,
sdr_engine_1area
(
1
,
k_area
),
'o'
,
'LineWidth'
,
3
,
'DisplayName'
,
txt4
);
end
end
xlabel
(
'$\lambda$'
,
'Interpreter'
,
'latex'
)
ylabel
(
'SDR(dB)'
)
set
(
gca
,
'XScale'
,
'log'
);
grid
on
;
set
(
gca
,
'FontSize'
,
20
,
'fontName'
,
'Times'
);
legend
(
'SDR'
,
'TFF-O'
,
'TFF-1'
,
'TFF-E'
,
'Zero fill'
)
saveas
(
gcf
,
fullfile
(
fig_dir
,
'tuning_lambda.pdf'
));
%%
is_wideband_l
=
zeros
(
length
(
l_range
),
1
);
if
tol_subregions
==
0
figure
;
for
l
=
1
:
length
(
l_range
)
is_wideband_l
(
l
)
=
is_wideband
(
l_range
(
l
));
end
plot
(
l_range
,
is_wideband_l
,
'-'
,
'LineWidth'
,
3
)
plot
(
lambda_oracle
,
is_wideband
(
lambda_oracle
),
'o'
,
'LineWidth'
,
3
)
plot
(
lambda_est
,
is_wideband
(
lambda_est
),
'o'
)
plot
(
lambda_true_energy
,
is_wideband
(
lambda_true_energy
),
'o'
,
'LineWidth'
,
3
)
plot
(
1
,
is_wideband
(
1
),
'o'
,
'LineWidth'
,
3
)
xlabel
(
'$\lambda$'
,
'Interpreter'
,
'latex'
)
ylabel
(
'IS (dB)'
)
set
(
gca
,
'XScale'
,
'log'
);
grid
()
legend
(
'SDR'
,
'TFF-O'
,
'TFF-1'
,
'TFF-E'
,
'Zero fill'
)
axis
tight
;
saveas
(
gcf
,
fullfile
(
fig_dir
,
'tuning_lambda_IS.pdf'
));
%%
figure
;
yyaxis
left
;
plot
(
l_range
,
sdr_wideband_l
,
'-'
,
'LineWidth'
,
3
);
hold
on
;
plot
(
lambda_est
,
sdr_wideband
(
lambda_est
),
'o'
,
'MarkerSize'
,
3
,
'LineWidth'
,
3
)
plot
(
lambda_true_energy
,
sdr_wideband
(
lambda_true_energy
),
'bo'
,
'LineWidth'
,
3
)
plot
(
lambda_oracle
,
sdr_wideband
(
lambda_oracle
),
'go'
,
'LineWidth'
,
3
)
plot
(
1
,
sdr_wideband
(
1
),
'mo'
,
'LineWidth'
,
3
);
grid
on
;
xlabel
(
'$\lambda$'
,
'Interpreter'
,
'latex'
)
ylabel
(
'SDR (dB)'
)
set
(
gca
,
'XScale'
,
'log'
);
yyaxis
right
;
plot
(
l_range
,
is_wideband_l
,
'-'
,
'LineWidth'
,
3
);
hold
on
;
plot
(
lambda_est
,
is_wideband
(
lambda_est
),
'o'
,
'MarkerSize'
,
3
,
'LineWidth'
,
3
)
plot
(
lambda_true_energy
,
is_wideband
(
lambda_true_energy
),
'bo'
,
'LineWidth'
,
3
)
plot
(
lambda_oracle
,
is_wideband
(
lambda_oracle
),
'go'
,
'LineWidth'
,
3
)
plot
(
1
,
is_wideband
(
1
),
'mo'
,
'LineWidth'
,
3
)
axis
tight
;
legend
(
'SDR'
,
'TFF-1'
,
'TFF-E'
,
'TFF-O'
,
'Zero fill'
,
'Location'
,
'northwest'
);
xlabel
(
'$\lambda$'
,
'Interpreter'
,
'latex'
)
ylabel
(
'IS divergence'
)
set
(
gca
,
'FontSize'
,
20
,
'fontName'
,
'Times'
);
%
% saveas(gcf,fullfile(fig_dir, 'tuning_lambda_SDR_IS.pdf'));
%
end
%% Reconstructec 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
);
x_est
=
x_rec
(
lambda_est
);
wav_write
(
'x_est.wav'
,
x_est
,
signal_params
.
fs
);
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
);
wav_write
(
'x_zero_fill.wav'
,
x_zero
,
signal_params
.
fs
);
x_interp
=
solver_tfgm_interp
(
tf_mat_mix
,
mask
,
idgt
);
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
);
sdr_zero
=
sdr
(
x_wideband
,
x_zero
);
sdr_interp
=
sdr
(
x_wideband
,
x_interp
);
sdr_mix
=
sdr
(
x_wideband
,
x_mix
);
%% Itakura saito
is_oracle
=
itakura_saito_dist_spectrum
(
x_wideband
,
x_oracle
);
is_est
=
itakura_saito_dist_spectrum
(
x_wideband
,
x_est
);
is_true_energy
=
itakura_saito_dist_spectrum
(
x_wideband
,
x_true_energy
);
is_zero
=
itakura_saito_dist_spectrum
(
x_wideband
,
x_zero
)
;
is_mix
=
itakura_saito_dist_spectrum
(
x_wideband
,
x_mix
)
;
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
);
fprintf
(
'Estimated lambda: %f \n'
,
lambda_est
);
fprintf
(
'SDR for estimated lambda: %f dB\n'
,
sdr_est
);
fprintf
(
'True-energy lambda: %f \n'
,
lambda_true_energy
);
fprintf
(
'SDR for true-energy lambda: %f dB\n'
,
sdr_true_energy
);
fprintf
(
'Zero filling SDR: %f dB\n'
,
sdr_zero
);
fprintf
(
'Mix SDR: %f dB \n'
,
sdr_mix
);
fprintf
(
'Interp + random phases filling SDR: %e dB\n'
,
sdr_interp
);
%%
figure
;
plot_spectrogram
(
x_mix
,
dgt_params
,
signal_params
,
dgt
);
title
([
'Mix SDR='
,
num2str
(
sdr_mix
,
4
),
'dB '
,
'IS= '
,
num2str
(
is_mix
)]);
set
(
gca
,
'FontSize'
,
20
,
'fontName'
,
'Times'
);
axis
tight
;
saveas
(
gcf
,
fullfile
(
fig_dir
,
'mix.pdf'
));
figure
;
plot_spectrogram
(
signals
.
wideband
,
dgt_params
,
signal_params
,
dgt
);
title
([
'True source -'
,
wideband_src
])
set
(
gca
,
'FontSize'
,
20
,
'fontName'
,
'Times'
);
saveas
(
gcf
,
fullfile
(
fig_dir
,
'spectrogram_true_wb_source.pdf'
));
figure
;
plot_spectrogram
(
x_zero
,
dgt_params
,
signal_params
,
dgt
)
title
([
'Zero fill SDR= '
,
num2str
(
sdr_zero
,
4
),
'dB '
,
'IS='
,
num2str
(
is_zero
)])
set
(
gca
,
'FontSize'
,
20
,
'fontName'
,
'Times'
);
saveas
(
gcf
,
fullfile
(
fig_dir
,
'spectrogram_zero_fill.pdf'
));
figure
;
plot_spectrogram
(
x_oracle
,
dgt_params
,
signal_params
,
dgt
)
title
([
'TFF-O SDR= '
,
num2str
(
sdr_oracle
,
4
),
'dB '
,
'IS='
,
num2str
(
is_oracle
)])
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
)
if
tol_subregions
==
0
title
([
'TFF-1 - SDR= '
,
num2str
(
sdr_est
,
4
),
'dB '
,
'IS='
,
num2str
(
is_est
)])
set
(
gca
,
'FontSize'
,
20
,
'fontName'
,
'Times'
);
axis
tight
;
saveas
(
gcf
,
fullfile
(
fig_dir
,
'spectrogram_TFF-1.pdf'
));
else
title
([
'TFF-P - SDR= '
,
num2str
(
sdr_est
,
4
),
'dB '
,
'IS='
,
num2str
(
is_est
)])
set
(
gca
,
'FontSize'
,
20
,
'fontName'
,
'Times'
);
axis
tight
;
saveas
(
gcf
,
fullfile
(
fig_dir
,
'spectrogram_TFF-P.pdf'
));
end
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'
));
%%
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment