Skip to content

Commit

Permalink
Add refresh button which updates sound device list (#3387)
Browse files Browse the repository at this point in the history
* Add refresh button which updates sound device list

* Update changelog
  • Loading branch information
javerbukh authored Jan 13, 2025
1 parent 1ad5fb0 commit 2084d96
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ New Features
Cubeviz
^^^^^^^

- Enhancements for the cube sonification plugin. [#3387]

Imviz
^^^^^

Expand Down
15 changes: 11 additions & 4 deletions jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ def __init__(self, *args, **kwargs):
' works on devices with valid sound output.')

else:
devices, indexes = self.build_device_lists()
self.sound_device_indexes = dict(zip(devices, indexes))
self.sound_devices_items = devices
self.sound_devices_selected = dict(zip(indexes, devices))[sd.default.device[1]]
self.sound_device_indexes = None
self.refresh_device_list()

# TODO: Remove hardcoded range and flux viewer
self.spec_viewer = self.app.get_viewer('spectrum-viewer')
Expand Down Expand Up @@ -118,6 +116,15 @@ def update_sound_device(self, event):
didx = dict(zip(*self.build_device_lists()))[event['new']]
self.flux_viewer.update_sound_device(didx)

def refresh_device_list(self):
devices, indexes = self.build_device_lists()
self.sound_device_indexes = dict(zip(devices, indexes))
self.sound_devices_items = devices
self.sound_devices_selected = dict(zip(indexes, devices))[sd.default.device[1]]

def vue_refresh_device_list_in_dropdown(self, *args):
self.refresh_device_list()

def build_device_lists(self):
# dedicated function to build the current *output*
# device and index lists
Expand Down
5 changes: 5 additions & 0 deletions jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@
>
Stop stream
</plugin-action-button>
<plugin-action-button
@click="refresh_device_list_in_dropdown"
>
Refresh Device List
</plugin-action-button>
</v-row>
<v-row>
<v-select
Expand Down

0 comments on commit 2084d96

Please sign in to comment.