Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
VAPython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Institute of Technical Acoustics (ITA)
VAPython
Commits
3233e7fa
Commit
3233e7fa
authored
Aug 29, 2017
by
Dipl.-Ing. Jonas Stienen
Browse files
Options
Downloads
Patches
Plain Diff
Fixing bugs in python binding methods
parent
924d22be
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/jupyter/va_scene_controller.ipynb
+191
-0
191 additions, 0 deletions
examples/jupyter/va_scene_controller.ipynb
src/vasingletonmethods.hpp
+8
-8
8 additions, 8 deletions
src/vasingletonmethods.hpp
with
199 additions
and
8 deletions
examples/jupyter/va_scene_controller.ipynb
0 → 100644
+
191
−
0
View file @
3233e7fa
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# VA scene controller\n",
"This is a simple example and utility notebook that demonstrates the use of scene control mechanisms."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Prerequisites\n",
"You can ignore this part, it is for preparation purposes only."
]
},
{
"cell_type": "code",
"execution_count": 168,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"sys.path.append( '../../Lib/site-packages' )\n",
"import ipywidgets as widgets\n",
"import va\n",
"if not va.connect() :\n",
" raise 'Could not connect to VA server on localhost'"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"### Listeners"
]
},
{
"cell_type": "code",
"execution_count": 181,
"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"
}
],
"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",
"\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",
"\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",
"\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",
"\n",
"listener_update_button = widgets.Button( description = 'Update' )\n",
"listener_update_button.on_click( on_listener_update )\n",
"\n",
"def on_listener_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",
" \n",
"listeners_dropdown_menu.observe( on_listener_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 )"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"### Sources"
]
},
{
"cell_type": "code",
"execution_count": 183,
"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"
}
],
"source": [
"sound_source_ids = va.get_sound_source_ids()\n",
"sound_sources_dict = {}\n",
"for source_id in sound_source_ids :\n",
" sound_sources_dict.update( { va.get_sound_source_name( source_id ) : source_id } )\n",
"\n",
"sound_sources_dropdown_menu = widgets.Dropdown( \n",
" options = sound_sources_dict,\n",
" description = 'Sound sources' )\n",
"if sound_source_ids :\n",
" first_sound_source_pos = va.get_sound_source_position( sound_source_ids[ 0 ] )\n",
"\n",
"def on_sound_source_update( w ) :\n",
" sound_source_id = sound_sources_dropdown_menu.value\n",
" if sound_source_id :\n",
" sound_source_pos = [ sound_source_input_pos_x.value, sound_source_input_pos_y.value, sound_source_input_pos_z.value ]\n",
" va.set_sound_source_position( sound_source_id, sound_source_pos )\n",
"\n",
"sound_source_input_pos_x = widgets.FloatText( description = 'X' )\n",
"sound_source_input_pos_y = widgets.FloatText( description = 'Y' )\n",
"sound_source_input_pos_z = widgets.FloatText( description = 'Z' )\n",
"\n",
"sound_source_update_button = widgets.Button( description = 'Update' )\n",
"sound_source_update_button.on_click( on_sound_source_update )\n",
"\n",
"def on_sound_source_select( d ) :\n",
" if d.type == 'change' and type( d.new ) is str :\n",
" sound_source_id = sound_sources_dropdown_menu.options[ d.new ] \n",
" sound_source_pos = va.get_sound_source_position( sound_source_id )\n",
" sound_source_input_pos_x.value = sound_source_pos[ 0 ]\n",
" sound_source_input_pos_y.value = sound_source_pos[ 1 ]\n",
" sound_source_input_pos_z.value = sound_source_pos[ 2 ]\n",
" \n",
"sound_sources_dropdown_menu.observe( on_sound_source_select )\n",
"\n",
"sound_source_input_widget_box = widgets.HBox( [ sound_sources_dropdown_menu, sound_source_input_pos_x, sound_source_input_pos_y, sound_source_input_pos_z, sound_source_update_button ] )\n",
"display( sound_source_input_widget_box )"
]
}
],
"metadata": {
"kernelspec": {
"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,
"nbformat_minor": 2
}
%% Cell type:markdown id: tags:
# VA scene controller
This is a simple example and utility notebook that demonstrates the use of scene control mechanisms.
%% Cell type:markdown id: tags:
### Prerequisites
You can ignore this part, it is for preparation purposes only.
%% Cell type:code id: tags:
```
python
import
sys
sys
.
path
.
append
(
'
../../Lib/site-packages
'
)
import
ipywidgets
as
widgets
import
va
if
not
va
.
connect
()
:
raise
'
Could not connect to VA server on localhost
'
```
%% Cell type:markdown id: tags:
### Listeners
%% Cell type:code id: tags:
```
python
listener_ids
=
va
.
get_listener_ids
()
listeners_dict
=
{}
for
listener_id
in
listener_ids
:
listeners_dict
.
update
(
{
va
.
get_listener_name
(
listener_id
)
:
listener_id
}
)
listeners_dropdown_menu
=
widgets
.
Dropdown
(
options
=
listeners_dict
,
description
=
'
Listeners
'
)
if
listener_ids
:
first_listener_pos
=
va
.
get_listener_position
(
listener_ids
[
0
]
)
def
on_listener_update
(
w
)
:
listener_id
=
listeners_dropdown_menu
.
value
if
listener_id
:
listener_pos
=
[
listeners_input_pos_x
.
value
,
listeners_input_pos_y
.
value
,
listeners_input_pos_z
.
value
]
va
.
set_listener_position
(
listener_id
,
listener_pos
)
listeners_input_pos_x
=
widgets
.
FloatText
(
description
=
'
X
'
)
listeners_input_pos_y
=
widgets
.
FloatText
(
description
=
'
Y
'
)
listeners_input_pos_z
=
widgets
.
FloatText
(
description
=
'
Z
'
)
listener_update_button
=
widgets
.
Button
(
description
=
'
Update
'
)
listener_update_button
.
on_click
(
on_listener_update
)
def
on_listener_select
(
d
)
:
if
d
.
type
==
'
change
'
and
type
(
d
.
new
)
is
str
:
listener_id
=
listeners_dropdown_menu
.
options
[
d
.
new
]
listener_pos
=
va
.
get_listener_position
(
listener_id
)
listeners_input_pos_x
.
value
=
listener_pos
[
0
]
listeners_input_pos_y
.
value
=
listener_pos
[
1
]
listeners_input_pos_z
.
value
=
listener_pos
[
2
]
listeners_dropdown_menu
.
observe
(
on_listener_select
)
listeners_input_widget_box
=
widgets
.
HBox
(
[
listeners_dropdown_menu
,
listeners_input_pos_x
,
listeners_input_pos_y
,
listeners_input_pos_z
,
listener_update_button
]
)
display
(
listeners_input_widget_box
)
```
%% Output
%% Cell type:markdown id: tags:
### Sources
%% Cell type:code id: tags:
```
python
sound_source_ids
=
va
.
get_sound_source_ids
()
sound_sources_dict
=
{}
for
source_id
in
sound_source_ids
:
sound_sources_dict
.
update
(
{
va
.
get_sound_source_name
(
source_id
)
:
source_id
}
)
sound_sources_dropdown_menu
=
widgets
.
Dropdown
(
options
=
sound_sources_dict
,
description
=
'
Sound sources
'
)
if
sound_source_ids
:
first_sound_source_pos
=
va
.
get_sound_source_position
(
sound_source_ids
[
0
]
)
def
on_sound_source_update
(
w
)
:
sound_source_id
=
sound_sources_dropdown_menu
.
value
if
sound_source_id
:
sound_source_pos
=
[
sound_source_input_pos_x
.
value
,
sound_source_input_pos_y
.
value
,
sound_source_input_pos_z
.
value
]
va
.
set_sound_source_position
(
sound_source_id
,
sound_source_pos
)
sound_source_input_pos_x
=
widgets
.
FloatText
(
description
=
'
X
'
)
sound_source_input_pos_y
=
widgets
.
FloatText
(
description
=
'
Y
'
)
sound_source_input_pos_z
=
widgets
.
FloatText
(
description
=
'
Z
'
)
sound_source_update_button
=
widgets
.
Button
(
description
=
'
Update
'
)
sound_source_update_button
.
on_click
(
on_sound_source_update
)
def
on_sound_source_select
(
d
)
:
if
d
.
type
==
'
change
'
and
type
(
d
.
new
)
is
str
:
sound_source_id
=
sound_sources_dropdown_menu
.
options
[
d
.
new
]
sound_source_pos
=
va
.
get_sound_source_position
(
sound_source_id
)
sound_source_input_pos_x
.
value
=
sound_source_pos
[
0
]
sound_source_input_pos_y
.
value
=
sound_source_pos
[
1
]
sound_source_input_pos_z
.
value
=
sound_source_pos
[
2
]
sound_sources_dropdown_menu
.
observe
(
on_sound_source_select
)
sound_source_input_widget_box
=
widgets
.
HBox
(
[
sound_sources_dropdown_menu
,
sound_source_input_pos_x
,
sound_source_input_pos_y
,
sound_source_input_pos_z
,
sound_source_update_button
]
)
display
(
sound_source_input_widget_box
)
```
%% Output
This diff is collapsed.
Click to expand it.
src/vasingletonmethods.hpp
+
8
−
8
View file @
3233e7fa
...
...
@@ -26,10 +26,10 @@ static PyObject* va_not_implemented( PyObject*, PyObject* )
static
void
RequireCoreAvailable
()
{
if
(
!
g_pVANetClient
)
VA_EXCEPT2
(
CVAException
::
NETWORK_ERROR
,
"VA client not available, please connect first"
);
VA_EXCEPT2
(
NETWORK_ERROR
,
"VA client not available, please connect first"
);
if
(
!
g_pVANetClient
->
GetCoreInstance
()
)
VA_EXCEPT2
(
CVAException
::
NETWORK_ERROR
,
"VA client available, but access to VA interface failed. Please reconnect."
);
VA_EXCEPT2
(
NETWORK_ERROR
,
"VA client available, but access to VA interface failed. Please reconnect."
);
};
std
::
string
SaveStringToUnicodeConversion
(
const
std
::
string
&
sInputString
)
...
...
@@ -112,7 +112,7 @@ CVAStruct ConvertPythonDictToVAStruct( PyObject* pInDict )
PyObject
*
pValue
=
PyList_GetItem
(
pValueList
,
i
);
char
*
pcKeyName
=
nullptr
;
if
(
!
PyArg_Parse
(
pKey
,
"s"
,
&
pcKeyName
)
)
VA_EXCEPT2
(
CVAException
::
INVALID_PARAMETER
,
"Invalid key '"
+
std
::
string
(
pcKeyName
)
+
"'"
);
VA_EXCEPT2
(
INVALID_PARAMETER
,
"Invalid key '"
+
std
::
string
(
pcKeyName
)
+
"'"
);
if
(
Py_None
==
pValue
)
{
...
...
@@ -134,7 +134,7 @@ CVAStruct ConvertPythonDictToVAStruct( PyObject* pInDict )
{
char
*
pcStringValue
=
nullptr
;
if
(
!
PyArg_Parse
(
pValue
,
"s"
,
&
pcStringValue
)
)
VA_EXCEPT2
(
CVAException
::
INVALID_PARAMETER
,
"Invalid string value at key '"
+
std
::
string
(
pcKeyName
)
+
"': "
+
std
::
string
(
pcStringValue
)
);
VA_EXCEPT2
(
INVALID_PARAMETER
,
"Invalid string value at key '"
+
std
::
string
(
pcKeyName
)
+
"': "
+
std
::
string
(
pcStringValue
)
);
oReturn
[
pcKeyName
]
=
std
::
string
(
pcStringValue
);
}
else
if
(
PyDict_Check
(
pValue
)
)
...
...
@@ -1854,7 +1854,7 @@ static PyObject* va_get_rendering_modules( PyObject*, PyObject* )
for
(
size_t
i
=
0
;
i
<
voInfos
.
size
();
i
++
)
{
CVAAudioRendererInfo
&
oInfo
(
voInfos
[
i
]
);
PyObject
*
pInfo
=
Py_BuildValue
(
"{s:b,s:s,s:s}"
,
PyObject
*
pInfo
=
Py_BuildValue
(
"{s:b,s:s,
s:s,
s:s}"
,
"enabled"
,
oInfo
.
bEnabled
,
"class"
,
SaveStringToUnicodeConversion
(
oInfo
.
sClass
).
c_str
(),
"description"
,
SaveStringToUnicodeConversion
(
oInfo
.
sDescription
).
c_str
(),
...
...
@@ -1906,7 +1906,7 @@ static PyObject* va_set_rendering_module_muted( PyObject*, PyObject** ppArgs, Py
VAPY_REQUIRE_CONN_TRY
;
static
const
char
*
const
_keywords
[]
=
{
"id"
,
"muted"
,
NULL
};
static
_PyArg_Parser
_parser
=
{
"
i
|b:set_rendering_module_muted"
,
_keywords
,
0
};
static
_PyArg_Parser
_parser
=
{
"
s
|b:set_rendering_module_muted"
,
_keywords
,
0
};
char
*
pcID
=
nullptr
;
bool
bMuted
=
true
;
if
(
!
_PyArg_ParseStack
(
ppArgs
,
nArgs
,
pKeywordNames
,
&
_parser
,
&
pcID
,
&
bMuted
)
)
...
...
@@ -1947,7 +1947,7 @@ static PyObject* va_get_reproduction_modules( PyObject*, PyObject* )
for
(
size_t
i
=
0
;
i
<
voInfos
.
size
();
i
++
)
{
CVAAudioReproductionInfo
&
oInfo
(
voInfos
[
i
]
);
PyObject
*
pInfo
=
Py_BuildValue
(
"{s:b,s:s,s:s}"
,
PyObject
*
pInfo
=
Py_BuildValue
(
"{s:b,s:s,s:s
,s:s
}"
,
"enabled"
,
oInfo
.
bEnabled
,
"class"
,
SaveStringToUnicodeConversion
(
oInfo
.
sClass
).
c_str
(),
"description"
,
SaveStringToUnicodeConversion
(
oInfo
.
sDescription
).
c_str
(),
...
...
@@ -1999,7 +1999,7 @@ static PyObject* va_set_reproduction_module_muted( PyObject*, PyObject** ppArgs,
VAPY_REQUIRE_CONN_TRY
;
static
const
char
*
const
_keywords
[]
=
{
"id"
,
"muted"
,
NULL
};
static
_PyArg_Parser
_parser
=
{
"
i
|b:set_reproduction_module_muted"
,
_keywords
,
0
};
static
_PyArg_Parser
_parser
=
{
"
s
|b:set_reproduction_module_muted"
,
_keywords
,
0
};
char
*
pcID
=
nullptr
;
bool
bMuted
=
true
;
if
(
!
_PyArg_ParseStack
(
ppArgs
,
nArgs
,
pKeywordNames
,
&
_parser
,
&
pcID
,
&
bMuted
)
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment