How to multiply 2 fft's with different lengths?

20 visualizaciones (últimos 30 días)
Talha Gungor
Talha Gungor el 26 de Mayo de 2021
Respondida: Paul Hoffrichter el 27 de Mayo de 2021
I want to find the output signal(y) from input signal(x) and impulse response(h). To do that first I take the fft of both x and h, then multply them, and finally taking the ifft of the result. The input signal is a 5 second sound. I tried to equalize the lengths of the FFTs but it didnt work. How can I overcome this?
[x,Fs]=audioread('hello.wav');
T=1/Fs;
L=220500;%length of the original sound
d=8820;%delay in terms of samples
a=0.8;%attenuation coefficient
h = [1 zeros(1,d-1) a];%impulse response h(n)
X=fft(x);
h1 =[h; zeros(length(x)-length(h),1)];
H=fft(h1);
Y=H.*X;
y=ifft(Y);

Respuestas (1)

Paul Hoffrichter
Paul Hoffrichter el 27 de Mayo de 2021
Is this your desired effect?
[x,Fs]=audioread('hello.wav');
sound(x,Fs);
T=1/Fs;
disp('Wait for music to complete')
pause( length(x)*T + 1);
L=length(x); % 220500;%length of the original sound
d=8820;%delay in terms of samples
a=0.8;%attenuation coefficient
h = [1 zeros(1,d-1) a];%impulse response h(n)
X=fft(x);
h1 =[h(:); zeros(length(x)-length(h),1)];
H=fft(h1);
Y=H.*X;
y=ifft(Y);
sound(y,Fs);

Categorías

Más información sobre Audio I/O and Waveform Generation en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by