diff --git a/.github/workflows/build-multi-os.yml b/.github/workflows/build-multi-os.yml index 6721c663..3f9e1454 100644 --- a/.github/workflows/build-multi-os.yml +++ b/.github/workflows/build-multi-os.yml @@ -470,8 +470,6 @@ jobs: sudo apt-get install -y avrdude libasound2-dev ./AppRun -m pip install --upgrade pip ./AppRun -m pip install --upgrade setuptools - # hack to fix setup.py script with faulty include - ./AppRun -m pip install --global-option=build_ext --global-option="-I$(pwd)/opt/${{steps.vars.outputs.python-minor}}/include/${{steps.vars.outputs.python-minor}}" simpleaudio ./AppRun -m pip install -r requirements.build.txt - name: Add AppDir subdirectories to PATH run: | diff --git a/mypy.ini b/mypy.ini index c6c137ec..dbbe6d61 100644 --- a/mypy.ini +++ b/mypy.ini @@ -11,8 +11,6 @@ exclude = (?x)( follow_imports= silent strict= True -[mypy-simpleaudio] -ignore_missing_imports= True [mypy-sliplib] ignore_missing_imports= True [mypy-fbs_runtime.*] diff --git a/requirements.build.txt b/requirements.build.txt index d5a2cf1e..02858177 100644 --- a/requirements.build.txt +++ b/requirements.build.txt @@ -5,7 +5,6 @@ Pillow==10 pyserial==3.5 sliplib==0.6.2 bitarray==2.9.2 -simpleaudio==1.0.4 numpy==1.26.4 charset-normalizer<3.0.0 semver==3.0.2 \ No newline at end of file diff --git a/src/main/python/main/ayab/audio.py b/src/main/python/main/ayab/audio.py index 8b539161..c60d2b34 100644 --- a/src/main/python/main/ayab/audio.py +++ b/src/main/python/main/ayab/audio.py @@ -21,8 +21,8 @@ from __future__ import annotations from os import path - -import simpleaudio as sa +from PySide6.QtCore import QUrl +from PySide6.QtMultimedia import QSoundEffect from typing import TYPE_CHECKING @@ -34,7 +34,7 @@ class AudioPlayer: def __init__(self, gui: GuiMain): self.__dir = gui.app_context.get_resource("assets") self.__prefs = gui.prefs - self.__cache: dict[str, sa.WaveObject] = {} + self.__cache: dict[str, QSoundEffect] = {} def play(self, sound: str) -> None: """Play audio.""" @@ -47,7 +47,7 @@ def play(self, sound: str) -> None: # else wave_obj.play() - def __wave(self, sound: str) -> sa.WaveObject | None: + def __wave(self, sound: str) -> QSoundEffect | None: """Get and cache audio.""" if sound not in self.__cache: wave_object = self.__load_wave(sound) @@ -56,7 +56,9 @@ def __wave(self, sound: str) -> sa.WaveObject | None: self.__cache[sound] = wave_object return self.__cache[sound] - def __load_wave(self, sound: str) -> sa.WaveObject | None: + def __load_wave(self, sound: str) -> QSoundEffect | None: """Get audio from file.""" filename = path.join(self.__dir, sound + ".wav") - return sa.WaveObject.from_wave_file(filename) + effect = QSoundEffect() + effect.setSource(QUrl.fromLocalFile(filename)) + return effect