Commit 1950fda9 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Adding propagation path algorithm example, and a little tweak in outdoor example@

parent cedfb2ba
......@@ -12,6 +12,7 @@ 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();
......@@ -26,8 +27,8 @@ H = va.create_directivity_from_file( 'ITA_Artificial_Head_5x5_44kHz_128.v17.ir.d
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( fullfile('C:\ITASoftware\Raven\RavenDatabase\SoundDatabase','Full song - Vulfpeck - Dean Town.wav') );
%X = va.create_signal_source_buffer_from_file( 'musting_idle.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 offline simulation/auralization example for outputs of the propagation path algorithm
% Requires VA to run with a virtual audio device that can be triggered by
% the user. Also the generic path prototype rendering module(s) has to record the output
% to hard drive.
% Requires ITA-Toolbox, obtain from http://www.ita-toolbox.org
ppa_folder = '../../../ITAGeometricalAcoustics/ITAPropagationPathSim/tests/CombinedModel/PropagationPaths';
%% 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;
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' );
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 )
%% Run synchronized scene update & audio processing simulation/auralization
frame_rate = 128 / 44100; % here: depends on block size and sample rate
manual_clock = 0;
va.set_core_clock( 0 );
N = numel( file_listinging );
disp( [ 'Simulation result duration: ' num2str( N * frame_rate ) ' s' ] )
h = waitbar( 0, 'Hold on, running auralization' );
% Iterate over frames
for n = 1:length( N )
% Load propagation paths for current frame
ppa_file_path = fullfile( file_listing( n ).folder, file_listing( n ).name );
pps = ita_propagation_load_paths( ppa_file_path );
% Update source (first anchor)
source_pos = pps( n ).propagation_anchors{ 1 }.interaction_point; % OpenGL coordinates?! -> transform using
source_pos_OpenGL = ita_matlab2openGL( source_pos );
va.set_sound_source_position( S, source_pos_OpenGL );
% Update receiver (last anchor)
receiver_pos = pps( n ).propagation_anchors{ end }.interaction_point; % OpenGL coordinates?! -> transform using
receiver_pos_OpenGL = ita_matlab2openGL( receiver_pos );
va.set_sound_receiver_position( R, source_pos_OpenGL );
paths_update = struct();
for p = 1:numel( pps )
pp = pps( n ); % Propagation path
pu = struct(); % Path update
% Assemble DSP settings (gain, delay & filter coefficients)
pu.source = S;
pu.receiver = R;
pu.ID = pp.ID; % string -> int ID lookup required
pu.path = strcat( 'direct_', num2str(S), '_to_', num2str(R) ); %sound path ID
pu.gain = 1 / ita_propagation_path_attenuation( pp );
pu.delay = ita_propagation_path_length( pp ) / c;
pu.frequencies = f;
pu.frequency_magnitudes = ita_propagation_path_filter( pp, f );
pu.position = pp{ end-1 }.interaction_point; % next to last anchor
pu.delete = false; %set to true when an existing path should be deleted
pu.audible = true;
paths_upate( n ) = pu;
end
% 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 ) );
% Process audio chain by incrementing one block
va.call_module( 'virtualaudiodevice', struct( 'trigger', true ) );
waitbar( n / numsteps )
end
close( h )
va.disconnect
disp( 'Stop VA to export simulation results from rendering module(s)' )
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