Skip to content

Commit

Permalink
Add refresh button which updates sound device list
Browse files Browse the repository at this point in the history
  • Loading branch information
javerbukh committed Jan 10, 2025
1 parent d019ae4 commit fd5937e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
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()

Check warning on line 70 in jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py#L69-L70

Added lines #L69 - L70 were not covered by tests

# 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]]

Check warning on line 123 in jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py#L120-L123

Added lines #L120 - L123 were not covered by tests

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

Check warning on line 126 in jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py#L126

Added line #L126 was not covered by tests

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 fd5937e

Please sign in to comment.