Merging new VA convenience class (now called VA instead of itaVA, but old...

Merging new VA convenience class (now called VA instead of itaVA, but old class name still works) and fixing a bug in VA_setup script where the API version was not properly requested from the library
parent 80fb5959
This diff is collapsed.
......@@ -7,7 +7,7 @@
% It takes the class template code and inserts
% all stubs for the functions in the VAConnector
% interface. These are derived using the reflexion
% mechanism ('enumerateFunctions')
% mechanism ('enumerate_functions')
%
va_base_dir = '..'; % VA folder with bin, lib, matlab, data etc.
......@@ -24,7 +24,7 @@ if exist( va_script_dir, 'dir' ) ~= 7
end
if exist( [ 'VAMatlab' '.' mexext ], 'file' )
warning( 'VAMatlab already found at location "%s", are you sure to build itaVA against this executable? Will proceed now.', which( 'VAMatlab' ) )
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 )
......@@ -36,12 +36,12 @@ else
end
% Parameters
templateFile = 'itaVA.m.proto';
outputFile = fullfile( va_script_dir, 'itaVA.m' );
templateFile = 'VA.m.proto';
outputFile = fullfile( va_script_dir, 'VA.m' );
fprintf( 'Generating code for itaVA Matlab class ''%s'' ...\n', outputFile );
fprintf( 'Generating code for VA Matlab class ''%s'' ...\n', outputFile );
code = fileread( templateFile );
stubCode = itaVA_generateStubs();
stubCode = VA_generate_stubs();
code = strrep( code, '###STUBCODE###', stubCode );
......
%% 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)' );
H = va.create_directivity_from_file( '$(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
% to hard drive.
buffer_size = 64;
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)' );
H = va.create_directivity_from_file( '$(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 );
......@@ -25,7 +22,7 @@ va.set_sound_source_signal_source( S, X )
%% Example for a synchronized scene update & audio processing simulation/auralization
timestep = buffer_size / sampling_rate; % here: depends on block size and sample rate
timestep = 128 / 44100; % here: depends on block size and sample rate
manual_clock = 0;
va.set_core_clock( 0 );
......
%% itaVA simple example code
%% VA simple example code
% Create itaVA
va = itaVA;
% Create VA
va = VA;
% Connect to VA application (start the application first)
va.connect( 'localhost' )
......@@ -21,18 +21,18 @@ 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( 'itaVA_Source' );
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( 'itaVA_Listener' );
L = va.create_sound_receiver( 'VA_Listener' );
va.set_sound_receiver_position( L, [ 0 1.7 0 ] )
H = va.create_directivity( '$(DefaultHRIR)' );
H = va.create_directivity_from_file( '$(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 itaVA'' for more information.' )
disp( 'Type ''doc VA'' for more information.' )
%% itaVA tracked listener example code
%% VA tracked listener example code
% This assumes you already have set up a virtual scene without listener
% Create itaVA and connect
va = itaVA( 'localhost' );
% Create VA and connect
va = VA( 'localhost' );
% Create a sound receiver
L = va.create_sound_receiver( 'itaVA_Tracked_Listener' );
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
......
% Stub generator for the VA Matlab facade class
% Author: Frank Wefers (fwefers@akustik.rwth-aachen.de)
function [output] = VA_generate_stubs()
% 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 = itaVA_setup(varargin)
% ITAVA_SETUP MATLAB code for itaVA_setup.fig
% ITAVA_SETUP, by itself, creates a new ITAVA_SETUP or raises the existing
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 = ITAVA_SETUP returns the handle to a new ITAVA_SETUP or the handle to
% H = VA_SETUP returns the handle to a new VA_SETUP or the handle to
% the existing singleton*.
%
% ITAVA_SETUP('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in ITAVA_SETUP.M with the given input arguments.
% VA_SETUP('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in VA_SETUP.M with the given input arguments.
%
% ITAVA_SETUP('Property','Value',...) creates a new ITAVA_SETUP or raises the
% 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 itaVA_setup_OpeningFcn gets called. An
% 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 itaVA_setup_OpeningFcn via varargin.
% 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 itaVA_setup
% Edit the above text to modify the response to help VA_setup
% Last Modified by GUIDE v2.5 08-Feb-2017 15:42:50
% Last Modified by GUIDE v2.5 05-Dec-2018 16:00:56
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @itaVA_setup_OpeningFcn, ...
'gui_OutputFcn', @itaVA_setup_OutputFcn, ...
'gui_OpeningFcn', @VA_setup_OpeningFcn, ...
'gui_OutputFcn', @VA_setup_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
......@@ -44,15 +44,15 @@ end
% End initialization code - DO NOT EDIT
% --- Executes just before itaVA_setup is made visible.
function itaVA_setup_OpeningFcn(hObject, eventdata, handles, varargin)
% --- 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 itaVA_setup (see VARARGIN)
% varargin command line arguments to VA_setup (see VARARGIN)
% Choose default command line output for itaVA_setup
% Choose default command line output for VA_setup
handles.output = hObject;
% Update handles structure
......@@ -67,7 +67,7 @@ if ~isempty( current_va_mex_dir )
set( handles.edit_vamatlab_full_path, 'String', current_va_mex_dir )
try
v = VAMatlab( 'getVersion' );
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.' )
......@@ -104,7 +104,7 @@ uiwait( handles.figure1 );
% --- Outputs from this function are returned to the command line.
function varargout = itaVA_setup_OutputFcn(hObject, eventdata, handles)
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
......@@ -218,7 +218,7 @@ if vamatlab_found
savepath
end
set( handles.edit_vamatlab_full_path, 'String', fullfile( vamatlab_dir, [ 'VAMatlab.' mexext ] ) )
v = VAMatlab( 'getVersion' );
v = VAMatlab( 'get_version' );
set( handles.edit_vamatlab_version, 'String', v )
else
set( handles.edit_vamatlab_full_path, 'String', 'not found' )
......
This diff is collapsed.
......@@ -55,7 +55,7 @@ function itaVA_NCTC_gui_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for itaVA_NCTC_gui
handles.output = hObject;
handles.va = itaVA;
handles.va = VA;
handles.repros = [];
handles.current_repro_params = struct();
......
%% itaVA simple example code for a text-to-speech sound source
% @todo apply new VA method naming conventions (all small caps with
% underscores between words)
% Quick setup
itaVAq
va.reset();
......
%% itaVA tracked head-above-torso listener example code
% Create itaVA and connect
va = itaVA( 'localhost' );
va = VA( 'localhost' );
va.reset()
va.set_output_gain( .25 )
......@@ -17,7 +17,7 @@ va.set_sound_source_signal_source( S, X );
% Create a sound receiver with HATO (actually OTAH) HRTF
L = va.create_sound_receiver( 'itaVA_Tracked_HATO_Listener' );
H = va.create_directivity( 'FABIAN_OTAH_5x5x5_256_44100Hz.v17.ir.daff' );
H = va.create_directivity_from_file( 'FABIAN_OTAH_5x5x5_256_44100Hz.v17.ir.daff' );
va.set_sound_receiver_directivity( L, H );
......
......@@ -2,6 +2,8 @@
itaVA_experimental_start_server
itaVA_experimental_renderer_prepare
% @todo apply new VA method naming conventions (all small caps with
% underscores between words)
%% Direct signal out without room (variables L and S prepared by itaVA_experimental_renderer_prepare)
dirac = ita_amplify( ita_generate_impulse, '-12dB' );
......
if ~exist( 'VAServer.exe', 'file' )
itaVA_setup
end
[ basepath, basename, ext ]= fileparts( which( 'VAServer.exe') );
[ va_basepath, ~, ~ ]= fileparts( basepath );
conf_path = fullfile( va_basepath, 'conf', 'VACore.experimental.ini' );
va_args = [ 'localhost:12340 ' conf_path ];
os_call = [ which( 'VAServer.exe') ' ' va_args ' &' ];
return_to_dir = pwd;
cd( va_basepath );
[ status, cmdout ] = system( os_call );
cd( return_to_dir );
if ~exist( 'VAServer.exe', 'file' )
VA_setup
end
[ basepath, basename, ext ]= fileparts( which( 'VAServer.exe') );
[ va_basepath, ~, ~ ]= fileparts( basepath );
conf_path = fullfile( va_basepath, 'conf', 'VACore.experimental.ini' );
va_args = [ 'localhost:12340 ' conf_path ];
os_call = [ which( 'VAServer.exe') ' ' va_args ' &' ];
return_to_dir = pwd;
cd( va_basepath );
[ status, cmdout ] = system( os_call );
cd( return_to_dir );
%% Short tutorial for itaVA, a Matlab interface for Virtual Acoustics (VA)
%% Short tutorial for VA, a Matlab interface for Virtual Acoustics (VA)
% The tutorial covers basic operations for setting up a simple virtual scene
% (1 receiver, 1 static / 1 moving virtual sound source), and explains how to
% set up a synchronized playback of multiple virtual sound sources.
......@@ -12,7 +12,7 @@
% which can be downloaded here: http://www.virtualacoustics.org/ (section Download)
% For a more detailed introduction, the reader is referred to http://www.virtualacoustics.org/start.html
%
% Explore itaVA by typing "doc itaVA" in Matlab's command window.
% Explore VA by typing "doc VA" in Matlab's command window.
%
% Author: Florian Pausch, fpa@akustik.rwth-aachen.de
% Version: 2018-03-27 (compatible with VA.v2018a_preview.win32-x64.vc12 (and probably higher))
......@@ -49,8 +49,8 @@ else
end
%% Step 2: Create itaVA object and connect to VAServer
a = itaVA;
%% Step 2: Create VA object and connect to VAServer
a = VA;
% Connect to VAServer (must be running and listening to default port on localhost)
if ~a.get_connected % only connect if no connection to server is established
......@@ -268,7 +268,7 @@ if useTracker
a.disconnect_tracker
end
% disconnect itaVA object from server
% disconnect VA object from server
a.disconnect()
%% itaVA quick connect
va = itaVA( 'localhost' );
va = VA( 'localhost' );
%% Also add current dir to VA search path
va.add_search_path( pwd );
\ 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