Commit 4c0f05a6 authored by henryjandrew's avatar henryjandrew

changed the data struct which is sent to a new format which is compatible with...

changed the data struct which is sent to a new format which is compatible with the VA receiving end. Also added a check for if the source is in the shadow zone, in which case the direct path is deleted in VA.
parent 6634181c
......@@ -10,7 +10,7 @@
% mechanism ('enumerate_functions')
%
va_base_dir = 'D:/Users/stienen/dev/VA/dist/win32-x64.vc14'; % VA folder with bin, lib, matlab, data etc.
va_base_dir = 'D:/Users/andrew/dev/ITASuite/dist/win32-x64.vc12'; % VA folder with bin, lib, matlab, data etc.
va_script_dir = fullfile( va_base_dir, 'matlab' ); % Matlab scripts target directory
va_bin_dir = fullfile( va_base_dir, 'bin' );
va_lib_dir = fullfile( va_base_dir, 'lib' );
......
......@@ -14,11 +14,15 @@ f = ita_ANSI_center_frequencies;
L = va.create_sound_receiver( 'VA_Listener' );
receiver_pos = [ 2 1.7 0 ]; % OpenGL coordinates
va.set_sound_receiver_position( L, receiver_pos )
H = va.create_directivity_from_file( '$(DefaultHRIR)' );
%H = va.create_directivity_from_file( '$(DefaultHRIR)' );
H = va.create_directivity_from_file( 'D:/Users/andrew/dev/ITASuite/VA/VAMatlab/matlab/ITA_Artificial_Head_5x5_44kHz_128.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( '$(DemoSound)' );
%X = va.create_signal_source_buffer_from_file( '$(DemoSound)' );
X = va.create_signal_source_buffer_from_file( 'D:/Users/andrew/dev/ITASuite/VA/VAMatlab/matlab/WelcomeToVA.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 )
......@@ -40,7 +44,10 @@ disp( [ 'Simulation result duration: ' num2str( numsteps * timestep ) ' s' ] )
x = linspace( -1, 1, numsteps ) * 50; % motion from x = -5m to x = 5m
n0_of_paths = 2;
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)
......@@ -51,34 +58,59 @@ for n = 1:length( x )
% Manually create direct sound path and diffracted sound path
prop_path_direct = struct();
prop_path_direct.distance = distance;
prop_path_direct.delay = distance / c;
prop_path_direct.frequencies = f;
if ita_diffraction_shadow_zone( w, source_pos, receiver_pos )
prop_path.values = zeros( 1, numel( f ) );
shadow_zone = ita_diffraction_shadow_zone(w, source_pos, receiver_pos); %is receiver in shadow zone?
if( shadow_zone == false )
prop_path_direct = struct();
prop_path_direct.distance = 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);
prop_path_direct.frequency_magnitudes = values;
prop_path_direct.source = S; %sound source ID
prop_path_direct.receiver = L; %sound receiver ID
prop_path_direct.path = strcat( 'direct_', num2str(S), '_to_', num2str(L) ); %sound path ID
prop_path_direct.delete = false; %set to true when the path should be deleted
direct_deleted = false;
else
prop_path.values = ones( 1, numel( f ) );
prop_path_direct = struct();
prop_path_direct.path = strcat( 'direct_', num2str(S), '_to_', num2str(L) ); %sound path ID
prop_path_direct.delete = true; %if source is in shadow zone, delete direct path
direct_deleted = true;
end
%maybe use this to fade out direct sound by setting distance to inf or
%seting flter to 0
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;
prop_path_diffracted.delay = detour / c;
prop_path_diffracted.frequencies = f;
prop_path.values = ita_diffraction_utd( w, source_pos, receiver_pos, f, c );
values = abs( ita_diffraction_utd( w, source_pos, receiver_pos, f, c ) );
prop_path_diffracted.frequency_magnitudes = values';
prop_path_diffracted.source = S;
prop_path_diffracted.receiver = L;
prop_path_diffracted.path = strcat( 'diff1_', num2str(S), '_to_', num2str(L) );
prop_path_diffracted.delete = false;
% @todo at some point: load all paths from pre-calculated simulation -> ITAPropagationPathSim (C++) output
% D:/Users/andrew/dev/ITASuite/VA/VACore/tests/BinauralOutdoorNoiseRendererTest.VACore.ini
% Update wave fronts in renderer
path_update = struct();
path_update.source = S;
path_update.receiver = L;
path_update.prop_path_1 = prop_path_direct;
path_update.prop_path_2 = prop_path_diffracted;
if( direct_deleted == false )
path_update.prop_path_0 = prop_path_direct;
path_update.prop_path_1 = prop_path_diffracted;
else
path_update.prop_path_0 = prop_path_diffracted;
end
va.set_rendering_module_parameters( 'MyBinauralOutdoorNoise', path_update );
% Increment core clock
......
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