0
votes

I'm in the process attempting to convolve and export an audio signal y(t) with a frequency response h(t) in different ways for a MATLAB project. It's been straightforward for the most part, however, I've run into difficulty when trying to convolve the signals using the Convolution Theorem.

I'm able to take the Fourier Transforms of both signals easily using the fft() function, but when I multiply those two results together then use the ifft() functionto find my final signal, the program always outputs garbage. I've tried playing around with padding the input with zeros, but it hasn't done much.

Here's the gist of the code I have at the moment (plot functions were removed for readability).

Y = fft(y);
H = fft(h);

F = Y*H;

f = ifft(F);

For those who are interested, the audio file is a 38 second long .wav file with a sample rate of 22050. The impulse response is the Cosine function between -pi/2 and pi/2.

Thanks in advance, any help is greatly appreciated.

1

1 Answers

2
votes

I am a bit rusty with the Convolution Theorem, so I can say something wrong; but I will highlight two things:

  • The product in frequency should be an element-wise multiplication, i.e. F=Y.*H.
  • The frequency response should be a cosine in frequency, not in time. I guess you want a frequency response that does low-pass filtering.

I played a bit with these ideas, and this is what I got:

clear all; close all; clc;

% Signal
load handel.mat;
%sound(y,Fs)
N = numel(y);
t = linspace(0,(N-1)/Fs,N);

% Response
H = abs(cos(linspace(0,pi,N))).';

% FFT product
Y = fft(y);
h = abs(ifft(H));
F = Y.*H;
f = abs(ifft(F));

% Plot
figure('Name','Time-domain');
subplot(3,1,1); plot(t,y); title('Signal');
subplot(3,1,2); plot(t,h); title('System');
subplot(3,1,3); plot(t,f); title('Output');
figure('Name','Frequency-domain');
subplot(3,1,1); plot(abs(Y)); title('Signal');
subplot(3,1,2); plot(abs(H)); title('System');
subplot(3,1,3); plot(abs(F)); title('Output');

% Play
sound(y,Fs);
sound(f,Fs);

In the frequency domain, it looks like the low-pass filtering is working. However, if you listen to the audio, the result for the Handel track is not amazing.

enter image description here

Don't forget to have a look at the good answer of Luis Mendo in here.