Commit c7f5cf55 authored by henryjandrew's avatar henryjandrew

added analysis script

parent 26579f2f
......@@ -82,6 +82,9 @@ H_reflected_log = [];
H_total_field_log = [];
IL_log = []; % Insertion loss
run_data = cell(3,length(x));
all_path_names = {'direct_path', 'diffracted_path', 'reflected_path'};
h = waitbar( 0, 'Hold on, running auralization' );
direct_deleted = false; %set to true when the direct path has been deleted
for n = 1:length( x )
......@@ -186,6 +189,10 @@ for n = 1:length( x )
paths_update.reflected_path = prop_path_reflected;
end
run_data{1,n} = paths_update;
run_data{2,n} = source_pos;
run_data{3,n} = receiver_pos;
if ~dry_run
rends = va.get_rendering_modules();
......@@ -225,6 +232,8 @@ for n = 1:length( x )
end
close( h )
save( 'example_outdoor_acoustics_output_data.mat', 'run_data', 'all_path_names' ); %save variables to file
if ~dry_run
va.disconnect
......
%% Input conditions
%target_path = 'path_03eff9730b428fe4b136ffe27c6684a3'; %path to follow through simulation
target_path = 'diffracted_path';
plot_single_path_freq = true;
plot_all_delay_changes = true;
plot_all_gain_changes = true;
%load('example_ppa_output_data.mat','-mat');
load('example_outdoor_acoustics_output_data','-mat');
%% Initial set up
N_frames = size( run_data, 2 );
N_paths = numel(all_path_names);
if plot_single_path_freq
freq_evolution = zeros(N_frames,31);
valid_evolution = zeros(N_frames,31);
end
if plot_all_delay_changes
delay_changes = zeros(N_frames, N_paths);
prev_delay = zeros(1,N_paths);
end
if plot_all_gain_changes
gain_changes = zeros(N_frames, N_paths);
prev_gain = zeros(1,N_paths);
end
f = ita_ANSI_center_frequencies;
%% Main loop
for n = 1:N_frames %loop over all frames
if plot_single_path_freq
try
path = run_data{1,n}.(target_path);
freq_evolution(n,:) = path.frequency_magnitudes;
valid_evolution(n,:) = path.audible;
catch
freq_evolution(n,:) = zeros(1,31);
valid_evolution(n,:) = zeros(1,31);
end
end
if plot_all_delay_changes || plot_all_gain_changes
for p = 1:N_paths
try
path = run_data{1,n}.(all_path_names{p});
delay_changes(n,p) = path.delay - prev_delay(p);
prev_delay(p) = path.delay;
gain_changes(n,p) = path.gain - prev_gain(p);
prev_gain(p) = path.gain;
catch
end
end
end
end
%% Plot Graphs
if plot_single_path_freq
single_path_freq_evolution( f, N_frames, freq_evolution, valid_evolution );
end
if plot_all_delay_changes
all_path_delay_changes( delay_changes(2:end,:), N_paths, N_frames-1 );
end
if plot_all_gain_changes
all_path_gain_changes( gain_changes(2:end,:), N_paths, N_frames-1 );
end
%% Plot functions
function single_path_freq_evolution( f, N, freq_evolution, valid_evolution )
[X,Y] = meshgrid(f, 1:N);
figure
surf( X, Y, freq_evolution, valid_evolution )
xlabel('Frequency (KHz)')
ylabel('Frame number')
zlabel('Frequency Magnitudes')
grid off
end
function all_path_delay_changes( delay_changes, N_paths, N_frames )
[X,Y] = meshgrid(1:N_paths, 1:N_frames);
figure
surf( X, Y, delay_changes)
xlabel('Frames')
ylabel('Paths')
zlabel('Delay Change')
grid off
end
function all_path_gain_changes( gain_changes, N_paths, N_frames )
[X,Y] = meshgrid(1:N_paths, 1:N_frames);
figure
surf( X, Y, gain_changes)
xlabel('Frames')
ylabel('Paths')
zlabel('Gain Change')
grid off
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