Merge pull request #6 from UniversityRadioYork/linux

Add linux build support + audio handing into helper
This commit is contained in:
Matthew Stratford 2020-11-03 22:12:40 +00:00 committed by GitHub
commit 7435eca60d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 8 deletions

View file

@ -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

17
build/build-linux.sh Executable file
View file

@ -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

View file

@ -0,0 +1 @@
pyinstaller

26
helpers/device_manager.py Normal file
View file

@ -0,0 +1,26 @@
import sounddevice as sd
import importlib
from helpers.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

View file

@ -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,