From c1e88fcf71cdb77468ca28b132e2cad607b615ca Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Tue, 3 Nov 2020 20:13:32 +0000 Subject: [PATCH 1/5] Add linux build support. --- build/build-linux.sh | 17 +++++++++++++++++ build/requirements-linux.txt | 1 + 2 files changed, 18 insertions(+) create mode 100755 build/build-linux.sh create mode 100644 build/requirements-linux.txt diff --git a/build/build-linux.sh b/build/build-linux.sh new file mode 100755 index 0000000..1e66aba --- /dev/null +++ b/build/build-linux.sh @@ -0,0 +1,17 @@ +#!/bin/bash +cd "$(dirname "$0")" + +apt install libportaudio2 + +pip3 install -r requirements.txt +pip3 install -r requirements-linux.txt +pip3 install -e ..\ + +python3 ./generate-build-exe-config.py + +python3 ./build-exe.py + +bash ./build-exe-pyinstaller-command.sh + +rm ./*.spec + diff --git a/build/requirements-linux.txt b/build/requirements-linux.txt new file mode 100644 index 0000000..ef376ca --- /dev/null +++ b/build/requirements-linux.txt @@ -0,0 +1 @@ +pyinstaller From 94e01aa1440ecb1064bf6c3a60e968d7a3278787 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Tue, 3 Nov 2020 21:24:45 +0000 Subject: [PATCH 2/5] Move audio device to DeviceManager --- helpers/device_manager.py | 27 +++++++++++++++++++++++++++ server.py | 9 ++------- 2 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 helpers/device_manager.py diff --git a/helpers/device_manager.py b/helpers/device_manager.py new file mode 100644 index 0000000..266b823 --- /dev/null +++ b/helpers/device_manager.py @@ -0,0 +1,27 @@ +import sounddevice as sd +import importlib +from os_environment import isMacOS + +class DeviceManager(): + + @classmethod + def _isOutput(self, device): + return device["max_output_channels"] > 0 + + @classmethod + def _getDevices(self): + # To update the list of devices + # Sadly this doesn't work on MacOS. + if not isMacOS(): + sd._terminate() + sd._initialize() + devices = sd.query_devices() + return devices + + @classmethod + def getOutputs(self): + outputs = filter(self._isOutput, self._getDevices()) + + return outputs + + # TODO: Maybe some hotplug event triggers support for the players? diff --git a/server.py b/server.py index c44412b..afe60f1 100644 --- a/server.py +++ b/server.py @@ -2,10 +2,10 @@ import multiprocessing import player from flask import Flask, render_template, send_from_directory, request import json -import sounddevice as sd import setproctitle import logging from helpers.os_environment import isMacOS +from helpers.device_manager import DeviceManager setproctitle.setproctitle("BAPSicle - Server") @@ -55,12 +55,7 @@ def ui_config(): for i in range(3): channel_states.append(status(i)) - devices = sd.query_devices() - outputs = [] - - for device in devices: - if device["max_output_channels"] > 0: - outputs.append(device) + outputs = DeviceManager.getOutputs() data = { 'channels': channel_states, From 6f78e1e9f77bc9d948eb6adcfd3c71a9ce82b69a Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Tue, 3 Nov 2020 21:28:05 +0000 Subject: [PATCH 3/5] Fix import error --- helpers/device_manager.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/helpers/device_manager.py b/helpers/device_manager.py index 266b823..d0cd2a4 100644 --- a/helpers/device_manager.py +++ b/helpers/device_manager.py @@ -1,27 +1,28 @@ import sounddevice as sd import importlib -from os_environment import isMacOS +from helpers.os_environment import isMacOS + class DeviceManager(): - @classmethod - def _isOutput(self, device): - return device["max_output_channels"] > 0 + @classmethod + def _isOutput(self, device): + return device["max_output_channels"] > 0 - @classmethod - def _getDevices(self): - # To update the list of devices - # Sadly this doesn't work on MacOS. - if not isMacOS(): - sd._terminate() - sd._initialize() - devices = sd.query_devices() - return devices + @classmethod + def _getDevices(self): + # To update the list of devices + # Sadly this doesn't work on MacOS. + if not isMacOS(): + sd._terminate() + sd._initialize() + devices = sd.query_devices() + return devices - @classmethod - def getOutputs(self): - outputs = filter(self._isOutput, self._getDevices()) + @classmethod + def getOutputs(self): + outputs = filter(self._isOutput, self._getDevices()) - return outputs + return outputs - # TODO: Maybe some hotplug event triggers support for the players? + # TODO: Maybe some hotplug event triggers support for the players? From 4378093e9c8896145e64a9b88f8c1fd312d9a696 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Tue, 3 Nov 2020 22:05:48 +0000 Subject: [PATCH 4/5] Add linux build to the readme. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 98e013a..f0390e4 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ To build a ``BAPSicle.exe``, run ``build\build-exe.bat``. The resulting file wil ### Linux -Coming soon... +To build a ``BAPSicle`` executable, run ``build/build-linux.sh``. The resulting file will appear in ``build/output``. ### MacOS From 1c95486b19bec0969cc23b94a2f60051ea707d86 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Tue, 3 Nov 2020 22:11:54 +0000 Subject: [PATCH 5/5] Remove actioned TODO --- helpers/device_manager.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/helpers/device_manager.py b/helpers/device_manager.py index d0cd2a4..fc5a437 100644 --- a/helpers/device_manager.py +++ b/helpers/device_manager.py @@ -24,5 +24,3 @@ class DeviceManager(): outputs = filter(self._isOutput, self._getDevices()) return outputs - - # TODO: Maybe some hotplug event triggers support for the players?