From cfcd238044c7ce06dfdf1f9e08c3842bfa07979b Mon Sep 17 00:00:00 2001 From: skal Date: Tue, 17 Feb 2026 20:54:15 +0100 Subject: feat(mq_editor): Complete Phase 2 - JS synthesizer with STFT cache Phase 2 - JS Synthesizer: - Created mq_synth.js with replica oscillator bank - Bezier curve evaluation (cubic De Casteljau algorithm) - Replica synthesis: frequency spread, amplitude decay, phase jitter - PCM buffer generation from extracted MQ partials - Normalization to prevent clipping - Key '1' plays synthesized audio, key '2' plays original - Playback comparison with animated playhead STFT Cache Optimization: - Created STFTCache class in fft.js for pre-computed windowed FFT frames - Clean interface: getFFT(t), getMagnitudeDB(t, freq), setHopSize() - Pre-computes all frames on WAV load (eliminates redundant FFT calls) - Dynamic cache update when hop size changes - Shared across spectrogram, tooltip, and mini-spectrum viewer - Significant performance improvement Mini-Spectrum Viewer: - Bottom-right overlay (200x100) matching spectral_editor style - Real-time FFT display at playhead or mouse position - 100-bar visualization with cyan-to-yellow gradient - Updates during playback or mouse hover Files: - tools/mq_editor/mq_synth.js (new) - tools/mq_editor/fft.js (STFTCache class added) - tools/mq_editor/index.html (synthesis playback, cache integration) - tools/mq_editor/viewer.js (cache-based rendering, spectrum viewer) Co-Authored-By: Claude Sonnet 4.5 --- doc/SPECTRAL_BRUSH_2.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/SPECTRAL_BRUSH_2.md b/doc/SPECTRAL_BRUSH_2.md index 442db6d..7714ce3 100644 --- a/doc/SPECTRAL_BRUSH_2.md +++ b/doc/SPECTRAL_BRUSH_2.md @@ -521,7 +521,13 @@ void pattern_callback(int sample_id, float volume) { - [x] Cubic bezier curve fitting for freq/amp trajectories - [x] Spectrogram visualization with zoom/scroll/playhead - [x] Original WAV playback -- [ ] Phase 2: JS synthesizer + - [x] STFT cache for optimized FFT computation + - [x] Mini-spectrum viewer +- [x] Phase 2: JS synthesizer + - [x] Bezier evaluation (cubic De Casteljau) + - [x] Replica oscillator bank (frequency spread, amplitude decay, phase jitter) + - [x] PCM synthesis from MQ partials + - [x] Playback comparison (original vs synthesized) - [ ] Phase 3: Web editor UI - [ ] Phase 4: C++ code generator - [ ] Phase 5: C++ synthesis + integration -- cgit v1.2.3