function [imp_resp]=make_sensor_ir(elev,azim,H,F); %Usage: [imp_resp]=make_sensor_ir(elev,azim,H,F); % Build an N point impulse response for a sensor. % H is the desired magnitude response at the frequencies F. % Frequency values have a range 0 to 1 (0 Hz to Nyquist) and % need not be evenly spaced. The H values are interpolated to % N/2 points prior to an IFFT to form the impulse response. % % N.B. Uncomment the code for the desired microphone/sensor type (below) before running make_directivity_table.m % %----------------------------------------------------------------------------- % % Copyright (C) 2003 Douglas R Campbell % % 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 in the MATLAB file roomsim_licence.m ; if not, % write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. %----------------------------------------------------------------------------------- %Functions called: deg2rad=pi/180; elev=elev.*deg2rad; azim=azim.*deg2rad; N=128; %Required order of FIR filter modelling impulse response of sensor if length(H)==1, % No variation with frequency h=H; % set sensor gain else, % Compute parameters for converting sensor frequency response to impulse response Half_I=fix(N./2); % Half length of FIR filter model Half_I_plusone = Half_I+1; % Half length shift required for FIR filter model of sensor impulse response interp_x=[0: 1./Half_I :1].'; % Generate a column vector of interpolation grid points window = 0.5.*(1 - cos(2*pi*(0:N).'./N)); % Compute the (N+1) point column vector Hann window if length(H)= pi-azim_beam))), % % if (abs(elev)<= elev_beam & abs(azim)<= azim_beam) | (abs(abs(azim)-pi)<=azim_beam & abs(abs(elev)-pi)<= elev_beam ), % imp_resp= h; % else, % imp_resp= 0; % end; %-------------------------------------------------------- % This is a Uni-directional sensor with a gain of h over the rectilinear solid angle (beam angle) % +/-elev_beam and +/-azim_beam % elev_beam=30.*deg2rad; % azim_beam=10.*deg2rad; % if abs(elev)<= elev_beam & abs(azim)<= azim_beam, % imp_resp= h; % else, % imp_resp= 0; % end; %-------------------------------------------------------- % End of make_sensor_ir.m