Commit 6ba6cd45 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Adding a dry-run option

parent 89231f44
......@@ -6,40 +6,57 @@
% Requires ITA-Toolbox, obtain from http://www.ita-toolbox.org
ppa_folder = '../../../dist/win32-x64.vc12/bin/UrbanTrajectory';
ppa_folder = '../../../ITAGeometricalAcoustics/ITAPropagationPathSim/tests/CombinedModel/UrbanTrajectory';
%ppa_folder = '../../../dist/win32-x64.vc12/bin/UrbanTrajectory';
if isfolder( ppa_folder )
warning( 'Could not find trajectory source folder "%s".', ppa_folder )
end
ppa_diffraction_model = 'utd';
%% Preps
file_listing = dir( strcat( ppa_folder, '/*.json' ) );
c = ita_propagation_speed_of_sound_air_approx( 20 );
f = ita_ANSI_center_frequencies;
%% VA
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' );
c = va.get_homogeneous_medium_sound_speed();
f = ita_ANSI_center_frequencies;
va = VA;
R = va.create_sound_receiver( 'PPA_sensor' );
H = va.create_directivity_from_file( 'ITA_Artificial_Head_5x5_44kHz_128.v17.ir.daff' );
va.set_sound_receiver_directivity( R, H );
try
dry_run = ~va.connect;
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' );
c = va.get_homogeneous_medium_sound_speed();
R = va.create_sound_receiver( 'PPA_sensor' );
H = va.create_directivity_from_file( 'ITA_Artificial_Head_5x5_44kHz_128.v17.ir.daff' );
va.set_sound_receiver_directivity( R, H );
S = va.create_sound_source( 'PPA_emitter' );
%X = va.create_signal_source_buffer_from_file( 'WelcomeToVA.wav' );
X = va.create_signal_source_buffer_from_file( 'Full song - Vulfpeck - Dean Town.wav' );
S = va.create_sound_source( 'PPA_emitter' );
%X = va.create_signal_source_buffer_from_file( 'WelcomeToVA.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 )
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;
disp 'No VA client to connect to, starting dry run.'
S = -1;
R = -1;
c = ita_propagation_speed_of_sound_air_approx( 20 );
end
path_identifiers = containers.Map('KeyType','char','ValueType','uint16'); %a map linking the path number to name
path_status = cell(1); %cell array indexed by path number containing a struct with onfo on path
......@@ -49,7 +66,10 @@ path_count = 0; %The total number of paths, NOTE -NOT a count of paths in curren
frame_rate = 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
N = numel( file_listing );
disp( [ 'Simulation result duration: ' num2str( N * frame_rate ) ' s' ] )
......@@ -63,15 +83,21 @@ for n = 1:N
ppa_file_path = fullfile( file_listing( n ).folder, file_listing( n ).name );
pps = ita_propagation_load_paths( ppa_file_path ); %pps = struct containing the current time frame
pps = ita_propagation_hash_paths( pps ),
% Update source (first anchor)
source_pos = pps( n ).propagation_anchors{ 1 }.interaction_point; % OpenGL coordinates?! -> transform using
source_pos_OpenGL = ita_matlab2openGL( source_pos(1:3)' );
va.set_sound_source_position( S, source_pos_OpenGL );
if ~dry_run
va.set_sound_source_position( S, source_pos_OpenGL );
end
% Update receiver (last anchor)
receiver_pos = pps( n ).propagation_anchors{ end }.interaction_point; % OpenGL coordinates?! -> transform using
receiver_pos_OpenGL = ita_matlab2openGL( receiver_pos(1:3)' );
va.set_sound_receiver_position( R, source_pos_OpenGL );
receiver_pos_OpenGL = ita_matlab2openGL( receiver_pos(1:3)' );
if ~dry_run
va.set_soun_receiver_position( R, source_pos_OpenGL );
end
paths_update = struct();
......@@ -133,22 +159,28 @@ for n = 1:N
path_status{i}.updated = false;
end
if ~dry_run
% Update all propagation paths
va.set_rendering_module_parameters( 'MyBinauralOutdoorNoise', paths_upate );
% Increment core clock
manual_clock = manual_clock + frame_rate;
va.call_module( 'manualclock', struct( 'time', manual_clock ) );
va.set_rendering_module_parameters( 'MyBinauralOutdoorNoise', paths_upate );
end
% Process audio chain by incrementing one block
va.call_module( 'virtualaudiodevice', struct( 'trigger', true ) );
if ~dry_run
% Increment core clock
manual_clock = manual_clock + frame_rate;
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 / N )
end
close( h )
va.disconnect
if va.get_connected
va.disconnect
end
disp( 'Stop VA to export simulation results from rendering module(s)' )
......@@ -197,6 +229,7 @@ function [frequency_mags, gain, delay] = ita_get_propagation_path_data( path_str
total_distance = total_distance + segment_distance;
switch anchor_type
case 'outer_edge_diffraction' %case for diffraction
main_face_normal = path_data{i}.main_wedge_face_normal(1:3);
opposite_face_normal = path_data{i}.opposite_wedge_face_normal(1:3);
......@@ -257,7 +290,8 @@ function [frequency_mags, gain, delay] = ita_get_propagation_path_data( path_str
else
gain = gain * A;
end
frequency_mags = frequency_mags .* abs(D);
frequency_mags = frequency_mags .* abs(D);
case 'inner_edge_diffraction'
source_pos = path_data{i-1}.interaction_point(1:3);
receiver_pos = path_data{i+1}.interaction_point(1:3);
......
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