Aufgrund einer Wartung wird GitLab am 28.09. zwischen 10:00 und 11:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 28.09. between 10:00 and 11:00 am.

Commit 0691ea42 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen

Merge branch 'develop' of https://git.rwth-aachen.de/ita/VAMatlab into develop

parents 91953d9c 09d6c2ce
......@@ -13,7 +13,7 @@ if( NOT DEFINED ITA_VAMATLAB_VERSION_MAJOR )
endif( NOT DEFINED ITA_VAMATLAB_VERSION_MAJOR )
if( NOT DEFINED ITA_VAMATLAB_VERSION_MINOR )
set( ITA_VAMATLAB_VERSION_MINOR "b" CACHE STRING "VAMatlab version minor (usually a,b,c ...)" )
set( ITA_VAMATLAB_VERSION_MINOR "c" CACHE STRING "VAMatlab version minor (usually a,b,c ...)" )
endif( NOT DEFINED ITA_VAMATLAB_VERSION_MINOR )
if( NOT DEFINED ITA_VAMATLAB_SHOW_BANNER )
......@@ -51,7 +51,7 @@ add_definitions( "-DVAMATLAB_VERSION_MINOR=\"${ITA_VAMATLAB_VERSION_MINOR}\"" )
if( ITA_VAMATLAB_SHOW_BANNER )
add_definitions( "-DVAMATLAB_SHOW_BANNER" )
endif( )
# Sources
set( VAMATLAB_SRC
......@@ -81,7 +81,14 @@ set_target_properties( VAMatlab PROPERTIES SUFFIX ".${MATLAB_MEX_EXTENSION}")
# VA matlab scripts file
set( VAMATLAB_DEPLOY_DIR "${CMAKE_INSTALL_PREFIX}/bin" )
set( VAMATLAB_SCRIPT_DIR "${CMAKE_INSTALL_PREFIX}/matlab" )
set( VAMATLAB_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" )
set( VAMATLAB_BASE_DIR "${CMAKE_INSTALL_PREFIX}" )
configure_file( "matlab/itaVA_build.m.proto" "${CMAKE_CURRENT_SOURCE_DIR}/matlab/itaVA_build_absolute.m" @ONLY )
set( VAMATLAB_BASE_DIR ".." ) # relative path from matlab folder
configure_file( "matlab/itaVA_build.m.proto" "${CMAKE_CURRENT_SOURCE_DIR}/matlab/itaVA_build.m" @ONLY )
# Install specialties
install( FILES "matlab/itaVA_build.m" DESTINATION "matlab" )
install( FILES "matlab/itaVA.m.proto" DESTINATION "matlab" )
install( FILES "matlab/itaVA_generateStubs.m" DESTINATION "matlab" )
install( FILES "matlab/itaVA_example_simple.m" DESTINATION "matlab" )
install( FILES "matlab/itaVA_example_tracked_listener.m" DESTINATION "matlab" )
Copyright 2015-2016 Institute of Technical Acoustics, RWTH Aachen University
Copyright 2015-2017 Institute of Technical Acoustics, 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,11 +5,28 @@ VAMatlab is a binding to the VA interface for Matlab. It uses the VA network con
### License
See [LICENSE](LICENSE.md) file.
Copyright 2015-2017 Institute of Technical Acoustics, 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.
You may obtain a copy of the License at
<http://www.apache.org/licenses/LICENSE-2.0>
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
### Quick build guide
#### Visual Studio
It is recommended to clone and follow the build guide of the parent project [VA](https://git.rwth-aachen.de/ita/VA), which includes this project as a submodule.
Generate VA with the Matlab binding flag activated. It will generate the Matlab executable. You will then have to generate the itaVA Matlab facade class, see below.
#### Matlab executable
......@@ -23,12 +40,15 @@ To also include a lightweight Optitrack tracker connection using the NatNetSDK,
#### itaVA class
To ease usage, a facade class called `itaVA` can be generated that will also add volatile help on the available functionality of VA.
To create this Matlab class, run `itaVA_build.m`, which will create a class file `itaVA.m` based on stubs that are filled by calls to the VAMatlab executable, which has to be build prior.
To create this Matlab class, run either `itaVA_build.m` after deploy of VA, or `itaVA_build_absolute.m` from the repository directory.
Both scripts will create a class file named `itaVA.m` based on stubs that are filled by calls to the VAMatlab executable, which has to be build prior.
> Make sure that Matlab will use the correct VA Matlab executable and not an older version of it which might have been added to the PATH of Matlab.
#### Deploy
If the deploy script is not used, manual deploy will include the following:
Deploying the Matlab executable will require to copy all necessary DLLs into a deploy directory (next to the VAMatlab executable file).
On Windows platform, provide the following files
- VistaAspects.dll
......
......@@ -10,33 +10,34 @@
% mechanism ('enumerateFunctions')
%
script_dir = '@VAMATLAB_SCRIPT_DIR@'; % Matlab scripts target directory
deploy_dir = '@VAMATLAB_DEPLOY_DIR@'; % Deploy directory, i.e. 'C:/dev/VA/dist/win32-x64.vc12'
lib_dir = '@VAMATLAB_LIB_DIR@';
va_base_dir = '@VAMATLAB_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( deploy_dir, 'dir' ) ~= 7
error( 'Deploy dir ''%s'' does not exist. Please build and install VAMatlab first.', deploy_dir )
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( script_dir, 'dir' ) ~= 7
mkdir( script_dir );
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 itaVA against this executable? Will proceed now.', which( 'VAMatlab' ) )
else
% Add to PATH temporarily and attempt to move lib to bin dir
addpath( script_dir, deploy_dir )
addpath( va_script_dir, va_bin_dir )
[ s ] = movefile( fullfile( lib_dir, 'VAMatlab*' ), deploy_dir );
[ s ] = movefile( fullfile( va_lib_dir, 'VAMatlab*' ), va_bin_dir );
if ~s && ~exist( [ 'VAMatlab' '.' mexext ], 'file' )
error( 'Could locate VAMatlab executable. Please make sure that it can be found.' )
error( 'Could not locate VAMatlab executable. Please make sure that it can be found.' )
end
end
% Parameters
templateFile = 'itaVA.m.proto';
outputFile = fullfile( script_dir, 'itaVA.m' );
outputFile = fullfile( va_script_dir, 'itaVA.m' );
fprintf( 'Generating code for itaVA Matlab class ''%s'' ...\n', outputFile );
code = fileread( templateFile );
......@@ -51,9 +52,7 @@ fclose( fid );
fprintf( 'Matlab class ''%s'' successfully built\n', outputFile );
% Install examples
copyfile( 'itaVA_example*', script_dir );
% Remove from MATLABPATH (otherwise naming conflicts may occur with
% ITA-Toolbox/applications/VirtualAcoustics/VA/* scripts)
rmpath( script_dir, deploy_dir )
rmpath( va_script_dir, va_bin_dir )
......@@ -216,7 +216,8 @@ void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
REGISTER_PRIVATE_FUNCTION( enumerateFunctions );
void enumerateFunctions( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) {
void enumerateFunctions( int nlhs, mxArray *plhs[], int nrhs, const mxArray** )
{
// Count public functions
mwSize nPublicFuncs = 0;
for( FunctionMapIterator it = g_mFunctionMap.begin(); it != g_mFunctionMap.end(); ++it )
......@@ -229,8 +230,10 @@ void enumerateFunctions( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prh
plhs[ 0 ] = pStruct;
mwIndex i = 0;
for( FunctionMapIterator it = g_mFunctionMap.begin(); it != g_mFunctionMap.end(); ++it ) {
if( !it->second.bPublic ) continue;
for( FunctionMapIterator it = g_mFunctionMap.begin(); it != g_mFunctionMap.end(); ++it )
{
if( !it->second.bPublic )
continue;
// Input arguments
mxSetField( pStruct, i, ppszFieldNames[ 0 ], mxCreateString( it->second.sName.c_str() ) );
......@@ -1209,8 +1212,8 @@ DECLARE_FUNCTION_REQUIRED_INARG( createAudiofileSignalSource, filename, "string"
DECLARE_FUNCTION_OPTIONAL_INARG( createAudiofileSignalSource, name, "string", "Displayed name", "''" );
DECLARE_FUNCTION_OUTARG( createAudiofileSignalSource, signalSourceID, "string", "Signal source ID" );
void createAudiofileSignalSource( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) {
void createAudiofileSignalSource( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 3 );
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
......@@ -1223,6 +1226,22 @@ void createAudiofileSignalSource( int nlhs, mxArray *plhs[], int nrhs, const mxA
plhs[ 0 ] = mxCreateString( sID.c_str() );
}
// ------------------------------------------------------------
REGISTER_PUBLIC_FUNCTION( createTextToSpeechSignalSource, "Creates a text to speech signal", "Note: depending on mode, either Speech WAV files are generated and then played back, or TTS sentence is directly played back." );
DECLARE_FUNCTION_OPTIONAL_INARG( createTextToSpeechSignalSource, name, "string", "Displayed name", "''" );
DECLARE_FUNCTION_OUTARG( createTextToSpeechSignalSource, signalSourceID, "string", "Signal source ID" );
void createTextToSpeechSignalSource( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 2 );
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
CVAMatlabConnection* pConnection = g_vpConnections[ hHandle ];
std::string sName = matlabGetString( prhs[ 1 ], "name" );
std::string sID = pConnection->pCoreInterface->CreateTextToSpeechSignalSource( sName );
plhs[ 0 ] = mxCreateString( sID.c_str() );
}
// ------------------------------------------------------------
REGISTER_PUBLIC_FUNCTION( createEngineSignalSource, "Creates an engine signal source", "" );
......@@ -1431,6 +1450,44 @@ void setAudiofileSignalSourcePlayPosition( int nlhs, mxArray *plhs[], int nrhs,
pConnection->pCoreInterface->SetAudiofileSignalSourcePlaybackPosition( sSignalSourceID, dPlaybackPosition );
}
// ------------------------------------------------------------
REGISTER_PUBLIC_FUNCTION( getSignalSourceParameters, "Returns the current signal source parameters", "" );
DECLARE_FUNCTION_REQUIRED_INARG( getSignalSourceParameters, ID, "string", "Signal source identifier" );
DECLARE_FUNCTION_REQUIRED_INARG( getSignalSourceParameters, args, "mstruct", "Requested parameters" );
DECLARE_FUNCTION_OUTARG( getSignalSourceParameters, params, "mstruct", "Parameters" );
void getSignalSourceParameters( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 3 );
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
CVAMatlabConnection* pConnection = g_vpConnections[ hHandle ];
std::string sID = matlabGetString( prhs[ 1 ], "ID" );
CVAStruct oArgs = matlabGetStruct( prhs[ 2 ], "args" );
CVAStruct oRet = pConnection->pCoreInterface->GetSignalSourceParameters( sID, oArgs );
plhs[ 0 ] = matlabCreateStruct( oRet );
}
// ------------------------------------------------------------
REGISTER_PUBLIC_FUNCTION( setSignalSourceParameters, "Sets signal source parameters", "" );
DECLARE_FUNCTION_REQUIRED_INARG( setSignalSourceParameters, ID, "string", "Signal source identifier" );
DECLARE_FUNCTION_REQUIRED_INARG( setSignalSourceParameters, params, "mstruct", "Parameters" );
void setSignalSourceParameters( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 3 );
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
CVAMatlabConnection* pConnection = g_vpConnections[ hHandle ];
std::string sID = matlabGetString( prhs[ 1 ], "ID" );
CVAStruct oParams = matlabGetStruct( prhs[ 2 ], "params" );
pConnection->pCoreInterface->SetSignalSourceParameters( sID, oParams );
}
// ------------------------------------------------------------
REGISTER_PUBLIC_FUNCTION( addSoundPlayback, "Adds a sound playback for a sequencer signal source", "" );
......
......@@ -52,7 +52,7 @@ void TrackerDataHandler( sFrameOfMocapData* sFrame, void* pUserData )
// Real-world listener
int iTrackedRealWorldListenerID = pVAMatlabTracker->iTrackedRealWorldListenerID;
int iTrackedRealWorldListenerRigidBodyIndex = pVAMatlabTracker->iTrackedListenerRigidBodyIndex;
int iTrackedRealWorldListenerRigidBodyIndex = pVAMatlabTracker->iTrackedRealWorldListenerRigidBodyIndex;
if( ( iTrackedRealWorldListenerID != -1 ) && ( iTrackedRealWorldListenerRigidBodyIndex <= sFrame->nRigidBodies ) && ( iTrackedRealWorldListenerRigidBodyIndex > 0 ) )
{
......
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