Aufgrund von Umarbeiten des s3 Storage wird es in GitLab, in nächster Zeit, mögliche Performance-Einbußen geben. Näheres dazu unter: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/43/show_ticket/6670

Commit 7e195730 authored by henryjandrew's avatar henryjandrew

some cleaning up and small updates to example_ppa

parent 12596270
......@@ -27,6 +27,7 @@ frame_rate = 128 / 44100; % here: depends on block size and sample rate
file_listing = dir( strcat( ppa_folder, '/*.json' ) );
f = ita_ANSI_center_frequencies;
c = 343;
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
......@@ -40,8 +41,6 @@ R = 1;
N = numel( file_listing );
disp( [ 'Simulation result duration: ' num2str( N * frame_rate ) ' s' ] )
run_data = cell(3,N);
h = waitbar( 0, 'Hold on, running simulation of path data for each frame' );
% Iterate over frames
......@@ -67,18 +66,14 @@ for n = n_continue:N %loop over frames
% Update source (first anchor)
if isa( pps( 1 ).propagation_anchors, 'struct' )
source_pos = pps( 1 ).propagation_anchors( 1 ).interaction_point; % OpenGL coordinates?! -> transform using
receiver_pos = pps( 1 ).propagation_anchors( end ).interaction_point; % OpenGL coordinates?! -> transform using
source_pos = pps( 1 ).propagation_anchors( 1 ).interaction_point(1:3); % OpenGL coordinates?! -> transform using
receiver_pos = pps( 1 ).propagation_anchors( end ).interaction_point(1:3); % OpenGL coordinates?! -> transform using
else
source_pos = pps( 1 ).propagation_anchors{ 1 }.interaction_point; % OpenGL coordinates?! -> transform using
receiver_pos = pps( 1 ).propagation_anchors{ end }.interaction_point; % OpenGL coordinates?! -> transform using
end
source_str.(strcat('source_',num2str(S)))(n,:) = source_pos;
receiver_str.(strcat('receiver_',num2str(R)))(n,:) = receiver_pos;
run_data{2,n} = source_pos;
run_data{3,n} = receiver_pos;
source_pos = pps( 1 ).propagation_anchors{ 1 }.interaction_point(1:3); % OpenGL coordinates?! -> transform using
receiver_pos = pps( 1 ).propagation_anchors{ end }.interaction_point(1:3); % OpenGL coordinates?! -> transform using
end
source_str.(strcat('source_',num2str(S))) = source_pos;
receiver_str.(strcat('receiver_',num2str(R))) = receiver_pos;
paths_update = struct();
......@@ -175,20 +170,16 @@ for n = n_continue:N %loop over frames
file_name = sprintf( 'frame%04idata.mat', n );
file_path = fullfile( output_folder, file_name );
save( file_path, 'paths_update' ); %save current frame data
save( file_path, 'S', 'R', '-append' );
save( file_path, 'source_pos', 'receiver_pos', '-append' );
save( file_path, 'paths_update', 'source_str', 'receiver_str' ); %save current frame data
if( record_paths )
save( file_path, 'all_paths_data', '-append' );
end
run_data{1,n} = paths_update;
waitbar( n / N )
end
close( h )
save( 'example_ppa_out\example_ppa_output_data.mat', 'all_path_names', 'source_str', 'receiver_str' ); %save variables to file
save( 'example_ppa_out\example_ppa_output_data.mat', 'all_path_names' ); %save variables to file
disp('Finished generating path data for every frame. Data is saved in struct "run_data".');
......@@ -205,7 +196,7 @@ for n=1:N
end
[ ~, idx ] = sort( frame_datenums );
load( 'example_ppa_out\example_ppa_output_data.mat', 'all_path_names', 'source_str', 'receiver_str' )
load( 'example_ppa_out\example_ppa_output_data.mat', 'all_path_names' )
va = VA;
......@@ -239,20 +230,20 @@ h = waitbar( 0, 'Hold on, running auralisation using generated data' );
for n = 1:N
idx_current = idx( n );
frame_data = load( fullfile( output_folder, file_listing( idx_current ).name ) );
load( fullfile( output_folder, file_listing( idx_current ).name ), '-mat' );
path_ids = fieldnames( frame_data.paths_update );
source_pos = source_str.source_0( n, 1:3 );
source_pos = source_str.(strcat('source_',num2str(S)));
receiver_pos = receiver_str.(strcat('receiver_',num2str(R)));
% Update all propagation paths
source_pos_OpenGL = ita_matlab2openGL( source_pos );
receiver_pos_OpenGL = ita_matlab2openGL( receiver_pos( 1:3 ) );
source_pos_OpenGL = ita_matlab2openGL( source_pos' );
receiver_pos_OpenGL = ita_matlab2openGL( receiver_pos' );
% 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', frame_data.paths_update );
va.set_rendering_module_parameters( 'MyBinauralOutdoorNoise', paths_update );
% Increment core clock
manual_clock = manual_clock + frame_rate;
......
......@@ -4,7 +4,8 @@ target_path = 'path_03eff9730b428fe4b136ffe27c6684a3'; %path to follow through s
input_folder = 'example_ppa_out';
out_filename = 'Path_evolution.gif';
plot_single_path_freq = false;
out_filename_freq = 'Path_evolution_freq.gif';
plot_single_path_freq = true;
plot_single_path = true;
plot_all_delay_changes = false;
plot_all_gain_changes = false;
......@@ -36,7 +37,8 @@ f = ita_ANSI_center_frequencies;
%% Main loop
for n = 1:N_frames %loop over all frames
load(strcat(input_folder,'\frame',num2str(n),'data.mat'),'-mat'); %load path data for the next frame
file_name = sprintf( '/frame%04idata.mat', n );
load(strcat(input_folder,file_name),'-mat'); %load path data for the next frame
if plot_single_path_freq || plot_single_path
try
......@@ -75,7 +77,8 @@ end
%% Plot Graphs
if plot_single_path
visualise_single_path( path_data, out_filename, N_interaction_points );
visualise_single_path( path_data, out_filename, N_interaction_points, f, freq_evolution, valid_evolution );
%visualise_single_freq( f, N_frames, freq_evolution, valid_evolution, out_filename_freq )
end
if plot_single_path_freq
single_path_freq_evolution( f, N_frames, freq_evolution, valid_evolution );
......@@ -126,10 +129,13 @@ function all_path_gain_changes( gain_changes, N_paths, N_frames )
grid off
end
function visualise_single_path( path_data, out_filename, N_interaction_points )
function visualise_single_path( path_data, out_filename, N_interaction_points, f, freq_evolution, valid_evolution )
%% Export giff of selected path
f = figure;
a = axes;
fig1 = figure;
fig1.Units = 'pixels';
fig1.Position = [50 50 1000 400 ];
a1 = subplot(1,2,1);
axis equal;
plot3([-5.1251,-5.1251],[-46.6484,53.5954],[20.8399,20.8399],'-k')
......@@ -154,9 +160,9 @@ function visualise_single_path( path_data, out_filename, N_interaction_points )
plot3([6.8749,6.8749],[53.5954,53.5954],[-0.1337,19.7963],'-k')
plot3([-5.1251,-12.6201],[53.5954,53.5954],[20.8399,28.2501],'-k')
plot3([-5.1251,-12.6201],[-46.6484,-46.6484],[20.8399,28.2501],'-k')
a.XLim = [-10 20];
a.YLim = [-60 20];
a.ZLim = [-0.1337 20.8399];
a1.XLim = [-10 20];
a1.YLim = [-60 20];
a1.ZLim = [-0.1337 20.8399];
axis off;
N_frames = numel(path_data);
......@@ -171,16 +177,31 @@ function visualise_single_path( path_data, out_filename, N_interaction_points )
try
pointA = path_data{1}(i,:);
pointB = path_data{1}(i+1,:);
segment{i} = plot3(a, [pointA(1),pointB(1)], [pointA(2),pointB(2)], [pointA(3),pointB(3)] );
segment{i} = plot3(a1, [pointA(1),pointB(1)], [pointA(2),pointB(2)], [pointA(3),pointB(3)] );
catch
segment{i} = plot3([-12.6201,-12.6201],[-46.6484,-46.6484],[28.2501,28.2501],'-b');
end
end
end
a2 = subplot(1,2,2);
if valid_evolution(1,1) == 1
p = plot( a2, f, freq_evolution(1,:), 'k' );
else
p = plot( a2, f, freq_evolution(1,:), 'r' );
end
set( a2, 'YScale', 'log' );
set( a2, 'XScale', 'log' );
xlabel('Frequency (Hz)')
ylabel('Frequency Magnitudes')
grid off
a2.YLim = [10^-6 1];
a2.XLim = [min(f) max(f)];
drawnow
frame = getframe(f);
frame = getframe(fig1);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
imwrite( imind, cm, out_filename, 'gif', 'Loopcount', inf, 'DelayTime', 0.03 );
imwrite( imind, cm, out_filename, 'gif', 'Loopcount', inf, 'DelayTime', 0.05 );
path_start = false;
for n = 2:10:N_frames
......@@ -197,11 +218,19 @@ function visualise_single_path( path_data, out_filename, N_interaction_points )
segment{i}.ZData = [path_data{n}(i,3), path_data{n}(i+1,3)];
path_start = true;
end
p.YData = freq_evolution(n,:);
if( valid_evolution(n,1) == 1 )
p.Color = 'k';
else
p.Color = 'r';
end
drawnow
frame = getframe(f);
frame = getframe(fig1);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
imwrite( imind, cm, out_filename, 'gif', 'WriteMode', 'append', 'DelayTime', 0.03 );
imwrite( imind, cm, out_filename, 'gif', 'WriteMode', 'append', 'DelayTime', 0.05 );
catch
if path_start
return
......@@ -209,4 +238,56 @@ function visualise_single_path( path_data, out_filename, N_interaction_points )
end
end
end
function visualise_single_freq( f, N_frames, freq_evolution, valid_evolution, out_filename_freq )
%%
fig = figure;
a2 = axes;
if valid_evolution(1,1) == 1
p = plot( a2, f, freq_evolution(1,:), 'k' );
start_plot = 1;
else
p = plot( a2, f, freq_evolution(1,:), 'r' );
start_plot = 0;
end
set( a2, 'YScale', 'log' );
xlabel('Frequency (KHz)')
ylabel('Frequency Magnitudes')
grid off
a2.YLim = [10^-6 1];
a2.XLim = [min(f) max(f)];
drawnow
frame = getframe(fig);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
imwrite( imind, cm, out_filename_freq, 'gif', 'Loopcount', inf, 'DelayTime', 0.03 );
no_path = 0;
for n = 2:10:N_frames
if( valid_evolution(n,1) == 1 )
start_plot = 1;
p.Color = 'k';
else
p.Color = 'r';
if( start_plot == 1)
no_path = no_path + 1;
end
end
if( start_plot == 0 ) %skip time before target path kicks in
continue
end
p.YData = freq_evolution(n,:);
drawnow
frame = getframe(fig);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
imwrite( imind, cm, out_filename_freq, 'gif', 'WriteMode', 'append', 'DelayTime', 0.03 );
if( (no_path>=10) && (start_plot==1) ) %cut off time after path has finished
return
end
end
end
\ No newline at end of file
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