view pick_ir.m @ 0:90220f7249fc

Initial commit
author Timos Papadopoulos <tp@isvr.soton.ac.uk>
date Sat, 16 Nov 2013 18:25:24 +0000
parents
children
line wrap: on
line source
function picked_ir = pick_ir(simdata, dist, azim, orient, dirweight)
%Picks a 2-row matrix of binaural responses for specified geometry and source directivity from simulated_echo.m output
% 
% - simdata input argument must be a structure as outputed from simulate_echo.m
% - dist input argument must be the distance in meters
% - azim input argument must be the azimuthal angle of the board center in degrees with 0 corresponding to dead front,
% positive values to left and negative values to right
% - orient input argument must be either 'horz' or 'angled'
% - dirweight input argument must be a nonnegative real scalar determining what is the relative weight of the emission path
% to the echo path (i.e. due to directivity focus in the frontal direction of the source, the emission which is directed
% upwards and backwards in our specific geometry is significantly attenuated, typically by factor in the vicinity of 0.1)
% 
% picked_ir output is a 2-row matrix of binaural responses (left ear in the top row and right ear in the bottom row) 
% 
% If any of the specified dist, azim, orient values are not among the cases included in the specified simdata stucture,
% then an error is returned.
% 
% picked_ir = pick_ir(simdata, dist, azim, orient, dirweight)
% 

dist_ind = find(dist == simdata.params.board_dist);
azim_ind = find(mod(90+azim,360)*pi/180 == simdata.params.board_azim);
orient_ind = find(strcmp(orient,simdata.params.board_orientation));

try
    dist_ind = dist_ind(1);
    azim_ind = azim_ind(1);
    orient_ind = orient_ind(1);
catch %#ok<CTCH>
    error('at least on of specified distance, azimuth, orientation does not exist in this dataset')
end

picked_ir = dirweight*simdata.emission{dist_ind,azim_ind,orient_ind} + simdata.echo{dist_ind,azim_ind,orient_ind};