Skip to content
Snippets Groups Projects
Commit a0caf1f3 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Fixing little bug in scene controller jupyter notebook example

parent ff88f8ae
No related branches found
No related tags found
No related merge requests found
%% 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' )
sys.path.append( '../../dist/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:
### Sound receiver
%% Cell type:code id: tags:
``` python
sound_receiver_ids = va.get_sound_receiver_ids()
sound_receivers_dict = {}
for sound_receiver_id in sound_receiver_ids :
sound_receivers_dict.update( { va.get_sound_receiver_name( sound_receiver_id ) : sound_receiver_id } )
sound_receiver_dropdown_menu = widgets.Dropdown(
sound_receivers_dropdown_menu = widgets.Dropdown(
options = sound_receivers_dict,
description = 'Sound receivers' )
if sound_receiver_ids :
first_sound_receiver_pos = va.get_sound_receiver_position( sound_receiver_ids[ 0 ] )
def on_sound_receiver_update( w ) :
sound_receiver_id = sound_receivers_dropdown_menu.value
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 ]
va.set_sound_receiver_position( sound_receiver_id, sound_receiver_pos )
sound_receivers_input_pos_x = widgets.FloatText( description = 'X' )
sound_receivers_input_pos_y = widgets.FloatText( description = 'Y' )
sound_receivers_input_pos_z = widgets.FloatText( description = 'Z' )
sound_receiver_update_button = widgets.Button( description = 'Update' )
sound_receiver_update_button.on_click( on_sound_receiver_update )
def on_sound_receiver_select( d ) :
if d.type == 'change' and type( d.new ) is str :
sound_receiver_id = sound_receivers_dropdown_menu.options[ d.new ]
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_y.value = sound_receiver_pos[ 1 ]
sound_receivers_input_pos_z.value = sound_receiver_pos[ 2 ]
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 ] )
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:
### 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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment