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
a0caf1f3
Commit
a0caf1f3
authored
7 years ago
by
Dipl.-Ing. Jonas Stienen
Browse files
Options
Downloads
Patches
Plain Diff
Fixing little bug in scene controller jupyter notebook example
parent
ff88f8ae
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/jupyter/va_scene_controller.ipynb
+32
-5
32 additions, 5 deletions
examples/jupyter/va_scene_controller.ipynb
with
32 additions
and
5 deletions
examples/jupyter/va_scene_controller.ipynb
+
32
−
5
View file @
a0caf1f3
...
@@ -42,16 +42,28 @@
...
@@ -42,16 +42,28 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
null
,
"execution_count":
2
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "Exception",
"evalue": "Not implemented (error code 8)",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mException\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-2-28e67d0dde0f>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 8\u001b[0m description = 'Sound receivers' )\n\u001b[0;32m 9\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0msound_receiver_ids\u001b[0m \u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 10\u001b[1;33m \u001b[0mfirst_sound_receiver_pos\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mva\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_sound_receiver_position\u001b[0m\u001b[1;33m(\u001b[0m \u001b[0msound_receiver_ids\u001b[0m\u001b[1;33m[\u001b[0m \u001b[1;36m0\u001b[0m \u001b[1;33m]\u001b[0m \u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 11\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 12\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mon_sound_receiver_update\u001b[0m\u001b[1;33m(\u001b[0m \u001b[0mw\u001b[0m \u001b[1;33m)\u001b[0m \u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mException\u001b[0m: Not implemented (error code 8)"
]
}
],
"source": [
"source": [
"sound_receiver_ids = va.get_sound_receiver_ids()\n",
"sound_receiver_ids = va.get_sound_receiver_ids()\n",
"sound_receivers_dict = {}\n",
"sound_receivers_dict = {}\n",
"for sound_receiver_id in sound_receiver_ids :\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",
" sound_receivers_dict.update( { va.get_sound_receiver_name( sound_receiver_id ) : sound_receiver_id } )\n",
"\n",
"\n",
"sound_receiver_dropdown_menu = widgets.Dropdown( \n",
"sound_receiver
s
_dropdown_menu = widgets.Dropdown( \n",
" options = sound_receivers_dict,\n",
" options = sound_receivers_dict,\n",
" description = 'Sound receivers' )\n",
" description = 'Sound receivers' )\n",
"if sound_receiver_ids :\n",
"if sound_receiver_ids :\n",
...
@@ -95,9 +107,24 @@
...
@@ -95,9 +107,24 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
null
,
"execution_count":
3
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "87f1cda6f53e44bbb8eb4e0af40b3b5b",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"A Jupyter Widget"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"source": [
"sound_source_ids = va.get_sound_source_ids()\n",
"sound_source_ids = va.get_sound_source_ids()\n",
"sound_sources_dict = {}\n",
"sound_sources_dict = {}\n",
...
...
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
# VA scene controller
# VA scene controller
This is a simple example and utility notebook that demonstrates the use of scene control mechanisms.
This is a simple example and utility notebook that demonstrates the use of scene control mechanisms.
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
### Prerequisites
### Prerequisites
You can ignore this part, it is for preparation purposes only.
You can ignore this part, it is for preparation purposes only.
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
import
sys
import
sys
sys
.
path
.
append
(
'
../../Lib/site-packages
'
)
sys
.
path
.
append
(
'
../../Lib/site-packages
'
)
sys
.
path
.
append
(
'
../../dist/Lib/site-packages
'
)
sys
.
path
.
append
(
'
../../dist/Lib/site-packages
'
)
import
ipywidgets
as
widgets
import
ipywidgets
as
widgets
import
va
import
va
if
not
va
.
connect
()
:
if
not
va
.
connect
()
:
raise
'
Could not connect to VA server on localhost
'
raise
'
Could not connect to VA server on localhost
'
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
### Sound receiver
### Sound receiver
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
sound_receiver_ids
=
va
.
get_sound_receiver_ids
()
sound_receiver_ids
=
va
.
get_sound_receiver_ids
()
sound_receivers_dict
=
{}
sound_receivers_dict
=
{}
for
sound_receiver_id
in
sound_receiver_ids
:
for
sound_receiver_id
in
sound_receiver_ids
:
sound_receivers_dict
.
update
(
{
va
.
get_sound_receiver_name
(
sound_receiver_id
)
:
sound_receiver_id
}
)
sound_receivers_dict
.
update
(
{
va
.
get_sound_receiver_name
(
sound_receiver_id
)
:
sound_receiver_id
}
)
sound_receiver_dropdown_menu
=
widgets
.
Dropdown
(
sound_receiver
s
_dropdown_menu
=
widgets
.
Dropdown
(
options
=
sound_receivers_dict
,
options
=
sound_receivers_dict
,
description
=
'
Sound receivers
'
)
description
=
'
Sound receivers
'
)
if
sound_receiver_ids
:
if
sound_receiver_ids
:
first_sound_receiver_pos
=
va
.
get_sound_receiver_position
(
sound_receiver_ids
[
0
]
)
first_sound_receiver_pos
=
va
.
get_sound_receiver_position
(
sound_receiver_ids
[
0
]
)
def
on_sound_receiver_update
(
w
)
:
def
on_sound_receiver_update
(
w
)
:
sound_receiver_id
=
sound_receivers_dropdown_menu
.
value
sound_receiver_id
=
sound_receivers_dropdown_menu
.
value
if
sound_receiver_id
:
if
sound_receiver_id
:
sound_receiver_pos
=
[
sound_receivers_input_pos_x
.
value
,
sound_receivers_input_pos_y
.
value
,
sound_receivers_input_pos_z
.
value
]
sound_receiver_pos
=
[
sound_receivers_input_pos_x
.
value
,
sound_receivers_input_pos_y
.
value
,
sound_receivers_input_pos_z
.
value
]
va
.
set_sound_receiver_position
(
sound_receiver_id
,
sound_receiver_pos
)
va
.
set_sound_receiver_position
(
sound_receiver_id
,
sound_receiver_pos
)
sound_receivers_input_pos_x
=
widgets
.
FloatText
(
description
=
'
X
'
)
sound_receivers_input_pos_x
=
widgets
.
FloatText
(
description
=
'
X
'
)
sound_receivers_input_pos_y
=
widgets
.
FloatText
(
description
=
'
Y
'
)
sound_receivers_input_pos_y
=
widgets
.
FloatText
(
description
=
'
Y
'
)
sound_receivers_input_pos_z
=
widgets
.
FloatText
(
description
=
'
Z
'
)
sound_receivers_input_pos_z
=
widgets
.
FloatText
(
description
=
'
Z
'
)
sound_receiver_update_button
=
widgets
.
Button
(
description
=
'
Update
'
)
sound_receiver_update_button
=
widgets
.
Button
(
description
=
'
Update
'
)
sound_receiver_update_button
.
on_click
(
on_sound_receiver_update
)
sound_receiver_update_button
.
on_click
(
on_sound_receiver_update
)
def
on_sound_receiver_select
(
d
)
:
def
on_sound_receiver_select
(
d
)
:
if
d
.
type
==
'
change
'
and
type
(
d
.
new
)
is
str
:
if
d
.
type
==
'
change
'
and
type
(
d
.
new
)
is
str
:
sound_receiver_id
=
sound_receivers_dropdown_menu
.
options
[
d
.
new
]
sound_receiver_id
=
sound_receivers_dropdown_menu
.
options
[
d
.
new
]
sound_receiver_pos
=
va
.
get_sound_receiver_position
(
sound_receiver_id
)
sound_receiver_pos
=
va
.
get_sound_receiver_position
(
sound_receiver_id
)
sound_receivers_input_pos_x
.
value
=
sound_receiver_pos
[
0
]
sound_receivers_input_pos_x
.
value
=
sound_receiver_pos
[
0
]
sound_receivers_input_pos_y
.
value
=
sound_receiver_pos
[
1
]
sound_receivers_input_pos_y
.
value
=
sound_receiver_pos
[
1
]
sound_receivers_input_pos_z
.
value
=
sound_receiver_pos
[
2
]
sound_receivers_input_pos_z
.
value
=
sound_receiver_pos
[
2
]
sound_receivers_dropdown_menu
.
observe
(
on_sound_receiver_select
)
sound_receivers_dropdown_menu
.
observe
(
on_sound_receiver_select
)
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
]
)
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
]
)
display
(
sound_receivers_input_widget_box
)
display
(
sound_receivers_input_widget_box
)
```
```
%% Output
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
<ipython-input-2-28e67d0dde0f> in <module>()
8 description = 'Sound receivers' )
9 if sound_receiver_ids :
---> 10 first_sound_receiver_pos = va.get_sound_receiver_position( sound_receiver_ids[ 0 ] )
11
12 def on_sound_receiver_update( w ) :
Exception: Not implemented (error code 8)
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
### Sources
### Sources
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
sound_source_ids
=
va
.
get_sound_source_ids
()
sound_source_ids
=
va
.
get_sound_source_ids
()
sound_sources_dict
=
{}
sound_sources_dict
=
{}
for
source_id
in
sound_source_ids
:
for
source_id
in
sound_source_ids
:
sound_sources_dict
.
update
(
{
va
.
get_sound_source_name
(
source_id
)
:
source_id
}
)
sound_sources_dict
.
update
(
{
va
.
get_sound_source_name
(
source_id
)
:
source_id
}
)
sound_sources_dropdown_menu
=
widgets
.
Dropdown
(
sound_sources_dropdown_menu
=
widgets
.
Dropdown
(
options
=
sound_sources_dict
,
options
=
sound_sources_dict
,
description
=
'
Sound sources
'
)
description
=
'
Sound sources
'
)
if
sound_source_ids
:
if
sound_source_ids
:
first_sound_source_pos
=
va
.
get_sound_source_position
(
sound_source_ids
[
0
]
)
first_sound_source_pos
=
va
.
get_sound_source_position
(
sound_source_ids
[
0
]
)
def
on_sound_source_update
(
w
)
:
def
on_sound_source_update
(
w
)
:
sound_source_id
=
sound_sources_dropdown_menu
.
value
sound_source_id
=
sound_sources_dropdown_menu
.
value
if
sound_source_id
:
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
]
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
)
va
.
set_sound_source_position
(
sound_source_id
,
sound_source_pos
)
sound_source_input_pos_x
=
widgets
.
FloatText
(
description
=
'
X
'
)
sound_source_input_pos_x
=
widgets
.
FloatText
(
description
=
'
X
'
)
sound_source_input_pos_y
=
widgets
.
FloatText
(
description
=
'
Y
'
)
sound_source_input_pos_y
=
widgets
.
FloatText
(
description
=
'
Y
'
)
sound_source_input_pos_z
=
widgets
.
FloatText
(
description
=
'
Z
'
)
sound_source_input_pos_z
=
widgets
.
FloatText
(
description
=
'
Z
'
)
sound_source_update_button
=
widgets
.
Button
(
description
=
'
Update
'
)
sound_source_update_button
=
widgets
.
Button
(
description
=
'
Update
'
)
sound_source_update_button
.
on_click
(
on_sound_source_update
)
sound_source_update_button
.
on_click
(
on_sound_source_update
)
def
on_sound_source_select
(
d
)
:
def
on_sound_source_select
(
d
)
:
if
d
.
type
==
'
change
'
and
type
(
d
.
new
)
is
str
:
if
d
.
type
==
'
change
'
and
type
(
d
.
new
)
is
str
:
sound_source_id
=
sound_sources_dropdown_menu
.
options
[
d
.
new
]
sound_source_id
=
sound_sources_dropdown_menu
.
options
[
d
.
new
]
sound_source_pos
=
va
.
get_sound_source_position
(
sound_source_id
)
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_x
.
value
=
sound_source_pos
[
0
]
sound_source_input_pos_y
.
value
=
sound_source_pos
[
1
]
sound_source_input_pos_y
.
value
=
sound_source_pos
[
1
]
sound_source_input_pos_z
.
value
=
sound_source_pos
[
2
]
sound_source_input_pos_z
.
value
=
sound_source_pos
[
2
]
sound_sources_dropdown_menu
.
observe
(
on_sound_source_select
)
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
]
)
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
)
display
(
sound_source_input_widget_box
)
```
```
%% Output
...
...
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