# Convolve audio signal with filter with different sampling rates

I would like to convolve two signals:

• Room impulse response that was obtained by deconvolution, measured at 48 kHz. Truncated to 8192 samples.
• Anechoic recording (.wav) recorded at 41.1 kHz

If I perform a fast convolution in the frequency domain, I understand I should do as follows:

[x, fs] = audioread('sound.wav');
L = length(x);
M = length(rir);

N = 2^nextpow2(L + M - 1);
H = fft(rir, N);
X = fft(x, N);

y = real(ifft(H.*X));
iend = M+L-1;
y = y(1:iend)';

audiowrite('convAudio.wav', y, fs)


Is this correct? Can I use the sampling frequency of the .wav signal?

• No, you should resample one of the signals so that they have the same sample rate. Commented Jan 26, 2022 at 10:15

Resampling from 48kHz to 44.1kHz is fairly awkward and involves a fair bit of trade-offs, so the best option depends on your specific requirements. For a room impulse response h44 = resample(h48,441,480)*480/441 is probably a good starting point (although it messes up the transients a bit).
Tip: you can use fftfilt() to implement the frequency domain filter operation. That's significantly more efficient than doing a full size FFT over the whole wave file and it handles frame size, overlap and hop size automatically.
• thanks a lot for your answer! May I ask why you add that factor? *480/441