diff --git a/helpers/device_manager.py b/helpers/device_manager.py index e628db0..2c146f9 100644 --- a/helpers/device_manager.py +++ b/helpers/device_manager.py @@ -1,4 +1,4 @@ -from typing import Any, Dict +from typing import Any, Dict, List import sounddevice as sd from helpers.os_environment import isMacOS @@ -10,7 +10,7 @@ class DeviceManager(): return device["max_output_channels"] > 0 @classmethod - def _getDevices(cls) -> sd.DeviceList: + def _getAudioDevices(cls) -> sd.DeviceList: # To update the list of devices # Sadly this doesn't work on MacOS. if not isMacOS(): @@ -20,7 +20,7 @@ class DeviceManager(): return devices @classmethod - def getOutputs(cls) -> sd.DeviceList: - outputs: sd.DeviceList = filter(cls._isOutput, cls._getDevices()) - - return outputs + def getAudioOutputs(cls) -> List[Dict]: + outputs: List[Dict] = list(filter(cls._isOutput, cls._getAudioDevices())) + outputs = sorted(outputs, key=lambda k: k['name']) + return [{"name": None}] + outputs diff --git a/server.py b/server.py index 1cdcb8a..36ec92d 100644 --- a/server.py +++ b/server.py @@ -130,7 +130,7 @@ def ui_config(): for i in range(state.state["num_channels"]): channel_states.append(status(i)) - outputs = DeviceManager.getOutputs() + outputs = DeviceManager.getAudioOutputs() data = { 'channels': channel_states, diff --git a/templates/config.html b/templates/config.html index 33f5e8d..c35127c 100644 --- a/templates/config.html +++ b/templates/config.html @@ -1,9 +1,15 @@ {% extends 'base.html' %} {% block content_inner %} +
- Set Channel 0 Set Channel 1 Set Channel 2 - System Default Output
+
{% for output in data.outputs %}
- Set Channel 0 Set Channel 1 Set Channel 2 - {{output.name}}
+
+ Set for:
+ {% for channel in data.channels %}
+ Channel {{channel.channel}}
+ {% endfor %}
+ - {% if output.name %}{{output.name}}{% else %}System Default Output{% endif %}
{% endfor %}
{% endblock %}