Convolution of two .wav files and deconvolve to get back original

조회 수: 13 (최근 30일)
Saravanakumar Chandrasekaran
Saravanakumar Chandrasekaran 2021년 6월 13일
답변: Arjun 2025년 2월 26일
i have convolved two audio files in .WAV format (y1 and y2) to compute y3. Now i would like to de convolve ( i mean i m trying to get back the audio y2 from y3). I didnt get the same value(y2 is not equal to x1). How to get the same values. The code is given below. i have attached the audio files also.
clear all;
close all;
% Fs = 8000;
[y1,Fs] = audioread('modern.wav');
% sound(y1,Fs);
[y2,Fs] = audioread('second.wav');
% sound(y2,Fs);
%Perform Convolution
y3 = conv(y1,y2);
% sound(y3,Fs);
%Perform De convolution to get back y2
Lx=length(y3)-length(y1)+1; %
Lx2=pow2(nextpow2(Lx)); % Find smallest power of 2 that is > Lx
Y=fft(y3, Lx2); % Fast Fourier transform
H=fft(y1, Lx2); % Fast Fourier transform
X=Y.*H;
xchk = ifft(X);
x=real(ifft(X, Lx2)); % Inverse fast Fourier transform
x1=x(1:1:Lx);
sound(x1,Fs);

답변 (1개)

Arjun
Arjun 2025년 2월 26일
I understand that you have performed convolution of two audio signal files and now you wish to perform deconvolution to get back the original audio.
In order to do so you can use the "deconv" function of matlab which can perform this deconvolution for you.
[x,r] = deconv(y,h)
The above code segment deconvolves a vector h out of a vector y using polynomial long division, and returns the quotient x and remainder r such that y = conv(x,h) + r. If y and h are vectors of polynomial coefficients, then deconvolving them is equivalent to dividing the polynomial represented by y by the polynomial represented by h.
Kindly refer to this MATLAB Answer to gain some more insights: https://www.mathworks.com/matlabcentral/answers/1860958-performing-a-deconvolution-on-signals
Kindly refer to the documentation of "deconv" in MATLAB R2021a here: https://www.mathworks.com/help//releases/R2021a/matlab/ref/deconv.html
In recent versions of MATLAB since R2023b, you can also use "Least-Squares Deconvolution". To read more about this, Kindly refer to this documentation link: https://www.mathworks.com/help/matlab/ref/deconv.html#d126e389077
I hope this will help!

카테고리

Help CenterFile Exchange에서 Discrete Fourier and Cosine Transforms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by