Commit 547a2ffc authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

WiP fixing auralization

parent 5b6720ad
......@@ -6,20 +6,21 @@
% Requires ITA-Toolbox, obtain from http://www.ita-toolbox.org
%output_folder = fullfile( 'C:\Users\jonas\sciebo\Thesis stuff\auralization\resources', 'example_ppa/s1_r1' );
output_folder = fullfile( 'D:\Users\stienen\Sciebo\Thesis stuff\auralization\resources', 'example_ppa/s1_r1' );
output_folder = fullfile( 'C:\Users\jonas\sciebo\Thesis stuff\auralization\resources', 'example_ppa/s1_r1' );
%output_folder = fullfile( 'D:\Users\stienen\Sciebo\Thesis stuff\auralization\resources', 'example_ppa/s1_r1' );
frame_rate = 128 / 44100; % block length / sampling frequency
sort_by_date = false;
record_paths = true;
ppa_diffraction_model = 'utd';
%single_path_id = 'path_003ca6d3a74540310873574908219251';
S = 1;
R = 1;
ppa_example_mode = questdlg( 'Please select', 'VA example ppa mode selection', ...
'simulation', 'auralization', 'all', 'auralization');
ppa_example_mode = 'postprocessing'
%% Prepare run data
if any( strcmpi( ppa_example_mode, { 'simulation', 'all' } ) )
......@@ -27,7 +28,7 @@ if any( strcmpi( ppa_example_mode, { 'simulation', 'all' } ) )
if ~exist( output_folder, 'dir' )
mkdir( output_folder )
end
ppa_folder = '../../../dist/win32-x64.vc12/bin/UrbanTrajectory';
if ~exist( ppa_folder, 'dir' )
......@@ -56,7 +57,7 @@ if any( strcmpi( ppa_example_mode, { 'simulation', 'all' } ) )
% Iterate over frames
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
......@@ -89,8 +90,6 @@ if any( strcmpi( ppa_example_mode, { 'simulation', 'all' } ) )
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 )
......@@ -173,7 +172,7 @@ if any( strcmpi( ppa_example_mode, { 'simulation', 'all' } ) )
waitbar( n / N )
end
end
close( h )
if record_paths
......@@ -182,14 +181,11 @@ if any( strcmpi( ppa_example_mode, { 'simulation', 'all' } ) )
fprintf( 'Finished generating path data for every frame. Data is saved into separate files in folder ''%s''\n', output_folder );
end
%% Run postprocessing
postproc_all_paths = struct();
if any( strcmpi( ppa_example_mode, { 'postprocessing', 'all' } ) )
%% Run postprocessing
disp( 'Starting post-processing' )
% Load data
......@@ -212,7 +208,7 @@ if any( strcmpi( ppa_example_mode, { 'postprocessing', 'all' } ) )
% Run postprocessing over frames from front and back
for n = 1:N
idx_current_front = idx( n );
idx_current_front = idx( n );
load( fullfile( output_folder, file_listing( idx_current_front ).name ), '-mat' );
pathnames = fieldnames( paths_update );
......@@ -225,7 +221,7 @@ if any( strcmpi( ppa_example_mode, { 'postprocessing', 'all' } ) )
idx_current_back = idx( N + 1 - n );
load( fullfile( output_folder, file_listing( idx_current_back ).name ), '-mat' );
pathnames = fieldnames( paths_update );
for p = 1:numel( pathnames )
path_id = pathnames{ p };
......@@ -246,9 +242,12 @@ end
%% Run auralization
if any( strcmpi( ppa_example_mode, { 'auralization', 'all' } ) )
% Load data
load( fullfile( output_folder, 'postprocessing_data.mat' ), 'postproc_all_paths' )
file_listing = dir( strcat( output_folder, '/frame*data.mat' ) );
N = numel( file_listing );
fprintf( 'Found data on %i frames in folder ''%s''\n', N, output_folder )
......@@ -301,26 +300,44 @@ if any( strcmpi( ppa_example_mode, { 'auralization', 'all' } ) )
% frame
load( fullfile( output_folder, file_listing( idx_current ).name ), '-mat' );
fn = fieldnames( paths_update );
for p = 1:numel( fn )
path_id = fn{ p };
if n < postproc_all_paths.( path_id ).last_frame && paths_update.( path_id ).delete
paths_update.( path_id ).delete = false;
disp( 'Prevented path from deletion because it will be re-appear in a follow up frame' )
end
end
% Update all propagation paths
source_pos_OpenGL = ita_matlab2openGL( source_pos( 1:3 )' );
receiver_pos_OpenGL = ita_matlab2openGL( receiver_pos( 1:3 )' );
va.lock_update
va.lock_update;
% Update receiver (last anchor)
va.set_sound_source_position( S, source_pos_OpenGL );
va.set_sound_receiver_position( R, receiver_pos_OpenGL );
single_path_id = 'path_003ca6d3a74540310873574908219251';
if isfield( paths_update, single_path_id )
single_path_update = struct( 'p', paths_update.( single_path_id ) );
va.set_rendering_module_parameters( 'MyBinauralOutdoorNoise', single_path_update );
if exist( 'single_path_id', 'var' )
% Define a single_path_id if you want to run an auralization
% for an individual path, only (see first section)
if isfield( paths_update, single_path_id )
single_path_update = struct( 'p', paths_update.( single_path_id ) );
va.set_rendering_module_parameters( 'MyBinauralOutdoorNoise', single_path_update );
else
disp( 'Single path not found in current frame, skipping update' )
end
else
disp( 'not found, skipping update' )
% Update all paths
va.set_rendering_module_parameters( 'MyBinauralOutdoorNoise', paths_update );
end
va.unlock_update
va.unlock_update; % triggers scene update for renderers
% Increment core clock
manual_clock = manual_clock + frame_rate;
......
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