Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
VAMatlab
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Institute of Technical Acoustics (ITA)
VAMatlab
Commits
d34e4774
Commit
d34e4774
authored
Aug 09, 2019
by
Dipl.-Ing. Jonas Stienen
Browse files
Options
Browse Files
Download
Plain Diff
Merging
parents
f63e1222
5858d436
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
106 additions
and
53 deletions
+106
-53
matlab/VA_example_ppa.m
matlab/VA_example_ppa.m
+49
-28
matlab/ppa_run_analysis.m
matlab/ppa_run_analysis.m
+57
-25
No files found.
matlab/VA_example_ppa.m
View file @
d34e4774
...
...
@@ -6,6 +6,8 @@
% Requires ITA-Toolbox, obtain from http://www.ita-toolbox.org
record_paths
=
true
;
ppa_folder
=
'../../../dist/win32-x64.vc12/bin/UrbanTrajectory'
;
if
~
exist
(
ppa_folder
,
'dir'
)
...
...
@@ -56,18 +58,18 @@ catch
dry_run
=
true
;
disp
'No VA client to connect to, starting dry run.'
S
=
-
1
;
R
=
-
1
;
S
=
0
;
R
=
0
;
c
=
ita_propagation_speed_of_sound_air_approx
(
20
);
end
output_folder
=
'example_ppa_out'
;
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
;
source_str
=
struct
;
%struct with fields of source ID's and data of source positions for each frame
receiver_str
=
struct
;
receiver_str
.
ID
=
R
;
all_paths_data
=
struct
;
%% Run synchronized scene update & audio processing simulation/auralization
...
...
@@ -110,10 +112,11 @@ for n = n_continue:N %loop over frames
receiver_pos
=
pps
(
1
)
.
propagation_anchors
{
end
}
.
interaction_point
;
% OpenGL coordinates?! -> transform using
end
source_str
.
position
=
source_pos
;
receiver_str
.
position
=
receiver_pos
;
run_data
{
2
,
n
}
=
source_str
;
run_data
{
3
,
n
}
=
receiver_str
;
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
;
paths_update
=
struct
();
...
...
@@ -140,23 +143,29 @@ for n = n_continue:N %loop over frames
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
);
if
(
record_paths
)
[
frequency_mags
,
gain
,
delay
,
valid_p
,
path_data
]
=
ita_propagation_path_get_data
(
pp
,
f
,
c
,
'record_paths'
);
all_paths_data
.
(
strcat
(
'path_'
,
pu
.
identifier
)
)
=
path_data
;
else
[
frequency_mags
,
gain
,
delay
,
valid_p
]
=
ita_propagation_path_get_data
(
pp
,
f
,
c
);
end
%{
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
);
%}
if
valid_p
pu
.
gain
=
gain
;
pu
.
frequency_magnitudes
=
abs
(
frequency_mags
);
end
pu
.
frequencies
=
f
;
pu
.
delay
=
delay
;
if
isa
(
pp
.
propagation_anchors
,
'struct'
)
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
(
1
:
3
);
% next to last anchor
end
pu
.
delete
=
false
;
pu
.
audible
=
true
;
...
...
@@ -173,36 +182,48 @@ for n = n_continue:N %loop over frames
pu
.
receiver
=
R
;
pu
.
identifier
=
pp
.
identifier
;
[
frequency_mags
,
gain
,
delay
,
valid_p
]
=
ita_propagation_path_get_data
(
pp
,
f
,
c
);
if
(
record_paths
)
[
frequency_mags
,
gain
,
delay
,
valid_p
,
path_data
]
=
ita_propagation_path_get_data
(
pp
,
f
,
c
,
'record_paths'
);
all_paths_data
.
(
strcat
(
'path_'
,
pu
.
identifier
)
)
=
path_data
;
else
[
frequency_mags
,
gain
,
delay
,
valid_p
]
=
ita_propagation_path_get_data
(
pp
,
f
,
c
);
end
%{
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
);
%}
if
(
valid_p
)
pu
.
gain
=
gain
;
pu
.
frequency_magnitudes
=
abs
(
frequency_mags
);
end
pu
.
frequencies
=
f
;
pu
.
delay
=
delay
;
if
isa
(
pp
.
propagation_anchors
,
'struct'
)
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
(
1
:
3
);
% next to last anchor
end
pu
.
delete
=
false
;
pu
.
audible
=
true
;
paths_update
.
(
strcat
(
'path_'
,
pu
.
identifier
)
)
=
pu
;
end
run_data
{
1
,
n
}
=
paths_update
;
%save data to struct
if
(
record_paths
)
save
(
strcat
(
output_folder
,
'\frame'
,
num2str
(
n
),
'data.mat'
),
'paths_update'
,
'all_paths_data'
);
%save current frame data
else
save
(
strcat
(
output_folder
,
'\frame'
,
num2str
(
n
),
'data.mat'
),
'paths_update'
);
%save current frame data
end
run_data
{
1
,
n
}
=
paths_update
;
waitbar
(
n
/
N
)
end
close
(
h
)
save
(
'example_ppa_out
put_data.mat'
,
'run_data'
,
'all_path_names
'
);
%save variables to file
save
(
'example_ppa_out
\example_ppa_output_data.mat'
,
'all_path_names'
,
'source_str'
,
'receiver_str
'
);
%save variables to file
disp
(
'Finished generating path data for every frame. Data is saved in struct "run_data".'
);
...
...
@@ -215,8 +236,8 @@ if ~dry_run
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
)
'
);
source_pos_OpenGL
=
ita_matlab2openGL
(
run_data
{
2
,
n
}
);
receiver_pos_OpenGL
=
ita_matlab2openGL
(
run_data
{
3
,
n
}
);
% Update receiver (last anchor)
va
.
set_sound_source_position
(
S
,
source_pos_OpenGL
);
...
...
matlab/ppa_run_analysis.m
View file @
d34e4774
%% Input conditions
%target_path = 'path_19a0a7019da43b074b372bcbdf6adb25'; %path to follow through simulation
target_path
=
'path_50df740f16865a987b4b69ff1bb12c2f'
;
target_path
=
'path_03eff9730b428fe4b136ffe27c6684a3'
;
%path to follow through simulation
%target_path = 'diffracted_path';
%target_path = 'path_50df740f16865a987b4b69ff1bb12c2f';
input_folder
=
'example_ppa_out'
;
plot_single_path_freq
=
true
;
plot_all_delay_changes
=
false
;
plot_all_gain_changes
=
false
;
%load('example_ppa_output_data.mat','-mat');
plot_single_path
=
true
;
plot_all_delay_changes
=
true
;
plot_all_gain_changes
=
true
;
load
(
strcat
(
input_folder
,
'\example_ppa_output_data.mat'
),
'-mat'
);
%load('example_outdoor_acoustics_output_data','-mat');
%% Initial set up
N_frames
=
size
(
run_data
,
2
);
file_listing
=
dir
(
strcat
(
input_folder
,
'/*.mat'
)
);
N_frames
=
numel
(
file_listing
)
-
1
;
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_single_path
path_data
=
cell
(
1
,
N_paths
);
end
if
plot_all_delay_changes
delay_changes
=
zeros
(
N_frames
,
N_paths
);
prev_delay
=
zeros
(
1
,
N_paths
);
path_altered
=
zeros
(
1
,
N_paths
);
end
if
plot_all_gain_changes
gain_changes
=
zeros
(
N_frames
,
N_paths
);
...
...
@@ -28,12 +36,15 @@ f = ita_ANSI_center_frequencies;
%% Main loop
for
n
=
1
:
N_frames
%loop over all frames
%tic
if
plot_single_path_freq
load
(
strcat
(
input_folder
,
'\frame'
,
num2str
(
n
),
'data.mat'
),
'-mat'
);
%load path data for the next frame
if
plot_single_path_freq
||
plot_single_path
try
path
=
run_data
{
1
,
n
}
.
(
target_path
);
path
=
paths_update
.
(
target_path
);
freq_evolution
(
n
,:)
=
path
.
frequency_magnitudes
;
valid_evolution
(
n
,:)
=
path
.
audible
;
path_data
{
n
}
=
all_paths_data
.
(
target_path
);
catch
freq_evolution
(
n
,:)
=
zeros
(
1
,
31
);
valid_evolution
(
n
,:)
=
zeros
(
1
,
31
);
...
...
@@ -42,12 +53,18 @@ for n = 1:N_frames %loop over all frames
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
;
path
=
paths_update
.
(
all_path_names
{
p
});
if
(
path_altered
(
p
)
==
1
)
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
;
else
path_altered
(
p
)
=
1
;
prev_delay
(
p
)
=
path
.
delay
;
prev_gain
(
p
)
=
path
.
gain
;
end
catch
end
...
...
@@ -58,14 +75,17 @@ for n = 1:N_frames %loop over all frames
end
%% Plot Graphs
if
plot_single_path
visualise_single_path
(
path_data
);
end
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
);
all_path_delay_changes
(
delay_changes
,
N_paths
,
N_frames
);
end
if
plot_all_gain_changes
all_path_gain_changes
(
gain_changes
(
2
:
end
,:),
N_paths
,
N_frames
-
1
);
all_path_gain_changes
(
gain_changes
,
N_paths
,
N_frames
);
end
...
...
@@ -73,8 +93,10 @@ end
function
single_path_freq_evolution
(
f
,
N
,
freq_evolution
,
valid_evolution
)
[
X
,
Y
]
=
meshgrid
(
f
,
1
:
N
);
figure
s1
=
surf
(
X
,
Y
,
freq_evolution
,
valid_evolution
);
set
(
s1
,
'EdgeAlpha'
,
0.05
);
a
=
axes
;
s
=
surf
(
a
,
X
,
Y
,
freq_evolution
,
valid_evolution
);
set
(
a
,
'ZScale'
,
'log'
);
set
(
s
,
'EdgeAlpha'
,
0.05
);
xlabel
(
'Frequency (KHz)'
)
ylabel
(
'Frame number'
)
zlabel
(
'Frequency Magnitudes'
)
...
...
@@ -84,9 +106,11 @@ 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'
)
a
=
axes
;
s
=
surf
(
a
,
X
,
Y
,
delay_changes
);
set
(
s
,
'EdgeAlpha'
,
0.05
);
ylabel
(
'Frames'
)
xlabel
(
'Paths'
)
zlabel
(
'Delay Change'
)
grid
off
end
...
...
@@ -94,9 +118,17 @@ 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'
)
a
=
axes
;
s
=
surf
(
a
,
X
,
Y
,
gain_changes
);
set
(
s
,
'EdgeAlpha'
,
0.05
);
ylabel
(
'Frames'
)
xlabel
(
'Paths'
)
zlabel
(
'Gain Change'
)
grid
off
end
function
visualise_single_path
(
path_data
)
figure
a
=
axes
;
end
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment