From a3256ac15d8b7577aef93eeb1b09ca69d4b2333c Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 4 Apr 2026 14:31:13 -0400 Subject: [PATCH] =?UTF-8?q?play.py:=20slower=20spectrum=20decay=20(0.4/fra?= =?UTF-8?q?me)=20=E2=80=94=20peaks=20hold=20and=20fall=20gently?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) --- play.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/play.py b/play.py index 2864eb8..ee5ef1c 100644 --- a/play.py +++ b/play.py @@ -264,7 +264,7 @@ def play_audio(buf, sample_rate, title="", info_lines=None, offset_sec=0.0): big_seek = int(30 * sample_rate) state = {"pos": 0, "playing": True, "quit": False, "action": None} - prev_heights = [0] * 76 # peak hold for spectrum + prev_heights = [0.0] * 76 # peak hold for spectrum (float for slow decay) lock = threading.Lock() def callback(outdata, frames, time_info, status): @@ -367,7 +367,7 @@ def play_audio(buf, sample_rate, title="", info_lines=None, offset_sec=0.0): # Peak hold with decay heights = [] for j, h in enumerate(raw_heights): - held = max(h, prev_heights[j] - 1) # decay by 1 per frame + held = max(h, prev_heights[j] - 0.4) # slow decay heights.append(held) prev_heights[j] = held @@ -377,7 +377,7 @@ def play_audio(buf, sample_rate, title="", info_lines=None, offset_sec=0.0): threshold_lo = (n_rows - 1 - row) * 4 # top row = highest threshold row_parts = [] for j, h in enumerate(heights): - level = max(0, min(4, h - threshold_lo)) + level = int(max(0, min(4, int(h) - threshold_lo))) frac = j / scope_w if frac < 0.33: c = "\033[32m"