NOTE: this function is now available from the IoSR Matlab Toolbox as iosr.acoustics.irStats.
-------------------------
Calculate RT, DRR, Cte, and EDT for impulse response file
RT = IR_STATS(FILENAME) returns the reverberation time (to -60 dB)
using a method based on ISO 3382-1:2009. The function uses reverse
cumulative trapezoidal integration to estimate the decay curve, and a
linear least-square fit to estimate the slope between 0 dB and -60 dB.
Estimates are taken in octave bands and the overall figure is an
average of the 500 Hz and 1 kHz bands.
FILENAME should be the full path to an audio file or the name of an
audio file on the Matlab search path. The file can be of any format
supported by the AUDIOREAD function, and have any number of channels;
estimates (and plots) will be returned for each channel.
The function returns a 1xN vector of RTs, where N is the number of
channels in the audio file.
The function determines the direct sound as the peak of the squared
impulse response.
[RT,DRR] = IR_STATS(FILENAME) returns the direct-to-reverberant-ratio
DRR for the impulse; DRR is the same size as RT. This is calculated
in the following way:
DRR = 10 * log10( X(T0-C:T0+C)^2 / X(T0+C+1:end)^2 )
where X is the approximated integral of the impulse, T0 is the time of
the direct impulse, and C=2.5ms [1].
[RT,DRR,CTE] = IR_STATS(FILENAME) returns the early-to-late index CTE
for the impulse; CTE is the same size as RT. This is calculated in
the following way:
CTE = 10 * log10( X(T0-C:T0+TE)^2 / X(T0+TE+1:end)^2 )
where TE is 50 ms.
[RT,DRR,CTE,CFS] = IR_STATS(FILENAME) returns the octave-band centre
frequencies CFS used in the calculation of RT.
[RT,DRR,CTE,CFS,EDT] = IR_STATS(FILENAME) returns the early decay
time EDT, which is the same size as RT. The slope of the decay curve
is determined from the fit between 0 and -10 dB. The decay time is
calculated from the slope as the time required for a 60 dB decay.
... = IR_STATS(...,'PARAMETER',VALUE) allows numerous
parameters to be specified. These parameters are:
'graph' : {false} | true
Controls whether decay curves are plotted. Specifically, graphs
are plotted of the impulse response, decay curves, and linear
least-square fit for each octave band and channel of the audio
file. If the EDT output is specified, the EDT fit will also be
plotted.
'te' : {0.05} | scalar
Specifies the early time limit (in seconds).
'spec' : {'mean'} | 'full'
Determines the nature of RT and EDT outputs. With spec='mean'
(default) the reported RT and EDT are the mean of the 500 Hz
and 1 kHz bands. With spec='full', the function returns the
RT and EDT as calculated for each octave band returned in
CFS; RT and EDT have size [M N] where M=length(CFS).
'y_fit' : {[0 60]} | two-element vector
Specifies the decibel range over which the decay curve should
be evaluated. For example, 'y_fit' may be [-5 -25] or [-5 -35]
corresponding to the RT20 and RT30 respectively.
'correction' : {0.0025} | scalar
Specifies the correction parameter C (in seconds) given above
for DRR and CTE calculations. Values of up to 10 ms have been
suggested in the literature.
Octave-band filters are calculated according to ANSI S1.1-1986 and IEC
standards. Note that the OCTDSGN function recommends centre frequencies
fc in the range fs/200 < fc < fs/5.
The author would like to thank Feifei Xiong for his input on the
correction parameter.
References
[1] Zahorik, P., 2002: 'Direct-to-reverberant energy ratio
sensitivity', The Journal of the Acoustical Society of America,
112, 2110-2117.
See also AUDIOREAD, OCTDSGN.
Christopher Hummersone (2021). Impulse response acoustic information calculator (https://github.com/IoSR-Surrey/MatlabToolbox), GitHub. Retrieved .
Inspired by: octave
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.
I have the irStats function showing a figure box, however no plots appear. Any advice on how to resolve this?
how to draw a decay curve figure as shown in the title? the irStats function is straight output the decay time
Hey Not sure if you still look this stream but I had some questions
(1): the rt estimates will not work for me it says ">> iosr.acoustics.rtEst(abs_coeff, room, formula)
Unrecognized function or variable 'abs_coeff'."
I am not sure what that means and trying t define abs_coeff has not worked either.
(2) I can not get the irstats to find my file, there are warnings all over and I can not seem to figure out what they mean.
So do you have like examples I could review or maybe some other advice/ideas that be helpful because I am at the end if my rope at this point and feel very lost. Thank you!
@Mohsin can you post a link to the impulse response file that causes the error (or send the file to me directly).
I am having this error:
>> RT = iosr.acoustics.irStats('K:\EmoDB_distance\Release_RT_estimation_MatlabFileExchange\speech_file\TSP1min48.wav', 'graph', false, 'te', 0.05 , 'y_fit', [-5 -25], 'correction', 0.0025, 'spec', 'mean')
In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in iosr.acoustics.irStats (line 191)
t0(n) = find(x(:,n).^2==max(x(:,n).^2)); % find direct impulse
I tried the following command
RT = irStats('K:\EmoDB_distance\Release_RT_estimation_MatlabFileExchange\speech_file\merged.wav', 'graph', true, 'te', 0.05 , 'spec', 'full', 'y_fit', [0 60], 'correction', 0.0025)
but cannot make it work. it says
'Undefined function 'irStats' for input arguments of type 'char'.' Could you please help me fix this issue?
@Razvan can you post a minimal working example so that I can try to reproduce and fix the bug? Please also post a link to the impulse response file that causes the error (or send the file to me directly).
I can not find calc_decay function
>> rt=irStats(filename);
Undefined function 'calc_decay' for input arguments of type 'double'.
Error in irStats (line 201)
[rt_temp(f,n),E_rt,fit_rt] = calc_decay(z(f,t0:end,n),options.y_fit,60,fs,cfs(f)); % estimate
RT
Thanks for the bug fix! Seems to work well now even with impulse responses having a low dynamic range.
@Earl, can you post a minimal working example so that I can try to reproduce and fix the bug?
I often get:
Assignment has more non-singleton rhs dimensions than non-singleton subscripts
Error in IR_stats (line 186)
[rt_temp(f,n),E_rt,fit_rt] = calc_decay(z(f,t0:end,n),options.y_fit,60,fs);
Hi Augusto. Yes you can. Try:
Rt60 = ir_stats(filename,'spec','full');
Chris
Hi there,
Is it possible with this .m file to determine de RT60 for the separate octave bands? I was trying to do so but I couldn't figure it out. Tried to pass a filtered IR generated with the audiowrite function but it didn't work out.
Hi Clay. I need a bit more information in order to help. Firstly, did you download the Octave toolbox per the requirements above (and add the files to your MATLAB search path)?
An error comes up:
Error in IR_stats (line 164)
[b(f,:),a(f,:)] = octdsgn(cfs(f),fs,N);
Any thoughts?