Files
Streamer/audio/eq_manager.py
T
2026-10-05 09:45:26 +02:00

41 lines
1.5 KiB
Python
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# audio/eq_manager.py
import logging
log = logging.getLogger(__name__)
class EQManager:
"""
Przechowuje i udostępnia ustawienia korektora dla każdego źródła.
Konfiguracja jest wczytywana z `config.json` przy starcie.
"""
def __init__(self, eq_cfg: dict):
"""
`eq_cfg` – słownik z kluczami: radio, bluetooth, phono, line1, line2, spdif,
każda wartość to lista 10 liczb (dB).
"""
self._eq = eq_cfg.copy()
log.info("EQManager – załadowano konfigurację dla %d źródeł", len(self._eq))
def get_eq(self, source_name: str):
"""Zwraca listę 10 wartości dla podanego źródła (lub domyślny flat)."""
return self._eq.get(source_name, [0] * 10)
def set_eq(self, source_name: str, bands: list):
if len(bands) != 10:
raise ValueError("EQ wymaga dokładnie 10 wartości")
self._eq[source_name] = bands
log.info("EQ set dla %s → %s", source_name, bands)
# --------- Używane w AudioEngine ----------
def apply_to_engine(self, audio_engine, source_name: str):
"""Przekazuje aktualny zestaw bandów do silnika audio."""
bands = self.get_eq(source_name)
audio_engine.set_eq(bands)
def get_current_eq(self):
"""Zwraca aktualny zestaw EQ – najprostsze API do UI."""
# Zakładamy, że `audio_engine` ma atrybut `current_source_name`
# W tym uproszczonym przykładzie nie wiemy, więc zwracamy all.
return self._eq