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.
Asked
Active
Viewed 1,295 times
3
3 Answers
1
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);
robert bristow-johnson
- 20,661
- 4
- 38
- 76
0
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.
0
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.
zoulzubazz
- 88
- 4
fftboth the input file and the output file (perhaps zero-padding both). divide thefftof the output with thefftof the input. thenifftthe result. – robert bristow-johnson Nov 19 '16 at 20:59