WIP adding dry-run option

parent 248c6fd1
......@@ -7,50 +7,67 @@
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 ) )
receiver_pos = [ 3 0 3 ]; % OpenGL coordinates
f = ita_ANSI_center_frequencies;
% House corner
w = itaInfiniteWedge( [ 1 0 0 ], [ 0 0 -1 ], [ 0 0 0 ] ); % OpenGL coordinates
%% Connect and set up simple scene
va = VA( 'localhost' );
va.add_search_path( 'D:/Users/andrew/dev/ITASuite/VA/VACore/data' );
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' );
va = VA;
try
va.connect;
dry_run = ~va.get_connected;
va.add_search_path( 'D:/Users/andrew/dev/ITASuite/VA/VACore/data' );
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();
f = ita_ANSI_center_frequencies;
c = va.get_homogeneous_medium_sound_speed();
L = va.create_sound_receiver( 'VA_Listener' );
va.set_sound_receiver_position( L, receiver_pos )
%H = va.create_directivity_from_file( '$(DefaultHRIR)' );
H = va.create_directivity_from_file( 'ITA-Kunstkopf_HRIR_AP11_Pressure_Equalized_3x3_256.v17.ir.daff' );
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-Kunstkopf_HRIR_AP11_Pressure_Equalized_3x3_256.v17.ir.daff' );
va.set_sound_receiver_directivity( L, H );
va.set_sound_receiver_directivity( L, H );
S = va.create_sound_source( 'VA_Source' );
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 )
%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 )
catch
dry_run = true;
c = 343;
S = -1;
L = -1;
end
% House corner
w = itaFiniteWedge( [ 1 0 0 ], [ 0 0 -1 ], [ 0 -2 0 ], 4 ); % OpenGL coordinates
%% Example for a synchronized scene update & audio processing simulation/auralization
timestep = 128 / 44100; % here: depends on block size and sample rate
manual_clock = 0;
va.set_core_clock( 0 );
if ~dry_run
va.set_core_clock( 0 );
end
spatialstep = 0.1;
disp( [ 'Resulting sound source speed: ' num2str( spatialstep / timestep ) ' m/s' ] )
......@@ -62,16 +79,17 @@ x = linspace( -1, 1, numsteps ) * 50; % motion from x = -50m to x = 50m
n0_of_paths = 2;
D_log = [];
A_log = [];
gain_log = [];
H_log = []; % Diffracted field
IL_log = []; % Insertion loss
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 )
source_pos = [ x( n ) 1.1 -3 ]; % OpenGL coordinates
va.set_sound_source_position( S, source_pos );
source_pos = [ x( n ) 0 -3 ]; % OpenGL coordinates
if ~dry_run
va.set_sound_source_position( S, source_pos );
end
%% Direct sound path
......@@ -102,14 +120,15 @@ for n = 1:length( x )
prop_path_direct.audible = ~shadow_zone; % Direct field: may be occluded
end
H_direct = exp( -1i * 2 * pi * f / c / distance ) / distance;
%% Diffracted sound path
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 );
[ H, D, A ] = ita_diffraction_utd( w, source_pos, receiver_pos, f, c );
rho = norm( apex - source_pos );
prop_path_diffracted = struct();
prop_path_diffracted.source = S;
prop_path_diffracted.receiver = L;
......@@ -132,24 +151,37 @@ for n = 1:length( x )
paths_update.diffracted_path = prop_path_diffracted;
end
va.set_rendering_module_parameters( renderer_id, paths_update );
% Increment core clock
manual_clock = manual_clock + timestep;
va.call_module( 'manualclock', struct( 'time', manual_clock ) );
% Process audio chain by incrementing one block
va.call_module( 'virtualaudiodevice', struct( 'trigger', true ) );
if ~dry_run
rends = va.get_rendering_modules();
for rend = 1:numel( rends )
if strcmpi( rend.class, 'BinauralOutdoorNoise' )
va.set_rendering_module_parameters( rend.id, paths_update );
end
end
% Increment core clock
manual_clock = manual_clock + timestep;
va.call_module( 'manualclock', struct( 'time', manual_clock ) );
% Process audio chain by incrementing one block
va.call_module( 'virtualaudiodevice', struct( 'trigger', true ) );
end
waitbar( n / numsteps )
D_log = [ D_log; D ];
A_log = [ A_log; A ];
gain_log = [ gain_log; prop_path_diffracted.gain ];
H_log = [ H_log; H ];
if shadow_zone
IL_log = [ IL_log; H ./ H_direct ];
else
IL_log = [ IL_log; ( H + H_direct ) ./ H_direct ];
end
end
close( h )
va.disconnect
disp( 'Stop VA to export simulation results from rendering module(s)' )
if ~dry_run
va.disconnect
disp( 'Stop VA to export simulation results from rendering module(s)' )
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