From bf3929220be7eddf32cebe12573b870fc9b54997 Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 18 Feb 2026 06:02:32 +0100 Subject: fix(mq_editor): mini-spectrum and spectrogram display improvements - Fix mini-spectrum: log-scale frequency axis, per-pixel bin averaging, red peak bars after extraction - Fix key handlers swallowing digits in input fields - Clamp hop size to min 64 to prevent hang - Store maxDB in STFTCache, use it to normalize both mini-spectrum and main spectrogram (fixes clipping at 0dB for pure tones) - Add Test WAV console validation for 440/660Hz peaks - Grayscale colormap for main spectrogram handoff(Gemini): mq_editor display fixes complete, tests not affected --- tools/mq_editor/fft.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tools/mq_editor/fft.js') diff --git a/tools/mq_editor/fft.js b/tools/mq_editor/fft.js index 9b9bc94..10a5b45 100644 --- a/tools/mq_editor/fft.js +++ b/tools/mq_editor/fft.js @@ -115,6 +115,7 @@ class STFTCache { compute() { this.frames = []; + this.maxDB = -Infinity; const numFrames = Math.floor((this.signal.length - this.fftSize) / this.hopSize); for (let frameIdx = 0; frameIdx < numFrames; ++frameIdx) { @@ -138,10 +139,14 @@ class STFTCache { const re = fftOut[i * 2]; const im = fftOut[i * 2 + 1]; squaredAmplitude[i] = re * re + im * im; + const db = 10 * Math.log10(Math.max(squaredAmplitude[i], 1e-20)); + if (db > this.maxDB) this.maxDB = db; } this.frames.push({time, offset, squaredAmplitude}); } + + if (!isFinite(this.maxDB)) this.maxDB = 0; } setHopSize(hopSize) { -- cgit v1.2.3