Commit f7becf20 authored by henryjandrew's avatar henryjandrew

fixed issues with example_ppa

parent d0113c31
......@@ -43,7 +43,7 @@ try
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' );
X = va.create_signal_source_buffer_from_file( 'LKW Leerlauf 2.wav' );
va.set_signal_source_buffer_playback_action( X, 'play' )
va.set_signal_source_buffer_looping( X, true );
......@@ -59,34 +59,36 @@ catch
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
all_path_names = cell(1);
path_count = 0; %The total number of paths, NOTE -NOT a count of paths in current frame, if paths are deleted, they are not removed from this count
source_str = struct;
source_str.ID = S;
receiver_str = struct;
receiver_str.ID = R;
%% Run synchronized scene update & audio processing simulation/auralization
frame_rate = 128 / 44100; % here: depends on block size and sample rate
manual_clock = 0;
if ~dry_run
va.set_core_clock( 0 );
end
N = numel( file_listing );
disp( [ 'Simulation result duration: ' num2str( N * frame_rate ) ' s' ] )
h = waitbar( 0, 'Hold on, running auralization' );
run_data = cell(3,N);
h = waitbar( 0, 'Hold on, running simulation of path data for each frame' );
% Iterate over frames
n_continue = 1;
for n = n_continue:N
for n = n_continue:N %loop over frames
all_path_name = [];
path_number = 1;
% 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 ); %pps = struct containing the current time frame
pps = ita_propagation_paths_add_identifiers( pps );
if n == 1
if n == n_continue
pps_new = pps;
pps_del = [];
pps_common = [];
......@@ -105,38 +107,35 @@ for n = n_continue:N
receiver_pos = pps( 1 ).propagation_anchors{ end }.interaction_point; % OpenGL coordinates?! -> transform using
end
source_pos_OpenGL = ita_matlab2openGL( source_pos(1:3)' );
receiver_pos_OpenGL = ita_matlab2openGL( receiver_pos(1:3)' );
% Update receiver (last anchor)
if ~dry_run
va.set_sound_source_position( S, source_pos_OpenGL );
va.set_sound_receiver_position( R, source_pos_OpenGL );
end
source_str.position = source_pos;
receiver_str.position = receiver_pos;
run_data{2,n} = source_str;
run_data{3,n} = receiver_str;
paths_update = struct();
% Delete non-available paths
for p = 1:numel( pps_del )
pu = struct(); % Path update
pu.source = S;
pu.receiver = R;
pu.identifier = pps_del( p ).identifier;
pu.delete = true;
paths_update.( strcat( 'path_', pu.identifier ) ) = pu;
end
for p = 1:numel( pps_new )
pp = pps( p ); % Propagation path
pp = pps_new( p ); % Propagation path
pu = struct(); % Path update
% Assemble DSP settings (gain, delay & filter coefficients)
pu.source = S;
pu.receiver = R;
pu.identifier = pp.identifier;
path_count = path_count + 1;
all_path_names{path_count} = pp.identifier;
[ frequency_mags, gain, delay, valid_p ] = ita_propagation_path_get_data( pp, f, c);
......@@ -158,13 +157,12 @@ for n = n_continue:N
pu.delete = false;
pu.audible = true;
paths_update.( strcat( 'path_', pu.identifier ) ) = pu;
paths_update.( strcat( 'path_', pu.identifier ) ) = pu;
end
for p = 1:numel( pps_common )
pp = pps( p ); % Propagation path
pp = pps_common( p ); % Propagation path
pu = struct(); % Path update
% Assemble DSP settings (gain, delay & filter coefficients)
......@@ -173,7 +171,6 @@ for n = n_continue:N
pu.identifier = pp.identifier;
[ frequency_mags, gain, delay, valid_p ] = ita_propagation_path_get_data( pp, f, c);
ita_res
if ~valid_p %catch for error in ita_propagation_path_get_data
warning( 'Error in ita_propagation_path_get_data, found invalid path ''%s'', skipping', pp.identifier );
......@@ -194,27 +191,45 @@ for n = n_continue:N
pu.audible = true;
paths_update.( strcat( 'path_', pu.identifier ) ) = pu;
end
if ~dry_run
% Update all propagation paths
va.set_rendering_module_parameters( 'MyBinauralOutdoorNoise', paths_update );
end
run_data{1,n} = paths_update; %save data to struct
end
close( h )
save( 'example_ppa_output_data.m', 'run_data', 'all_path_names' ); %save variables to file
disp('Finished generating path data for every frame. Data is saved in struct "run_data".');
%% Run VA simulation
if ~dry_run
manual_clock = 0;
va.set_core_clock( 0 );
h = waitbar( 0, 'Hold on, running auralisation using generated data' );
for n = n_continue:N
% Update all propagation paths
source_pos_OpenGL = ita_matlab2openGL( run_data{2,n}.position(1:3)' );
receiver_pos_OpenGL = ita_matlab2openGL( run_data{3,n}.position(1:3)' );
% Update receiver (last anchor)
va.set_sound_source_position( S, source_pos_OpenGL );
va.set_sound_receiver_position( R, receiver_pos_OpenGL );
va.set_rendering_module_parameters( 'MyBinauralOutdoorNoise', run_data{1,n} );
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 ) );
waitbar( n / N )
end
waitbar( n / N )
close( h )
end
close( h )
if va.get_connected
va.disconnect
......
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