Renaming all itaVA class references to VA

parent 6e0e572e
% This debug script is for debugging the VA-to-Matlab connection
% without the use of the facade class "itaVA"
% without the use of the facade class "VA"
% To use MSVS for debugging the MEX library, in VS select "Debugging >
% Append to process" ... then select the MATLAB.exe process and start to
% execute commands in Matlab that are calling functions of the MEX file
......@@ -40,7 +40,7 @@ disp( reproductions )
%% Tests
L = VAMatlabD( 'create_sound_receiver', conn, 'itaVA_Tracked_Listener', 'default', -1 );
L = VAMatlabD( 'create_sound_receiver', conn, 'VA_Tracked_Listener', 'default', -1 );
VAMatlabD( 'set_tracked_sound_receiver', conn,L )
%VAMatlabD( 'set_tracked_sound_source', conn,L )
......
% THIS FILE WILL BE OVERWRITTEN BY CMAKE WITHOUT WARNING
%
% Code generator for the VA Matlab interface facade class
%
% Desc: This script generates the code for the Matlab
% facade class to the VAInterface MEXExtension.
% It takes the class template code and inserts
% all stubs for the functions in the VAConnector
% interface. These are derived using the reflexion
% mechanism ('enumerate_functions')
%
va_base_dir = '..'; % VA folder with bin, lib, matlab, data etc.
va_script_dir = fullfile( va_base_dir, 'matlab' ); % Matlab scripts target directory
va_bin_dir = fullfile( va_base_dir, 'bin' );
va_lib_dir = fullfile( va_base_dir, 'lib' );
if exist( va_bin_dir, 'dir' ) ~= 7
error( 'Deploy dir ''%s'' does not exist. Please build and install VAMatlab first.', va_bin_dir )
end
if exist( va_script_dir, 'dir' ) ~= 7
mkdir( va_script_dir );
end
if exist( [ 'VAMatlab' '.' mexext ], 'file' )
warning( 'VAMatlab already found at location "%s", are you sure to build VA against this executable? Will proceed now.', which( 'VAMatlab' ) )
else
% Add to PATH temporarily and attempt to move lib to bin dir
addpath( va_script_dir, va_bin_dir )
[ s ] = movefile( fullfile( va_lib_dir, 'VAMatlab*' ), va_bin_dir );
if ~s && ~exist( [ 'VAMatlab' '.' mexext ], 'file' )
error( 'Could not locate VAMatlab executable. Please make sure that it can be found.' )
end
end
% Parameters
templateFile = 'VA.m.proto';
outputFile = fullfile( va_script_dir, 'VA.m' );
fprintf( 'Generating code for VA Matlab class ''%s'' ...\n', outputFile );
code = fileread( templateFile );
stubCode = VA_generate_stubs();
code = strrep( code, '###STUBCODE###', stubCode );
% Write the results
fid = fopen( outputFile, 'w' );
fprintf( fid, '%s', code );
fclose( fid );
fprintf( 'Matlab class ''%s'' successfully built\n', outputFile );
% Remove from MATLABPATH (otherwise naming conflicts may occur with
% ITA-Toolbox/applications/VirtualAcoustics/VA/* scripts)
rmpath( va_script_dir, va_bin_dir )
% THIS FILE WILL BE OVERWRITTEN BY CMAKE WITHOUT WARNING
%
% Code generator for the VA Matlab interface facade class
%
% Desc: This script generates the code for the Matlab
% facade class to the VAInterface MEXExtension.
% It takes the class template code and inserts
% all stubs for the functions in the VAConnector
% interface. These are derived using the reflexion
% mechanism ('enumerate_functions')
%
va_base_dir = 'D:/Users/stienen/dev/VA/dist/win32-x64.vc12'; % VA folder with bin, lib, matlab, data etc.
va_script_dir = fullfile( va_base_dir, 'matlab' ); % Matlab scripts target directory
va_bin_dir = fullfile( va_base_dir, 'bin' );
va_lib_dir = fullfile( va_base_dir, 'lib' );
if exist( va_bin_dir, 'dir' ) ~= 7
error( 'Deploy dir ''%s'' does not exist. Please build and install VAMatlab first.', va_bin_dir )
end
if exist( va_script_dir, 'dir' ) ~= 7
mkdir( va_script_dir );
end
if exist( [ 'VAMatlab' '.' mexext ], 'file' )
warning( 'VAMatlab already found at location "%s", are you sure to build VA against this executable? Will proceed now.', which( 'VAMatlab' ) )
else
% Add to PATH temporarily and attempt to move lib to bin dir
addpath( va_script_dir, va_bin_dir )
[ s ] = movefile( fullfile( va_lib_dir, 'VAMatlab*' ), va_bin_dir );
if ~s && ~exist( [ 'VAMatlab' '.' mexext ], 'file' )
error( 'Could not locate VAMatlab executable. Please make sure that it can be found.' )
end
end
% Parameters
templateFile = 'VA.m.proto';
outputFile = fullfile( va_script_dir, 'VA.m' );
fprintf( 'Generating code for VA Matlab class ''%s'' ...\n', outputFile );
code = fileread( templateFile );
stubCode = VA_generate_stubs();
code = strrep( code, '###STUBCODE###', stubCode );
% Write the results
fid = fopen( outputFile, 'w' );
fprintf( fid, '%s', code );
fclose( fid );
fprintf( 'Matlab class ''%s'' successfully built\n', outputFile );
% Remove from MATLABPATH (otherwise naming conflicts may occur with
% ITA-Toolbox/applications/VirtualAcoustics/VA/* scripts)
rmpath( va_script_dir, va_bin_dir )
%% itaVA offline simulation/auralization example
%% VA offline simulation/auralization example
% Requires VA to run with a virtual audio device that can be triggered by
% the user. Also the rendering module(s) have to be set to record the output
......@@ -9,14 +9,14 @@ sampling_rate = 44100;
%% Connect and set up simple scene
va = itaVA( 'localhost' );
va = VA( 'localhost' );
L = va.create_sound_receiver( 'itaVA_Listener' );
L = va.create_sound_receiver( 'VA_Listener' );
va.set_sound_receiver_position( L, [ 0 1.7 0 ] )
H = va.create_directivity( '$(DefaultHRIR)' );
va.set_sound_receiver_directivity( L, H );
S = va.create_sound_source( 'itaVA_Source' );
S = va.create_sound_source( 'VA_Source' );
X = va.create_signal_source_buffer_from_file( '$(DemoSound)' );
va.set_signal_source_buffer_playback_action( X, 'play' )
va.set_signal_source_buffer_looping( X, true );
......
%% itaVA offline simulation/auralization example that uses impulse responses
%% VA offline simulation/auralization example that uses impulse responses
% Requires VA to run with a virtual audio device that can be triggered by
% the user. Also the generic path prototype rendering module(s) has to record the output
......@@ -6,14 +6,14 @@
%% Connect and set up simple scene
va = itaVA( 'localhost' );
va = VA( 'localhost' );
L = va.create_sound_receiver( 'itaVA_Listener' );
L = va.create_sound_receiver( 'VA_Listener' );
va.set_sound_receiver_position( L, [ 0 1.7 0 ] )
H = va.create_directivity( '$(DefaultHRIR)' );
va.set_sound_receiver_directivity( L, H );
S = va.create_sound_source( 'itaVA_Source' );
S = va.create_sound_source( 'VA_Source' );
X = va.create_signal_source_buffer_from_file( '$(DemoSound)' );
va.set_signal_source_buffer_playback_action( X, 'play' )
va.set_signal_source_buffer_looping( X, true );
......
%% VA simple example code
% Create VA
va = VA;
% Connect to VA application (start the application first)
va.connect( 'localhost' )
% Reset VA to clear the scene
va.reset()
% Control output gain
va.set_output_gain( .25 )
% Add the current absolute folder path to VA application
va.add_search_path( pwd );
% Create a signal source and start playback
X = va.create_signal_source_buffer_from_file( '$(DemoSound)' );
va.set_signal_source_buffer_playback_action( X, 'play' )
va.set_signal_source_buffer_looping( X, true );
% Create a virtual sound source and set a position
S = va.create_sound_source( 'VA_Source' );
va.set_sound_source_position( S, [ 2 1.7 2 ] )
% Create a listener with a HRTF and position him
L = va.create_sound_receiver( 'VA_Listener' );
va.set_sound_receiver_position( L, [ 0 1.7 0 ] )
H = va.create_directivity( '$(DefaultHRIR)' );
va.set_sound_receiver_directivity( L, H );
% Connect the signal source to the virtual sound source
va.set_sound_source_signal_source( S, X )
% More information
disp( 'Type ''doc VA'' for more information.' )
%% VA tracked listener example code
% This assumes you already have set up a virtual scene without listener
% Create VA and connect
va = VA( 'localhost' );
% Create a sound receiver
L = va.create_sound_receiver( 'VA_Tracked_Listener' );
% OptiTrack tracker conneection and sound receiver updates
va.set_tracked_sound_receiver( L ) % For virtual scene / rendering
va.set_tracked_real_world_sound_receiver( L ) % For CTC reproductions
va.connect_tracker
pause( 12 ) % Observe how you can move the virtual sound receiver
va.disconnect_tracker
% Remove listener again
va.delete_sound_receiver( L )
% Stub generator for the VA Matlab facade class
% Author: Frank Wefers (fwefers@akustik.rwth-aachen.de)
function [output] = generateStubs()
% Get interface describtion
d = VAMatlab('enumerate_functions');
code = '';
for i=1:length(d)
% Concatenate the input and output argument lists
inargs = '';
ninargs = length(d(i).inargs);
for j=1:ninargs
if (j>1) inargs = strcat(inargs, ', '); end
inargs = strcat(inargs, sprintf('%s', d(i).inargs(j).name));
end
outargs = '';
noutargs = length(d(i).outargs);
for j=1:noutargs
if (j>1) outargs = strcat(outargs, ', '); end
outargs = strcat(outargs, sprintf('%s', d(i).outargs(j).name));
end
if ninargs > 0
code = [code sprintf('\tfunction [%s] = %s(this, %s)\n', outargs, d(i).name, inargs)];
else
code = [code sprintf('\tfunction [%s] = %s(this)\n', outargs, d(i).name)];
end
code = [code sprintf('\t\t%% %s\n', d(i).desc)];
% Argument and return value documentation
code = [code sprintf('\t\t%%\n\t\t%% Parameters:\n\t\t%%\n')];
if (ninargs == 0)
code = [code sprintf('\t\t%% \tNone\n')];
else
for j=1:ninargs
if (d(i).inargs(j).optional)
code = [code sprintf('\t\t%% \t%s [%s] %s (optional, default: %s)\n', ...
d(i).inargs(j).name, ...
d(i).inargs(j).type, ...
d(i).inargs(j).desc, ...
d(i).inargs(j).default)];
else
code = [code sprintf('\t\t%% \t%s [%s] %s\n', ...
d(i).inargs(j).name, ...
d(i).inargs(j).type, ...
d(i).inargs(j).desc)];
end
end
end
code = [code sprintf('\t\t%%\n\t\t%% Return values:\n\t\t%%\n')];
if (noutargs == 0)
code = [code sprintf('\t\t%% \tNone\n')];
else
for j=1:noutargs
code = [code sprintf('\t\t%% \t%s [%s] %s\n', ...
d(i).outargs(j).name, ...
d(i).outargs(j).type, ...
d(i).outargs(j).desc)];
end
end
code = [code sprintf('\t\t%%\n\n')];
% Matlab code that checks that a connection is established
code = [code sprintf('\t\tif this.handle==0, error(''Not connected.''); end;\n\n')];
% Matlab code for default values in optional input parameters
for j=1:ninargs
if (d(i).inargs(j).optional)
code = [code sprintf('\t\tif ~exist(''%s'',''var''), %s = %s; end\n', ...
d(i).inargs(j).name, d(i).inargs(j).name, d(i).inargs(j).default)];
end
end
% Matlab code calling the MEX
if (noutargs > 0)
if (ninargs > 0)
code = [code sprintf('\t\t[%s] = VAMatlab(''%s'', this.handle, %s);\n', outargs, d(i).name, inargs)];
else
code = [code sprintf('\t\t[%s] = VAMatlab(''%s'', this.handle);\n', outargs, d(i).name)];
end
else
if (ninargs > 0)
code = [code sprintf('\t\tVAMatlab(''%s'', this.handle, %s);\n', d(i).name, inargs)];
else
code = [code sprintf('\t\tVAMatlab(''%s'', this.handle);\n', d(i).name)];
end
end
code = [code sprintf('\tend\n\n')];
end
output = code;
end
\ No newline at end of file
function varargout = VA_setup(varargin)
% VA_SETUP MATLAB code for VA_setup.fig
% VA_SETUP, by itself, creates a new VA_SETUP or raises the existing
% singleton*.
%
% H = VA_SETUP returns the handle to a new VA_SETUP or the handle to
% the existing singleton*.
%
% VA_SETUP('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in VA_SETUP.M with the given input arguments.
%
% VA_SETUP('Property','Value',...) creates a new VA_SETUP or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before VA_setup_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to VA_setup_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help VA_setup
% Last Modified by GUIDE v2.5 08-Feb-2017 15:42:50
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @VA_setup_OpeningFcn, ...
'gui_OutputFcn', @VA_setup_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before VA_setup is made visible.
function VA_setup_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to VA_setup (see VARARGIN)
% Choose default command line output for VA_setup
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% VAMatlab
current_va_mex_dir = which( 'VAMatlab' );
if ~isempty( current_va_mex_dir )
[ va_mex_path, ~, ~ ] = fileparts( current_va_mex_dir );
[ va_path, ~, ~ ] = fileparts( va_mex_path );
set( handles.va_search_dir, 'String', fullfile( va_path ) );
set( handles.edit_vamatlab_full_path, 'String', current_va_mex_dir )
try
v = VAMatlab( 'get_version' );
set( handles.edit_vamatlab_version, 'String', v )
catch
set( handles.edit_vamatlab_version, 'String', 'Failed to execute VAMatlab, probably a depending library is missing.' )
end
end
% VAServer
current_va_server_dir = which( 'VAServer.exe' );
if ~isempty( current_va_server_dir )
set( handles.edit_vaserver_full_path, 'String', current_va_server_dir )
[ ~, v ] = system( [ current_va_server_dir ' --version' ] );
vs = strsplit( v, '\n' );
for i = 1:numel( vs )
vss = vs{ 1, i };
if numel( vss ) > 6
if strcmpi( vss( 3:10 ), 'VAServer' )
server_version = vss( 15:end );
set( handles.edit_vaserver_version, 'String', strcat( server_version ) )
end
end
end
end
% NatNetML
current_natnet_dir = which( 'NatNetML.dll' );
if ~isempty( current_natnet_dir )
ainfo = NET.addAssembly( current_natnet_dir );
natnetversion_raw = NatNetML.NatNetClientML( 0 ).NatNetVersion();
vs = sprintf( 'NatNetML (OptiTrack) %d.%d', natnetversion_raw(1), natnetversion_raw(2) );
set( handles.edit_natnet_version, 'String', vs )
end
uiwait( handles.figure1 );
% --- Outputs from this function are returned to the command line.
function varargout = VA_setup_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
if ~isempty( handles )
varargout{1} = handles.output;
end
% --- Executes on button press in pushbutton_close.
function pushbutton_close_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_close (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close( gcf )
function edit_vamatlab_full_path_Callback(hObject, eventdata, handles)
% hObject handle to edit_vamatlab_full_path (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_vamatlab_full_path as text
% str2double(get(hObject,'String')) returns contents of edit_vamatlab_full_path as a double
% --- Executes during object creation, after setting all properties.
function edit_vamatlab_full_path_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_vamatlab_full_path (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_vaserver_full_path_Callback(hObject, eventdata, handles)
% hObject handle to edit_vaserver_full_path (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_vaserver_full_path as text
% str2double(get(hObject,'String')) returns contents of edit_vaserver_full_path as a double
% --- Executes during object creation, after setting all properties.
function edit_vaserver_full_path_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_vaserver_full_path (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes during object creation, after setting all properties.
function va_search_dir_CreateFcn(hObject, eventdata, handles)
% hObject handle to va_search_dir (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function checkbox_recursively_Callback(hObject, eventdata, handles)
function checkbox_permanently_Callback(hObject, eventdata, handles)
% --- Executes on button press in pushbutton_va_dir_browse.
function pushbutton_va_dir_browse_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_va_dir_browse (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
start_path = get( handles.va_search_dir, 'String' );
if exist( start_path, 'file' ) ~= 7
start_path = pwd;
end
va_search_dir = uigetdir( start_path );
if ~isempty( va_search_dir )
set( handles.va_search_dir, 'String', va_search_dir )
find_VA( va_search_dir, handles )
end
function find_VA( va_search_dir, handles )
recursive_flag = get( handles.checkbox_recursively, 'Value' );
permanent_flag = get( handles.checkbox_permanently, 'Value' );
set( handles.edit_vamatlab_full_path, 'String', 'Scanning ... ' )
set( handles.edit_vaserver_full_path, 'String', 'Scanning ... ' )
% VAMatlab
[ vamatlab_found, vamatlab_dir ] = find_VA_Component( va_search_dir, [ 'VAMatlab.' mexext ], recursive_flag );
if vamatlab_found
addpath( vamatlab_dir )
if permanent_flag
savepath
end
set( handles.edit_vamatlab_full_path, 'String', fullfile( vamatlab_dir, [ 'VAMatlab.' mexext ] ) )
v = VAMatlab( 'getVersion' );
set( handles.edit_vamatlab_version, 'String', v )
else
set( handles.edit_vamatlab_full_path, 'String', 'not found' )
end
% VAServer
[ vaserver_found, vaserver_dir ] = find_VA_Component( va_search_dir, 'VAServer.exe', recursive_flag );
if vaserver_found
addpath( vaserver_dir )
if permanent_flag
savepath
end
vaserver_path = fullfile( vaserver_dir, 'VAServer.exe' );
set( handles.edit_vaserver_full_path, 'String', vaserver_path )
[ ~, v ] = system( [ vaserver_path ' --version' ] );
vs = strsplit( v, '\n' );
for i = 1:numel( vs )
vss = vs{ 1, i };
if numel( vss ) > 6
if strcmpi( vss( 3:10 ), 'VAServer' )
server_version = vss( 15:end );
set( handles.edit_vaserver_version, 'String', strcat( server_version ) )
end
end
end
else
set( handles.edit_vaserver_full_path, 'String', 'not found' )
end
function [ found, va_component_dir ] = find_VA_Component( va_search_dir, component, recursive )
found = false;
va_component_dir = '';
if isempty( va_search_dir )
return % something went wrong
end
if ~va_search_dir
return;
end
if exist( fullfile( va_search_dir, component ), 'file' )
found = true;
va_component_dir = fullfile( va_search_dir ); % Base path is one folder up
end
if ~found && recursive
listing = dir( va_search_dir );
for idx = 1:length( listing )
current_file_name = listing( idx ).name;
if listing( idx ).isdir && current_file_name(1) ~= '.'
[ found, va_component_dir ] = find_VA_Component( fullfile( va_search_dir, current_file_name ), component, recursive );
if found
break % Find first
end
end
end
end
function va_search_dir_Callback(hObject, eventdata, handles)
% hObject handle to va_search_dir (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of va_search_dir as text
% str2double(get(hObject,'String')) returns contents of va_search_dir as a double
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton_close.
function pushbutton_close_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to pushbutton_close (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close( handles.gui )