Fixes and more jupyter examples

parent 49be549b
......@@ -103,22 +103,19 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "878c6d78501a48f0916f2488a270ac8a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"A Jupyter Widget"
]
},
"metadata": {},
"output_type": "display_data"
"ename": "NameError",
"evalue": "name 'widgets' is not defined",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-1-d87da51b8000>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m output_gain_slider = widgets.FloatSlider( \n\u001b[0m\u001b[0;32m 2\u001b[0m \u001b[0mvalue\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mva\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_output_gain\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[0mdescription\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'Output gain:'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[0mmin\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m0.0\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[0mmax\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m1.0\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mNameError\u001b[0m: name 'widgets' is not defined"
]
}
],
"source": [
......
......@@ -21,27 +21,27 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Connected.\n"
"Successfully connected, server core version is: VACore v2017.d (debug)\n"
]
}
],
"source": [
"import sys\n",
"sys.path.append( '../../Lib/site-packages' )\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",
" raise 'Could not connect to local VA server'\n",
"else :\n",
" print( 'Connected.' )\n",
"va.reset()"
" print( 'Successfully connected, server core version is: ' + va.get_version() )"
]
},
{
......@@ -57,22 +57,22 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"PrototypeGenericPath:Experimental\n"
"Experimental\n"
]
}
],
"source": [
"for rmod in va.get_rendering_modules() :\n",
" if rmod['class'] == 'PrototypeGenericPath' :\n",
" print( rmod['class'] + ':' + rmod['id'] )\n",
"rmod_name = 'PrototypeGenericPath:Experimental' # alter this if you are using a different name"
" print( rmod['id'] )\n",
"rmod_name = 'Experimental' # alter this if you are using a different name"
]
},
{
......@@ -85,14 +85,14 @@
},
{
"cell_type": "code",
"execution_count": 120,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"\n",
" --- GenericPath renderer instance 'PrototypeGenericPath:Experimental' ---\n",
" --- GenericPath renderer instance 'Experimental' ---\n",
"\n",
"[help]\n",
"If the call module struct contains a key with the name 'help', this help text will be shown and the return struct will be returned with the key name 'help'.\n",
......@@ -101,11 +101,11 @@
"If the call module struct contains a key with the name 'info', information on the static configuration of the renderer will be returned.\n",
"\n",
"[update]\n",
"For every successful path update, the VA source and listener ID has to be passed like this:\n",
" listener: <int>, the number of the listener identifier\n",
"For every successful path update, the VA source and sound receiver ID has to be passed like this:\n",
" receiver: <int>, the number of the sound receiver identifier\n",
" source: <int>, the number of the source identifier\n",
"\n",
"Updating the path filter (impulse response in time domain) for a listener and a source can be performed in two ways:\n",
"Updating the path filter (impulse response in time domain) for a sound receiver and a source can be performed in two ways:\n",
" a) using a path to a multi-channel WAV file:\n",
" Provide a key with the name 'filepath' and the path to the WAV file (absolute or containing the macro '$(VADataDir)' or relative to the executable) [priority given to 'filepath' if b) also applies]\n",
" b) sending floating-point data for each channel\n",
......@@ -122,7 +122,8 @@
}
],
"source": [
"rmod_generic_info = va.call_module( rmod_name, {} )\n",
"rmod_generic_info = va.get_rendering_module_parameters( rmod_name )\n",
"\n",
"from IPython.display import Markdown, display\n",
"display( Markdown( rmod_generic_info[ 'help' ] ) )"
]
......@@ -136,7 +137,7 @@
},
{
"cell_type": "code",
"execution_count": 45,
"execution_count": 4,
"metadata": {},
"outputs": [
{
......@@ -148,13 +149,13 @@
" 'numpaths': 0}"
]
},
"execution_count": 45,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"va.call_module( rmod_name, { 'info' : True } )"
"va.get_rendering_module_parameters( rmod_name, { 'info' : True } )"
]
},
{
......@@ -163,19 +164,21 @@
"source": [
"### Input data preparation\n",
"Let us quickly set up a virtual scene using input data from the Internet.\n",
"Download for example anechoic recordings directly from [here](http://www.openairlib.net/sites/default/files/anechoic/data/judebrereton/modern-clarinet-bb/mono/cl-mod-bb-piece-32.wav) and a binaural impulse response from [here](http://www.openairlib.net/sites/default/files/auralization/data/audiolab/lady-chapel-st-albans-cathedral/stereo/stalbans_a_binaural.wav). Either add the download folder as search path, or put the files where VA can find it."
"Download for example anechoic recordings directly from [here](http://www.openairlib.net/sites/default/files/anechoic/data/judebrereton/modern-clarinet-bb/mono/cl-mod-bb-piece-32.wav) and a binaural impulse response from [here](http://www.openairlib.net/sites/default/files/auralization/data/audiolab/lady-chapel-st-albans-cathedral/stereo/stalbans_a_binaural.wav). Either add the download folder as search path, or put the files where VA can find it (e.g. in the `data` folder)."
]
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"va.add_search_path( 'C:/Users/jonas/Downloads' )\n",
"signal_source_id = va.create_audio_file_signal_source( 'cl-mod-bb-piece-32.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 )"
"va.add_search_path( '../../../VACore/data' )\n",
"va.add_search_path( 'C:\\dev\\VA\\VACore\\data' )\n",
"\n",
"signal_source_id = va.create_signal_source_buffer_from_file( 'cl-mod-bb-piece-32.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 )"
]
},
{
......@@ -188,7 +191,7 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": 6,
"metadata": {},
"outputs": [
{
......@@ -204,7 +207,7 @@
"sound_source_id = va.create_sound_source( 'PyExperimentalSoundSource' )\n",
"print( 'Experimental sound source id: ' + str( sound_source_id ) )\n",
"va.set_sound_source_signal_source( sound_source_id, signal_source_id )\n",
"listener_id = va.create_listener( 'PyExperimentalListener' )\n",
"receiver_id = va.create_sound_receiver( 'PyExperimentalListener' )\n",
"print( 'Experimental listener id: ' + str( sound_source_id ) )"
]
},
......@@ -220,20 +223,20 @@
},
{
"cell_type": "code",
"execution_count": 134,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'listener': 1, 'source': 1, 'ch1': [0.9, 0.0, 0.0, 0.0], 'ch2': [0.0, 0.0, -0.4, 0.0], 'verbose': True}\n"
"{'receiver': 1, 'source': 1, 'ch1': [0.9, 0.0, 0.0, 0.0], 'ch2': [0.0, 0.0, -0.4, 0.0], 'verbose': True}\n"
]
}
],
"source": [
"update_dirac = dict()\n",
"update_dirac[ 'listener' ] = listener_id\n",
"update_dirac[ 'receiver' ] = receiver_id\n",
"update_dirac[ 'source' ] = sound_source_id\n",
"update_dirac[ 'ch1' ] = [ 0.9, 0.0, 0.0, 0.0 ] # Length of samples is arbitrary, here\n",
"update_dirac[ 'ch2' ] = [ 0.0, 0.0, -0.4, 0.0 ] # Length of samples is arbitrary, here\n",
......@@ -250,22 +253,11 @@
},
{
"cell_type": "code",
"execution_count": 135,
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Updated sound path <L1, S1, C1> with 4 new samples\n",
"Updated sound path <L1, S1, C2> with 4 new samples\n"
]
}
],
"outputs": [],
"source": [
"msg = va.call_module( rmod_name, update_dirac )\n",
"print( msg[ 'info_ch1' ] )\n",
"print( msg[ 'info_ch2' ] )"
"va.set_rendering_module_parameters( rmod_name, update_dirac )"
]
},
{
......@@ -279,20 +271,20 @@
},
{
"cell_type": "code",
"execution_count": 125,
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'listener': 1, 'source': 1, 'filepath': 'stalbans_a_binaural.wav', 'verbose': True}\n"
"{'receiver': 1, 'source': 1, 'filepath': 'stalbans_a_binaural.wav', 'verbose': True}\n"
]
}
],
"source": [
"update_filepath = dict()\n",
"update_filepath[ 'listener' ] = listener_id\n",
"update_filepath[ 'receiver' ] = receiver_id\n",
"update_filepath[ 'source' ] = sound_source_id\n",
"update_filepath[ 'filepath' ] = 'stalbans_a_binaural.wav'\n",
"#update_filepath[ 'channel' ] = 2 # ... in case you explicitly want to update a single channel with a mono IR file\n",
......@@ -302,20 +294,11 @@
},
{
"cell_type": "code",
"execution_count": 136,
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Updated sound path <L1, S1> using (unrolled) file path 'C:\\Users\\jonas\\Downloads\\stalbans_a_binaural.wav'\n"
]
}
],
"outputs": [],
"source": [
"msg = va.call_module( rmod_name, update_filepath )\n",
"print( msg[ 'info' ] )"
"va.set_rendering_module_parameters( rmod_name, update_filepath )"
]
},
{
......@@ -330,7 +313,7 @@
},
{
"cell_type": "code",
"execution_count": 47,
"execution_count": 18,
"metadata": {},
"outputs": [
{
......@@ -366,29 +349,25 @@
},
{
"cell_type": "code",
"execution_count": 48,
"execution_count": 19,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Updated sound path <L1, S1, C1> with 88200 new samples\n",
"Updated sound path <L1, S1, C2> with 88200 new samples\n"
]
}
],
"outputs": [],
"source": [
"update_ir = dict()\n",
"update_ir[ 'listener' ] = listener_id\n",
"update_ir[ 'receiver' ] = receiver_id\n",
"update_ir[ 'source' ] = sound_source_id\n",
"update_ir[ 'ch1' ] = ir[ 0 ]; # Requires ir samples to be floating point, so sample type conversion might be required\n",
"update_ir[ 'ch2' ] = ir[ 1 ]; # Requires ir samples to be floating point, so sample type conversion might be required\n",
"update_ir[ 'verbose' ] = True;\n",
"\n",
"msg = va.call_module( rmod_name, update_ir )\n",
"print( msg[ 'info_ch1'] )\n",
"print( msg[ 'info_ch2'] )"
"update_ir[ 'verbose' ] = True;"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"va.set_rendering_module_parameters( rmod_name, update_ir )"
]
}
],
......@@ -397,6 +376,18 @@
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.2"
}
},
"nbformat": 4,
......
......@@ -318,7 +318,7 @@ static PyObject* call_module( PyObject*, PyObject** ppArgs, Py_ssize_t nArgs, Py
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcModuleName, &PyDict_Type, &pArgumentsDict ) )
return NULL;
std::string sModuleName = std::string( pcModuleName );
std::string sModuleName = pcModuleName? std::string( pcModuleName ) : "";
CVAStruct oInArgs = ConvertPythonDictToVAStruct( pArgumentsDict );
CVAStruct oOutArgs = g_pVANetClient->GetCoreInstance()->CallModule( sModuleName, oInArgs );
......@@ -2160,11 +2160,11 @@ static PyObject* get_rendering_module_parameters( PyObject*, PyObject** ppArgs,
{
VAPY_REQUIRE_CONN_TRY;
static const char * const _keywords[] = { "id", "arguments", NULL };
static const char * const _keywords[] = { "renderer_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 ) )
PyObject* pArgs = nullptr;
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcID, &PyDict_Type, &pArgs ) )
return NULL;
std::string sID = pcID ? std::string( pcID ) : "";
......@@ -2184,7 +2184,7 @@ static PyObject* set_rendering_module_parameters( PyObject*, PyObject** ppArgs,
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 ) )
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcID, &PyDict_Type, &pParams ) )
return NULL;
std::string sID = pcID ? std::string( pcID ) : "";
......@@ -2297,7 +2297,7 @@ static PyObject* get_reproduction_module_parameters( PyObject*, PyObject** ppArg
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 ) )
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcID, &PyDict_Type, &pArgs ) )
return NULL;
std::string sID = pcID ? std::string( pcID ) : "";
......@@ -2317,7 +2317,7 @@ static PyObject* set_reproduction_module_parameters( PyObject*, PyObject** ppArg
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 ) )
if( !_PyArg_ParseStack( ppArgs, nArgs, pKeywordNames, &_parser, &pcID, &PyDict_Type, &pParams ) )
return NULL;
std::string sID = pcID ? std::string( pcID ) : "";
......
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