Does someone have a matlab script to get the impulse response from the recorded measurements using log sweep? I have the input file (sweep) and the output and I need to get the impulse response and then calculate reverberation times for octave bands.
referenceFilename = 'reference.wav'; responseFilename = 'response.wav'; [reference, referenceFs] = audioread(referenceFilename); [nReferenceSamples, nReferenceChannels] = size(reference); [response, responseFs] = audioread(responseFilename); [nResponseSamples, nResponseChannels] = size(response); if referenceFs ~= responseFs error('reference audio and response audio files must have same sample rate'); end nFFT = 2^( ceil( log2(nReferenceSamples+nResponseSamples) ) ); x = zeros(nFFT, 1); y = zeros(nFFT, 1); x(1:nReferenceSamples) = reference(:,1); % use only left channel y(1:nResponseSamples) = response(:,1); % use only left channel h = ifft( fft(y) ./ fft(x) ); h = h(1:nFFT/2); % truncate latter half plot(h); sound(h, responseFs);
Once you obtain the IR you must square it, integrate it backwards (Schroeder integral), use octave filters and calculate the slope which is the RT.
A deconvolution algorithm would work. In the simplest form it is the inverse Fourier transform of the result of dividing the the Fourier transform of the output and the Fourier transform of the input. This may not work if the FT of the input has zeros in it but there are algorithms referenced in the link below which address this issue.