Industrial Experiences

Professional Services


Room Impulse Response for Directional source generator (RIRDgen)

by Sina Hafezi, Alastair H. Moore, and Patrick A. Naylor

Microphone Type: Free-field mic

Coding Language: MATLAB


To appear.


In this work we present a new room impulse response simulation for free-field microphone taking into account source directivity. We calculate the emission angle of the sound ray leaving the source based on the location of the image and the receiver using Allen and Berkley's image method [1]. We provide an implementation of a room impulse response simulator for a free-field mic which follows the same structure explained in [2,3] but includes a directional source with arbitrary directivity.


  [1] J. B. Allen and D. A. Berkley

  Image method for efficiently simulating small-room acoustics, Journal of the Acoustical Society of America, Volume 65, Issue 4, pp. 943-950, April 1979.

  [2] D. P. Jarrett, E. A. P. Habets, M. R. P. Thomas and P. A. Naylor

  Rigid sphere room impulse response simulation: algorithm and applications, Journal of the Acoustical Society of America, Volume 132, Issue 3, pp. 1462-1472, 2012.

  [3] D. P. Jarrett, E. A. P. Habets, M. R. P. Thomas and P. A. Naylor

  Simulating room impulse responses for spherical microphone arrays, Proc. of the IEEE International Conference on Acoustics, Speech, and Signal Processing (ICASSP 2011), Prague, Czech Republic, May 22-27, 2011.


Download Code


c = 340;                    % Sound velocity (m/s)
fs = 8000;                 % 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)

betha=repmat(.5,2,3);       % Walls reflection coefficients
n = 1000;                    % Number of samples
max_ref=-1;              % Maximum reflection order (-1 is all possible reflection order)

r_s=r-s;                    % Receiver location w/ resp. to source
% Source orientation (radian) [azimuth elevation]
source_orient= [atan(r_s(2)/r_s(1)) (pi/2)-acos(r_s(3)/norm(r_s))];

% Directivity pattern
% Standard pattern

% Customized pattern
%Note for Customized pattern: The sample azimuth, elevation and frequency must fully cover their range due to interpolation)
azimuth_samples=[0 2*pi-0.0001];
elevation_samples=[-pi/2 +pi/2];
frequency_samples=[0 20000];
gain=repmat(1,length(azimuth_samples),length(elevation_samples),length(frequency_samples)); % Sampled Omnidirectinal
source_type={azimuth_samples,elevation_samples,frequency_samples,gain}; % Constructing a cell for pattern

interp_method='linear';             % interpolation method used in directivity pattern in case of customised pattern

h = rird_generator(c, fs, r, s, L, betha, n, source_orient, max_ref,source_type, interp_method);

% plotting
xlabel('time (s)');ylabel('h');title('Room Impulse Response (RIR)');

Impulse Response


Sina Hafezi, 2015