Site menu:

Room Impulse Response Generator for MATLAB

Abstract

The image method, proposed by Allen and Berkley in 1979 [1], is probably one of the most commonly used methods in the acoustic signal processing community to create synthetic room impulse responses. A mex-function, which can be used in MATLAB, was developed to generate multi-channel room impulse responses using the image method. This function enables the user to control the reflection order, room dimension and microphone directivity. This package includes a tutorial, MATLAB examples, and the source code.

References

  1. J.B. Allen and D.A. Berkley
    Image method for efficiently simulating small-room acoustics
    Journal Acoustic Society of America, 65(4), April 1979, p 943.

Example

c = 340; % Sound velocity (m/s)
fs = 16000; % Sample frequency (samples/s)
r = [ 2 1.5 2 ]; % Receiver position [ x y z ] (m)
s = [ 2 3.5 2 ]; % Source position [ x y z ] (m)
L = [ 5 4 6 ]; % Room dimensions [ x y z ] (m)
beta = 0 . 4; % Reverberationtime (s)
nsample = 4096; % Number of samples
mtype = ’ hypercardioid ’; % Type of microphone
order = −1; % −1 equals maximum reflection order!
dim = 3; % Room dimension
orientation = [pi/2 0]; % Microphone orientation [azimuth elevation] in radians
hp_filter = 1; % Enable high-pass filter

h = rir_generator(c, fs, r, s, L, beta, nsample, mtype, order, dim, orientation, hp_filter);

History

1.0.20030606

Initial version

1.1.20040803

+ Microphone directivity
+ Improved phase accuracy

1.2.20040312

+ Reflection order

1.3.20050930

+ Reverberation Time

1.4.20051114

+ Supports multi-channels

1.5.20051116

+ High-pass filter [1]
+ Microphone directivity control

1.6.20060327

+ Minor improvements

1.7.20060531

+ Minor improvements

1.8.20080713

+ Minor improvements

1.9.20090822

+ 3D microphone directivity control

2.0.20100920

+ Calculation of the source-image position
   changed in the code and tutorial.
   This ensures a proper response to reflections
   in case a directional microphone is used.

Downloads

Latest version (source code, examples and tutorial)
Tutorial

How to build the MEX-function

You will need to build the MEX-function using MATLAB. MATLAB supports the use of a variety of compilers for building MEX-files. MathWorks also maintains a list of supported and compatible compilers. Once you have verified that you are using a supported C++ compiler, you are ready to configure your system to build the rir_generator using the following steps:

  1. Start MATLAB
  2. Run the following command from the MATLAB command prompt and select a C++ compiler: mex -setup
  3. Now build the MEX-function using: mex rir_generator.cpp
Please do not hesitate to contact me if you experience any problems while building the MEX-function.

Copyright

Copyright (C) 2003-2010 E.A.P. Habets, The Netherlands.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA