More methods

parent dc033be6
......@@ -128,6 +128,11 @@ static struct PyMethodDef va_methods[] =
{ "get_homogeneous_medium_parameters", ( PyCFunction ) get_homogeneous_medium_parameters, METH_FASTCALL, no_doc },
{ "set_homogeneous_medium_parameters", ( PyCFunction ) set_homogeneous_medium_parameters, METH_FASTCALL, no_doc },
{ "create_acoustic_material_from_file", ( PyCFunction ) create_acoustic_material_from_file, METH_FASTCALL, no_doc },
{ "get_acoustic_material_infos", ( PyCFunction ) get_acoustic_material_infos, METH_FASTCALL, no_doc },
{ "get_rendering_modules", ( PyCFunction ) get_rendering_modules, METH_FASTCALL, no_doc },
{ "set_rendering_module_muted", ( PyCFunction ) set_rendering_module_muted, METH_FASTCALL, no_doc },
{ "get_rendering_module_muted", ( PyCFunction ) get_rendering_module_muted, METH_FASTCALL, no_doc },
......
......@@ -43,6 +43,36 @@ std::string SaveStringToUnicodeConversion( const std::string& sInputString )
return &sOutputString[ 0 ];
};
PyObject* ConvertFloatVectorToPythonList( const std::vector< float > vfValues )
{
PyObject* pList = PyList_New( vfValues.size() );
for( Py_ssize_t i = 0; i < PyList_GET_SIZE( pList ); i++ )
PyList_SetItem( pList, i, PyLong_FromDouble( vfValues[ i ] ) );
return pList;
};
PyObject* ConvertDoubleVectorToPythonList( const std::vector< double > vdValues )
{
PyObject* pList = PyList_New( vdValues.size() );
for( Py_ssize_t i = 0; i < PyList_GET_SIZE( pList ); i++ )
PyList_SetItem( pList, i, PyLong_FromDouble( vdValues[ i ] ) );
return pList;
};
PyObject* ConvertIntVectorToPythonList( const std::vector< int > viValues )
{
PyObject* pList = PyList_New( viValues.size() );
for( Py_ssize_t i = 0; i < PyList_GET_SIZE( pList ); i++ )
PyList_SetItem( pList, i, PyLong_FromLong( viValues[ i ] ) );
return pList;
};
//! Helper to convert recursively from VAStruct to Python dict
PyObject* ConvertVAStructToPythonDict( const CVAStruct& oInStruct )
{
......@@ -108,6 +138,9 @@ CVAStruct ConvertPythonDictToVAStruct( PyObject* pInDict )
{
CVAStruct oReturn;
if( pInDict == nullptr )
return oReturn;
PyObject* pKeyList = PyDict_Keys( pInDict );
PyObject* pValueList = PyDict_Values( pInDict );
......@@ -180,6 +213,12 @@ CVAStruct ConvertPythonDictToVAStruct( PyObject* pInDict )
return oReturn;
};
CVAAcousticMaterial ConvertPythonDictToAcousticMaterial( PyObject* pMaterial )
{
CVAAcousticMaterial oMaterial;
oMaterial.
}
// ------------------------------- Python module extension methods
......@@ -418,14 +457,8 @@ static PyObject* 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;
g_pVANetClient->GetCoreInstance()->GetSoundSourceIDs( viIDs );
return ConvertIntVectorToPythonList( viIDs );
VAPY_CATCH_RETURN;
};
......@@ -580,13 +613,17 @@ static PyObject* get_sound_source_auralization_mode( PyObject*, PyObject** ppArg
{
VAPY_REQUIRE_CONN_TRY;
static const char * const _keywords[] = { "id", NULL };
static _PyArg_Parser _parser = { "i:get_sound_source_auralization_mode", _keywords, 0 };
static const char * const _keywords[] = { "id", "short_mode", NULL };
static _PyArg_Parser _parser = { "i|b:get_sound_source_auralization_mode", _keywords, 0 };
long iID = -1;
bool bShortMode = true;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) )
return NULL;
return PyLong_FromLong( g_pVANetClient->GetCoreInstance()->GetSoundSourceAuralizationMode( iID ) );
const int iAM = g_pVANetClient->GetCoreInstance()->GetSoundSourceAuralizationMode( iID );
const std::string sAM = SaveStringToUnicodeConversion( IVAInterface::GetAuralizationModeStr( iAM, bShortMode ) );
return PyUnicode_FromString( sAM.c_str() );
VAPY_CATCH_RETURN;
};
......@@ -596,13 +633,17 @@ static PyObject* set_sound_source_auralization_mode( PyObject*, PyObject** ppArg
VAPY_REQUIRE_CONN_TRY;
static const char * const _keywords[] = { "id", "auralizationmode", NULL };
static _PyArg_Parser _parser = { "ii:set_sound_source_auralization_mode", _keywords, 0 };
static _PyArg_Parser _parser = { "is:set_sound_source_auralization_mode", _keywords, 0 };
long iID = -1;
long iAuralizationMode = -1;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID, &iAuralizationMode ) )
char* pcAM = nullptr;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID, &pcAM ) )
return NULL;
g_pVANetClient->GetCoreInstance()->SetSoundSourceAuralizationMode( iID, iAuralizationMode );
std::string sAM = pcAM ? std::string( pcAM ) : "";
const int iCurrentAM = g_pVANetClient->GetCoreInstance()->GetSoundSourceAuralizationMode( iID );
const int iAM = IVAInterface::ParseAuralizationModeStr( sAM, iCurrentAM );
g_pVANetClient->GetCoreInstance()->SetSoundSourceAuralizationMode( iID, iAM );
return Py_None;
VAPY_CATCH_RETURN;
......@@ -931,13 +972,17 @@ static PyObject* get_sound_receiver_auralization_mode( PyObject*, PyObject** ppA
{
VAPY_REQUIRE_CONN_TRY;
static const char * const _keywords[] = { "id", NULL };
static _PyArg_Parser _parser = { "i:get_sound_receiver_auralization_mode", _keywords, 0 };
static const char * const _keywords[] = { "id", "short_mode", NULL };
static _PyArg_Parser _parser = { "i|b:get_sound_receiver_auralization_mode", _keywords, 0 };
long iID = -1;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) )
bool bShortMode = true;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID, &bShortMode ) )
return NULL;
return PyLong_FromLong( g_pVANetClient->GetCoreInstance()->GetSoundReceiverAuralizationMode( iID ) );
const int iAM = g_pVANetClient->GetCoreInstance()->GetSoundReceiverAuralizationMode( iID );
const std::string sAM = SaveStringToUnicodeConversion( IVAInterface::GetAuralizationModeStr( iAM, bShortMode ) );
return PyUnicode_FromString( sAM.c_str() );
VAPY_CATCH_RETURN;
};
......@@ -946,14 +991,18 @@ static PyObject* set_sound_receiver_auralization_mode( PyObject*, PyObject** ppA
{
VAPY_REQUIRE_CONN_TRY;
static const char * const _keywords[] = { "id", "auralizationmode", NULL };
static _PyArg_Parser _parser = { "ii:set_sound_receiver_auralization_mode", _keywords, 0 };
static const char * const _keywords[] = { "id", "auralization_mode", NULL };
static _PyArg_Parser _parser = { "is:set_sound_receiver_auralization_mode", _keywords, 0 };
long iID = -1;
long iAuralizationMode = -1;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID, &iAuralizationMode ) )
char* pcAM = nullptr;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID, &pcAM ) )
return NULL;
g_pVANetClient->GetCoreInstance()->SetSoundReceiverAuralizationMode( iID, iAuralizationMode );
const std::string sAM = pcAM ? std::string( pcAM ) : "";
const int iCurrentAM = g_pVANetClient->GetCoreInstance()->GetSoundReceiverAuralizationMode( iID );
const int iAM = IVAInterface::ParseAuralizationModeStr( sAM, iCurrentAM );
g_pVANetClient->GetCoreInstance()->SetSoundReceiverAuralizationMode( iID, iAM );
return Py_None;
VAPY_CATCH_RETURN;
......@@ -1915,6 +1964,91 @@ static PyObject* set_homogeneous_medium_parameters( PyObject*, PyObject** ppArgs
};
static PyObject* get_acoustic_material_infos( PyObject*, PyObject* )
{
VAPY_REQUIRE_CONN_TRY;
std::vector< CVAAcousticMaterial > voInfos;
g_pVANetClient->GetCoreInstance()->GetAcousticMaterialInfos( voInfos );
PyObject* pList = PyList_New( voInfos.size() );
for( size_t i = 0; i < voInfos.size(); i++ )
{
CVAAcousticMaterial& oInfo( voInfos[ i ] );
PyObject* pInfo = Py_BuildValue( "{s:i,s:i,s:O!,s:s,s:O!,s:O!,s:O!,s:O!}",
"id", oInfo.iID,
"class", oInfo.iType,
"parameters", ConvertVAStructToPythonDict( oInfo.oParams ),
"name", SaveStringToUnicodeConversion( oInfo.sName ).c_str(),
"absorption_values", ConvertFloatVectorToPythonList( oInfo.vfAbsorptionValues ),
"scattering_values", ConvertFloatVectorToPythonList( oInfo.vfScatteringValues ),
"transmission_values", ConvertFloatVectorToPythonList( oInfo.vfTransmissionValues ) );
PyList_SetItem( pList, i, pInfo ); // steals reference
}
return pList;
VAPY_CATCH_RETURN;
};
static PyObject* create_acoustic_material_from_file( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
VAPY_REQUIRE_CONN_TRY;
static const char * const _keywords[] = { "parameters", "name", NULL };
static _PyArg_Parser _parser = { "s|s:create_acoustic_material_from_file", _keywords, 0 };
char* pcFilePath = nullptr;
char* pcName = nullptr;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcFilePath, &pcName ) )
return NULL;
std::string sFilePath = pcFilePath ? std::string( pcFilePath ) : "";
std::string sName = pcName ? std::string( pcName ) : "";
const int iID = g_pVANetClient->GetCoreInstance()->CreateAcousticMaterialFromFile( sFilePath, sName );
return PyLong_FromLong( iID );
VAPY_CATCH_RETURN;
};
static PyObject* create_acoustic_material_from_parameters( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
VAPY_REQUIRE_CONN_TRY;
static const char * const _keywords[] = { "parameters", "name", NULL };
static _PyArg_Parser _parser = { "O!|s:create_acoustic_material_from_parameters", _keywords, 0 };
PyObject* pParams = nullptr;
char* pcName = nullptr;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pParams, &pcName ) )
return NULL;
const CVAStruct oParams = ConvertPythonDictToVAStruct( pParams );
std::string sName = pcName ? std::string( pcName ) : "";
const int iID = g_pVANetClient->GetCoreInstance()->CreateAcousticMaterialFromParameters( oParams, sName );
return PyLong_FromLong( iID );
VAPY_CATCH_RETURN;
};
static PyObject* create_acoustic_material( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
VAPY_REQUIRE_CONN_TRY;
static const char * const _keywords[] = { "material", "name", NULL };
static _PyArg_Parser _parser = { "O!|s:create_acoustic_material", _keywords, 0 };
PyObject* pMaterial = nullptr;
char* pcName = nullptr;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pMaterial, &pcName ) )
return NULL;
const CVAAcousticMaterial oMaterial = ConvertPythonDictToAcousticMaterial( pMaterial );
std::string sName = pcName ? std::string( pcName ) : "";
const int iID = g_pVANetClient->GetCoreInstance()->CreateAcousticMaterial( oMaterial, sName );
return PyLong_FromLong( iID );
VAPY_CATCH_RETURN;
};
static PyObject* get_rendering_modules( PyObject*, PyObject* )
{
VAPY_REQUIRE_CONN_TRY;
......@@ -1978,6 +2112,89 @@ static PyObject* set_rendering_module_gain( PyObject*, PyObject** ppArgs, Py_ssi
VAPY_CATCH_RETURN;
};
static PyObject* get_rendering_module_auralization_mode( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
VAPY_REQUIRE_CONN_TRY;
static const char * const _keywords[] = { "id", "short_mode", NULL };
static _PyArg_Parser _parser = { "s|b:get_rendering_module_auralization_mode", _keywords, 0 };
char* pcID = nullptr;
bool bShortMode = true;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcID, &bShortMode ) )
return NULL;
std::string sID = pcID ? std::string( pcID ) : "";
const int iAM = g_pVANetClient->GetCoreInstance()->GetRenderingModuleAuralizationMode( sID );
const std::string sAM = IVAInterface::GetAuralizationModeStr( iAM, bShortMode );
return PyUnicode_FromString( SaveStringToUnicodeConversion( sAM ).c_str() );
VAPY_CATCH_RETURN;
};
static PyObject* set_rendering_module_auralization_mode( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
VAPY_REQUIRE_CONN_TRY;
static const char * const _keywords[] = { "id", "auralization_mode", NULL };
static _PyArg_Parser _parser = { "ss:set_rendering_module_auralization_mode", _keywords, 0 };
char* pcID = nullptr;
char* pcAM = nullptr;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcID, &pcAM ) )
return NULL;
std::string sID = pcID ? std::string( pcID ) : "";
const std::string sAM = pcAM ? std::string( pcAM ) : "";
const int iCurrentAM = g_pVANetClient->GetCoreInstance()->GetRenderingModuleAuralizationMode( sID );
const int iAM = IVAInterface::ParseAuralizationModeStr( sAM, iCurrentAM );
g_pVANetClient->GetCoreInstance()->SetRenderingModuleAuralizationMode( sID, iAM );
return Py_None;
VAPY_CATCH_RETURN;
};
static PyObject* get_rendering_module_parameters( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
VAPY_REQUIRE_CONN_TRY;
static const char * const _keywords[] = { "id", "arguments", NULL };
static _PyArg_Parser _parser = { "s|O!:get_rendering_module_parameters", _keywords, 0 };
char* pcID = nullptr;
PyObject* pArgs = NULL;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcID, pArgs ) )
return NULL;
std::string sID = pcID ? std::string( pcID ) : "";
const CVAStruct oArgs = ConvertPythonDictToVAStruct( pArgs );
const CVAStruct oRet = g_pVANetClient->GetCoreInstance()->GetRenderingModuleParameters( sID, oArgs );
return ConvertVAStructToPythonDict( oRet );
VAPY_CATCH_RETURN;
};
static PyObject* set_rendering_module_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 = { "sO!:set_rendering_module_parameters", _keywords, 0 };
char* pcID = nullptr;
PyObject* pParams = NULL;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcID, pParams ) )
return NULL;
std::string sID = pcID ? std::string( pcID ) : "";
const CVAStruct oParameters = ConvertPythonDictToVAStruct( pParams );
g_pVANetClient->GetCoreInstance()->SetRenderingModuleParameters( sID, oParameters );
return Py_None;
VAPY_CATCH_RETURN;
};
static PyObject* set_rendering_module_muted( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
VAPY_REQUIRE_CONN_TRY;
......@@ -2071,6 +2288,45 @@ static PyObject* set_reproduction_module_gain( PyObject*, PyObject** ppArgs, Py_
VAPY_CATCH_RETURN;
};
static PyObject* get_reproduction_module_parameters( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
VAPY_REQUIRE_CONN_TRY;
static const char * const _keywords[] = { "id", "arguments", NULL };
static _PyArg_Parser _parser = { "s|O!:get_reproduction_module_parameters", _keywords, 0 };
char* pcID = nullptr;
PyObject* pArgs = NULL;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcID, pArgs ) )
return NULL;
std::string sID = pcID ? std::string( pcID ) : "";
const CVAStruct oArgs = ConvertPythonDictToVAStruct( pArgs );
const CVAStruct oRet = g_pVANetClient->GetCoreInstance()->GetReproductionModuleParameters( sID, oArgs );
return ConvertVAStructToPythonDict( oRet );
VAPY_CATCH_RETURN;
};
static PyObject* set_reproduction_module_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 = { "sO!:set_reproduction_module_parameters", _keywords, 0 };
char* pcID = nullptr;
PyObject* pParams = NULL;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcID, pParams ) )
return NULL;
std::string sID = pcID ? std::string( pcID ) : "";
const CVAStruct oParameters = ConvertPythonDictToVAStruct( pParams );
g_pVANetClient->GetCoreInstance()->SetReproductionModuleParameters( sID, oParameters );
return Py_None;
VAPY_CATCH_RETURN;
};
static PyObject* set_reproduction_module_muted( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
VAPY_REQUIRE_CONN_TRY;
......@@ -2200,7 +2456,11 @@ static PyObject* get_output_muted( PyObject*, PyObject* )
static PyObject* get_global_auralization_mode( PyObject*, PyObject* )
{
VAPY_REQUIRE_CONN_TRY;
return PyLong_FromLong( g_pVANetClient->GetCoreInstance()->GetGlobalAuralizationMode() );
const int iAM = g_pVANetClient->GetCoreInstance()->GetGlobalAuralizationMode();
const std::string sAM = SaveStringToUnicodeConversion( IVAInterface::GetAuralizationModeStr( iAM ) );
return PyUnicode_FromString( sAM.c_str() );
VAPY_CATCH_RETURN;
};
......@@ -2209,12 +2469,17 @@ static PyObject* set_global_auralization_mode( PyObject*, PyObject** ppArgs, Py_
VAPY_REQUIRE_CONN_TRY;
static const char * const _keywords[] = { "auralization_mode", NULL };
static _PyArg_Parser _parser = { "i:set_global_auralization_mode", _keywords, 0 };
long iAM = true;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iAM ) )
static _PyArg_Parser _parser = { "s:set_global_auralization_mode", _keywords, 0 };
char* pcAM = nullptr;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcAM ) )
return NULL;
std::string sAM = pcAM ? std::string( pcAM ) : "";
const int iCurrentAM = g_pVANetClient->GetCoreInstance()->GetGlobalAuralizationMode();
const int iAM = IVAInterface::ParseAuralizationModeStr( sAM, iCurrentAM );
g_pVANetClient->GetCoreInstance()->SetGlobalAuralizationMode( iAM );
return Py_None;
VAPY_CATCH_RETURN;
......
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