WIP

parent 85413495
......@@ -5,8 +5,14 @@
% to hard drive.
free_field_only = false;
direct_field_only = false; % with shadowing of edge
diffracted_field_only = false;
renderer_id = 'MyBinauralOutdoorNoise';
assert( ~( free_field_only && diffracted_field_only ) )
assert( ~( free_field_only && direct_field_only ) )
assert( ~( diffracted_field_only && direct_field_only ) )
%% Connect and set up simple scene
va = VA( 'localhost' );
va.add_search_path( 'D:/Users/andrew/dev/ITASuite/VA/VACore/data' );
......@@ -14,6 +20,7 @@ va.add_search_path( 'D:/Users/andrew/dev/ITASuite/VA/VAMatlab/matlab' );
va.add_search_path( 'C:/dev/VA/VACore/data' );
va.add_search_path( 'D:/Users/stienen/dev/VA/VACore/data' );
va.add_search_path( 'C:/ITASoftware/Raven/RavenDatabase/SoundDatabase' );
va.add_search_path( 'C:\Users\jonas\sciebo\ITA\Lehre\Masterarbeiten\2019 Henry Andrew\car_pass-by_corner' );
c = va.get_homogeneous_medium_sound_speed();
......@@ -23,16 +30,15 @@ L = va.create_sound_receiver( 'VA_Listener' );
receiver_pos = [ 1 1.7 2 ]; % OpenGL coordinates
va.set_sound_receiver_position( L, receiver_pos )
%H = va.create_directivity_from_file( '$(DefaultHRIR)' );
H = va.create_directivity_from_file( 'ITA_Artificial_Head_5x5_44kHz_128.v17.ir.daff' );
H = va.create_directivity_from_file( 'ITA-Kunstkopf_HRIR_AP11_Pressure_Equalized_3x3_256.v17.ir.daff' );
va.set_sound_receiver_directivity( L, H );
S = va.create_sound_source( 'VA_Source' );
%X = va.create_signal_source_buffer_from_file( 'WelcomeToVA.wav' );
X = va.create_signal_source_buffer_from_file( 'LKW Leerlauf 2.wav' );
%X = va.create_signal_source_buffer_from_file( 'Full song - Vulfpeck - Dean Town.wav' );
va.set_signal_source_buffer_playback_action( X, 'play' )
va.set_signal_source_buffer_looping( X, true );
va.set_sound_source_signal_source( S, X )
......@@ -56,26 +62,32 @@ x = linspace( -1, 1, numsteps ) * 50; % motion from x = -50m to x = 50m
n0_of_paths = 2;
D_log = [];
A_log = [];
gain_log = [];
h = waitbar( 0, 'Hold on, running auralization' );
direct_deleted = false; %set to true when the direct path has been deleted
for n = 1:length( x )
% Modify scene as you please (position has no real effect for prototype generic path renderer)
source_pos = [ x( n ) 1.1 -3 ]; % OpenGL coordinates
%distance = sum( abs( source_pos - receiver_pos ) );
distance = norm(source_pos - receiver_pos);
va.set_sound_source_position( S, source_pos );
% Manually create direct sound path and diffracted sound path
shadow_zone = ita_diffraction_shadow_zone(w, source_pos, receiver_pos); %is receiver in shadow zone?
%% Direct sound path
% Manually create direct sound path and diffracted sound path
shadow_zone = ita_diffraction_shadow_zone( w, source_pos, receiver_pos ); %is receiver in shadow zone?
if n > 1 && last_shadow_zone ~= shadow_zone
fprintf( 'Shadow zone has been crossed on frame %i\n', n )
end
last_shadow_zone = shadow_zone;
% Direct sound path (id 0)
distance = norm( source_pos - receiver_pos );
prop_path_direct = struct();
prop_path_direct.identifier = 'direct_path';
prop_path_direct.gain = 1/distance;
prop_path_direct.gain = 1 / distance;
prop_path_direct.delay = distance / c; %delay from sound emitting from source to being received at listener
prop_path_direct.frequencies = f; %Frequencies corresponding to the mags
values = ones(1,31);
......@@ -85,44 +97,39 @@ for n = 1:length( x )
prop_path_direct.delete = false; %set to true when an existing path should be deleted
prop_path_direct.position = source_pos;
if free_field_only
prop_path_direct.audible = true;
prop_path_direct.audible = true; % Free field: always audible
else
prop_path_direct.audible = ~shadow_zone
prop_path_direct.audible = ~shadow_zone; % Direct field: may be occluded
end
% Diffracted sound path (id 1)
%prop_path_direct.audible = false;
apex = w.get_aperture_point( source_pos, receiver_pos );
detour = norm( source_pos - apex ) + norm(apex - receiver_pos );
prop_path_diffracted = struct();
%prop_path_diffracted.distance = detour;
%% Diffracted sound path
prop_path_diffracted.delay = detour / c;
prop_path_diffracted.frequencies = f;
[H, D, A] = ita_diffraction_utd( w, source_pos, receiver_pos, f, c );
rho = norm(apex - source_pos);
prop_path_diffracted.gain = A / rho;
apex = w.get_aperture_point( source_pos, receiver_pos );
detour = norm( source_pos - apex ) + norm( apex - receiver_pos );
[ ~, D, A ] = ita_diffraction_utd( w, source_pos, receiver_pos, f, c );
rho = norm( apex - source_pos );
prop_path_diffracted.frequency_magnitudes = abs( D )
%prop_path_diffracted.frequency_magnitudes = values;
prop_path_diffracted = struct();
prop_path_diffracted.source = S;
prop_path_diffracted.receiver = L;
prop_path_diffracted.identifier = 'diffracted_path';
prop_path_diffracted.delete = false;
prop_path_diffracted.position = apex;
prop_path_diffracted.audible = true;
prop_path_diffracted.delay = detour / c;
prop_path_diffracted.frequencies = f;
prop_path_diffracted.gain = A / rho;
prop_path_diffracted.frequency_magnitudes = abs( D );
% @todo at some point: load all patqhs from pre-calculated simulation -> ITAPropagationPathSim (C++) output
% D:/Users/andrew/dev/ITASuite/VA/VACore/tests/BinauralOutdoorNoiseRendererTest.VACore.ini
%disp(strcat('**diff dirn: ', num2str(apex),' Delay = ',num2str(distance/c),'** Direct sound: ',num2str(source_pos),' Delay = ',num2str(detour/c),'**'));
% Update wave fronts in renderer
%% Update wave fronts in renderer
paths_update = struct();
paths_update.prop_path_0 = prop_path_direct;
if ~free_field_only
paths_update.prop_path_1 = prop_path_diffracted;
if ~diffracted_field_only
paths_update.direct_path = prop_path_direct;
end
if ~free_field_only && ~direct_field_only
paths_update.diffracted_path = prop_path_diffracted;
end
va.set_rendering_module_parameters( renderer_id, paths_update );
......@@ -136,6 +143,10 @@ for n = 1:length( x )
waitbar( n / numsteps )
D_log = [ D_log; D ];
A_log = [ A_log; A ];
gain_log = [ gain_log; prop_path_diffracted.gain ];
end
close( h )
......
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