Inverse the accidental add of time-shifted version of my audio signal

조회 수: 5 (최근 30일)
Maria Valliou
Maria Valliou 2021년 1월 27일
편집: Walter Roberson 2025년 3월 28일
Hello,
I have an audio signal (e.g. z(n)) which is the add of my original signal (e.g. x(n)) and a time shifted version of it (x(n-n0)) so z(n)=x(n)+x(n-n0). Can I use the properties of timeshifting in frequency domain in order to get my original signal back (get x(n) from z(n))?
I tried to change the code I found here and I tried the following code:
[data,fs] = audioread('z_signal.mp3');
no_frame = 1;
datalength = length(data);
N = floor(datalength/no_frame); %Framesize
temp = 0;
for i = 1 : no_frame
frames(i,:) = data(temp + 1 : temp + N,1);
temp = temp + N;
end
i=1; %for 1st frame
g=+1.6; %the number of seconds i suppose is the time-shift so n0=g*fs
t=g*fs; %number of sample shift
yi=frames(i,:);
yp(i,:)=fft(yi);
y(i,:) = exp(-1i*2*pi/N*(0:N-1)*t).*yp(i,:);
rslt(i,:)=ifft(y(i,:),'symmetric');
Do you have any ideas what I'm missing?
Thank you in advance

답변 (1개)

Suraj Kumar
Suraj Kumar 2025년 3월 28일
Hi Maria,
I understand you're trying to recover your original audio signal ( x(n) ) from the combined signal ( z(n) = x(n) + x(n-n_0) ). The solution involves using the Fourier Transform, which translates time shifts into phase shifts within the frequency domain.You can refer to the below mentioned steps:
1. Initially we can convert the time-domain signal ( z(n) ) into the frequency domain using "fft" function in MATLAB.
[data, fs] = audioread('z_signal.mp3');
datalength = length(data);
g = 1.6;
n0 = round(g * fs);
Z = fft(data);
2. Then we can observe that the time shift corresponds to a phase shift. We can use this to express the relationship between ( Z(f) ) and ( X(f) and solve for ( X(f) ) using the known relationship
N = length(Z);
f = (0:N-1)*(fs/N);
H = exp(-1i * 2 * pi * f * n0 / fs);
X = Z ./ (1 + H);
epsilon = 1e-10;
X(abs(1 + H) < epsilon) = 0;
3. Finally we can convert the isolated ( X(f) ) back to the time domain using "ifft" function in MATLAB.
x_recovered = ifft(X, 'symmetric');
x_recovered = x_recovered / max(abs(x_recovered));
audiowrite('recovered_signal.wav', x_recovered, fs);
sound(x_recovered, fs);
For more insights on the "fft" and "ifft" functions in MATLAB, you can refer to the following documentation links:
Hope this helps solving your query!

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by