Commit 6de4d6ca authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen

Merged

parents 990c01bb c256d3ce
matlab/VA_build.m
matlab/VA_build_absolute.m
*.gif
HTML
*.bat
*.mat
......
cmake_minimum_required( VERSION 2.8 )
cmake_minimum_required( VERSION 2.8 )
project( VAMatlab )
list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
......@@ -9,11 +9,11 @@ if( NOT DEFINED ITA_VA_MATLAB_BUILD_WITH_INTERNAL_CORE )
endif( NOT DEFINED ITA_VA_MATLAB_BUILD_WITH_INTERNAL_CORE )
if( NOT DEFINED ITA_VAMATLAB_VERSION_MAJOR )
set( ITA_VAMATLAB_VERSION_MAJOR "v2019" CACHE STRING "VAMatlab version major (usually 'v' and year)" )
set( ITA_VAMATLAB_VERSION_MAJOR "v2020" CACHE STRING "VAMatlab version major (usually 'v' and year)" )
endif( NOT DEFINED ITA_VAMATLAB_VERSION_MAJOR )
if( NOT DEFINED ITA_VAMATLAB_VERSION_MINOR )
set( ITA_VAMATLAB_VERSION_MINOR "a" CACHE STRING "VAMatlab version minor (usually a,b,c ...)" )
set( ITA_VAMATLAB_VERSION_MINOR "b" CACHE STRING "VAMatlab version minor (usually a,b,c ...)" )
endif( NOT DEFINED ITA_VAMATLAB_VERSION_MINOR )
if( NOT DEFINED ITA_VAMATLAB_SHOW_BANNER )
......
Copyright 2015-2018 Institute of Technical Acoustics (ITA), RWTH Aachen University
Copyright 2015-2020 Institute of Technical Acoustics (ITA), RWTH Aachen University
Licensed under the Apache License, Version 2.0 (the "License");
you may not use files of this project except in compliance with the License.
......
......@@ -5,7 +5,7 @@ VAMatlab is a binding to the VA interface for Matlab. It uses the VA network con
### License
Copyright 2015-2018 Institute of Technical Acoustics (ITA), RWTH Aachen University
Copyright 2015-2020 Institute of Technical Acoustics (ITA), RWTH Aachen University
Licensed under the Apache License, Version 2.0 (the "License");
you may not use files of this project except in compliance with the License.
......
......@@ -5,20 +5,25 @@
% to hard drive.
cont = struct();
conf.free_field_only = false; % No occlusion, no reflections
conf.direct_field_component = true;
conf.diffracted_field_component = true;
conf.reflected_field_component = false; % Causes heavy phasing due to comb filter effects
conf.free_field_only = false; % No occlusion, no reflections, will override field component setup
conf.direct_field_component = true; % If true, direct sound field component is included
conf.diffracted_field_component = true; % If true, direct sound field component is included
conf.reflected_field_component = true; % Causes heavy phasing due to comb filter effects
conf.update_gain_individually = true;
conf.with_delay_update = true;
conf.update_gain_individually = true; % If true, updates gain in DSP components, otherwise gain is applied to filter coefficients
conf.with_delay_update = true; % If true, updates the delay in VDL DSP component, otherwise propagation delay is ignored
receiver_pos = [ 3 0 3 ]; % OpenGL coordinates
buffer_length = 128;
sampling_rate = 44100;
f = ita_ANSI_center_frequencies;
receiver_pos = [ 3 0 3 ]; % OpenGL coordinates in meter
source_pos_range = [ [ -20 0 -3 ]; [ 20 0 -3 ] ]; % OpenGL coordinates in meter
source_velocity = 30 / 3.6; % m/s
% House corner
w = itaInfiniteWedge( [ 1 0 0 ], [ 0 0 -1 ], [ 0 0 0 ] ); % OpenGL coordinates
%% Connect and set up simple scene
va = VA;
......@@ -34,7 +39,8 @@ try
va.add_search_path( 'D:/Users/stienen/dev/VA/VACore/data' );
va.add_search_path( 'C:/ITASoftware/Raven/RavenDatabase/SoundDatabase' );
va.add_search_path( 'C:\Users\jonas\sciebo\ITA\Lehre\Masterarbeiten\2019 Henry Andrew\car_pass-by_corner' );
va.add_search_path( 'D:\Users\stienen\Sciebo\Thesis stuff\auralization\resources' );
c = va.get_homogeneous_medium_sound_speed();
L = va.create_sound_receiver( 'VA_Listener' );
......@@ -48,6 +54,9 @@ try
%X = va.create_signal_source_buffer_from_file( 'WelcomeToVA.wav' );
X = va.create_signal_source_buffer_from_file( 'LKW Leerlauf 2.wav' );
%X = va.create_signal_source_buffer_from_file( 'complex_tonal.wav' );
%X = va.create_signal_source_buffer_from_file( 'complex_tonal_and_noise.wav' );
%X = va.create_signal_source_buffer_from_file( 'pinknoise.wav' );
%X = va.create_signal_source_buffer_from_file( 'Full song - Vulfpeck - Dean Town.wav' );
va.set_signal_source_buffer_playback_action( X, 'play' )
va.set_signal_source_buffer_looping( X, true );
......@@ -65,21 +74,29 @@ end
k = 2 * pi * f ./ c;
%% Example for a synchronized scene update & audio processing simulation/auralization
timestep = 128 / 44100; % here: depends on block size and sample rate
%% Synchronized scene update & audio processing simulation/auralization
timestep = buffer_length / sampling_rate; % here: depends on block size and sample rate
disp( [ 'Resulting time step resolution: ' num2str( timestep ) 's' ] )
traj_distance = norm( source_pos_range( 1, : ) - source_pos_range( 2, : ) );
traj_duration = traj_distance / source_velocity;
numsteps = ceil( traj_duration / timestep );
fprintf( 'Simulation trajectory distance: %.1fs\n', traj_distance )
fprintf( 'Simulation result duration: %.1fs\n', traj_duration )
fprintf( 'Simulation frames total: %i\n', numsteps )
manual_clock = 0;
if ~dry_run
va.set_core_clock( 0 );
end
spatialstep = 0.1 / 2;
disp( [ 'Resulting sound source speed: ' num2str( spatialstep / timestep ) ' m/s' ] )
numsteps = 3400 * 2;
disp( [ 'Simulation result duration: ' num2str( numsteps * timestep ) ' s' ] )
x = linspace( -1, 1, numsteps ) * 20; % motion from x = -20m to x = 20m
source_pos_traj = zeros( numsteps, 3 );
source_pos_traj( :, 1 ) = linspace( source_pos_range( 1, 1 ), source_pos_range( 2, 1 ), numsteps );
source_pos_traj( :, 2 ) = linspace( source_pos_range( 1, 2 ), source_pos_range( 2, 2 ), numsteps );
source_pos_traj( :, 3 ) = linspace( source_pos_range( 1, 3 ), source_pos_range( 2, 3 ), numsteps );
H_direct_log = []; % Direct field component
H_diffracted_log = []; % Diffracted field component
......@@ -89,9 +106,9 @@ IL_log = []; % Insertion loss (total field relative to direct field under free-f
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 )
for n = 1:numsteps
source_pos = [ x( n ) 0 -3 ]; % OpenGL coordinates
source_pos = source_pos_traj( n, : ); % OpenGL coordinates
if ~dry_run
va.set_sound_source_position( S, source_pos );
end
......@@ -130,7 +147,8 @@ for n = 1:length( x )
prop_path_direct.frequency_magnitudes = abs( H_direct );
end
if ~conf.with_delay_update || n == 1
% Set delay (once if disabled)
if conf.with_delay_update || n == 1
prop_path_direct.delay = distance / c; %delay from sound emitting from source to being received at listener
end
......@@ -150,11 +168,7 @@ for n = 1:length( x )
prop_path_diffracted.position = apex;
prop_path_diffracted.frequencies = f;
prop_path_diffracted.audible = true;
if ~conf.with_delay_update || n == 1
prop_path_diffracted.delay = distance / c;
end
if conf.update_gain_individually
prop_path_diffracted.gain = ( -1 ) * A / rho; % Invert phase
prop_path_diffracted.frequency_magnitudes = abs( D );
......@@ -163,6 +177,14 @@ for n = 1:length( x )
prop_path_diffracted.frequency_magnitudes = abs( H_diffracted );
end
if ~conf.with_delay_update
if n == 1
prop_path_diffracted.delay = distance / c; % Set all-same distance once if disabled
end
else
prop_path_diffracted.delay = detour / c;
end
%% Reflected sound path
......@@ -198,14 +220,16 @@ for n = 1:length( x )
prop_path_reflected.gain = 1;
prop_path_reflected.frequency_magnitudes = abs( H_reflected );
end
if ~conf.with_delay_update
if n == 1
prop_path_reflected.delay = distance / c; % For all-same delay
prop_path_reflected.delay = distance / c; % For all-same delay, set once only if disabled
end
else
prop_path_reflected.delay = distance_image / c;
end
%% Update wave fronts in renderer
paths_update = struct();
if conf.free_field_only || conf.direct_field_component
......@@ -260,13 +284,11 @@ 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
disp( 'Stop VA to export simulation results from rendering module(s)' )
else
figure
plot( db( H_total_field_log ) )
plot( db( H_total_field_log ) ) % @todo make nicer plot
end
%% VA signal source jet engine example
% Preparations
va = VA;
va.connect
va.reset
va.set_output_gain( .25 )
L = va.create_sound_receiver( 'listener' );
va.set_sound_receiver_position( L, [ 0 1.7 0 ] );
H = va.create_directivity_from_file( '$(DefaultHRIR)' );
va.set_sound_receiver_directivity( L, H );
% Jet engine signal
sspt_jet_engine_conf.class = 'jet_engine';
JE = va.create_signal_source_prototype_from_parameters( sspt_jet_engine_conf );
% Far-away jet engine sound source with 120 dB SWL re 12pW
S = va.create_sound_source( 'jet engine' );
va.set_sound_source_position( S, [ 0 1.7 -300 ] );
va.set_sound_source_sound_power( S, 10^(130/10) * 1e-12 );
va.set_sound_source_signal_source( S, JE );
%% GUI
va.set_signal_source_parameters( JE, struct( 'rpm', 1500 ) )
pause( 2 )
va.set_signal_source_parameters( JE, struct( 'rpm', 1600 ) )
pause( 0.2 )
va.set_signal_source_parameters( JE, struct( 'rpm', 1700 ) )
pause( 0.2 )
va.set_signal_source_parameters( JE, struct( 'rpm', 1800 ) )
pause( 0.4 )
va.set_signal_source_parameters( JE, struct( 'rpm', 2100 ) )
pause( 1.4 )
va.set_signal_source_parameters( JE, struct( 'rpm', 3800 ) )
pause( 4 )
va.set_signal_source_parameters( JE, struct( 'rpm', 5000 ) )
......@@ -258,7 +258,6 @@ if ~isempty( current_natnet_dir )
end
function [ found, va_component_dir ] = find_VA_Component( va_search_dir, component, recursive )
found = false;
va_component_dir = '';
......
......@@ -4,7 +4,7 @@
* VVV VVV A Virtual Acoustics (VA) | http://www.virtualacoustics.org
* VVV VVV AAA Licensed under the Apache License, Version 2.0
* VVV VVV AAA
* VVV VVV AAA Copyright 2015-2019
* VVV VVV AAA Copyright 2015-2020
* VVVVVV AAA Institute of Technical Acoustics (ITA)
* VVVV AAA RWTH Aachen University
*
......
......@@ -4,7 +4,7 @@
* VVV VVV A Virtual Acoustics (VA) | http://www.virtualacoustics.org
* VVV VVV AAA Licensed under the Apache License, Version 2.0
* VVV VVV AAA
* VVV VVV AAA Copyright 2015-2019
* VVV VVV AAA Copyright 2015-2020
* VVVVVV AAA Institute of Technical Acoustics (ITA)
* VVVV AAA RWTH Aachen University
*
......
......@@ -4,7 +4,7 @@
* VVV VVV A Virtual Acoustics (VA) | http://www.virtualacoustics.org
* VVV VVV AAA Licensed under the Apache License, Version 2.0
* VVV VVV AAA
* VVV VVV AAA Copyright 2015-2019
* VVV VVV AAA Copyright 2015-2020
* VVVVVV AAA Institute of Technical Acoustics (ITA)
* VVVV AAA RWTH Aachen University
*
......@@ -160,7 +160,7 @@ void banner()
mexPrintf( " * VVV VVV A Virtual Acoustics (VA) | http://www.virtualacoustics.org\n" );
mexPrintf( " * VVV VVV AAA Licensed under the Apache License, Version 2.0\n" );
mexPrintf( " * VVV VVV AAA\n" );
mexPrintf( " * VVV VVV AAA Copyright 2015-2019\n" );
mexPrintf( " * VVV VVV AAA Copyright 2015-2020\n" );
mexPrintf( " * VVVVVV AAA Institute of Technical Acoustics (ITA)\n" );
mexPrintf( " * VVVV AAA RWTH Aachen University\n" );
mexPrintf( " *\n" );
......@@ -1071,6 +1071,24 @@ void get_directivity_infos( int nlhs, mxArray *plhs[], int nrhs, const mxArray *
plhs[ 0 ] = pCell;
}
REGISTER_PUBLIC_FUNCTION( create_scene, "Creates a scene from a file resource", "Note: this is a loose method with no clear definition. It may be interpreted differently among renderers." );
DECLARE_FUNCTION_REQUIRED_INARG( create_scene, params, "string", "Parameter struct" );
DECLARE_FUNCTION_OPTIONAL_INARG( create_scene, scene_name, "string", "Scene name", "''" );
DECLARE_FUNCTION_OUTARG( create_scene, scene_id, "string", "Scene identifier" );
void create_scene( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 3 );
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
CVAMatlabConnection* pConnection = g_vpConnections[ hHandle ];
CVAStruct oParams = matlabGetStruct( prhs[ 1 ], "params" );
std::string sName = matlabGetString( prhs[ 2 ], "name" );
std::string sID = pConnection->pCoreInterface->CreateScene( oParams, sName );
plhs[ 0 ] = mxCreateString( sID.c_str() );
}
REGISTER_PUBLIC_FUNCTION( create_signal_source_buffer_from_file, "Creates a signal source which plays an audiofile", "Note: The audiofile must be mono and its sampling rate must match that of the server." );
DECLARE_FUNCTION_REQUIRED_INARG( create_signal_source_buffer_from_file, filename, "string", "Filename" );
......@@ -1176,6 +1194,25 @@ void create_signal_source_network_stream( int nlhs, mxArray *plhs[], int nrhs, c
plhs[ 0 ] = mxCreateString( sID.c_str() );
}
REGISTER_PUBLIC_FUNCTION( create_signal_source_prototype_from_parameters, "Creates a prototype signal source, provide 'class' parameter!", "" );
DECLARE_FUNCTION_REQUIRED_INARG( create_signal_source_prototype_from_parameters, params, "struct", "Parameters" );
DECLARE_FUNCTION_OPTIONAL_INARG( create_signal_source_prototype_from_parameters, name, "string", "Displayed name", "''" );
DECLARE_FUNCTION_OUTARG( create_signal_source_prototype_from_parameters, signalSourceID, "string", "Signal source ID" );
void create_signal_source_prototype_from_parameters( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 3 );
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
CVAMatlabConnection* pConnection = g_vpConnections[ hHandle ];
CVAStruct oParams = matlabGetStruct( prhs[ 1 ], "params" );
std::string sName = matlabGetString( prhs[ 2 ], "name" );
std::string sID = pConnection->pCoreInterface->CreateSignalSourcePrototypeFromParameters( oParams, sName );
plhs[ 0 ] = mxCreateString( sID.c_str() );
}
// ------------------------------------------------------------
REGISTER_PUBLIC_FUNCTION( delete_signal_source, "Deletes a signal source", "A signal source can only be deleted, if it is not in use." );
......
......@@ -4,7 +4,7 @@
* VVV VVV A Virtual Acoustics (VA) | http://www.virtualacoustics.org
* VVV VVV AAA Licensed under the Apache License, Version 2.0
* VVV VVV AAA
* VVV VVV AAA Copyright 2015-2019
* VVV VVV AAA Copyright 2015-2020
* VVVVVV AAA Institute of Technical Acoustics (ITA)
* VVVV AAA RWTH Aachen University
*
......
......@@ -4,7 +4,7 @@
* VVV VVV A Virtual Acoustics (VA) | http://www.virtualacoustics.org
* VVV VVV AAA Licensed under the Apache License, Version 2.0
* VVV VVV AAA
* VVV VVV AAA Copyright 2015-2019
* VVV VVV AAA Copyright 2015-2020
* VVVVVV AAA Institute of Technical Acoustics (ITA)
* VVVV AAA RWTH Aachen University
*
......
......@@ -4,7 +4,7 @@
* VVV VVV A Virtual Acoustics (VA) | http://www.virtualacoustics.org
* VVV VVV AAA Licensed under the Apache License, Version 2.0
* VVV VVV AAA
* VVV VVV AAA Copyright 2015-2019
* VVV VVV AAA Copyright 2015-2020
* VVVVVV AAA Institute of Technical Acoustics (ITA)
* VVVV AAA RWTH Aachen University
*
......
......@@ -4,7 +4,7 @@
* VVV VVV A Virtual Acoustics (VA) | http://www.virtualacoustics.org
* VVV VVV AAA Licensed under the Apache License, Version 2.0
* VVV VVV AAA
* VVV VVV AAA Copyright 2015-2019
* VVV VVV AAA Copyright 2015-2020
* VVVVVV AAA Institute of Technical Acoustics (ITA)
* VVVV AAA RWTH Aachen University
*
......
......@@ -4,7 +4,7 @@
* VVV VVV A Virtual Acoustics (VA) | http://www.virtualacoustics.org
* VVV VVV AAA Licensed under the Apache License, Version 2.0
* VVV VVV AAA
* VVV VVV AAA Copyright 2015-2019
* VVV VVV AAA Copyright 2015-2020
* VVVVVV AAA Institute of Technical Acoustics (ITA)
* VVVV AAA RWTH Aachen University
*
......
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