vasingletonmethods.hpp 81.8 KB
Newer Older
1 2 3
#include <Python.h>
#include <VANetClient.h>
#include <VACore.h>
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
4
#include <VAStruct.h>
5 6 7
#include <VAException.h>
#include <string.h>

8
// If you want to extend the va Python pSelf interface, also add
9 10 11 12
// the function to the va_methods table in vasingleton.cpp - otherwise they will not show up.
// Documentation goes into vasingletondoc.hpp

static IVANetClient* g_pVANetClient = nullptr; //!< Static pointer to VANetClient instance
13
static PyObject* g_pVAError = nullptr; //!< Static pointer to error instance
14

15 16 17 18
// Ugly definitions to ease try-catching VA exceptions
#define VAPY_REQUIRE_CONN_TRY try { RequireCoreAvailable();
#define VAPY_CATCH_RETURN } catch (const CVAException& oError) { PyErr_SetString(PyExc_Exception, oError.ToString().c_str()); return NULL; }

19
//! Helper for API dev
20
static PyObject* va_not_implemented( PyObject*, PyObject* )
21 22
{
	VA_EXCEPT_NOT_IMPLEMENTED;
23
};
24

25 26 27
//! Raises an exception if core is not available
static void RequireCoreAvailable()
{
28
	if( !g_pVANetClient )
29
		VA_EXCEPT2( NETWORK_ERROR, "VA client not available, please connect first" );
30

31
	if( !g_pVANetClient->GetCoreInstance() )
32
		VA_EXCEPT2( NETWORK_ERROR, "VA client available, but access to VA interface failed. Please reconnect." );
33 34 35 36 37 38 39 40 41 42 43
};

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 ];
44
};
45

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
46
//! Helper to convert recursively from VAStruct to Python dict
47
PyObject* ConvertVAStructToPythonDict( const CVAStruct& oInStruct )
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
48
{
49 50 51
	PyObject* pOutDict = PyDict_New();

	CVAStruct::const_iterator cit = oInStruct.Begin();
52
	while( cit != oInStruct.End() )
53
	{
54 55
		const std::string sKey( ( *cit++ ).first );
		const CVAStructValue& oValue( oInStruct[ sKey ] );
56 57

		PyObject* pNewValue = nullptr;
58
		if( oValue.IsBool() )
59
		{
60
			pNewValue = PyBool_FromLong( bool( oValue ) );
61
		}
62
		else if( oValue.IsInt() )
63
		{
64
			pNewValue = PyLong_FromLong( int( oValue ) );
65
		}
66
		else if( oValue.IsDouble() )
67
		{
68
			pNewValue = PyFloat_FromDouble( double( oValue ) );
69
		}
70
		else if( oValue.IsString() )
71
		{
72
			pNewValue = PyUnicode_FromString( SaveStringToUnicodeConversion( std::string( oValue ) ).c_str() );
73
		}
74
		else if( oValue.IsStruct() )
75
		{
76
			pNewValue = ConvertVAStructToPythonDict( oValue );
77
		}
78
		else if( oValue.IsData() )
79 80 81
		{
			VA_EXCEPT_NOT_IMPLEMENTED;
		}
82
		else if( oValue.IsSampleBuffer() )
83 84 85 86 87
		{
			VA_EXCEPT_NOT_IMPLEMENTED;
		}
		else
		{
88
			VA_EXCEPT2( INVALID_PARAMETER, "Could not interpret value of key '" + sKey + "' as a supported python dict type. Value was" + oValue.ToString() );
89 90
		}

91 92
		if( !pNewValue )
			VA_EXCEPT2( INVALID_PARAMETER, "Could not create python object from value of key '" + sKey + "'. Value was" + oValue.ToString() );
93

94 95
		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() );
96 97 98
	}

	return pOutDict;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
99 100 101
};

//! Helper to convert recursively from Python dict to VAStruct
102
CVAStruct ConvertPythonDictToVAStruct( PyObject* pInDict )
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
103
{
104 105
	CVAStruct oReturn;

106 107
	PyObject* pKeyList = PyDict_Keys( pInDict );
	PyObject* pValueList = PyDict_Values( pInDict );
108

109
	for( Py_ssize_t i = 0; i < PyList_Size( pKeyList ); i++ )
110
	{
111 112
		PyObject* pKey = PyList_GetItem( pKeyList, i );
		PyObject* pValue = PyList_GetItem( pValueList, i );
113
		char* pcKeyName = nullptr;
114
		if( !PyArg_Parse( pKey, "s", &pcKeyName ) )
115
			VA_EXCEPT2( INVALID_PARAMETER, "Invalid key '" + std::string( pcKeyName ) + "'" );
116

117
		if( Py_None == pValue )
118
		{
119
			oReturn[ pcKeyName ] = false;
120
		}
121
		else if( PyBool_Check( pValue ) )
122
		{
123
			oReturn[ pcKeyName ] = ( PyLong_AsLong( pValue ) != 0 );
124
		}
125
		else if( PyLong_Check( pValue ) )
126
		{
127
			oReturn[ pcKeyName ] = PyLong_AsLong( pValue );
128
		}
129
		else if( PyFloat_Check( pValue ) )
130
		{
131
			oReturn[ pcKeyName ] = PyFloat_AsDouble( pValue );
132
		}
133
		else if( PyUnicode_Check( pValue ) )
134 135
		{
			char* pcStringValue = nullptr;
136
			if( !PyArg_Parse( pValue, "s", &pcStringValue ) )
137
				VA_EXCEPT2( INVALID_PARAMETER, "Invalid string value at key '" + std::string( pcKeyName ) + "': " + std::string( pcStringValue ) );
138
			oReturn[ pcKeyName ] = std::string( pcStringValue );
139
		}
140
		else if( PyDict_Check( pValue ) )
141
		{
142
			oReturn[ pcKeyName ] = ConvertPythonDictToVAStruct( pValue );
143
		}
144
		else if( PyList_Check( pValue ) )
145 146
		{
			// Sample buffer
147 148 149 150 151 152 153 154 155 156 157 158 159 160
			CVASampleBuffer oBuffer( int( PyList_Size( pValue ) ) );
			for( int n = 0; n < oBuffer.GetNumSamples(); n++ )
			{
				PyObject* pSample = PyList_GetItem( pValue, n );
				if( !PyFloat_Check( pSample ) )
				{
					VA_EXCEPT2( INVALID_PARAMETER, "Samples must be floating point values" );
				}
				else
				{
					oBuffer.vfSamples[ n ] = PyFloat_AsDouble( pSample );
				}
			}
			oReturn[ pcKeyName ] = oBuffer;
161
		}
162
		else if( PyByteArray_Check( pValue ) )
163 164
		{
			// Data blob
165 166 167 168
			size_t iBytes = PyByteArray_Size( pValue );
			char* pcData = PyByteArray_AsString( pValue );
			oReturn[ pcKeyName ] = CVAStructValue( pcData, iBytes );
			delete[] pcData;
169 170 171
		}
		else
		{
172
			VA_EXCEPT2( INVALID_PARAMETER, "Could not interpret value of key '" + std::string( pcKeyName ) + "' as a supported VAStruct type." )
173 174 175 176
		}
	}

	return oReturn;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
177 178 179 180 181
};


// ------------------------------- Python module extension methods

182
static PyObject* va_connect( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
183
{
184
	if( !g_pVANetClient )
185 186
		g_pVANetClient = IVANetClient::Create();

187
	if( g_pVANetClient->IsConnected() )
188
	{
189
		PyErr_WarnEx( NULL, "Was still connected, forced disconnect.", 1 );
190
		g_pVANetClient->Disconnect();
191 192 193
	}

	static const char * const _keywords[] = { "server", "port", NULL };
194
	static _PyArg_Parser _parser = { "|si:connect", _keywords, 0 };
195
	char* pcServerIP = nullptr;
196 197
	int iServerPort = 12340;

198
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcServerIP, &iServerPort ) )
199
		return NULL;
200

201
	std::string sServerIP = pcServerIP ? std::string( pcServerIP ) : "localhost";
202

203 204
	if( IVANetClient::VA_NO_ERROR == g_pVANetClient->Initialize( sServerIP, iServerPort ) )
		return PyBool_FromLong( 1 );
205

206
	PyErr_SetString( PyExc_ConnectionError, std::string( "Could not connect to " + sServerIP + " on " + std::to_string( ( long ) iServerPort ) ).c_str() );
207
	return NULL;
208
};
209

210
static PyObject* va_disconnect( PyObject*, PyObject* )
211
{
212 213
	if( !g_pVANetClient )
		return PyBool_FromLong( 0 );
214

215
	return PyBool_FromLong( g_pVANetClient->Disconnect() );
216
};
217

218
static PyObject* va_is_connected( PyObject*, PyObject* )
219
{
220 221
	if( !g_pVANetClient )
		return PyBool_FromLong( 0 );
222
	else
223
		return PyBool_FromLong( g_pVANetClient->IsConnected() );
224
};
225

226
static PyObject* va_reset( PyObject*, PyObject* )
227
{
228
	VAPY_REQUIRE_CONN_TRY;
229
	g_pVANetClient->GetCoreInstance()->Reset();
230
	Py_INCREF( Py_None );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
231
	return Py_None;
232 233
	VAPY_CATCH_RETURN;
};
234

235
static PyObject* va_enumerate_modules( PyObject*, PyObject* )
236
{
237
	VAPY_REQUIRE_CONN_TRY;
238 239

	std::vector< CVAModuleInfo > voModuleInfos;
240
	g_pVANetClient->GetCoreInstance()->EnumerateModules( voModuleInfos );
241

242
	PyObject* pModuleList = PyList_New( voModuleInfos.size() );
243

244
	for( size_t i = 0; i < voModuleInfos.size(); i++ )
245
	{
246
		CVAModuleInfo& oModule( voModuleInfos[ i ] );
247
		PyObject* pModuleInfo = Py_BuildValue( "{s:i,s:s,s:s}", "index", i, "name", SaveStringToUnicodeConversion( oModule.sName ).c_str(), "description", SaveStringToUnicodeConversion( oModule.sDesc ).c_str() );
248
		PyList_SetItem( pModuleList, i, pModuleInfo ); // steals reference
249 250 251 252
	}

	return pModuleList;

253 254 255
	VAPY_CATCH_RETURN;
};

256
static PyObject* va_call_module( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
257
{
258
	VAPY_REQUIRE_CONN_TRY;
259

260 261
	static const char * const _keywords[] = { "module_name", "arguments_dict", NULL };
	static _PyArg_Parser _parser = { "sO!:call_module", _keywords, 0 };
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
262
	char* pcModuleName = nullptr;
263
	PyObject* pArgumentsDict = nullptr;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
264

265
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcModuleName, &PyDict_Type, &pArgumentsDict ) )
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
266
		return NULL;
267

268 269
	std::string sModuleName = std::string( pcModuleName );
	CVAStruct oInArgs = ConvertPythonDictToVAStruct( pArgumentsDict );
270
	CVAStruct oOutArgs;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
271

272
	g_pVANetClient->GetCoreInstance()->CallModule( sModuleName, oInArgs, oOutArgs );
273

274
	return ConvertVAStructToPythonDict( oOutArgs );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
275

276 277 278
	VAPY_CATCH_RETURN;
};

279
static PyObject* va_add_search_path( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
280
{
281
	VAPY_REQUIRE_CONN_TRY;
282

283 284 285
	static const char * const _keywords[] = { "directory_path", NULL };
	static _PyArg_Parser _parser = { "s:add_search_path", _keywords, 0 };
	char* pcPath = nullptr;
286
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcPath ) )
287 288
		return NULL;

289
	return PyBool_FromLong( g_pVANetClient->GetCoreInstance()->AddSearchPath( std::string( pcPath ) ) );
290

291 292 293
	VAPY_CATCH_RETURN;
};

294
static PyObject* va_is_scene_locked( PyObject*, PyObject* )
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
295
{
296
	VAPY_REQUIRE_CONN_TRY;
297
	return PyLong_FromLong( g_pVANetClient->GetCoreInstance()->IsSceneLocked() );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
298 299 300
	VAPY_CATCH_RETURN;
};

301
static PyObject* va_lock_scene( PyObject*, PyObject* )
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
302
{
303
	VAPY_REQUIRE_CONN_TRY;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
304
	g_pVANetClient->GetCoreInstance()->LockScene();
305
	Py_INCREF( Py_None );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
306
	return Py_None;
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
307 308 309
	VAPY_CATCH_RETURN;
};

310
static PyObject* va_unlock_scene( PyObject*, PyObject* )
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
311 312
{
	VAPY_REQUIRE_CONN_TRY;
313
	return PyLong_FromLong( g_pVANetClient->GetCoreInstance()->UnlockScene() );
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
314 315
	VAPY_CATCH_RETURN;
};
316

317
static PyObject* va_load_directivity( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
318 319 320 321 322 323 324
{
	VAPY_REQUIRE_CONN_TRY;

	static const char * const _keywords[] = { "path", "name", NULL };
	static _PyArg_Parser _parser = { "s|s:load_directivity", _keywords, 0 };
	char* pcPath = nullptr;
	char* pcName = nullptr;
325
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcPath, &pcName ) )
326 327
		return NULL;

328 329
	std::string sName = pcName ? std::string( pcName ) : "";
	return PyBool_FromLong( g_pVANetClient->GetCoreInstance()->LoadDirectivity( std::string( pcPath ), sName ) );
330 331 332 333

	VAPY_CATCH_RETURN;
};

334
static PyObject* va_free_directivity( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
335 336 337 338 339 340
{
	VAPY_REQUIRE_CONN_TRY;

	static const char * const _keywords[] = { "id", NULL };
	static _PyArg_Parser _parser = { "i:free_directivity", _keywords, 0 };
	long iID = -1;
341
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) )
342
		return NULL;
343
	return PyBool_FromLong( g_pVANetClient->GetCoreInstance()->FreeDirectivity( iID ) );
344 345 346 347

	VAPY_CATCH_RETURN;
};

348
static PyObject* va_get_directivity_info( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
349 350 351 352 353 354
{
	VAPY_REQUIRE_CONN_TRY;

	static const char * const _keywords[] = { "id", NULL };
	static _PyArg_Parser _parser = { "i:get_directivity_info", _keywords, 0 };
	long iID = -1;
355
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) )
356
		return NULL;
357

358
	CVADirectivityInfo oInfo = g_pVANetClient->GetCoreInstance()->GetDirectivityInfo( iID );
359

360
	PyObject* pInfo = Py_BuildValue( "{s:i,s:s,s:s,s:i,s:s}",
361
		"id", oInfo.iID,
362 363
		"name", SaveStringToUnicodeConversion( oInfo.sName ).c_str(),
		"filepath", SaveStringToUnicodeConversion( oInfo.sFilename ).c_str(),
364
		"references", oInfo.iReferences,
365
		"description", SaveStringToUnicodeConversion( oInfo.sDesc ).c_str() );
366 367 368 369 370 371

	return pInfo;

	VAPY_CATCH_RETURN;
};

372
static PyObject* va_get_directivity_infos( PyObject*, PyObject* )
373 374 375 376
{
	VAPY_REQUIRE_CONN_TRY;

	std::vector< CVADirectivityInfo > voInfos;
377
	g_pVANetClient->GetCoreInstance()->GetDirectivityInfos( voInfos );
378

379
	PyObject* pInfoList = PyList_New( voInfos.size() );
380

381
	for( size_t i = 0; i < voInfos.size(); i++ )
382
	{
383 384
		CVADirectivityInfo& oInfo( voInfos[ i ] );
		PyObject* pInfo = Py_BuildValue( "{s:i,s:s,s:s,s:i,s:s}",
385
			"id", oInfo.iID,
386 387
			"name", SaveStringToUnicodeConversion( oInfo.sName ).c_str(),
			"filepath", SaveStringToUnicodeConversion( oInfo.sFilename ).c_str(),
388
			"references", oInfo.iReferences,
389 390
			"description", SaveStringToUnicodeConversion( oInfo.sDesc ).c_str() );
		PyList_SetItem( pInfoList, i, pInfo ); // steals reference
391 392 393 394 395
	}

	return pInfoList;

	VAPY_CATCH_RETURN;
396 397 398
};


399
static PyObject* va_load_hrir( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
400 401 402 403 404 405 406
{
	VAPY_REQUIRE_CONN_TRY;

	static const char * const _keywords[] = { "path", "name", NULL };
	static _PyArg_Parser _parser = { "s|s:load_hrir", _keywords, 0 };
	char* pcPath = nullptr;
	char* pcName = nullptr;
407
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcPath, &pcName ) )
408 409
		return NULL;

410 411
	std::string sName = pcName ? std::string( pcName ) : "";
	return PyBool_FromLong( g_pVANetClient->GetCoreInstance()->LoadHRIRDataset( std::string( pcPath ), sName ) );
412 413 414 415

	VAPY_CATCH_RETURN;
};

416
static PyObject* va_free_hrir( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
417 418 419 420 421 422
{
	VAPY_REQUIRE_CONN_TRY;

	static const char * const _keywords[] = { "id", NULL };
	static _PyArg_Parser _parser = { "i:free_hrir", _keywords, 0 };
	long iID = -1;
423
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) )
424
		return NULL;
425
	return PyBool_FromLong( g_pVANetClient->GetCoreInstance()->FreeHRIRDataset( iID ) );
426 427 428 429

	VAPY_CATCH_RETURN;
};

430
static PyObject* va_get_hrir_info( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
431 432 433 434 435 436
{
	VAPY_REQUIRE_CONN_TRY;

	static const char * const _keywords[] = { "id", NULL };
	static _PyArg_Parser _parser = { "i:get_hrir_info", _keywords, 0 };
	long iID = -1;
437
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) )
438 439
		return NULL;

440 441 442
	CVAHRIRInfo oInfo = g_pVANetClient->GetCoreInstance()->GetHRIRInfo( iID );

	PyObject* pInfo = Py_BuildValue( "{s:i,s:s,s:s,s:i,s:s}",
443
		"id", oInfo.iID,
444 445
		"name", SaveStringToUnicodeConversion( oInfo.sName ).c_str(),
		"filepath", SaveStringToUnicodeConversion( oInfo.sFilename ).c_str(),
446
		"references", oInfo.iReferences,
447
		"description", SaveStringToUnicodeConversion( oInfo.sDesc ).c_str() );
448 449 450 451 452 453

	return pInfo;

	VAPY_CATCH_RETURN;
};

454
static PyObject* va_get_hrir_infos( PyObject*, PyObject* )
455 456 457 458
{
	VAPY_REQUIRE_CONN_TRY;

	std::vector< CVAHRIRInfo > voInfos;
459
	g_pVANetClient->GetCoreInstance()->GetHRIRInfos( voInfos );
460

461
	PyObject* pInfoList = PyList_New( voInfos.size() );
462

463
	for( size_t i = 0; i < voInfos.size(); i++ )
464
	{
465 466
		CVAHRIRInfo& oInfo( voInfos[ i ] );
		PyObject* pInfo = Py_BuildValue( "{s:i,s:s,s:s,s:i,s:s}",
467
			"id", oInfo.iID,
468 469
			"name", SaveStringToUnicodeConversion( oInfo.sName ).c_str(),
			"filepath", SaveStringToUnicodeConversion( oInfo.sFilename ).c_str(),
470
			"references", oInfo.iReferences,
471 472
			"description", SaveStringToUnicodeConversion( oInfo.sDesc ).c_str() );
		PyList_SetItem( pInfoList, i, pInfo ); // steals reference
473 474 475 476 477 478
	}

	return pInfoList;

	VAPY_CATCH_RETURN;
};
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811

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 };
812
	static _PyArg_Parser _parser = { "i:vet_sound_source_position", _keywords, 0 };
813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834
	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 };
835
	static _PyArg_Parser _parser = { "i(ddd):set_sound_source_position", _keywords, 0 };
836
	long iID = -1;
837 838
	VAVec3 v3Pos;
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID, &v3Pos.x, &v3Pos.y, &v3Pos.z ) )
839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860
		return NULL;

	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 );

861
	return Py_BuildValue( "(ddd)(ddd)", v3View.x, v3View.y, v3View.z, v3Up.x, v3Up.y, v3Up.z );
862 863 864 865 866 867 868 869 870

	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 };
871
	static _PyArg_Parser _parser = { "i(ddd)(ddd):set_sound_source_orientation_vu", _keywords, 0 };
872
	long iID = -1;
873
	VAVec3 v3View, v3Up;
874
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID, &v3View.x, &v3View.y, &v3View.z, &v3Up.x, &v3Up.y, &v3Up.z ) )
875 876 877 878 879 880 881
		return NULL;

	g_pVANetClient->GetCoreInstance()->SetSoundSourceOrientationVU( iID, v3View.x, v3View.y, v3View.z, v3Up.x, v3Up.y, v3Up.z );
	return Py_None;

	VAPY_CATCH_RETURN;
};
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123

static PyObject* va_get_listener_ids( PyObject*, PyObject* )
{
	VAPY_REQUIRE_CONN_TRY;
	std::vector< int > viIDs;
	g_pVANetClient->GetCoreInstance()->GetListenerIDs( 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_listener( 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_listener", _keywords, 0 };
	char* pcName = nullptr;
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcName ) )
		return NULL;

	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_create_listener_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_listener_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 ) : "PyListener_" + sRenderer;
	return PyLong_FromLong( g_pVANetClient->GetCoreInstance()->CreateListenerExplicitRenderer( sName, sRenderer ) );

	VAPY_CATCH_RETURN;
};

static PyObject* va_delete_listener( 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_listener", _keywords, 0 };
	long iID = -1;
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) )
		return NULL;

	return PyLong_FromLong( g_pVANetClient->GetCoreInstance()->DeleteListener( iID ) );

	VAPY_CATCH_RETURN;
};

static PyObject* va_set_listener_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_listener_enabled", _keywords, 0 };
	long iID = -1;
	bool bEnabled = true;
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID, &bEnabled ) )
		return NULL;

	g_pVANetClient->GetCoreInstance()->SetListenerEnabled( iID, bEnabled );
	return Py_None;

	VAPY_CATCH_RETURN;
};

static PyObject* va_get_listener_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_listener_enabled", _keywords, 0 };
	long iID = -1;
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) )
		return NULL;

	return PyBool_FromLong( g_pVANetClient->GetCoreInstance()->GetListenerEnabled( iID ) );

	VAPY_CATCH_RETURN;
};

static PyObject* va_get_listener_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_listener_name", _keywords, 0 };
	long iID = -1;
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) )
		return NULL;

	return PyUnicode_FromString( SaveStringToUnicodeConversion( g_pVANetClient->GetCoreInstance()->GetListenerName( iID ) ).c_str() );

	VAPY_CATCH_RETURN;
};

static PyObject* va_get_listener_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_listener_auralization_mode", _keywords, 0 };
	long iID = -1;
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) )
		return NULL;

	return PyLong_FromLong( g_pVANetClient->GetCoreInstance()->GetListenerAuralizationMode( iID ) );

	VAPY_CATCH_RETURN;
};

static PyObject* va_set_listener_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_listener_auralization_mode", _keywords, 0 };
	long iID = -1;
	long iAuralizationMode = -1;
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID, &iAuralizationMode ) )
		return NULL;

	g_pVANetClient->GetCoreInstance()->SetListenerAuralizationMode( iID, iAuralizationMode );
	return Py_None;

	VAPY_CATCH_RETURN;
};

static PyObject* va_set_listener_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_listener_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()->SetListenerParameters( iID, oParameters );
	return Py_None;

	VAPY_CATCH_RETURN;
};


static PyObject* va_get_listener_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_listener_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()->GetListenerParameters( iID, oParameters );
	return ConvertVAStructToPythonDict( oReturn );

	VAPY_CATCH_RETURN;
};


static PyObject* va_get_listener_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:get_listener_hrir", _keywords, 0 };
	long iID = -1;
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) )
		return NULL;

	return PyLong_FromLong( g_pVANetClient->GetCoreInstance()->GetListenerHRIRDataset( iID ) );

	VAPY_CATCH_RETURN;
};

static PyObject* va_set_listener_hrir( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
	VAPY_REQUIRE_CONN_TRY;

	static const char * const _keywords[] = { "id", "hrir", NULL };
	static _PyArg_Parser _parser = { "ii:set_listener_hrir", _keywords, 0 };
	long iID = -1;
	long iHRIRID = -1;
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID, &iHRIRID ) )
		return NULL;

	g_pVANetClient->GetCoreInstance()->SetListenerHRIRDataset( iID, iHRIRID );
	return Py_None;

	VAPY_CATCH_RETURN;
};

static PyObject* va_get_listener_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:get_listener_position", _keywords, 0 };
	long iID = -1;
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) )
		return NULL;

	VAVec3 v3Pos;
	g_pVANetClient->GetCoreInstance()->GetListenerPosition( 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_listener_position( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
{
	VAPY_REQUIRE_CONN_TRY;

	static const char * const _keywords[] = { "id", "pos", NULL };
1124
	static _PyArg_Parser _parser = { "i(ddd):set_listener_position", _keywords, 0 };
1125
	long iID = -1;
1126
	VAVec3 v3Pos;
1127
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID, &v3Pos.x, &v3Pos.y, &v3Pos.z ) )
1128 1129
		return NULL;

1130
	g_pVANetClient->GetCoreInstance()->SetListenerPosition( iID, v3Pos.x, v3Pos.y, v3Pos.z );
1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148
	return Py_None;

	VAPY_CATCH_RETURN;
};

static PyObject* va_get_listener_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_listener_orientation_vu", _keywords, 0 };
	long iID = -1;
	if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &iID ) )
		return NULL;

	VAVec3 v3View, v3Up;
	g_pVANetClient->GetCoreInstance()->GetListenerOrientationVU( iID, v3View.x, v3View.y, v3View.z, v3Up.x, v3Up.y, v3Up.z );

1149
	return Py_BuildValue( "(ddd)(ddd)", v3View.x, v3View.y, v3View.z, v3Up.x, v3Up.y, v3Up.z );
1150 1151