Commit fcfc60ee authored by jonasstienen's avatar jonasstienen
Browse files

WIP pigeon project, improving calculation of transfer function and...

WIP pigeon project, improving calculation of transfer function and auralisation wavefront coefficients for automated simulation and modeling and auralisation
parent 73f30a2a
......@@ -5,8 +5,8 @@ if distance <= 0
error 'Distance cannot be zero or negative'
end
lambda = obj.c ./ obj.freq_vec( 2:end ); % Wavelength
k = 2 * pi ./ lambda; % Wavenumber
lambda = obj.c ./ obj.freq_vec( 2:end ); % Wavelength
k = 2 * pi ./ lambda; % Wavenumber
phase_by_delay = [ 0; exp( -1i .* k .* distance ) ]; % Note: DC value set to ZERO
......
......@@ -32,7 +32,11 @@ elseif ~receiver_closer_main && ~source_closer_main % but not in opposite face r
reflection_at_main_face = false;
else
% mixed situation
if( dot( n1 - n2, receiver_pos - loc ) + dot( n1 - n2, source_pos - loc ) > 0 )
nn = ( n1 + n2 ) / norm( n1 + n2 );
sa = ( loc - source_pos ) / norm( loc - source_pos );
ar = ( receiver_pos - loc ) / norm( receiver_pos - loc );
nx = ( nn + sa ) / norm( nn + sa );
if dot( nn, ar ) > dot( nn, nx )
reflection_at_main_face = true;
else
reflection_at_main_face = false;
......
......@@ -48,7 +48,7 @@ for n = 1 : N
effective_source_distance = distance_p; % whole distance in this case
else
effective_source_distance = ita_propagation_effective_source_distance( pp, n );
end
end
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;
......@@ -135,13 +135,14 @@ for n = 1 : N
if obj.sim_prop.diffraction
if ~incident_spreading_loss_applied
phase_by_delay = obj.phase_delay( effective_source_distance );
phase_by_delay = obj.phase_delay( effective_source_distance + effective_target_distance ); % Phase along full 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;
end
freq_data_linear = freq_data_linear .* obj.tf_diffraction( anchor, effective_source_position, effective_target_position, obj.diffraction_model );
diffr = obj.tf_diffraction( anchor, effective_source_position, effective_target_position, obj.diffraction_model );
freq_data_linear = freq_data_linear .* diffr;
end
......
......@@ -2,6 +2,7 @@ function [ linear_freq_data ] = tf_reflection( obj, anchor, incident_direction_v
%TF_REFLECTION Returns the specular reflection transfer function for an reflection point anchor with
% an incident and emitting direction
%linear_freq_data = ones( obj.num_bins, 1 ) * db2mag( -0.9 );
linear_freq_data = ones( obj.num_bins, 1 );
if ~isfield( anchor, 'material_id' )
......
function export_config( obj, s, r )
[ output_folder, file_base_name ] = fileparts( obj.config_file_path );
ini = IniConfig();
ini.AddSections( { 'pigeon:scene', 'pigeon:config' } );
ini.AddKeys( 'pigeon:scene', 'GeometryFilePath', obj.geometry_file_path );
ini.AddKeys( 'pigeon:scene', 'EmitterPos', s );
ini.AddKeys( 'pigeon:scene', 'SensorPos', r );
ini.AddKeys( 'pigeon:scene', 'OutputFilePath', obj.result_file_path );
ini.AddKeys( 'pigeon:config', 'MaxDiffractionOrder', obj.MaxDiffractionOrder );
ini.AddKeys( 'pigeon:config', 'MaxReflectionOrder', obj.MaxReflectionOrder );
ini.AddKeys( 'pigeon:config', 'MaxCombinedOrder', obj.MaxReflectionOrder );
ini.AddKeys( 'pigeon:config', 'OnlyNeighbouredEdgeDiffraction', double( obj.OnlyNeighbouredEdgeDiffraction ) );
ini.AddKeys( 'pigeon:config', 'DiffractionOnlyIntoShadowedEdges', double( obj.OnlyNeighbouredEdgeDiffraction ) );
ini.AddKeys( 'pigeon:config', 'FilterNotVisiblePathsBetweenEdges', double( obj.FilterNotVisiblePointToEdge ) );
ini.AddKeys( 'pigeon:config', 'FilterEmitterToEdgeIntersectedPaths', double( obj.FilterEmitterToEdgeIntersectedPaths ) );
ini.AddKeys( 'pigeon:config', 'FilterSensorToEdgeIntersectedPaths', double( obj.FilterSensorToEdgeIntersectedPaths ) );
ini.AddKeys( 'pigeon:config', 'FilterNotVisiblePaths', double( obj.FilterNotVisiblePaths ) );
ini.AddKeys( 'pigeon:config', 'IntersectionTestResolution', obj.IntersectionTestResolution );
ini.AddKeys( 'pigeon:config', 'NumIterations', obj.NumIterations );
ini.AddKeys( 'pigeon:config', 'MaxAccumulatedDiffractionAngle', obj.MaxAccumulatedDiffractionAngle );
ini.AddKeys( 'pigeon:config', 'LevelDropThreshold', obj.LevelDropThreshold );
ini.AddKeys( 'pigeon:config', 'ReflectionPenalty', obj.ReflectionPenalty );
ini.AddKeys( 'pigeon:config', 'DiffractionPenalty', obj.DiffractionPenalty );
ini.AddKeys( 'pigeon:config', 'ExportVisualisation', double( obj.export_visualization ) );
for idx = 1:numel( obj.visualizationPaths )
secname = sprintf( 'pigeon:visualization:pigeonVizLayer%00i', idx );
ini.AddSections( secname );
ini.AddKeys( secname, sprintf( 'path%00i', idx ), obj.visualizationPaths{ idx } );
end
%% Export INI file
if isempty( output_folder )
output_folder = pwd;
else
if ~exist( output_folder, 'dir' )
mkdir( output_folder );
end
end
export_file_path = fullfile( output_folder, strcat( file_base_name, '.ini' ) ) ;
if obj.saveBackupConfig && exist( export_file_path, 'file' ) ~= 0
export_file_path_backup = fullfile( output_folder, stract( file_base_name, '_backup.ini' ) ) ;
copyfile( export_file_path, export_file_path_backup );
end
ini.WriteFile( export_file_path );
end
......@@ -9,4 +9,4 @@ function dAirAbsorptionFactor = ita_atmospheric_absorption_factor( dFrequency, d
%Factor of absorbed signal energy [0:1]
dAirAbsorptionFactor = 1 - 10.^( -dAirAbsorptionDecibel / 10.0 );
end
\ No newline at end of file
end
......@@ -2,7 +2,11 @@ function [ absorption_db, alpha_iso ] = ita_atmospheric_absorption_level_dB( f,
% ISO 9613-1 Acoustics - Attenuation of sound during propagation outdoors
% Attenuation coefficient [dB/m], ~f, as assembly of Equation (5) parts
alpha_iso = ita_atmospheric_absorption_iso9613( f, varargin );
if nargin == 2
alpha_iso = ita_atmospheric_absorption_iso9613( f );
else
alpha_iso = ita_atmospheric_absorption_iso9613( f, varargin );
end
% Resulting atmospheric absorption [dB], ~alpha (~f)
% Equation (2)
......
......@@ -66,7 +66,7 @@ for n = 1:numel( pps )
if use_clear_text
pps_with_ids( n ).identifier = path_id_clear;
else
pps_with_ids( n ).identifier = path_id_hashed;
pps_with_ids( n ).identifier = strcat( 'hash', path_id_hashed ); % Put a non-numerical prefix to avoid indexing poblems
end
pps_hash_table( n ).key = path_id_clear;
pps_hash_table( n ).hash = path_id_hashed;
......
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