Implementing all sound source API calls (untested)

parent 9d35155d
......@@ -53,30 +53,31 @@ static struct PyMethodDef va_methods[] =
{ "lock_scene", ( PyCFunction ) va_lock_scene, METH_FASTCALL, va_no_doc },
{ "unlock_scene", ( PyCFunction ) va_unlock_scene, METH_FASTCALL, va_no_doc },
{ "get_sound_source_ids", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "create_sound_source", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "create_sound_source_explicit_renderer", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "delete_sound_source", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "set_sound_source_enabled", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "get_sound_source_enabled", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "get_sound_source_name", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "set_sound_source_enabled", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "get_sound_source_signal_source", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "set_sound_source_signal_source", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "remove_sound_source_signal_source", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "get_sound_source_auralization_mode", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "set_sound_source_auralization_mode", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "set_sound_source_parameters", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "get_sound_source_parameters", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "get_sound_source_directivity", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "set_sound_source_directivity", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "get_sound_source_volume", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "set_sound_source_volume", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "is_sound_source_muted", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "get_sound_source_position", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "set_sound_source_position", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "get_sound_source_orientation_vu", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "set_sound_source_orientation_vu", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "get_sound_source_ids", ( PyCFunction ) va_get_sound_source_ids, METH_FASTCALL, va_no_doc },
{ "create_sound_source", ( PyCFunction ) va_create_sound_source, METH_FASTCALL, va_no_doc },
{ "create_sound_source_explicit_renderer", ( PyCFunction ) va_create_sound_source_explicit_renderer, METH_FASTCALL, va_no_doc },
{ "delete_sound_source", ( PyCFunction ) va_delete_sound_source, METH_FASTCALL, va_no_doc },
{ "set_sound_source_enabled", ( PyCFunction ) va_set_sound_source_enabled, METH_FASTCALL, va_no_doc },
{ "get_sound_source_enabled", ( PyCFunction ) va_get_sound_source_enabled, METH_FASTCALL, va_no_doc },
{ "get_sound_source_name", ( PyCFunction ) va_get_sound_source_name, METH_FASTCALL, va_no_doc },
{ "set_sound_source_enabled", ( PyCFunction ) va_set_sound_source_enabled, METH_FASTCALL, va_no_doc },
{ "get_sound_source_signal_source", ( PyCFunction ) va_get_sound_source_signal_source, METH_FASTCALL, va_no_doc },
{ "set_sound_source_signal_source", ( PyCFunction ) va_set_sound_source_signal_source, METH_FASTCALL, va_no_doc },
{ "remove_sound_source_signal_source", ( PyCFunction ) va_remove_sound_source_signal_source, METH_FASTCALL, va_no_doc },
{ "get_sound_source_auralization_mode", ( PyCFunction ) va_get_sound_source_auralization_mode, METH_FASTCALL, va_no_doc },
{ "set_sound_source_auralization_mode", ( PyCFunction ) va_set_sound_source_auralization_mode, METH_FASTCALL, va_no_doc },
{ "set_sound_source_parameters", ( PyCFunction ) va_set_sound_source_parameters, METH_FASTCALL, va_no_doc },
{ "get_sound_source_parameters", ( PyCFunction ) va_get_sound_source_parameters, METH_FASTCALL, va_no_doc },
{ "get_sound_source_directivity", ( PyCFunction ) va_get_sound_source_directivity, METH_FASTCALL, va_no_doc },
{ "set_sound_source_directivity", ( PyCFunction ) va_set_sound_source_directivity, METH_FASTCALL, va_no_doc },
{ "get_sound_source_volume", ( PyCFunction ) va_get_sound_source_volume, METH_FASTCALL, va_no_doc },
{ "set_sound_source_volume", ( PyCFunction ) va_set_sound_source_volume, METH_FASTCALL, va_no_doc },
{ "is_sound_source_muted", ( PyCFunction ) va_is_sound_source_muted, METH_FASTCALL, va_no_doc },
{ "set_sound_source_muted", ( PyCFunction ) va_set_sound_source_muted, METH_FASTCALL, va_no_doc },
{ "get_sound_source_position", ( PyCFunction ) va_get_sound_source_position, METH_FASTCALL, va_no_doc },
{ "set_sound_source_position", ( PyCFunction ) va_set_sound_source_position, METH_FASTCALL, va_no_doc },
{ "get_sound_source_orientation_vu", ( PyCFunction ) va_get_sound_source_orientation_vu, METH_FASTCALL, va_no_doc },
{ "set_sound_source_orientation_vu", ( PyCFunction ) va_set_sound_source_orientation_vu, METH_FASTCALL, va_no_doc },
{ "get_sound_source_orientation_q", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "set_sound_source_orientation_q", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
......@@ -97,6 +98,7 @@ static struct PyMethodDef va_methods[] =
{ "get_listener_volume", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "set_listener_volume", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "is_listener_muted", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "set_listener_muted", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "get_listener_position", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "set_listener_position", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
{ "get_listener_orientation_vu", ( PyCFunction ) va_not_implemented, METH_FASTCALL, va_no_doc },
......
......@@ -17,7 +17,7 @@ static PyObject* g_pVAError = nullptr; //!< Static pointer to error instance
#define VAPY_CATCH_RETURN } catch (const CVAException& oError) { PyErr_SetString(PyExc_Exception, oError.ToString().c_str()); return NULL; }
//! Helper for API dev
static PyObject* va_not_implemented(PyObject*, PyObject*)
static PyObject* va_not_implemented( PyObject*, PyObject* )
{
VA_EXCEPT_NOT_IMPLEMENTED;
};
......@@ -25,124 +25,135 @@ static PyObject* va_not_implemented(PyObject*, PyObject*)
//! Raises an exception if core is not available
static void RequireCoreAvailable()
{
if (!g_pVANetClient)
VA_EXCEPT2(CVAException::NETWORK_ERROR, "VA client not available, please connect first");
if( !g_pVANetClient )
VA_EXCEPT2( CVAException::NETWORK_ERROR, "VA client not available, please connect first" );
if (!g_pVANetClient->GetCoreInstance())
VA_EXCEPT2(CVAException::NETWORK_ERROR, "VA client available, but access to VA interface failed. Please reconnect.");
if( !g_pVANetClient->GetCoreInstance() )
VA_EXCEPT2( CVAException::NETWORK_ERROR, "VA client available, but access to VA interface failed. Please reconnect." );
};
std::string SaveStringToUnicodeConversion( const std::string& sInputString )
{
std::string sOutputString = sInputString;
const Py_ssize_t iLength = sInputString.length();
char* pcBuffer( &sOutputString[ 0 ] );
for( Py_ssize_t i = 0; i < iLength; i++ )
if( pcBuffer[ i ] < 0 )
pcBuffer[ i ] = '_';
return &sOutputString[ 0 ];
};
//! Helper to convert recursively from VAStruct to Python dict
PyObject* ConvertVAStructToPythonDict(const CVAStruct& oInStruct)
PyObject* ConvertVAStructToPythonDict( const CVAStruct& oInStruct )
{
PyObject* pOutDict = PyDict_New();
CVAStruct::const_iterator cit = oInStruct.Begin();
while (cit != oInStruct.End())
while( cit != oInStruct.End() )
{
const std::string sKey((*cit++).first);
const CVAStructValue& oValue(oInStruct[sKey]);
const std::string sKey( ( *cit++ ).first );
const CVAStructValue& oValue( oInStruct[ sKey ] );
PyObject* pNewValue = nullptr;
if (oValue.IsBool())
if( oValue.IsBool() )
{
pNewValue = PyBool_FromLong(bool(oValue));
pNewValue = PyBool_FromLong( bool( oValue ) );
}
else if (oValue.IsInt())
else if( oValue.IsInt() )
{
pNewValue = PyLong_FromLong(int(oValue));
pNewValue = PyLong_FromLong( int( oValue ) );
}
else if (oValue.IsDouble())
else if( oValue.IsDouble() )
{
pNewValue = PyFloat_FromDouble(double(oValue));
pNewValue = PyFloat_FromDouble( double( oValue ) );
}
else if (oValue.IsString())
else if( oValue.IsString() )
{
pNewValue = PyUnicode_FromString(SaveStringToUnicodeConversion(std::string(oValue)).c_str());
pNewValue = PyUnicode_FromString( SaveStringToUnicodeConversion( std::string( oValue ) ).c_str() );
}
else if (oValue.IsStruct())
else if( oValue.IsStruct() )
{
pNewValue = ConvertVAStructToPythonDict(oValue);
pNewValue = ConvertVAStructToPythonDict( oValue );
}
else if (oValue.IsData())
else if( oValue.IsData() )
{
VA_EXCEPT_NOT_IMPLEMENTED;
}
else if (oValue.IsSampleBuffer())
else if( oValue.IsSampleBuffer() )
{
VA_EXCEPT_NOT_IMPLEMENTED;
}
else
{
VA_EXCEPT2(INVALID_PARAMETER, "Could not interpret value of key '" + sKey + "' as a supported python dict type. Value was" + oValue.ToString());
VA_EXCEPT2( INVALID_PARAMETER, "Could not interpret value of key '" + sKey + "' as a supported python dict type. Value was" + oValue.ToString() );
}
if (!pNewValue)
VA_EXCEPT2(INVALID_PARAMETER, "Could not create python object from value of key '" + sKey + "'. Value was" + oValue.ToString());
if( !pNewValue )
VA_EXCEPT2( INVALID_PARAMETER, "Could not create python object from value of key '" + sKey + "'. Value was" + oValue.ToString() );
if (PyDict_SetItemString(pOutDict, sKey.c_str(), pNewValue) == -1)
VA_EXCEPT2(INVALID_PARAMETER, "Could not create python object from value of key '" + sKey + "'. Value was" + oValue.ToString());
if( PyDict_SetItemString( pOutDict, sKey.c_str(), pNewValue ) == -1 )
VA_EXCEPT2( INVALID_PARAMETER, "Could not create python object from value of key '" + sKey + "'. Value was" + oValue.ToString() );
}
return pOutDict;
};
//! Helper to convert recursively from Python dict to VAStruct
CVAStruct ConvertPythonDictToVAStruct(PyObject* pInDict)
CVAStruct ConvertPythonDictToVAStruct( PyObject* pInDict )
{
CVAStruct oReturn;
PyObject* pKeyList = PyDict_Keys(pInDict);
PyObject* pValueList = PyDict_Values(pInDict);
PyObject* pKeyList = PyDict_Keys( pInDict );
PyObject* pValueList = PyDict_Values( pInDict );
for (Py_ssize_t i = 0; i < PyList_Size(pKeyList); i++)
for( Py_ssize_t i = 0; i < PyList_Size( pKeyList ); i++ )
{
PyObject* pKey = PyList_GetItem(pKeyList, i);
PyObject* pValue = PyList_GetItem(pValueList, i);
PyObject* pKey = PyList_GetItem( pKeyList, i );
PyObject* pValue = PyList_GetItem( pValueList, i );
char* pcKeyName = nullptr;
if (!PyArg_Parse(pKey, "s", &pcKeyName))
VA_EXCEPT2(CVAException::INVALID_PARAMETER, "Invalid key '" + std::string(pcKeyName) + "'");
if( !PyArg_Parse( pKey, "s", &pcKeyName ) )
VA_EXCEPT2( CVAException::INVALID_PARAMETER, "Invalid key '" + std::string( pcKeyName ) + "'" );
if (Py_None == pValue)
if( Py_None == pValue )
{
oReturn[pcKeyName] = false;
oReturn[ pcKeyName ] = false;
}
else if (PyBool_Check(pValue))
else if( PyBool_Check( pValue ) )
{
oReturn[pcKeyName] = ( PyLong_AsLong(pValue) != 0 );
oReturn[ pcKeyName ] = ( PyLong_AsLong( pValue ) != 0 );
}
else if (PyLong_Check(pValue))
else if( PyLong_Check( pValue ) )
{
oReturn[pcKeyName] = PyLong_AsLong(pValue);
oReturn[ pcKeyName ] = PyLong_AsLong( pValue );
}
else if (PyFloat_Check(pValue))
else if( PyFloat_Check( pValue ) )
{
oReturn[pcKeyName] = PyFloat_AsDouble(pValue);
oReturn[ pcKeyName ] = PyFloat_AsDouble( pValue );
}
else if (PyUnicode_Check(pValue))
else if( PyUnicode_Check( pValue ) )
{
char* pcStringValue = nullptr;
if (!PyArg_Parse(pValue, "s", &pcStringValue))
VA_EXCEPT2(CVAException::INVALID_PARAMETER, "Invalid string value at key '" + std::string(pcKeyName) + "': " + std::string(pcStringValue));
oReturn[pcKeyName] = std::string(pcStringValue);
if( !PyArg_Parse( pValue, "s", &pcStringValue ) )
VA_EXCEPT2( CVAException::INVALID_PARAMETER, "Invalid string value at key '" + std::string( pcKeyName ) + "': " + std::string( pcStringValue ) );
oReturn[ pcKeyName ] = std::string( pcStringValue );
}
else if (PyDict_Check(pValue))
else if( PyDict_Check( pValue ) )
{
oReturn[pcKeyName] = ConvertPythonDictToVAStruct(pValue);
oReturn[ pcKeyName ] = ConvertPythonDictToVAStruct( pValue );
}
else if (PyList_Check(pValue))
else if( PyList_Check( pValue ) )
{
// Sample buffer
VA_EXCEPT_NOT_IMPLEMENTED;
}
else if (PyByteArray_Check(pValue))
else if( PyByteArray_Check( pValue ) )
{
// Data blob
VA_EXCEPT_NOT_IMPLEMENTED;
}
else
{
VA_EXCEPT2(INVALID_PARAMETER, "Could not interpret value of key '" + std::string(pcKeyName) + "' as a supported VAStruct type.")
VA_EXCEPT2( INVALID_PARAMETER, "Could not interpret value of key '" + std::string( pcKeyName ) + "' as a supported VAStruct type." )
}
}
......@@ -150,27 +161,16 @@ CVAStruct ConvertPythonDictToVAStruct(PyObject* pInDict)
};
std::string SaveStringToUnicodeConversion( const std::string& sInputString)
{
std::string sOutputString = sInputString;
const Py_ssize_t iLength = sInputString.length();
char* pcBuffer( &sOutputString[0] );
for (Py_ssize_t i = 0; i < iLength; i++)
if (pcBuffer[i] < 0)
pcBuffer[i] = '_';
return &sOutputString[0];
};
// ------------------------------- Python module extension methods
static PyObject* va_connect(PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames)
static PyObject* va_connect( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
if (!g_pVANetClient)
if( !g_pVANetClient )
g_pVANetClient = IVANetClient::Create();
if (g_pVANetClient->IsConnected())
if( g_pVANetClient->IsConnected() )
{
PyErr_WarnEx(NULL, "Was still connected, forced disconnect.", 1);
PyErr_WarnEx( NULL, "Was still connected, forced disconnect.", 1 );
g_pVANetClient->Disconnect();
}
......@@ -179,57 +179,57 @@ static PyObject* va_connect(PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyOb
char* pcServerIP = nullptr;
int iServerPort = 12340;
if (!_PyArg_ParseStack(ppArgs, nArgs, pKeywordNames, &_parser, &pcServerIP, &iServerPort))
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcServerIP, &iServerPort ) )
return NULL;
std::string sServerIP = pcServerIP ? std::string(pcServerIP) : "localhost";
std::string sServerIP = pcServerIP ? std::string( pcServerIP ) : "localhost";
if (IVANetClient::VA_NO_ERROR == g_pVANetClient->Initialize(sServerIP, iServerPort))
return PyBool_FromLong(1);
if( IVANetClient::VA_NO_ERROR == g_pVANetClient->Initialize( sServerIP, iServerPort ) )
return PyBool_FromLong( 1 );
PyErr_SetString(PyExc_ConnectionError, std::string("Could not connect to " + sServerIP + " on " + std::to_string((long)iServerPort)).c_str());
PyErr_SetString( PyExc_ConnectionError, std::string( "Could not connect to " + sServerIP + " on " + std::to_string( ( long ) iServerPort ) ).c_str() );
return NULL;
};
static PyObject* va_disconnect(PyObject*, PyObject*)
static PyObject* va_disconnect( PyObject*, PyObject* )
{
if (!g_pVANetClient)
return PyBool_FromLong(0);
if( !g_pVANetClient )
return PyBool_FromLong( 0 );
return PyBool_FromLong(g_pVANetClient->Disconnect());
return PyBool_FromLong( g_pVANetClient->Disconnect() );
};
static PyObject* va_is_connected(PyObject*, PyObject*)
static PyObject* va_is_connected( PyObject*, PyObject* )
{
if (!g_pVANetClient)
return PyBool_FromLong(0);
if( !g_pVANetClient )
return PyBool_FromLong( 0 );
else
return PyBool_FromLong(g_pVANetClient->IsConnected());
return PyBool_FromLong( g_pVANetClient->IsConnected() );
};
static PyObject* va_reset(PyObject*, PyObject*)
static PyObject* va_reset( PyObject*, PyObject* )
{
VAPY_REQUIRE_CONN_TRY;
g_pVANetClient->GetCoreInstance()->Reset();
Py_INCREF(Py_None);
Py_INCREF( Py_None );
return Py_None;
VAPY_CATCH_RETURN;
};
static PyObject* va_enumerate_modules(PyObject*, PyObject*)
static PyObject* va_enumerate_modules( PyObject*, PyObject* )
{
VAPY_REQUIRE_CONN_TRY;
std::vector< CVAModuleInfo > voModuleInfos;
g_pVANetClient->GetCoreInstance()->EnumerateModules(voModuleInfos);
g_pVANetClient->GetCoreInstance()->EnumerateModules( voModuleInfos );
PyObject* pModuleList = PyList_New(voModuleInfos.size());
PyObject* pModuleList = PyList_New( voModuleInfos.size() );
for (size_t i = 0; i < voModuleInfos.size(); i++)
for( size_t i = 0; i < voModuleInfos.size(); i++ )
{
CVAModuleInfo& oModule(voModuleInfos[i]);
PyObject* pModuleInfo = Py_BuildValue("{s:i,s:s,s:s}", "index", i, "name", oModule.sName.c_str(), "description", oModule.sDesc.c_str());
PyList_SetItem(pModuleList, i, pModuleInfo); // steals reference
CVAModuleInfo& oModule( voModuleInfos[ i ] );
PyObject* pModuleInfo = Py_BuildValue( "{s:i,s:s,s:s}", "index", i, "name", oModule.sName.c_str(), "description", oModule.sDesc.c_str() );
PyList_SetItem( pModuleList, i, pModuleInfo ); // steals reference
}
return pModuleList;
......@@ -237,7 +237,7 @@ static PyObject* va_enumerate_modules(PyObject*, PyObject*)
VAPY_CATCH_RETURN;
};
static PyObject* va_call_module(PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames)
static PyObject* va_call_module( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
VAPY_REQUIRE_CONN_TRY;
......@@ -246,71 +246,76 @@ static PyObject* va_call_module(PyObject*, PyObject** ppArgs, Py_ssize_t nArgs,
char* pcModuleName = nullptr;
PyObject* pArgumentsDict = nullptr;
if (!_PyArg_ParseStack(ppArgs, nArgs, pKeywordNames, &_parser, &pcModuleName, &PyDict_Type, &pArgumentsDict))
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcModuleName, &PyDict_Type, &pArgumentsDict ) )
return NULL;
std::string sModuleName = std::string(pcModuleName);
CVAStruct oInArgs = ConvertPythonDictToVAStruct(pArgumentsDict);
std::string sModuleName = std::string( pcModuleName );
CVAStruct oInArgs = ConvertPythonDictToVAStruct( pArgumentsDict );
CVAStruct oOutArgs;
g_pVANetClient->GetCoreInstance()->CallModule(sModuleName, oInArgs, oOutArgs);
g_pVANetClient->GetCoreInstance()->CallModule( sModuleName, oInArgs, oOutArgs );
return ConvertVAStructToPythonDict(oOutArgs);
return ConvertVAStructToPythonDict( oOutArgs );
VAPY_CATCH_RETURN;
};
static PyObject* va_add_search_path(PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames)
static PyObject* va_add_search_path( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
VAPY_REQUIRE_CONN_TRY;
static const char * const _keywords[] = { "directory_path", NULL };
static _PyArg_Parser _parser = { "s:add_search_path", _keywords, 0 };
char* pcPath = nullptr;
if (!_PyArg_ParseStack(ppArgs, nArgs, pKeywordNames, &_parser, &pcPath))
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcPath ) )
return NULL;
return PyBool_FromLong(g_pVANetClient->GetCoreInstance()->AddSearchPath(std::string(pcPath)));
return PyBool_FromLong( g_pVANetClient->GetCoreInstance()->AddSearchPath( std::string( pcPath ) ) );
VAPY_CATCH_RETURN;
};
static PyObject* va_create_listener(PyObject*, PyObject*)
static PyObject* va_create_listener( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
VAPY_REQUIRE_CONN_TRY;
std::string sName = "PyListener";
int iID = g_pVANetClient->GetCoreInstance()->CreateListener(sName, IVACore::VA_AURAMODE_ALL);
static const char * const _keywords[] = { "name", NULL };
static _PyArg_Parser _parser = { "s:create_listener", _keywords, 0 };
char* pcName = nullptr;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcName ) )
return NULL;
return PyLong_FromLong(iID);
std::string sName = pcName ? std::string( pcName ) : "PyListener";
return PyLong_FromLong( g_pVANetClient->GetCoreInstance()->CreateListener( sName, IVACore::VA_AURAMODE_ALL ) );
VAPY_CATCH_RETURN;
};
static PyObject* va_is_scene_locked(PyObject*, PyObject*)
static PyObject* va_is_scene_locked( PyObject*, PyObject* )
{
VAPY_REQUIRE_CONN_TRY;
return PyLong_FromLong(g_pVANetClient->GetCoreInstance()->IsSceneLocked());
return PyLong_FromLong( g_pVANetClient->GetCoreInstance()->IsSceneLocked() );
VAPY_CATCH_RETURN;
};
static PyObject* va_lock_scene(PyObject* , PyObject*)
static PyObject* va_lock_scene( PyObject*, PyObject* )
{
VAPY_REQUIRE_CONN_TRY;
g_pVANetClient->GetCoreInstance()->LockScene();
Py_INCREF(Py_None);
Py_INCREF( Py_None );
return Py_None;
VAPY_CATCH_RETURN;
};
static PyObject* va_unlock_scene(PyObject* , PyObject*)
static PyObject* va_unlock_scene( PyObject*, PyObject* )
{
VAPY_REQUIRE_CONN_TRY;
return PyLong_FromLong(g_pVANetClient->GetCoreInstance()->UnlockScene());
return PyLong_FromLong( g_pVANetClient->GetCoreInstance()->UnlockScene() );
VAPY_CATCH_RETURN;
};
static PyObject* va_load_directivity(PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames)
static PyObject* va_load_directivity( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
VAPY_REQUIRE_CONN_TRY;
......@@ -318,72 +323,72 @@ static PyObject* va_load_directivity(PyObject*, PyObject** ppArgs, Py_ssize_t nA
static _PyArg_Parser _parser = { "s|s:load_directivity", _keywords, 0 };
char* pcPath = nullptr;
char* pcName = nullptr;
if (!_PyArg_ParseStack(ppArgs, nArgs, pKeywordNames, &_parser, &pcPath, &pcName))
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcPath, &pcName ) )
return NULL;
std::string sName = pcName ? std::string(pcName) : "";
return PyBool_FromLong(g_pVANetClient->GetCoreInstance()->LoadDirectivity(std::string(pcPath), sName));
std::string sName = pcName ? std::string( pcName ) : "";
return PyBool_FromLong( g_pVANetClient->GetCoreInstance()->LoadDirectivity( std::string( pcPath ), sName ) );
VAPY_CATCH_RETURN;
};
static PyObject* va_free_directivity(PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames)
static PyObject* va_free_directivity( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
VAPY_REQUIRE_CONN_TRY;
static const char * const _keywords[] = { "id", NULL };
static _PyArg_Parser _parser = { "i:free_directivity", _keywords, 0 };
long iID = -1;
if (!_PyArg_ParseStack(ppArgs, nArgs, pKeywordNames, &_parser, &iID))
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) )
return NULL;
return PyBool_FromLong(g_pVANetClient->GetCoreInstance()->FreeDirectivity(iID));
return PyBool_FromLong( g_pVANetClient->GetCoreInstance()->FreeDirectivity( iID ) );
VAPY_CATCH_RETURN;
};
static PyObject* va_get_directivity_info(PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames)
static PyObject* va_get_directivity_info( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
VAPY_REQUIRE_CONN_TRY;
static const char * const _keywords[] = { "id", NULL };
static _PyArg_Parser _parser = { "i:get_directivity_info", _keywords, 0 };
long iID = -1;
if (!_PyArg_ParseStack(ppArgs, nArgs, pKeywordNames, &_parser, &iID))
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) )
return NULL;
CVADirectivityInfo oInfo = g_pVANetClient->GetCoreInstance()->GetDirectivityInfo(iID);
CVADirectivityInfo oInfo = g_pVANetClient->GetCoreInstance()->GetDirectivityInfo( iID );
PyObject* pInfo = Py_BuildValue("{s:i,s:s,s:s,s:i,s:s}",
PyObject* pInfo = Py_BuildValue( "{s:i,s:s,s:s,s:i,s:s}",
"id", oInfo.iID,
"name", SaveStringToUnicodeConversion(oInfo.sName).c_str(),
"filepath", SaveStringToUnicodeConversion(oInfo.sFilename).c_str(),
"name", SaveStringToUnicodeConversion( oInfo.sName ).c_str(),
"filepath", SaveStringToUnicodeConversion( oInfo.sFilename ).c_str(),
"references", oInfo.iReferences,
"description", SaveStringToUnicodeConversion(oInfo.sDesc).c_str());
"description", SaveStringToUnicodeConversion( oInfo.sDesc ).c_str() );
return pInfo;
VAPY_CATCH_RETURN;
};
static PyObject* va_get_directivity_infos(PyObject*, PyObject*)
static PyObject* va_get_directivity_infos( PyObject*, PyObject* )
{
VAPY_REQUIRE_CONN_TRY;
std::vector< CVADirectivityInfo > voInfos;
g_pVANetClient->GetCoreInstance()->GetDirectivityInfos(voInfos);
g_pVANetClient->GetCoreInstance()->GetDirectivityInfos( voInfos );
PyObject* pInfoList = PyList_New(voInfos.size());
PyObject* pInfoList = PyList_New( voInfos.size() );
for (size_t i = 0; i < voInfos.size(); i++)
for( size_t i = 0; i < voInfos.size(); i++ )
{
CVADirectivityInfo& oInfo(voInfos[i]);
PyObject* pInfo = Py_BuildValue("{s:i,s:s,s:s,s:i,s:s}",
CVADirectivityInfo& oInfo( voInfos[ i ] );
PyObject* pInfo = Py_BuildValue( "{s:i,s:s,s:s,s:i,s:s}",
"id", oInfo.iID,
"name", SaveStringToUnicodeConversion(oInfo.sName).c_str(),
"filepath", SaveStringToUnicodeConversion(oInfo.sFilename).c_str(),
"name", SaveStringToUnicodeConversion( oInfo.sName ).c_str(),
"filepath", SaveStringToUnicodeConversion( oInfo.sFilename ).c_str(),
"references", oInfo.iReferences,
"description", SaveStringToUnicodeConversion(oInfo.sDesc).c_str());
PyList_SetItem(pInfoList, i, pInfo); // steals reference
"description", SaveStringToUnicodeConversion( oInfo.sDesc ).c_str() );
PyList_SetItem( pInfoList, i, pInfo ); // steals reference
}
return pInfoList;
......@@ -392,7 +397,7 @@ static PyObject* va_get_directivity_infos(PyObject*, PyObject*)
};
static PyObject* va_load_hrir(PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames)
static PyObject* va_load_hrir( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
VAPY_REQUIRE_CONN_TRY;
......@@ -400,75 +405,507 @@ static PyObject* va_load_hrir(PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, Py
static _PyArg_Parser _parser = { "s|s:load_hrir", _keywords, 0 };
char* pcPath = nullptr;
char* pcName = nullptr;
if (!_PyArg_ParseStack(ppArgs, nArgs, pKeywordNames, &_parser, &pcPath, &pcName))
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcPath, &pcName ) )
return NULL;
std::string sName = pcName ? std::string(pcName) : "";
return PyBool_FromLong(g_pVANetClient->GetCoreInstance()->LoadHRIRDataset(std::string(pcPath), sName));
std::string sName = pcName ? std::string( pcName ) : "";
return PyBool_FromLong( g_pVANetClient->GetCoreInstance()->LoadHRIRDataset( std::string( pcPath ), sName ) );
VAPY_CATCH_RETURN;
};
static PyObject* va_free_hrir(PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames)
static PyObject* va_free_hrir( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
VAPY_REQUIRE_CONN_TRY;
static const char * const _keywords[] = { "id", NULL };
static _PyArg_Parser _parser = { "i:free_hrir", _keywords, 0 };
long iID = -1;
if (!_PyArg_ParseStack(ppArgs, nArgs, pKeywordNames, &_parser, &iID))
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) )
return NULL;
return PyBool_FromLong(g_pVANetClient->GetCoreInstance()->FreeHRIRDataset(iID));
return PyBool_FromLong( g_pVANetClient->GetCoreInstance()->FreeHRIRDataset( iID ) );
VAPY_CATCH_RETURN;
};
static PyObject* va_get_hrir_info(PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames)
static PyObject* va_get_hrir_info( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
VAPY_REQUIRE_CONN_TRY;
static const char * const _keywords[] = { "id", NULL };
static _PyArg_Parser _parser = { "i:get_hrir_info", _keywords, 0 };
long iID = -1;
if (!_PyArg_ParseStack(ppArgs, nArgs, pKeywordNames, &_parser, &iID))
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) )
return NULL;
CVAHRIRInfo oInfo = g_pVANetClient->GetCoreInstance()->GetHRIRInfo(iID);
PyObject* pInfo = Py_BuildValue("{s:i,s:s,s:s,s:i,s:s}",
CVAHRIRInfo oInfo = g_pVANetClient->GetCoreInstance()->GetHRIRInfo( iID );
PyObject* pInfo = Py_BuildValue( "{s:i,s:s,s:s,s:i,s:s}",
"id", oInfo.iID,
"name", SaveStringToUnicodeConversion(oInfo.sName).c_str(),
"filepath", SaveStringToUnicodeConversion(oInfo.sFilename).c_str(),
"name", SaveStringToUnicodeConversion( oInfo.sName ).c_str(),
"filepath", SaveStringToUnicodeConversion( oInfo.sFilename ).c_str(),
"references", oInfo.iReferences,
"description", SaveStringToUnicodeConversion( oInfo.sDesc ).c_str());
"description", SaveStringToUnicodeConversion( oInfo.sDesc ).c_str() );
return pInfo;
VAPY_CATCH_RETURN;
};
static PyObject* va_get_hrir_infos(PyObject*, PyObject*)
static PyObject* va_get_hrir_infos( PyObject*, PyObject* )
{
VAPY_REQUIRE_CONN_TRY;
std::vector< CVAHRIRInfo > voInfos;
g_pVANetClient->GetCoreInstance()->GetHRIRInfos(voInfos);