No BSD License  

Highlights from
Brown Acoustic Simulator

image thumbnail
from Brown Acoustic Simulator by Avram Levi
Creates a source to microphone impulse response in complex room enviroments

direct_resp(pos, az_talker, el_talker, attn_high_res)
function [direct] = direct_resp(pos, az_talker, el_talker, attn_high_res)

% this function takes a position in the HMA room, azimuth and elevation orientation, the attenuation function and
% returns the magnitude of the source transfer function, distance and time
% delay, az_angle and el_angle for each microphone 

if az_talker==0
    az_talker=0.1;
end

temperature = 22.5;
speedofsound = 331.4 * sqrt(1.0 + (temperature + 273.0)/273.0);

X = hma_load_mic_locs;
X = X(2:449, :);

if size(pos,1)>1
    pos = pos';
end

pos = repmat(pos, 448, 1);
Y = X-pos;
dist = sqrt(Y(:, 1).^2+Y(:, 2).^2+Y(:, 3).^2);

% [attn_high_res, freq] = get_canadian_attn(freq_index, 1);

az = atan2(-Y(:, 1), -Y(:, 3))*180/pi;
el = atan2(Y(:, 2), sqrt(Y(:, 1).^2+Y(:, 3).^2))*180/pi;
for i=1:448
    i;
    if sign(az(i)) == sign(az_talker)
        az_rel_talker = az(i)-az_talker;
    else if sign(az_talker)==1
            if abs(az(i)-az_talker)<180
                az_rel_talker=az(i)-az_talker;
            else
                az_rel_talker=az(i)-az_talker+360;
            end
        elseif sign(az(i))==1
            if abs(az(i)-az_talker)<180
                az_rel_talker=az(i)-az_talker;
            else
                az_rel_talker=az(i)-az_talker-360;
            end
        end
    end
    el_rel_talker = el(i)-el_talker;
    attn(i) = attn_high_res(round(abs(az_rel_talker))+1, round(el_rel_talker)+91);
end

direct(:, 1) = attn;
direct(:, 2) = dist;
direct(:, 3) = dist/speedofsound; %time delay
direct(:, 4) = az;
direct(:, 5) = el;

    

Contact us at files@mathworks.com