progress on API change

parent 2a1d1277
......@@ -5,7 +5,7 @@
"metadata": {},
"source": [
"# VA core controller\n",
"This is a simple example how to control global VA core functionality"
"This is an example how to control global VA core functionality"
]
},
{
......@@ -23,6 +23,7 @@
"source": [
"import sys\n",
"sys.path.append( '../../Lib/site-packages' )\n",
"sys.path.append( '../../dist/Lib/site-packages' )\n",
"import ipywidgets as widgets\n",
"import va\n",
"if not va.connect() :\n",
......@@ -57,7 +58,7 @@
"metadata": {},
"outputs": [],
"source": [
"mute_output_button = widgets.ToggleButton( description = 'Output muted', value = va.is_output_muted() )\n",
"mute_output_button = widgets.ToggleButton( description = 'Output muted', value = va.get_output_muted() )\n",
"\n",
"def on_mute_button_clicked( b ) :\n",
" if b.name == 'value' :\n",
......@@ -108,13 +109,11 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"global_am = va.get_global_auralization_mode()\n",
"va.get_auralization_mode_str()"
"va.get_auralization_mode_str( global_am )"
]
},
{
......@@ -129,9 +128,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"print( '$(DefaultHRIR): ' + va.substitute_macro( '$(DefaultHRIR)' ) )\n",
......@@ -152,9 +149,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"reset_button = widgets.Button( description = 'Reset VA server' )\n",
......@@ -177,12 +172,10 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"allmods = va.enumerate_modules()\n",
"allmods = va.get_modules()\n",
"\n",
"modnames = list()\n",
"for mod in allmods[:] :\n",
......@@ -217,15 +210,13 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"allrmods = va.get_rendering_modules()\n",
"for rmod in allrmods :\n",
" print( rmod )\n",
" rmod_id = str( rmod.class + ':' + rmod.name )\n",
" rmod_id = str( rmod[ 'class' ] + ':' + rmod[ 'name' ] )\n",
" try :\n",
" magic_return = va.call_module( rmod_id, { 'help': True } )\n",
" print( magic_return )\n",
......
......@@ -18,12 +18,13 @@
},
{
"cell_type": "code",
"execution_count": 168,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"sys.path.append( '../../Lib/site-packages' )\n",
"sys.path.append( '../../dist/Lib/site-packages' )\n",
"import ipywidgets as widgets\n",
"import va\n",
"if not va.connect() :\n",
......@@ -36,66 +37,51 @@
"collapsed": true
},
"source": [
"### Listeners"
"### Sound receiver"
]
},
{
"cell_type": "code",
"execution_count": 181,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6f9ed2a29aa04c22996c8baa64f67a8f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"A Jupyter Widget"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"listener_ids = va.get_listener_ids()\n",
"listeners_dict = {}\n",
"for listener_id in listener_ids :\n",
" listeners_dict.update( { va.get_listener_name( listener_id ) : listener_id } )\n",
"sound_receiver_ids = va.get_sound_receiver_ids()\n",
"sound_receivers_dict = {}\n",
"for sound_receiver_id in sound_receiver_ids :\n",
" sound_receivers_dict.update( { va.get_sound_receiver_name( sound_receiver_id ) : sound_receiver_id } )\n",
"\n",
"listeners_dropdown_menu = widgets.Dropdown( \n",
" options = listeners_dict,\n",
" description = 'Listeners' )\n",
"if listener_ids :\n",
" first_listener_pos = va.get_listener_position( listener_ids[ 0 ] )\n",
"sound_receiver_dropdown_menu = widgets.Dropdown( \n",
" options = sound_receivers_dict,\n",
" description = 'Sound receivers' )\n",
"if sound_receiver_ids :\n",
" first_sound_receiver_pos = va.get_sound_receiver_position( sound_receiver_ids[ 0 ] )\n",
"\n",
"def on_listener_update( w ) :\n",
" listener_id = listeners_dropdown_menu.value\n",
" if listener_id :\n",
" listener_pos = [ listeners_input_pos_x.value, listeners_input_pos_y.value, listeners_input_pos_z.value ]\n",
" va.set_listener_position( listener_id, listener_pos )\n",
"def on_sound_receiver_update( w ) :\n",
" sound_receiver_id = sound_receivers_dropdown_menu.value\n",
" if sound_receiver_id :\n",
" sound_receiver_pos = [ sound_receivers_input_pos_x.value, sound_receivers_input_pos_y.value, sound_receivers_input_pos_z.value ]\n",
" va.set_sound_receiver_position( sound_receiver_id, sound_receiver_pos )\n",
"\n",
"listeners_input_pos_x = widgets.FloatText( description = 'X' )\n",
"listeners_input_pos_y = widgets.FloatText( description = 'Y' )\n",
"listeners_input_pos_z = widgets.FloatText( description = 'Z' )\n",
"sound_receivers_input_pos_x = widgets.FloatText( description = 'X' )\n",
"sound_receivers_input_pos_y = widgets.FloatText( description = 'Y' )\n",
"sound_receivers_input_pos_z = widgets.FloatText( description = 'Z' )\n",
"\n",
"listener_update_button = widgets.Button( description = 'Update' )\n",
"listener_update_button.on_click( on_listener_update )\n",
"sound_receiver_update_button = widgets.Button( description = 'Update' )\n",
"sound_receiver_update_button.on_click( on_sound_receiver_update )\n",
"\n",
"def on_listener_select( d ) :\n",
"def on_sound_receiver_select( d ) :\n",
" if d.type == 'change' and type( d.new ) is str :\n",
" listener_id = listeners_dropdown_menu.options[ d.new ] \n",
" listener_pos = va.get_listener_position( listener_id )\n",
" listeners_input_pos_x.value = listener_pos[ 0 ]\n",
" listeners_input_pos_y.value = listener_pos[ 1 ]\n",
" listeners_input_pos_z.value = listener_pos[ 2 ]\n",
" sound_receiver_id = sound_receivers_dropdown_menu.options[ d.new ] \n",
" sound_receiver_pos = va.get_sound_receiver_position( sound_receiver_id )\n",
" sound_receivers_input_pos_x.value = sound_receiver_pos[ 0 ]\n",
" sound_receivers_input_pos_y.value = sound_receiver_pos[ 1 ]\n",
" sound_receivers_input_pos_z.value = sound_receiver_pos[ 2 ]\n",
" \n",
"listeners_dropdown_menu.observe( on_listener_select )\n",
"sound_receivers_dropdown_menu.observe( on_sound_receiver_select )\n",
"\n",
"listeners_input_widget_box = widgets.HBox( [ listeners_dropdown_menu, listeners_input_pos_x, listeners_input_pos_y, listeners_input_pos_z, listener_update_button ] )\n",
"display( listeners_input_widget_box )"
"sound_receivers_input_widget_box = widgets.HBox( [ sound_receivers_dropdown_menu, sound_receivers_input_pos_x, sound_receivers_input_pos_y, sound_receivers_input_pos_z, sound_receiver_update_button ] )\n",
"display( sound_receivers_input_widget_box )"
]
},
{
......@@ -109,24 +95,9 @@
},
{
"cell_type": "code",
"execution_count": 183,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "826b9adcf6084a80b9894ccd81081eb6",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"A Jupyter Widget"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"sound_source_ids = va.get_sound_source_ids()\n",
"sound_sources_dict = {}\n",
......
......@@ -5,7 +5,7 @@
"metadata": {},
"source": [
"# VA simple acoustic scene\n",
"This is a simple example how to create a simple acoustic scene in VA using Python."
"This is an example notebook how to create a simple acoustic scene in VA using Python."
]
},
{
......@@ -13,7 +13,7 @@
"metadata": {},
"source": [
"#### Prerequisites\n",
"You can ignore this part, it is for preparation purposes only."
"If VA Python extension is not installed, add the folder manually."
]
},
{
......@@ -23,7 +23,8 @@
"outputs": [],
"source": [
"import sys\n",
"sys.path.append( '../../Lib/site-packages' )\n",
"sys.path.append( '../../Lib/site-packages' ) # deploy\n",
"sys.path.append( '../../dist/Lib/site-packages' ) # dev\n",
"import os\n",
"print( 'Current working directory:', os.getcwd() )\n",
"import va\n",
......@@ -57,9 +58,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"va.reset()"
......@@ -75,9 +74,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"va.set_output_gain( 0.25 )"
......@@ -87,7 +84,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Add the current working directory or any other relative or absolute directory as a search path to your VA application. From now on, only use relative paths or macros to paths.\n",
"Add the current working directory and any further relative or absolute directories where you want to put resource files. VA provides search paths where to look for any file. From now on, only use relative paths or macros to paths.\n",
"> Pathes are relevant on server side, not on a remote client. The files must be available on the computer **where the VA application is running**!"
]
},
......@@ -98,7 +95,7 @@
"outputs": [],
"source": [
"va.add_search_path( os.getcwd() );\n",
"va.add_search_path( 'C:\\dev\\VA\\VACore\\data' )"
"va.add_search_path( 'C:\\dev\\VA\\VACore\\data' );"
]
},
{
......@@ -115,9 +112,9 @@
"metadata": {},
"outputs": [],
"source": [
"signal_source_id = va.create_audio_file_signal_source( 'Audiofiles/Bauer.wav' )\n",
"va.set_audio_file_signal_source_playback_action_str( signal_source_id, 'play' )\n",
"va.set_audio_file_signal_source_playback_is_looping( signal_source_id, True )"
"signal_source_id = va.create_signal_source_buffer_from_file( 'Audiofiles/Bauer.wav' )\n",
"va.set_signal_source_buffer_playback_action_str( signal_source_id, 'play' )\n",
"va.set_signal_source_buffer_looping( signal_source_id, True )"
]
},
{
......@@ -131,9 +128,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"sound_source_id = va.create_sound_source( 'PySoundSource' )\n",
......@@ -151,9 +146,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"va.set_sound_source_signal_source( sound_source_id, signal_source_id )"
......@@ -164,7 +157,7 @@
"metadata": {},
"source": [
"### Head-related transfer function / Head-related impulse response\n",
"Load an HRIR (time domain representation of an HRTF). See [OpenDAFF](http://www.opendaff.org) for more information.\n",
"Load an HRIR (time domain representation of an HRTF) as a directivity that will be assigned to a sound receiver (aka listener). See [OpenDAFF](http://www.opendaff.org) for more information.\n",
"> We use a macro `DefaultHRIR` here, that is usually available for a VA core."
]
},
......@@ -174,7 +167,7 @@
"metadata": {},
"outputs": [],
"source": [
"hrir_id = va.load_hrir( '$(DefaultHRIR)' )"
"hrir_id = va.create_directivity_from_file( '$(DefaultHRIR)' )"
]
},
{
......@@ -182,7 +175,7 @@
"metadata": {},
"source": [
"### Virtual listener\n",
"Create a listener with arbitrary name, assign the HRTF/HRIR and set a position."
"Create a sound receiver with arbitrary name, assign the HRTF/HRIR and set a position."
]
},
{
......@@ -191,10 +184,10 @@
"metadata": {},
"outputs": [],
"source": [
"listener_id = va.create_listener( 'PyListener' )\n",
"va.set_listener_position( listener_id, ( 0, 1.7, 0 ) )\n",
"va.set_listener_orientation_vu( listener_id, ( 0, 0, -1, ), ( 0, 1, 0 ) ) # Default view is to -Z (OpenGL)\n",
"va.set_listener_hrir( listener_id, hrir_id )"
"listener_id = va.create_sound_receiver( 'PyListener' )\n",
"va.set_sound_receiver_position( listener_id, ( 0, 1.7, 0 ) )\n",
"va.set_sound_receiver_orientation_vu( listener_id, ( 0, 0, -1, ), ( 0, 1, 0 ) ) # Default view is to -Z (OpenGL)\n",
"va.set_sound_receiver_directivity( listener_id, hrir_id )"
]
},
{
......@@ -208,12 +201,10 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"va.set_active_listener( listener_id )"
"va.set_active_sound_receiver( listener_id )"
]
},
{
......@@ -226,22 +217,11 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"va.disconnect();"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
......
......@@ -114,13 +114,13 @@ static struct PyMethodDef va_methods[] =
{ "get_rendering_modules", ( PyCFunction ) get_rendering_modules, METH_FASTCALL, no_doc },
{ "set_rendering_module_muted", ( PyCFunction ) set_rendering_module_muted, METH_FASTCALL, no_doc },
{ "is_rendering_module_muted", ( PyCFunction ) is_rendering_module_muted, METH_FASTCALL, no_doc },
{ "get_rendering_module_muted", ( PyCFunction ) get_rendering_module_muted, METH_FASTCALL, no_doc },
{ "set_rendering_module_gain", ( PyCFunction ) set_rendering_module_gain, METH_FASTCALL, no_doc },
{ "get_rendering_module_gain", ( PyCFunction ) get_rendering_module_gain, METH_FASTCALL, no_doc },
{ "get_reprodution_modules", ( PyCFunction ) get_reproduction_modules, METH_FASTCALL, no_doc },
{ "set_reprodution_module_muted", ( PyCFunction ) set_reproduction_module_muted, METH_FASTCALL, no_doc },
{ "is_reprodution_module_muted", ( PyCFunction ) is_reproduction_module_muted, METH_FASTCALL, no_doc },
{ "get_reprodution_module_muted", ( PyCFunction ) get_reproduction_module_muted, METH_FASTCALL, no_doc },
{ "set_reprodution_module_gain", ( PyCFunction ) set_reproduction_module_gain, METH_FASTCALL, no_doc },
{ "get_reprodution_module_gain", ( PyCFunction ) get_reproduction_module_gain, METH_FASTCALL, no_doc },
......@@ -131,11 +131,11 @@ static struct PyMethodDef va_methods[] =
{ "get_input_gain", ( PyCFunction ) get_input_gain, METH_FASTCALL, no_doc },
{ "set_input_gain", ( PyCFunction ) set_input_gain, METH_FASTCALL, no_doc },
{ "is_input_muted", ( PyCFunction ) is_input_muted, METH_FASTCALL, no_doc },
{ "get_input_muted", ( PyCFunction ) get_input_muted, METH_FASTCALL, no_doc },
{ "set_input_muted", ( PyCFunction ) set_input_muted, METH_FASTCALL, no_doc },
{ "get_output_gain", ( PyCFunction ) get_output_gain, METH_FASTCALL, no_doc },
{ "set_output_gain", ( PyCFunction ) set_output_gain, METH_FASTCALL, no_doc },
{ "is_output_muted", ( PyCFunction ) is_output_muted, METH_FASTCALL, no_doc },
{ "get_output_muted", ( PyCFunction ) get_output_muted, METH_FASTCALL, no_doc },
{ "set_output_muted", ( PyCFunction ) set_output_muted, METH_FASTCALL, no_doc },
{ "get_global_auralization_mode", ( PyCFunction ) get_global_auralization_mode, METH_FASTCALL, no_doc },
{ "set_global_auralization_mode", ( PyCFunction ) set_global_auralization_mode, METH_FASTCALL, no_doc },
......
......@@ -1819,12 +1819,12 @@ static PyObject* set_rendering_module_muted( PyObject*, PyObject** ppArgs, Py_ss
VAPY_CATCH_RETURN;
};
static PyObject* is_rendering_module_muted( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
static PyObject* get_rendering_module_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 = { "s:is_rendering_module_muted", _keywords, 0 };
static _PyArg_Parser _parser = { "s:get_rendering_module_muted", _keywords, 0 };
char* pcID = nullptr;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcID ) )
return NULL;
......@@ -1912,12 +1912,12 @@ static PyObject* set_reproduction_module_muted( PyObject*, PyObject** ppArgs, Py
VAPY_CATCH_RETURN;
};
static PyObject* is_reproduction_module_muted( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, PyObject* pKeywordNames )
static PyObject* get_reproduction_module_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 = { "s:is_reproduction_module_muted", _keywords, 0 };
static _PyArg_Parser _parser = { "s:get_reproduction_module_muted", _keywords, 0 };
char* pcID = nullptr;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcID ) )
return NULL;
......@@ -1967,7 +1967,7 @@ static PyObject* set_input_muted( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs
VAPY_CATCH_RETURN;
};
static PyObject* is_input_muted( PyObject*, PyObject* )
static PyObject* get_input_muted( PyObject*, PyObject* )
{
VAPY_REQUIRE_CONN_TRY;
return PyBool_FromLong( g_pVANetClient->GetCoreInstance()->GetInputMuted() );
......@@ -1991,7 +1991,7 @@ static PyObject* set_output_gain( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &dGain ) )
return NULL;
g_pVANetClient->GetCoreInstance()->SetInputGain( dGain );
g_pVANetClient->GetCoreInstance()->SetOutputGain( dGain );
return Py_None;
VAPY_CATCH_RETURN;
......@@ -2007,16 +2007,16 @@ static PyObject* set_output_muted( PyObject*, PyObject** ppArgs, Py_ssize_t nArg
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &bMuted ) )
return NULL;
g_pVANetClient->GetCoreInstance()->SetInputMuted( bMuted );
g_pVANetClient->GetCoreInstance()->SetOutputMuted( bMuted );
return Py_None;
VAPY_CATCH_RETURN;
};
static PyObject* is_output_muted( PyObject*, PyObject* )
static PyObject* get_output_muted( PyObject*, PyObject* )
{
VAPY_REQUIRE_CONN_TRY;
return PyBool_FromLong( g_pVANetClient->GetCoreInstance()->GetInputMuted() );
return PyBool_FromLong( g_pVANetClient->GetCoreInstance()->GetOutputMuted() );
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