Commit 360e6a23 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Merge branch 'develop'

# Conflicts:
#	matlab/itaVA_build.m.proto
parents 7915bb98 f8700241
%this debug script is for debugging the VA-to-Matlab connection
% This debug script is for debugging the VA-to-Matlab connection
% without the use of the facade class "itaVA"
% 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
cd 'D:\Users\stienen\VA\VAMatlab\Matlab'
addpath( '../../VABuild/Build/Debug_x64' )
addpath( '../../VistaCoreLibs/lib/x64' )
addpath( '../../3rdParty/NatNetSDK/lib/x64' )
%% Pathes to required libs & dlls (cumbersome, but necessary)
vam_path = 'D:\Users\stienen\dev\VA\VAMatlab';
build_dir = 'build_win32-x64.vc12';
vanet_dir = 'D:\Users\stienen\dev\VA';
vista_dir = 'D:\Users\stienen\dev\ViSTA';
natnet_libs = 'X:\VR\dev\ExternalLibs\NatNetSDK\NatNetSDK-2.7\lib\x64';
addpath( fullfile( vam_path, build_dir, 'lib' ) ) % VAMatlabD
addpath( fullfile( vanet_dir, build_dir, 'lib' ) ) % VABaseD, VANetD
addpath( fullfile( vista_dir, build_dir, 'lib' ) ) % VistaBaseD, VistaAspectsD, VistaInterProcCommD
addpath( fullfile( natnet_libs ) ) % NatNetSDK (OptiTrack)
copy_dlls = true;
if( copy_dlls ) % Be careful with this option
dest = fullfile( vam_path, build_dir, 'lib' );
copyfile( which( 'VABaseD.dll' ), dest )
copyfile( which( 'VANetD.dll' ), dest )
copyfile( which( 'VistaBaseD.dll' ), dest )
copyfile( which( 'VistaAspectsD.dll' ), dest )
copyfile( which( 'VistaInterProcCommD.dll' ), dest )
copyfile( which( 'NatNetLib.dll' ), dest )
warning( 'DLLs have been copied, make sure to use the corresponding versions during debugging.' )
end
%% Connection
conn = VAMatlabD( 'connect', 'localhost:12340' );
renderers = VAMatlabD( 'getRenderingModules', conn, false );
disp( renderers )
reproductions = VAMatlabD( 'getReproductionModules', conn, false );
disp( reproductions )
%% Tests
L = VAMatlabD( 'createListener', conn, 'itaVA_Tracked_Listener', 'default', -1 );
......
......@@ -116,12 +116,15 @@ ConnectionHandle GenerateConnectionHandle() {
}
// Get connection handle from Matlab arguments and validate it
ConnectionHandle GetConnectionHandle(const mxArray *pArray, bool bAllowNullHandle=false) {
ConnectionHandle GetConnectionHandle( const mxArray *pArray, bool bAllowNullHandle = false )
{
// Strict typing! Make sure that the parameter has a valid type (scalar + handle datatype)
if (matlabIsScalar(pArray) && (mxGetClassID(pArray) == CONNECTIONHANDLE_CLASS_ID)) {
if( matlabIsScalar( pArray ) && ( mxGetClassID( pArray ) == CONNECTIONHANDLE_CLASS_ID ) )
{
ConnectionHandle hHandle = *((ConnectionHandle*) mxGetData(pArray));
if ((hHandle >= 0) && (hHandle <= VAMATLAB_MAX_CONNECTIONS)) {
if (g_vpConnections[hHandle] || ((hHandle == 0) && bAllowNullHandle))
if( ( hHandle >= 0 ) && ( hHandle <= VAMATLAB_MAX_CONNECTIONS ) )
{
if( g_vpConnections[ hHandle ] || ( ( hHandle == 0 ) && bAllowNullHandle ) )
return hHandle;
}
}
......@@ -135,22 +138,25 @@ ConnectionHandle GetConnectionHandle(const mxArray *pArray, bool bAllowNullHandl
// USED FOR? Convenience baby! This saves some lines of code below ...
// NOTE: In this MEX we are always checking for the exact number of arguments
// Optional values are predefined in the Matlab facade class
void vCheckInputArguments(int nrhs, int iRequiredNumArgs) {
if (nrhs != iRequiredNumArgs) {
switch (iRequiredNumArgs) {
case 0: VA_EXCEPT1("This function does not take any arguments");
case 1: VA_EXCEPT1("This function takes exactly one argument");
case 2: VA_EXCEPT1("This function takes exactly two arguments");
case 3: VA_EXCEPT1("This function takes exactly three arguments");
case 4: VA_EXCEPT1("This function takes exactly four arguments");
case 5: VA_EXCEPT1("This function takes exactly five arguments");
case 6: VA_EXCEPT1("This function takes exactly six arguments");
void vCheckInputArguments( int nrhs, int iRequiredNumArgs )
{
if( nrhs != iRequiredNumArgs )
{
switch( iRequiredNumArgs )
{
case 0: VA_EXCEPT1("This VAMatlab function does not take any arguments");
case 1: VA_EXCEPT1("This VAMatlab function takes exactly one argument");
case 2: VA_EXCEPT1("This VAMatlab function takes exactly two arguments");
case 3: VA_EXCEPT1("This VAMatlab function takes exactly three arguments");
case 4: VA_EXCEPT1("This VAMatlab function takes exactly four arguments");
case 5: VA_EXCEPT1("This VAMatlab function takes exactly five arguments");
case 6: VA_EXCEPT1("This VAMatlab function takes exactly six arguments");
// Do we need more?
default:
{
char buf[64];
sprintf_s(buf, 64, "This function takes exactly %d arguments", iRequiredNumArgs);
VA_EXCEPT1(buf);
sprintf_s( buf, 64, "This VAMatlab function takes exactly %d arguments", iRequiredNumArgs );
VA_EXCEPT1( buf );
}
}
}
......@@ -3088,83 +3094,116 @@ void setCoreClock(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
* | | *
* +----------------------------------------------------------+ */
REGISTER_PUBLIC_FUNCTION( setReproductionModuleGain, "Sets the output gain of a reproduction module", "" );
DECLARE_FUNCTION_REQUIRED_INARG( setReproductionModuleGain, sModuleID, "string", "Module identifier" );
DECLARE_FUNCTION_REQUIRED_INARG( setReproductionModuleGain, dGain, "double-1x1", "gain (factor)" );
// Rendering
void setReproductionModuleGain( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
REGISTER_PUBLIC_FUNCTION( setRenderingModuleGain, "Sets the output gain of a reproduction module", "" );
DECLARE_FUNCTION_REQUIRED_INARG( setRenderingModuleGain, sModuleID, "string", "Module identifier" );
DECLARE_FUNCTION_REQUIRED_INARG( setRenderingModuleGain, dGain, "double-1x1", "gain (factor)" );
void setRenderingModuleGain( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 3 );
ConnectionHandle hHandle = GetConnectionHandle(prhs[0]);
CVAMatlabConnection* pConnection = g_vpConnections[hHandle];
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
CVAMatlabConnection* pConnection = g_vpConnections[ hHandle ];
std::string sID = matlabGetString( prhs[1], "sModuleID" );
double dGain = matlabGetRealScalar( prhs[2], "dGain" );
std::string sID = matlabGetString( prhs[ 1 ], "sModuleID" );
double dGain = matlabGetRealScalar( prhs[ 2 ], "dGain" );
pConnection->pCoreInterface->SetReproductionModuleGain( sID, dGain );
pConnection->pCoreInterface->SetRenderingModuleGain( sID, dGain );
}
REGISTER_PUBLIC_FUNCTION( setReproductionModuleMuted, "Mutes a reproduction module", "" );
DECLARE_FUNCTION_REQUIRED_INARG( setReproductionModuleMuted, sModuleID, "string", "Module identifier" );
DECLARE_FUNCTION_REQUIRED_INARG( setReproductionModuleMuted, bMuted, "logical-1x1", "Mute (true) or unmute (false)" );
REGISTER_PUBLIC_FUNCTION( setRenderingModuleMuted, "Mutes a reproduction module", "" );
DECLARE_FUNCTION_REQUIRED_INARG( setRenderingModuleMuted, sModuleID, "string", "Module identifier" );
DECLARE_FUNCTION_REQUIRED_INARG( setRenderingModuleMuted, bMuted, "logical-1x1", "Mute (true) or unmute (false)" );
void setReproductionModuleMuted( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
void setRenderingModuleMuted( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 3 );
ConnectionHandle hHandle = GetConnectionHandle(prhs[0]);
CVAMatlabConnection* pConnection = g_vpConnections[hHandle];
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
CVAMatlabConnection* pConnection = g_vpConnections[ hHandle ];
std::string sID = matlabGetString( prhs[1], "sModuleID" );
bool bMuted = matlabGetBoolScalar( prhs[2], "bMuted" );
std::string sID = matlabGetString( prhs[ 1 ], "sModuleID" );
bool bMuted = matlabGetBoolScalar( prhs[ 2 ], "bMuted" );
pConnection->pCoreInterface->SetReproductionModuleMuted( sID, bMuted );
pConnection->pCoreInterface->SetRenderingModuleMuted( sID, bMuted );
}
REGISTER_PUBLIC_FUNCTION( isReproductionModuleMuted, "Is reproduction module muted?", "" );
DECLARE_FUNCTION_REQUIRED_INARG( isReproductionModuleMuted, sModuleID, "string", "Module identifier" );
DECLARE_FUNCTION_OUTARG( isReproductionModuleMuted, bMuted, "logical-1x1", "true if muted, false if unmuted");
REGISTER_PUBLIC_FUNCTION( isRenderingModuleMuted, "Is reproduction module muted?", "" );
DECLARE_FUNCTION_REQUIRED_INARG( isRenderingModuleMuted, sModuleID, "string", "Module identifier" );
DECLARE_FUNCTION_OUTARG( isRenderingModuleMuted, bMuted, "logical-1x1", "true if muted, false if unmuted" );
void isReproductionModuleMuted( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
void isRenderingModuleMuted( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 2 );
ConnectionHandle hHandle = GetConnectionHandle(prhs[0]);
CVAMatlabConnection* pConnection = g_vpConnections[hHandle];
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
CVAMatlabConnection* pConnection = g_vpConnections[ hHandle ];
std::string sID = matlabGetString( prhs[1], "sModuleID" );
bool bMuted = pConnection->pCoreInterface->IsReproductionModuleMuted( sID );
std::string sID = matlabGetString( prhs[ 1 ], "sModuleID" );
bool bMuted = pConnection->pCoreInterface->IsRenderingModuleMuted( sID );
plhs[0] = mxCreateLogicalScalar( bMuted );
plhs[ 0 ] = mxCreateLogicalScalar( bMuted );
}
REGISTER_PUBLIC_FUNCTION( getReproductionModuleGain, "Returns the reproduction module output gain", "" );
DECLARE_FUNCTION_REQUIRED_INARG( getReproductionModuleGain, sModuleID, "string", "Module identifier" );
DECLARE_FUNCTION_OUTARG( getReproductionModuleGain, dGain, "double-1x1", "Gain (scalar)");
REGISTER_PUBLIC_FUNCTION( getRenderingModuleGain, "Get rendering module output gain", "" );
DECLARE_FUNCTION_REQUIRED_INARG( getRenderingModuleGain, sModuleID, "string", "Module identifier" );
DECLARE_FUNCTION_OUTARG( getRenderingModuleGain, dGain, "double-1x1", "Gain (scalar)" );
void getReproductionModuleGain( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
void getRenderingModuleGain( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 2 );
ConnectionHandle hHandle = GetConnectionHandle(prhs[0]);
CVAMatlabConnection* pConnection = g_vpConnections[hHandle];
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
CVAMatlabConnection* pConnection = g_vpConnections[ hHandle ];
std::string sID = matlabGetString( prhs[1], "sModuleID" );
double dGain = pConnection->pCoreInterface->GetReproductionModuleGain( sID );
std::string sID = matlabGetString( prhs[ 1 ], "sModuleID" );
double dGain = pConnection->pCoreInterface->GetRenderingModuleGain( sID );
plhs[0] = mxCreateDoubleScalar( dGain );
plhs[ 0 ] = mxCreateDoubleScalar( dGain );
}
// Rendering
REGISTER_PUBLIC_FUNCTION( getRenderingModules, "Get list of rendering modules", "" );
DECLARE_FUNCTION_OPTIONAL_INARG( getRenderingModules, bFilterEnabled, "boolean-1x1", "Filter activated (true)", "1" );
DECLARE_FUNCTION_OUTARG( getRenderingModules, renderers, "cell-array of struct-1x1", "Renderer infos (names, descriptions, etc.)" );
void getRenderingModules( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
bool bFilterEnabled = true;
if( nrhs > 1 )
bFilterEnabled = matlabGetBoolScalar( prhs[ 1 ], "bFilterEnabled" );
REGISTER_PUBLIC_FUNCTION( setRenderingModuleGain, "Sets the output gain of a reproduction module", "" );
DECLARE_FUNCTION_REQUIRED_INARG( setRenderingModuleGain, sModuleID, "string", "Module identifier" );
DECLARE_FUNCTION_REQUIRED_INARG( setRenderingModuleGain, dGain, "double-1x1", "gain (factor)" );
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
CVAMatlabConnection* pConnection = g_vpConnections[ hHandle ];
void setRenderingModuleGain( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
std::vector< CVAAudioRendererInfo > voRenderers;
pConnection->pCoreInterface->GetRenderingModules( voRenderers, bFilterEnabled );
const size_t nDims = int( voRenderers.size() );
const int nFields = 4;
const char* ppszFieldNames[] = { "id", "class", "enabled", "desc" };
plhs[ 0 ] = mxCreateStructArray( 1, &nDims, nFields, ppszFieldNames );
for( size_t i = 0; i < nDims; i++ )
{
size_t j = 0;
mxSetField( plhs[ 0 ], i, ppszFieldNames[ j++ ], mxCreateString( voRenderers[ i ].sID.c_str() ) );
mxSetField( plhs[ 0 ], i, ppszFieldNames[ j++ ], mxCreateString( voRenderers[ i ].sClass.c_str() ) );
mxSetField( plhs[ 0 ], i, ppszFieldNames[ j++ ], mxCreateLogicalScalar( voRenderers[ i ].bEnabled ) );
mxSetField( plhs[ 0 ], i, ppszFieldNames[ j++ ], mxCreateString( voRenderers[ i ].sDescription.c_str() ) );
}
}
// Reproduction
REGISTER_PUBLIC_FUNCTION( setReproductionModuleGain, "Sets the output gain of a reproduction module", "" );
DECLARE_FUNCTION_REQUIRED_INARG( setReproductionModuleGain, sModuleID, "string", "Module identifier" );
DECLARE_FUNCTION_REQUIRED_INARG( setReproductionModuleGain, dGain, "double-1x1", "gain (factor)" );
void setReproductionModuleGain( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 3 );
......@@ -3175,14 +3214,14 @@ void setRenderingModuleGain( int nlhs, mxArray *plhs[], int nrhs, const mxArray
std::string sID = matlabGetString( prhs[1], "sModuleID" );
double dGain = matlabGetRealScalar( prhs[2], "dGain" );
pConnection->pCoreInterface->SetRenderingModuleGain( sID, dGain );
pConnection->pCoreInterface->SetReproductionModuleGain( sID, dGain );
}
REGISTER_PUBLIC_FUNCTION( setRenderingModuleMuted, "Mutes a reproduction module", "" );
DECLARE_FUNCTION_REQUIRED_INARG( setRenderingModuleMuted, sModuleID, "string", "Module identifier" );
DECLARE_FUNCTION_REQUIRED_INARG( setRenderingModuleMuted, bMuted, "logical-1x1", "Mute (true) or unmute (false)" );
REGISTER_PUBLIC_FUNCTION( setReproductionModuleMuted, "Mutes a reproduction module", "" );
DECLARE_FUNCTION_REQUIRED_INARG( setReproductionModuleMuted, sModuleID, "string", "Module identifier" );
DECLARE_FUNCTION_REQUIRED_INARG( setReproductionModuleMuted, bMuted, "logical-1x1", "Mute (true) or unmute (false)" );
void setRenderingModuleMuted( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
void setReproductionModuleMuted( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 3 );
......@@ -3192,14 +3231,14 @@ void setRenderingModuleMuted( int nlhs, mxArray *plhs[], int nrhs, const mxArray
std::string sID = matlabGetString( prhs[1], "sModuleID" );
bool bMuted = matlabGetBoolScalar( prhs[2], "bMuted" );
pConnection->pCoreInterface->SetRenderingModuleMuted( sID, bMuted );
pConnection->pCoreInterface->SetReproductionModuleMuted( sID, bMuted );
}
REGISTER_PUBLIC_FUNCTION( isRenderingModuleMuted, "Is reproduction module muted?", "" );
DECLARE_FUNCTION_REQUIRED_INARG( isRenderingModuleMuted, sModuleID, "string", "Module identifier" );
DECLARE_FUNCTION_OUTARG( isRenderingModuleMuted, bMuted, "logical-1x1", "true if muted, false if unmuted");
REGISTER_PUBLIC_FUNCTION( isReproductionModuleMuted, "Is reproduction module muted?", "" );
DECLARE_FUNCTION_REQUIRED_INARG( isReproductionModuleMuted, sModuleID, "string", "Module identifier" );
DECLARE_FUNCTION_OUTARG( isReproductionModuleMuted, bMuted, "logical-1x1", "true if muted, false if unmuted");
void isRenderingModuleMuted( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
void isReproductionModuleMuted( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 2 );
......@@ -3207,16 +3246,16 @@ void isRenderingModuleMuted( int nlhs, mxArray *plhs[], int nrhs, const mxArray
CVAMatlabConnection* pConnection = g_vpConnections[hHandle];
std::string sID = matlabGetString( prhs[1], "sModuleID" );
bool bMuted = pConnection->pCoreInterface->IsRenderingModuleMuted( sID );
bool bMuted = pConnection->pCoreInterface->IsReproductionModuleMuted( sID );
plhs[0] = mxCreateLogicalScalar( bMuted );
}
REGISTER_PUBLIC_FUNCTION( getRenderingModuleGain, "Get rendering module output gain", "" );
DECLARE_FUNCTION_REQUIRED_INARG( getRenderingModuleGain, sModuleID, "string", "Module identifier" );
DECLARE_FUNCTION_OUTARG( getRenderingModuleGain, dGain, "double-1x1", "Gain (scalar)");
REGISTER_PUBLIC_FUNCTION( getReproductionModuleGain, "Returns the reproduction module output gain", "" );
DECLARE_FUNCTION_REQUIRED_INARG( getReproductionModuleGain, sModuleID, "string", "Module identifier" );
DECLARE_FUNCTION_OUTARG( getReproductionModuleGain, dGain, "double-1x1", "Gain (scalar)");
void getRenderingModuleGain( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
void getReproductionModuleGain( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 2 );
......@@ -3224,11 +3263,42 @@ void getRenderingModuleGain( int nlhs, mxArray *plhs[], int nrhs, const mxArray
CVAMatlabConnection* pConnection = g_vpConnections[hHandle];
std::string sID = matlabGetString( prhs[1], "sModuleID" );
double dGain = pConnection->pCoreInterface->GetRenderingModuleGain( sID );
double dGain = pConnection->pCoreInterface->GetReproductionModuleGain( sID );
plhs[0] = mxCreateDoubleScalar( dGain );
}
REGISTER_PUBLIC_FUNCTION( getReproductionModules, "Get list of rendering modules", "" );
DECLARE_FUNCTION_OPTIONAL_INARG( getReproductionModules, bFilterEnabled, "boolean-1x1", "Filter activated (true)", "1" );
DECLARE_FUNCTION_OUTARG( getReproductionModules, reproductionmodules, "cell-array of struct-1x1", "Reproduction module infos (names, descriptions, etc.)" );
void getReproductionModules( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
bool bFilterEnabled = true;
if( nrhs > 1 )
bFilterEnabled = matlabGetBoolScalar( prhs[ 1 ], "bFilterEnabled" );
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
CVAMatlabConnection* pConnection = g_vpConnections[ hHandle ];
std::vector< CVAAudioReproductionInfo > voReproductions;
pConnection->pCoreInterface->GetReproductionModules( voReproductions, bFilterEnabled );
const size_t nDims = int( voReproductions.size() );
const int nFields = 4;
const char* ppszFieldNames[] = { "id", "class", "enabled", "desc" };
plhs[ 0 ] = mxCreateStructArray( 1, &nDims, nFields, ppszFieldNames );
for( size_t i = 0; i < nDims; i++ )
{
size_t j = 0;
mxSetField( plhs[ 0 ], i, ppszFieldNames[ j++ ], mxCreateString( voReproductions[ i ].sID.c_str() ) );
mxSetField( plhs[ 0 ], i, ppszFieldNames[ j++ ], mxCreateString( voReproductions[ i ].sClass.c_str() ) );
mxSetField( plhs[ 0 ], i, ppszFieldNames[ j++ ], mxCreateLogicalScalar( voReproductions[ i ].bEnabled ) );
mxSetField( plhs[ 0 ], i, ppszFieldNames[ j++ ], mxCreateString( voReproductions[ i ].sDescription.c_str() ) );
}
}
/* +----------------------------------------------------------+ *
* | | *
* | Timer | *
......
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