Commit d0113c31 authored by henryjandrew's avatar henryjandrew
Browse files

debugged example_ppm and added hashing

parent e8cc5a52
......@@ -26,7 +26,8 @@ f = ita_ANSI_center_frequencies;
va = VA;
try
dry_run = ~va.connect;
va.connect;
dry_run = false;
va.add_search_path( 'D:/Users/andrew/dev/ITASuite/VA/VACore/data' );
va.add_search_path( 'D:/Users/andrew/dev/ITASuite/VA/VAMatlab/matlab' );
......@@ -77,12 +78,22 @@ disp( [ 'Simulation result duration: ' num2str( N * frame_rate ) ' s' ] )
h = waitbar( 0, 'Hold on, running auralization' );
% Iterate over frames
n_continue = 1538;
n_continue = 1;
for n = n_continue: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 ); %pps = struct containing the current time frame
pps = ita_propagation_paths_add_identifiers( pps );
if n == 1
pps_new = pps;
pps_del = [];
pps_common = [];
else
[ pps_new, pps_del, pps_common ] = ita_propagation_paths_diff( pps_last, pps );
end
pps_last = pps;
% Update source (first anchor)
......@@ -100,12 +111,24 @@ for n = n_continue:N
% Update receiver (last anchor)
if ~dry_run
va.set_sound_source_position( S, source_pos_OpenGL );
va.set_soun_receiver_position( R, source_pos_OpenGL );
va.set_sound_receiver_position( R, source_pos_OpenGL );
end
paths_update = struct();
for p = 1:numel( pps )
% 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
pu = struct(); % Path update
......@@ -113,29 +136,44 @@ for n = n_continue:N
% Assemble DSP settings (gain, delay & filter coefficients)
pu.source = S;
pu.receiver = R;
path_name = get_path(pp);
pu.path = path_name;
exists = isKey( path_identifiers, path_name );
if( ~exists ) %if path does not already exist, add a new path with a unique int ID
path_count = path_count + 1;
ID = path_count;
new_ID = struct;
new_ID.ID = ID;
new_ID.updated = true;
new_ID.deleted = false;
new_ID.name = path_name;
path_status{ID} = new_ID;
path_identifiers(path_name) = ID;
pu.identifier = pp.identifier;
[ frequency_mags, gain, delay, valid_p ] = ita_propagation_path_get_data( pp, f, c);
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 );
continue
end
pu.gain = gain;
pu.delay = delay;
pu.frequency_magnitudes = abs(frequency_mags);
pu.frequencies = f;
if isa(pp.propagation_anchors, 'struct')
pu.position = pp.propagation_anchors( end-1 ).interaction_point( 1:3 ); % next to last anchor
else
ID = path_identifiers(path_name);
path_status{ID}.updated = true; %if path already exists, mark that it has been updated
pu.position = pp.propagation_anchors{ end-1 }.interaction_point( 1:3 ); % next to last anchor
end
pu.ID = ID;
%pu.path = strcat( 'direct_', num2str(S), '_to_', num2str(R) ); %sound path ID
pu.delete = false;
pu.audible = true;
paths_update.( strcat( 'path_', pu.identifier ) ) = pu;
end
for p = 1:numel( pps_common )
pp = pps( p ); % Propagation path
pu = struct(); % Path update
% Assemble DSP settings (gain, delay & filter coefficients)
pu.source = S;
pu.receiver = R;
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 );
......@@ -144,36 +182,24 @@ for n = n_continue:N
pu.gain = gain;
pu.delay = delay;
pu.frequency_magnitudes = frequency_mags;
pu.frequency_magnitudes = abs(frequency_mags);
pu.frequencies = f;
if isa(pp.propagation_anchors, 'struct')
pu.position = pp.propagation_anchors( end-1 ).interaction_point; % next to last anchor
pu.position = pp.propagation_anchors( end-1 ).interaction_point( 1:3 ); % next to last anchor
else
pu.position = pp.propagation_anchors{ end-1 }.interaction_point; % next to last anchor
pu.position = pp.propagation_anchors{ end-1 }.interaction_point( 1:3 ); % next to last anchor
end
pu.delete = false;
pu.audible = true;
paths_upate.(strcat('prop_path_',num2str(p))) = pu; %create a new field in the update struct containing the new path data
paths_update.( strcat( 'path_', pu.identifier ) ) = pu;
end
for i = 1:numel(path_status) %add any paths which need to be deleted to the update struct
if( (path_status{i}.updated == false) && (path_status{i}.deleted == false) )
p = p + 1;
dpu = struct();
dpu.ID = i;
dpu.delete = true;
paths_upate.(strcat('prop_path_',num2str(p))) = dpu; %set a new field in the path update struct telling the renderer to delete the path which no longer appears
path_status{i}.deleted = true;
end
path_status{i}.updated = false;
end
if ~dry_run
% Update all propagation paths
va.set_rendering_module_parameters( 'MyBinauralOutdoorNoise', paths_upate );
va.set_rendering_module_parameters( 'MyBinauralOutdoorNoise', paths_update );
end
if ~dry_run
......
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