From d68fa4782e971b8ea41204ef5898141efcb243af Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 18 Feb 2026 05:36:49 +0100 Subject: test(mq_editor): add isolated FFT test page and sine generator - tools/mq_editor/test_fft.html: browser test for fft.js (12 tests: DC impulse, single tone, STFT magnitude, pairs, triplets) - tools/gen_sine_440.py: generate 1s 440Hz WAV at 32kHz for manual testing handoff(Gemini): FFT isolation tests added, all passing in browser. --- tools/gen_sine_440.py | 18 ++++ tools/mq_editor/README.md | 1 + tools/mq_editor/test_fft.html | 229 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 248 insertions(+) create mode 100644 tools/gen_sine_440.py create mode 100644 tools/mq_editor/test_fft.html diff --git a/tools/gen_sine_440.py b/tools/gen_sine_440.py new file mode 100644 index 0000000..6458dc8 --- /dev/null +++ b/tools/gen_sine_440.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 +import wave, struct, math + +SAMPLE_RATE = 32000 +FREQ = 440.0 +DURATION = 1.0 +AMPLITUDE = 32767 + +samples = [int(AMPLITUDE * math.sin(2 * math.pi * FREQ * i / SAMPLE_RATE)) + for i in range(int(SAMPLE_RATE * DURATION))] + +with wave.open("sine_440.wav", "w") as f: + f.setnchannels(1) + f.setsampwidth(2) + f.setframerate(SAMPLE_RATE) + f.writeframes(struct.pack(f"<{len(samples)}h", *samples)) + +print(f"Written sine_440.wav: {FREQ}Hz, {DURATION}s, {SAMPLE_RATE}Hz mono") diff --git a/tools/mq_editor/README.md b/tools/mq_editor/README.md index 1f43c19..71ad90f 100644 --- a/tools/mq_editor/README.md +++ b/tools/mq_editor/README.md @@ -31,6 +31,7 @@ open tools/mq_editor/index.html - `fft.js` - Fast Fourier Transform (Cooley-Tukey radix-2) - `mq_extract.js` - MQ algorithm (peak detection, tracking, bezier fitting) - `viewer.js` - Visualization (spectrogram, partials, zoom, mouse interaction) +- `test_fft.html` - Isolated FFT correctness tests (open in browser, no server needed) ## Implementation Status diff --git a/tools/mq_editor/test_fft.html b/tools/mq_editor/test_fft.html new file mode 100644 index 0000000..b4e7f48 --- /dev/null +++ b/tools/mq_editor/test_fft.html @@ -0,0 +1,229 @@ + + + + + +FFT Test + + + +

FFT Isolation Test

+

+
+
+
+
+
-- 
cgit v1.2.3