Commit 11835220 authored by jonasstienen's avatar jonasstienen
Browse files

Progress on geometrical acoustics class and automatic tf calculation

parent d4053ba3
function [ freq_data_linear ] = run( obj )
function [ freq_data_linear ] = run( obj, with_progress_bar )
%RUN Calculates the transfer function (tf) of the superimposed (geometrical) propagation path in frequency domain
freq_data_linear = zeros( obj.num_bins, 1 );
if nargin < 2 || ~with_progress_bar
with_progress_bar = false;
else
h = waitbar( 0, 'Hold on, running propagation modeling' );
end
% Iterate over propagation paths, calculate transfer function and sum up
for n = 1:numel( obj.pps )
N = numel( obj.pps );
for n = 1:N
if with_progress_bar
waitbar( n / N )
end
pp = obj.pps( n );
pp_tf = obj.tf( pp );
freq_data_linear = freq_data_linear + pp_tf;
end
if with_progress_bar
close( h )
end
end
......@@ -13,9 +13,9 @@ end
freq_data_linear = ones( obj.num_bins, 1 );
distance_p = ita_propagation_path_length( pp );
fprintf( 'Path metrics: distance=%.1fm, delay=%.1fms\n', distance_p, distance_p / obj.c * 1e3 );
%fprintf( 'Path metrics: distance=%.1fm, delay=%.1fms\n', distance_p, distance_p / obj.c * 1e3 );
if distance_p / obj.c > 2 * obj.num_bins / obj.fs
error 'Propagation path length too long, increase number of bins to generate transfer function for this propagation path'
error( 'Propagation path length too long (%.1fm vs %.d bins), increase number of bins to generate transfer function for this propagation path', distance_p, obj.num_bins )
end
incident_spreading_loss_applied = false;
......@@ -85,7 +85,7 @@ for n = 1 : N
end
target_position_relative = target_pos( 1:3 ) - anchor.interaction_point( 1:3 ); % Outgoing direction vector
target_position_relative = target_pos( 1:3 ) - anchor.interaction_point( 1:3 ); % Icoming or outgoing direction vector
if obj.sim_prop.directivity
freq_data_linear = freq_data_linear .* obj.tf_directivity( anchor, target_position_relative / norm( target_position_relative ) );
......@@ -116,9 +116,14 @@ for n = 1 : N
error( 'Detected a diffraction at beginning or end of propagation path.' )
end
% Diffraction values are summed up using the source /
% receiver effective distances.
% Spreading loss is spherical until first diffraction, after
% that its a combination of spherical and cylindrical
source_pos = pp.propagation_anchors{ n - 1 }.interaction_point( 1:3 );
target_pos = pp.propagation_anchors{ n + 1 }.interaction_point( 1:3 );
source_direction = ( source_pos - anchor.interaction_point( 1:3 ) ) / norm( source_pos - anchor.interaction_point( 1:3 ) );
target_direction = ( target_pos - anchor.interaction_point( 1:3 ) ) / norm( target_pos - anchor.interaction_point( 1:3 ) );
......@@ -128,16 +133,16 @@ for n = 1 : N
effective_target_position = anchor.interaction_point( 1:3 ) + target_direction * effective_target_distance;
if obj.sim_prop.diffraction
freq_data_linear = freq_data_linear .* obj.tf_diffraction( anchor, effective_source_position, effective_target_position );
% If not already applied by another diffraction edge, include incident field
if ~incident_spreading_loss_applied
phase_by_delay = obj.phase_delay( effective_source_distance );
spreading_loss = ita_propagation_spreading_loss( effective_source_distance, 'spherical' );
freq_data_linear = freq_data_linear .* phase_by_delay .* spreading_loss;
incident_spreading_loss_applied = true;
incident_spreading_loss_applied = true;
end
freq_data_linear = freq_data_linear .* obj.tf_diffraction( anchor, effective_source_position, effective_target_position, obj.diffraction_model );
end
otherwise
......@@ -148,4 +153,6 @@ for n = 1 : N
end
assert( incident_spreading_loss_applied )
end
function [ linear_freq_data ] = tf_diffraction( obj, anchor, effective_source_position, effective_receiver_position )
function [ linear_freq_data ] = tf_diffraction( obj, anchor, effective_source_position, effective_receiver_position, diffraction_model )
%TF_REFLECTION Returns the specular reflection transfer function for a diffraction point to an effective receiver point with
% an incident and emitting direction
......@@ -58,13 +58,8 @@ end
switch( diffraction_model )
case 'utd'
% Includes spreading loss after diffraction, but not phase shift
% With or without spreading loss after diffraction
linear_freq_data = obj.tf_diffraction_utd( w, effective_source_position, effective_receiver_position );
eff_receiver_distance = norm( apex_point - effective_receiver_position );
phase_delay_after_diffr = obj.phase_delay( eff_receiver_distance );
linear_freq_data = linear_freq_data .* phase_delay_after_diffr;
case 'maekawa'
......
......@@ -2,7 +2,12 @@ function [ linear_freq_data ] = tf_diffraction_utd( obj, wedge, source_pos, rece
%TF_DIFFRACTION_UTD Calculates the diffraction filter based on uniform
%theory of diffraction (with Kawai approximation).
[ ~, D, A ] = ita_diffraction_utd( wedge, source_pos, receiver_pos, obj.freq_vec( 2:end ), obj.c );
apx = wedge.apex_point_approx( source_pos, receiver_pos );
[ ~, D, A ] = ita_diffraction_utd( wedge, source_pos, receiver_pos, obj.freq_vec( 2:end ), obj.c, apx );
%D = D ./ D;
% incident field component missing, 1 / rho and phase of source-apex
% connection
linear_freq_data = [ 0; A .* D ];
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment