clc;
clear all;
close all;
% [s1, fs ] = audioread( 'Thunder5.wav' );
% [s2, fs ] = audioread( 'babble_4.wav' );
% [s3, fs ] = audioread( '123_16.wav' );
% 输入信号
[s1, fs ] = audioread( '2024.12.23.wav' );
[s2, fs ] = audioread( '2024.12.23.1.wav' );
[s3, fs ] = audioread( '2024.12.23.4.wav' );
% 将信号裁剪为1s
s1 = s1(1:1*fs,:);
s2 = s2(1:1*fs,:);
s3 = s3(1:1*fs,:);
%源信号
S = [s1';s2';s3'];
%用来绘制时域图的时间轴横坐标
time = (1:length(s1))/fs; %时间轴
A = rand(2,3);
%观测矩阵
X = A*S;
%%
% 进行STFT的参数
[m,~] = size(X);
windowlength = 1024;%窗长
nfft = 1024;
d = round(0.15*windowlength)*2;%帧移
overlap = windowlength - d;%重叠数
window = hann(windowlength);
T = size(X,2);
n_frames = fix((T-overlap)/(windowlength-overlap)); % 计算帧数
[stft_x1, f_1, t_1] = stft(X(1,:), fs, 'Window', window, 'OverlapLength', overlap, 'FFTLength', nfft);
[stft_x2, f_2, t_2] = stft(X(2,:), fs, 'Window', window, 'OverlapLength', overlap, 'FFTLength', nfft);
recovered_signals(1,:) = real(istft(stft_x1, 'Window', window, ...
'OverlapLength', overlap, 'FFTLength', nfft));
recovered_signals(2,:) = real(istft(stft_x2, 'Window', window, ...
'OverlapLength', overlap, 'FFTLength', nfft));
为什么使用短时傅里叶变换后直接再使用短时傅里叶逆变换后的信号要比源信号短