mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 11:40:13 +01:00
hot fixes
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import cffi
|
import cffi
|
||||||
|
import platform
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@@ -103,14 +104,27 @@ ffi.cdef("""
|
|||||||
""")
|
""")
|
||||||
|
|
||||||
# Load the compiled C library
|
# 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
|
# gcc -shared -fPIC -o libaudio.so audio.c -lportaudio -lsndfile -lpthread
|
||||||
try:
|
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:
|
except OSError as e:
|
||||||
print(f"Failed to load libaudio.so: {e}")
|
print(f"Failed to load shared library: {e}")
|
||||||
print("Make sure to compile your C code first:")
|
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")
|
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
|
raise
|
||||||
|
|
||||||
class AudioEngine:
|
class AudioEngine:
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import pyray as ray
|
import pyray as ray
|
||||||
import sounddevice as sd
|
|
||||||
|
|
||||||
from libs.audio import audio
|
from libs.audio import audio
|
||||||
from libs.utils import (
|
from libs.utils import (
|
||||||
@@ -76,16 +75,8 @@ class SettingsScreen:
|
|||||||
"""Cycle through predefined string values"""
|
"""Cycle through predefined string values"""
|
||||||
current_value = self.config[section][key]
|
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 = {
|
options = {
|
||||||
'language': ['ja', 'en'],
|
'language': ['ja', 'en'],
|
||||||
'device_type': audio_devices
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if key in options:
|
if key in options:
|
||||||
|
|||||||
Reference in New Issue
Block a user