From cfc58dd75f2f7459692091c24bbaa4fd9e3ee463 Mon Sep 17 00:00:00 2001 From: Anthony Samms Date: Mon, 15 Sep 2025 14:04:08 -0400 Subject: [PATCH] hot fixes --- libs/audio.py | 24 +++++++++++++++++++----- scenes/settings.py | 9 --------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/libs/audio.py b/libs/audio.py index 87d3481..f961173 100644 --- a/libs/audio.py +++ b/libs/audio.py @@ -1,4 +1,5 @@ import cffi +import platform from pathlib import Path from typing import Optional import numpy as np @@ -103,14 +104,27 @@ ffi.cdef(""" """) # Load the compiled C library -# You'll need to compile your C code into a shared library first # gcc -shared -fPIC -o libaudio.so audio.c -lportaudio -lsndfile -lpthread try: - lib = ffi.dlopen("libs/audio_c/libaudio.so") # Adjust path as needed + if platform.system() == "Windows": + lib = ffi.dlopen("libaudio.dll") # or "libaudio.dll" if that's the compiled name + elif platform.system() == "Darwin": + lib = ffi.dlopen("libaudio.dylib") + else: # Assume Linux/Unix + lib = ffi.dlopen("libaudio.so") except OSError as e: - print(f"Failed to load libaudio.so: {e}") - print("Make sure to compile your C code first:") - print("gcc -shared -fPIC -o libaudio.so audio.c -lportaudio -lsndfile -lpthread") + print(f"Failed to load shared library: {e}") + print("Make sure to compile your C code first.") + if platform.system() == "Linux": + print("Example:") + print("gcc -shared -fPIC -o libaudio.so audio.c -lportaudio -lsndfile -lpthread") + elif platform.system() == "Windows": + print("On Windows, make sure you've built a DLL with MinGW or MSVC:") + print("Example with MinGW:") + print("gcc -shared -o libaudio.dll audio.c -lportaudio -lsndfile -lpthread") + elif platform.system() == "Darwin": + print("On macOS:") + print("gcc -dynamiclib -o libaudio.dylib audio.c -lportaudio -lsndfile -lpthread") raise class AudioEngine: diff --git a/scenes/settings.py b/scenes/settings.py index 2d7da14..30df341 100644 --- a/scenes/settings.py +++ b/scenes/settings.py @@ -1,5 +1,4 @@ import pyray as ray -import sounddevice as sd from libs.audio import audio from libs.utils import ( @@ -76,16 +75,8 @@ class SettingsScreen: """Cycle through predefined string values""" current_value = self.config[section][key] - hostapis = sd.query_hostapis() - audio_devices = [] - if isinstance(hostapis, tuple): - for api in hostapis: - if isinstance(api, dict): - audio_devices.append(api['name']) - options = { 'language': ['ja', 'en'], - 'device_type': audio_devices } if key in options: