From 40843e4ac911c2dbbc7b9171a94eabc35b5037c6 Mon Sep 17 00:00:00 2001 From: Spencer Grimes Date: Sat, 31 Jan 2026 17:28:47 -0600 Subject: [PATCH] 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' --- audio_effects.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/audio_effects.py b/audio_effects.py index bbf01df..8103c55 100644 --- a/audio_effects.py +++ b/audio_effects.py @@ -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