IR Capture & FFT Reverb MATLAB Script [Dec ’24]

● Created a MATLAB script to take a time-domain input signal and impulse response, convert to frequency-domain using FFT, Y(F)=H(F)X(F), convert result into time-domain, and export output to a .wav file
● A qualitative description of the output in the context of audio engineering is an audio signal with an added reverb effect
● Impulse Response of various acoustic chambers & spaces captured using the Impulse Response Measurer app from the Audio Toolbox using ESS (Exponential Sine Sweep)
● Utilises GPU acceleration from the Parallel Computing Toolbox

%Default Test Function: projectimpulsemagicfft6("s_2_hands.mp3","r_LX48L_x_Small RChrch.wav",0.5,1)
function fft6verb = projectimpulsemagicfft6(signal_name,reverb_name,wet,speed_multiplier)
[signal,fs]=audioread(signal_name);
reverb=audioread(reverb_name);
%Move into GPU
signal = gpuArray(signal);
reverb = gpuArray(reverb);
%FFT
reverb_length = length(signal)+length(reverb);
f_signal=complex(fft(signal,reverb_length));
f_reverb=complex(fft(reverb,reverb_length));
%Cleanup
clear reverb;
%Convolution
f_conv=complex(f_signal.*f_reverb);
%Cleanup
clear f_signal f_reverb;
%IFFT
conv = real(ifft(f_conv));
%Fix Array Sizes
[m,n] = size(signal);
[m1,n1] = size(conv);
if m < m1
signal(m1,:) = 0; % extend A with rows of zeros, up to the number of rows of A1
elseif m > m1
conv(m,:) = 0; % extend A1 with rows of zeros, up to the number of rows of A
end
if n < n1
signal(:,n1) = 0; % extend A with columns of zeros, up to the number of columns of A1
elseif n > n1
conv(:,n) = 0; % extend A1 with columns of zeros, up to the number of columns of A
end
%Normalize Audio to Prevent Clipping
max_signal = max(signal);
signal_n = signal./max_signal;
max_conv = max(conv);
conv_n = conv./max_conv;
%Wet Dry Parameter
par_ng = 0.9*(wet*conv_n+(1-wet)*signal_n);
%Move GPU Array Back to Memory
par_n = gather(par_ng);
%Output
%sound(par_n,44100);
%fft5verb = par_n;
output_name = strrep(("o_" + signal_name + "_" + reverb_name + "_" + wet + "_wet_" + speed_multiplier + "x_speed"),".","_") + ".wav";
audiowrite(output_name, par_n, round(fs*speed_multiplier));
clearvars

The bedroom IRs below were captured using MATLAB’s IR capture tool. I used a speaker to play a sine sweep and placed a microphone at the other end of the bedroom to capture the room’s acoustics. This was then processed into an impulse response. I went around the house obtaining impulse responses for each bedroom. I understand there is some variability since the frequency responses of my microphone and especially my speaker are not flat across the audible frequency range, but this is a decent proof of concept.

Impulse Response of Bedroom #1

Impulse Response of Bedroom #2

Impulse Response of Bedroom #3

After obtaining these impulse responses, I used the FFT algorithm to essentially convolve the impulse responses to a sample audio. In the example below, it sounds like I’m recording the music from a speaker in my room, but it is truly just the source music convolved with the impulse response.

Sample Output: DJ Snake – Middle (100% Bedroom Reverb Mix)

Next, I wanted to try some higher-quality, professionally recorded impulse responses, so I found an open-source impulse response library and used a small church impulse response that I thought would sound nice.

Impulse Response of Small Church (WARNING THIS IS LOUD)

Sample Output: Ariana Grande – No Tears Left to Cry (50% Small Church Reverb Mix)

Sample Output: Tate McRae – Greenlight (100% Small Church Reverb Mix)