diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-18 06:02:32 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-18 06:02:32 +0100 |
| commit | bf3929220be7eddf32cebe12573b870fc9b54997 (patch) | |
| tree | 27318902f41b0e4f5deb73831d9cfc03ca37b229 /tools/mq_editor/fft.js | |
| parent | 14c3bfe09f906e9b80d6100b126e59c9a88ac976 (diff) | |
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
Diffstat (limited to 'tools/mq_editor/fft.js')
| -rw-r--r-- | tools/mq_editor/fft.js | 5 |
1 files changed, 5 insertions, 0 deletions
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) { |
