fix: convert string values to proper types in count_active_effects

JSON stores effect values as strings, but count_active_effects was
tryting to compare them directly with integers/floats.

Now properly converts:
- pitch, echo, robot, chorus -> int
- speed, tremolo_depth -> float

Before comparison to avoid TypeError: '>' not supported between
instances of 'str' and 'int'
This commit is contained in:
2026-01-31 17:28:47 -06:00
parent 7e76deed3d
commit 40843e4ac9

View File

@@ -265,17 +265,25 @@ class AudioEffects:
def count_active_effects(cls, **effects) -> int:
"""Count how many effects are active (non-default)."""
count = 0
if effects.get("pitch", cls.PITCH_DEFAULT) != cls.PITCH_DEFAULT:
# Convert values to proper types (JSON stores them as strings)
pitch = int(effects.get("pitch", cls.PITCH_DEFAULT))
speed = float(effects.get("speed", cls.SPEED_DEFAULT))
echo = int(effects.get("echo", cls.ECHO_DEFAULT))
robot = int(effects.get("robot", cls.ROBOT_DEFAULT))
chorus = int(effects.get("chorus", cls.CHORUS_DEFAULT))
tremolo_depth = float(effects.get("tremolo_depth", cls.TREMOLO_DEPTH_DEFAULT))
if pitch != cls.PITCH_DEFAULT:
count += 1
if effects.get("speed", cls.SPEED_DEFAULT) != cls.SPEED_DEFAULT:
if speed != cls.SPEED_DEFAULT:
count += 1
if effects.get("echo", cls.ECHO_DEFAULT) > cls.ECHO_DEFAULT:
if echo > cls.ECHO_DEFAULT:
count += 1
if effects.get("robot", cls.ROBOT_DEFAULT) > cls.ROBOT_DEFAULT:
if robot > cls.ROBOT_DEFAULT:
count += 1
if effects.get("chorus", cls.CHORUS_DEFAULT) > cls.CHORUS_DEFAULT:
if chorus > cls.CHORUS_DEFAULT:
count += 1
if effects.get("tremolo_depth", cls.TREMOLO_DEPTH_DEFAULT) > cls.TREMOLO_DEPTH_DEFAULT:
if tremolo_depth > cls.TREMOLO_DEPTH_DEFAULT:
count += 1
# tremolo_rate only counts if depth is also active
return count