Skip to content
Snippets Groups Projects
Commit a08c0210 authored by Marina Kreme's avatar Marina Kreme
Browse files

refactor

parent c78b421b
No related branches found
No related tags found
No related merge requests found
Pipeline #5949 passed
function x_interp= solver_tfgm_interp(X, mask, idgt) function x_est= interpolation_solver(x, mask, dgt, idgt, dgt_params,...,
%% x_interp= solver_tfgm_interp(X, mask, idgt) signal_params, fig_dir)
%% x_est= interpolation_solver(x, mask, dgt, idgt, dgt_params,...,
% signal_params, fig_dir)
% Time-frequency fading solver using linear interpolation and random phases
% This function apply a linear interpolation along % This function apply a linear interpolation along
% the frequency axis of the magnitude of observation time-frequency matrix % the frequency axis of the magnitude of observation time-frequency matrix
% and draws the related phase uniformly at random. % and draws the related phase uniformly at random.
% %
% Inputs: % Inputs:
% - X: time-frequency matrix % - x (nd array): mix signal
% - mask: binary mask % - mask (nd- array): time-frequency mask
% - idgt: Inverse of Gabor transform operator % - idgt,dgt (handle): DGT and IDGT . see utils/get_stft_operators.m
% - dgt_params (struct) : DGT parameters
% - signal_params (struct) . :signals parameters
% - fig_dir : folder where figures are stored
% Outputs: % Outputs:
% -x_interp: estimated signal % -x_est (nd array): estimated signal
% %
% %
% Author: Marina KREME % Author: Marina KREME
%% %%
x_tf = dgt(x);
X_abs = abs(X); x_abs = abs(x_tf);
X_ang = angle(X); x_ang = angle(x_tf);
mask_copy = mask; mask_copy = mask;
%% modulus interpolation %%
Y = X_abs.*(1-mask_copy); y_tf = x_abs.*(1-mask_copy);
figure;
plotdgtreal(y_tf,dgt_params.('hop'), dgt_params.('nbins'), signal_params.('fs'));
title('Mask Before Interpolated TF matrix')
saveas(gcf,fullfile(fig_dir,'interp_mask.pdf'));
figure; imagesc(Y); title('before interp');
Z = (Y==0); %%
z_tf = (y_tf==0);
y_tf(z_tf) = interp1(find(~z_tf),y_tf(~z_tf), find(z_tf),'linear');
Y(Z) = interp1(find(~Z),Y(~Z), find(Z),'linear'); figure
figure; imagesc(Y); title('after interp') plotdgtreal(y_tf,dgt_params.('hop'), dgt_params.('nbins'), signal_params.('fs'));
title('Interpolated TF matrix')
saveas(gcf,fullfile(fig_dir,'interp_tf_est.pdf'));
%% %%
X_ang(mask==1) = 2*pi*rand(sum(mask(:)),1); x_ang(mask==1) = 2*pi*rand(sum(mask(:)),1);
X_interp = abs(Y).*exp(1i.*X_ang); x_est = abs(y_tf).*exp(1i.*x_ang);
x_interp = compute_idgt(X_interp, idgt); x_est = idgt(x_est);
figure;
plot_spectrogram(x_est, dgt_params,signal_params, dgt);
title('Reconstructed signal by interp')
saveas(gcf,fullfile(fig_dir,'interp_sig_est.pdf'));
end end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment