diff --git a/src/vasingleton.cpp b/src/vasingleton.cpp index 78d632c3f7e7622713ed85c694655a98b9808666..dd14a2c16396db58a87c49962c4dc288f62b5876 100644 --- a/src/vasingleton.cpp +++ b/src/vasingleton.cpp @@ -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 }, diff --git a/src/vasingletonmethods.hpp b/src/vasingletonmethods.hpp index 89a254fff1fbf191d9cf98b14f4e92a3e1099deb..9e441c3613e58215b90b4714b18347011c94590a 100644 --- a/src/vasingletonmethods.hpp +++ b/src/vasingletonmethods.hpp @@ -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); + g_pVANetClient->GetCoreInstance()->GetHRIRInfos( 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++ ) { - CVAHRIRInfo& oInfo(voInfos[i]); - PyObject* pInfo = Py_BuildValue("{s:i,s:s,s:s,s:i,s:s}", + CVAHRIRInfo& 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; VAPY_CATCH_RETURN; }; + +static PyObject* va_get_sound_source_ids( PyObject*, PyObject* ) +{ + VAPY_REQUIRE_CONN_TRY; + std::vector< int > viIDs; + g_pVANetClient->GetCoreInstance()->GetSoundSourceIDs( viIDs ); + + PyObject* pIDList = PyList_New( viIDs.size() ); + for( Py_ssize_t i = 0; i < PyList_GET_SIZE( pIDList ); i++ ) + PyList_SetItem( pIDList, i, PyLong_FromLong( viIDs[ i ] ) ); + + return pIDList; + + VAPY_CATCH_RETURN; +}; + +static PyObject* va_create_sound_source( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames ) +{ + VAPY_REQUIRE_CONN_TRY; + + static const char * const _keywords[] = { "name", NULL }; + static _PyArg_Parser _parser = { "s:create_sound_source", _keywords, 0 }; + char* pcName = nullptr; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcName ) ) + return NULL; + + std::string sName = pcName ? std::string( pcName ) : "PySoundSource"; + return PyLong_FromLong( g_pVANetClient->GetCoreInstance()->CreateSoundSource( sName, IVACore::VA_AURAMODE_ALL ) ); + + VAPY_CATCH_RETURN; +}; + + +static PyObject* va_create_sound_source_explicit_renderer( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames ) +{ + VAPY_REQUIRE_CONN_TRY; + + static const char * const _keywords[] = { "name", "renderer", NULL }; + static _PyArg_Parser _parser = { "ss:create_sound_source_explicit_renderer", _keywords, 0 }; + char* pcName = nullptr; + char* pcRenderer = nullptr; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcName, &pcRenderer ) ) + return NULL; + + std::string sRenderer = pcRenderer ? std::string( pcRenderer ) : "Unspecified"; + std::string sName = pcName ? std::string( pcName ) : "PySoundSource_" + sRenderer; + return PyLong_FromLong( g_pVANetClient->GetCoreInstance()->CreateSoundSourceExplicitRenderer( sName, sRenderer ) ); + + VAPY_CATCH_RETURN; +}; + +static PyObject* va_delete_sound_source( 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:delete_sound_source", _keywords, 0 }; + long iID = -1; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) ) + return NULL; + + return PyLong_FromLong( g_pVANetClient->GetCoreInstance()->DeleteSoundSource( iID ) ); + + VAPY_CATCH_RETURN; +}; + +static PyObject* va_set_sound_source_enabled( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames ) +{ + VAPY_REQUIRE_CONN_TRY; + + static const char * const _keywords[] = { "id", "enabled", NULL }; + static _PyArg_Parser _parser = { "i|b:set_sound_source_enabled", _keywords, 0 }; + long iID = -1; + bool bEnabled = true; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID, &bEnabled ) ) + return NULL; + + g_pVANetClient->GetCoreInstance()->SetSoundSourceEnabled( iID, bEnabled ); + return Py_None; + + VAPY_CATCH_RETURN; +}; + +static PyObject* va_get_sound_source_enabled( 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_sound_source_enabled", _keywords, 0 }; + long iID = -1; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) ) + return NULL; + + return PyBool_FromLong( g_pVANetClient->GetCoreInstance()->GetSoundSourceEnabled( iID ) ); + + VAPY_CATCH_RETURN; +}; + +static PyObject* va_get_sound_source_name( 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_sound_source_name", _keywords, 0 }; + long iID = -1; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) ) + return NULL; + + return PyUnicode_FromString( SaveStringToUnicodeConversion( g_pVANetClient->GetCoreInstance()->GetSoundSourceName( iID ) ).c_str() ); + + VAPY_CATCH_RETURN; +}; + +static PyObject* va_get_sound_source_signal_source( 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_sound_source_signal_source", _keywords, 0 }; + long iID = -1; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) ) + return NULL; + + return PyUnicode_FromString( SaveStringToUnicodeConversion( g_pVANetClient->GetCoreInstance()->GetSoundSourceSignalSource( iID ) ).c_str() ); + + VAPY_CATCH_RETURN; +}; + +static PyObject* va_set_sound_source_signal_source( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames ) +{ + VAPY_REQUIRE_CONN_TRY; + + static const char * const _keywords[] = { "id", "signalsource", NULL }; + static _PyArg_Parser _parser = { "is:set_sound_source_signal_source", _keywords, 0 }; + long iID = -1; + char* pcSignalSourceID; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID, &pcSignalSourceID ) ) + return NULL; + + std::string sSIgnalSourceID = pcSignalSourceID ? std::string( pcSignalSourceID ) : ""; + g_pVANetClient->GetCoreInstance()->SetSoundSourceSignalSource( iID, sSIgnalSourceID ); + + return Py_None; + + VAPY_CATCH_RETURN; +}; + +static PyObject* va_remove_sound_source_signal_source( 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:remove_sound_source_signal_source", _keywords, 0 }; + long iID = -1; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) ) + return NULL; + + g_pVANetClient->GetCoreInstance()->RemoveSoundSourceSignalSource( iID ); + return Py_None; + + VAPY_CATCH_RETURN; +}; + +static PyObject* va_get_sound_source_auralization_mode( 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_sound_source_auralization_mode", _keywords, 0 }; + long iID = -1; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) ) + return NULL; + + return PyLong_FromLong( g_pVANetClient->GetCoreInstance()->GetSoundSourceAuralizationMode( iID ) ); + + VAPY_CATCH_RETURN; +}; + +static PyObject* va_set_sound_source_auralization_mode( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames ) +{ + VAPY_REQUIRE_CONN_TRY; + + static const char * const _keywords[] = { "id", "auralizationmode", NULL }; + static _PyArg_Parser _parser = { "ii:set_sound_source_auralization_mode", _keywords, 0 }; + long iID = -1; + long iAuralizationMode = -1; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID, &iAuralizationMode ) ) + return NULL; + + g_pVANetClient->GetCoreInstance()->SetSoundSourceAuralizationMode( iID, iAuralizationMode ); + return Py_None; + + VAPY_CATCH_RETURN; +}; + +static PyObject* va_set_sound_source_parameters( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames ) +{ + VAPY_REQUIRE_CONN_TRY; + + static const char * const _keywords[] = { "id", "parameters", NULL }; + static _PyArg_Parser _parser = { "iO!:set_sound_source_parameters", _keywords, 0 }; + long iID = -1; + PyObject* pParameters = nullptr; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID, &pParameters ) ) + return NULL; + + CVAStruct oParameters = ConvertPythonDictToVAStruct( pParameters ); + g_pVANetClient->GetCoreInstance()->SetSoundSourceParameters( iID, oParameters ); + return Py_None; + + VAPY_CATCH_RETURN; +}; + + +static PyObject* va_get_sound_source_parameters( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames ) +{ + VAPY_REQUIRE_CONN_TRY; + + static const char * const _keywords[] = { "id", NULL }; + static _PyArg_Parser _parser = { "io!:get_sound_source_parameters", _keywords, 0 }; + long iID = -1; + PyObject* pParameters = nullptr; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID, &pParameters ) ) + return NULL; + + CVAStruct oParameters = ConvertPythonDictToVAStruct( pParameters ); + CVAStruct oReturn = g_pVANetClient->GetCoreInstance()->GetSoundSourceParameters( iID, oParameters ); + return ConvertVAStructToPythonDict( oReturn ); + + VAPY_CATCH_RETURN; +}; + + +static PyObject* va_get_sound_source_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:get_sound_source_directivity", _keywords, 0 }; + long iID = -1; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) ) + return NULL; + + return PyLong_FromLong( g_pVANetClient->GetCoreInstance()->GetSoundSourceDirectivity( iID ) ); + + VAPY_CATCH_RETURN; +}; + +static PyObject* va_set_sound_source_directivity( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames ) +{ + VAPY_REQUIRE_CONN_TRY; + + static const char * const _keywords[] = { "id", "directivity", NULL }; + static _PyArg_Parser _parser = { "ii:set_sound_source_directivity", _keywords, 0 }; + long iID = -1; + long iDirectivityID = -1; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID, &iDirectivityID ) ) + return NULL; + + g_pVANetClient->GetCoreInstance()->SetSoundSourceDirectivity( iID, iDirectivityID ); + return Py_None; + + VAPY_CATCH_RETURN; +}; + +static PyObject* va_get_sound_source_volume( 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_sound_source_volume", _keywords, 0 }; + long iID = -1; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) ) + return NULL; + + return PyFloat_FromDouble( g_pVANetClient->GetCoreInstance()->GetSoundSourceVolume( iID ) ); + + VAPY_CATCH_RETURN; +}; + +static PyObject* va_set_sound_source_volume( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames ) +{ + VAPY_REQUIRE_CONN_TRY; + + static const char * const _keywords[] = { "id", "gain", NULL }; + static _PyArg_Parser _parser = { "id:set_sound_source_volume", _keywords, 0 }; + long iID = -1; + double dGain = -1; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID, &dGain ) ) + return NULL; + + g_pVANetClient->GetCoreInstance()->SetSoundSourceVolume( iID, dGain ); + return Py_None; + + VAPY_CATCH_RETURN; +}; + +static PyObject* va_set_sound_source_muted( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames ) +{ + VAPY_REQUIRE_CONN_TRY; + + static const char * const _keywords[] = { "id", "muted", NULL }; + static _PyArg_Parser _parser = { "i|b:set_sound_source_muted", _keywords, 0 }; + long iID = -1; + bool bMuted = true; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID, &bMuted ) ) + return NULL; + + g_pVANetClient->GetCoreInstance()->SetSoundSourceMuted( iID, bMuted ); + return Py_None; + + VAPY_CATCH_RETURN; +}; + +static PyObject* va_is_sound_source_muted( 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:is_sound_source_muted", _keywords, 0 }; + long iID = -1; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) ) + return NULL; + + return PyBool_FromLong( g_pVANetClient->GetCoreInstance()->IsSoundSourceMuted( iID ) ); + + VAPY_CATCH_RETURN; +}; + +static PyObject* va_get_sound_source_position( 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:va_get_sound_source_position", _keywords, 0 }; + long iID = -1; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) ) + return NULL; + + VAVec3 v3Pos; + g_pVANetClient->GetCoreInstance()->GetSoundSourcePosition( iID, v3Pos.x, v3Pos.y, v3Pos.z ); + + PyObject* pPosList = PyList_New( 3 ); + PyList_SetItem( pPosList, 0, PyFloat_FromDouble( v3Pos.x ) ); + PyList_SetItem( pPosList, 1, PyFloat_FromDouble( v3Pos.y ) ); + PyList_SetItem( pPosList, 2, PyFloat_FromDouble( v3Pos.z ) ); + + return pPosList; + + VAPY_CATCH_RETURN; +}; + +static PyObject* va_set_sound_source_position( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames ) +{ + VAPY_REQUIRE_CONN_TRY; + + static const char * const _keywords[] = { "id", "pos", NULL }; + static _PyArg_Parser _parser = { "i(d,d,d):va_set_sound_source_position", _keywords, 0 }; + long iID = -1; + PyObject* pPosList = nullptr; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID, &pPosList ) ) + return NULL; + + VAVec3 v3Pos; + v3Pos.x = PyFloat_AsDouble( PyList_GetItem( pPosList, 0 ) ); + v3Pos.y = PyFloat_AsDouble( PyList_GetItem( pPosList, 1 ) ); + v3Pos.z = PyFloat_AsDouble( PyList_GetItem( pPosList, 2 ) ); + g_pVANetClient->GetCoreInstance()->SetSoundSourcePosition( iID, v3Pos.x, v3Pos.y, v3Pos.z ); + return Py_None; + + VAPY_CATCH_RETURN; +}; + + +static PyObject* va_get_sound_source_orientation_vu( 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_sound_source_orientation_vu", _keywords, 0 }; + long iID = -1; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) ) + return NULL; + + VAVec3 v3View, v3Up; + g_pVANetClient->GetCoreInstance()->GetSoundSourceOrientationVU( iID, v3View.x, v3View.y, v3View.z, v3Up.x, v3Up.y, v3Up.z ); + + PyObject* pViewList = PyList_New( 3 ); + PyList_SetItem( pViewList, 0, PyFloat_FromDouble( v3View.x ) ); + PyList_SetItem( pViewList, 1, PyFloat_FromDouble( v3View.y ) ); + PyList_SetItem( pViewList, 2, PyFloat_FromDouble( v3View.z ) ); + + PyObject* pUpList = PyList_New( 3 ); + PyList_SetItem( pUpList, 0, PyFloat_FromDouble( v3View.x ) ); + PyList_SetItem( pUpList, 1, PyFloat_FromDouble( v3View.y ) ); + PyList_SetItem( pUpList, 2, PyFloat_FromDouble( v3View.z ) ); + + PyObject* pViewUpList = PyList_New( 2 ); + PyList_SetItem( pUpList, 0, pViewList ); + PyList_SetItem( pUpList, 1, pUpList ); + return pViewUpList; + + VAPY_CATCH_RETURN; +}; + +static PyObject* va_set_sound_source_orientation_vu( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames ) +{ + VAPY_REQUIRE_CONN_TRY; + + static const char * const _keywords[] = { "id", "view", "up", NULL }; + static _PyArg_Parser _parser = { "i(d,d,d)(d,d,d):set_sound_source_orientation_vu", _keywords, 0 }; + long iID = -1; + PyObject* pViewList = nullptr; + PyObject* pUpList = nullptr; + if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID, &pViewList, &pUpList ) ) + return NULL; + + VAVec3 v3View; + v3View.x = PyFloat_AsDouble( PyList_GetItem( pViewList, 0 ) ); + v3View.y = PyFloat_AsDouble( PyList_GetItem( pViewList, 1 ) ); + v3View.z = PyFloat_AsDouble( PyList_GetItem( pViewList, 2 ) ); + + VAVec3 v3Up; + v3Up.x = PyFloat_AsDouble( PyList_GetItem( pUpList, 0 ) ); + v3Up.y = PyFloat_AsDouble( PyList_GetItem( pUpList, 1 ) ); + v3Up.z = PyFloat_AsDouble( PyList_GetItem( pUpList, 2 ) ); + + g_pVANetClient->GetCoreInstance()->SetSoundSourceOrientationVU( iID, v3View.x, v3View.y, v3View.z, v3Up.x, v3Up.y, v3Up.z ); + return Py_None; + + VAPY_CATCH_RETURN; +};