mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 11:40:13 +01:00
fix insane config bottleneck
This commit is contained in:
@@ -475,13 +475,14 @@ class AudioEngine:
|
||||
if isinstance(device_info, sd.DeviceList):
|
||||
raise Exception("Invalid ASIO Device")
|
||||
print(f"Using default ASIO device: {device_info['name']}")
|
||||
print(device_info)
|
||||
self.buffer_size = rounded(device_info['default_low_output_latency']*1000)
|
||||
if 'buffer_size' in get_config()['audio']:
|
||||
self.buffer_size = get_config()['audio']['buffer_size']
|
||||
self.target_sample_rate = device_info['default_samplerate']
|
||||
if 'sample_rate' in get_config()['audio']:
|
||||
self.target_sample_rate = get_config()['audio']['sample_rate']
|
||||
if self.target_sample_rate == -1:
|
||||
self.target_sample_rate = device_info['default_samplerate']
|
||||
# Set output channels based on device capabilities
|
||||
self.output_channels = device_info['max_output_channels']
|
||||
if self.output_channels > 2:
|
||||
|
||||
11
libs/tja.py
11
libs/tja.py
@@ -35,10 +35,13 @@ class Note:
|
||||
def __le__(self, other):
|
||||
return self.hit_ms <= other.hit_ms
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.hit_ms == other.hit_ms
|
||||
|
||||
def _get_hash_data(self) -> bytes:
|
||||
"""Get deterministic byte representation for hashing"""
|
||||
field_values = []
|
||||
for f in sorted([f.name for f in fields(self)]): # Sort for consistency
|
||||
for f in sorted([f.name for f in fields(self)]):
|
||||
value = getattr(self, f, None)
|
||||
field_values.append((f, value))
|
||||
field_values.append(('__class__', self.__class__.__name__))
|
||||
@@ -66,6 +69,9 @@ class Drumroll(Note):
|
||||
def __repr__(self):
|
||||
return str(self.__dict__)
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.hit_ms == other.hit_ms
|
||||
|
||||
def __post_init__(self):
|
||||
for field_name in [f.name for f in fields(Note)]:
|
||||
if hasattr(self._source_note, field_name):
|
||||
@@ -94,6 +100,9 @@ class Balloon(Note):
|
||||
def __repr__(self):
|
||||
return str(self.__dict__)
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.hit_ms == other.hit_ms
|
||||
|
||||
def __post_init__(self):
|
||||
for field_name in [f.name for f in fields(Note)]:
|
||||
if hasattr(self._source_note, field_name):
|
||||
|
||||
@@ -106,7 +106,7 @@ def save_config(config: dict[str, Any]) -> None:
|
||||
tomlkit.dump(config, f)
|
||||
|
||||
def is_l_don_pressed() -> bool:
|
||||
keys = get_config()["keybinds"]["left_don"]
|
||||
keys = global_data.config["keybinds"]["left_don"]
|
||||
for key in keys:
|
||||
if ray.is_key_pressed(ord(key)):
|
||||
return True
|
||||
@@ -126,7 +126,7 @@ def is_l_don_pressed() -> bool:
|
||||
return False
|
||||
|
||||
def is_r_don_pressed() -> bool:
|
||||
keys = get_config()["keybinds"]["right_don"]
|
||||
keys = global_data.config["keybinds"]["right_don"]
|
||||
for key in keys:
|
||||
if ray.is_key_pressed(ord(key)):
|
||||
return True
|
||||
@@ -146,7 +146,7 @@ def is_r_don_pressed() -> bool:
|
||||
return False
|
||||
|
||||
def is_l_kat_pressed() -> bool:
|
||||
keys = get_config()["keybinds"]["left_kat"]
|
||||
keys = global_data.config["keybinds"]["left_kat"]
|
||||
for key in keys:
|
||||
if ray.is_key_pressed(ord(key)):
|
||||
return True
|
||||
@@ -166,7 +166,7 @@ def is_l_kat_pressed() -> bool:
|
||||
return False
|
||||
|
||||
def is_r_kat_pressed() -> bool:
|
||||
keys = get_config()["keybinds"]["right_kat"]
|
||||
keys = global_data.config["keybinds"]["right_kat"]
|
||||
for key in keys:
|
||||
if ray.is_key_pressed(ord(key)):
|
||||
return True
|
||||
@@ -212,6 +212,7 @@ class GlobalData:
|
||||
selected_song: Path = Path()
|
||||
textures: dict[str, list[ray.Texture]] = field(default_factory=lambda: dict())
|
||||
songs_played: int = 0
|
||||
config: dict = field(default_factory=lambda: dict())
|
||||
|
||||
global_data = GlobalData()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user