Add min/max value range to audio value sources
Add min_value and max_value fields to AudioValueSource so audio brightness can be mapped to a configurable range (e.g. silence = 30% brightness floor instead of fully black). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -91,6 +91,8 @@ class ValueSource:
|
||||
mode=data.get("mode") or "rms",
|
||||
sensitivity=float(data.get("sensitivity") or 1.0),
|
||||
smoothing=float(data.get("smoothing") or 0.3),
|
||||
min_value=float(data.get("min_value") or 0.0),
|
||||
max_value=float(data["max_value"]) if data.get("max_value") is not None else 1.0,
|
||||
)
|
||||
|
||||
if source_type == "adaptive_time":
|
||||
@@ -167,10 +169,12 @@ class AudioValueSource(ValueSource):
|
||||
into a scalar value for brightness modulation.
|
||||
"""
|
||||
|
||||
audio_source_id: str = "" # references a MonoAudioSource
|
||||
audio_source_id: str = "" # references an audio source (mono or multichannel)
|
||||
mode: str = "rms" # rms | peak | beat
|
||||
sensitivity: float = 1.0 # gain multiplier (0.1–5.0)
|
||||
smoothing: float = 0.3 # temporal smoothing (0.0–1.0)
|
||||
min_value: float = 0.0 # minimum output (0.0–1.0)
|
||||
max_value: float = 1.0 # maximum output (0.0–1.0)
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
d = super().to_dict()
|
||||
@@ -178,6 +182,8 @@ class AudioValueSource(ValueSource):
|
||||
d["mode"] = self.mode
|
||||
d["sensitivity"] = self.sensitivity
|
||||
d["smoothing"] = self.smoothing
|
||||
d["min_value"] = self.min_value
|
||||
d["max_value"] = self.max_value
|
||||
return d
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user