diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-17 21:28:58 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-17 21:28:58 +0100 |
| commit | 99e94d18ce54d1ad73c7c0349119d4cd8fb4f965 (patch) | |
| tree | e39536f70a9ff62cc42315ecb1fb5397ccf762b8 /tools/mq_editor/index.html | |
| parent | fbdfa2a7b54894a565fd57d5e27f19d752fe39fa (diff) | |
feat(mq_editor): peaks display, STFT cache refactor, threshold reactivity
- STFTCache: cache squaredAmplitude (re²+im²) per frame, add getSquaredAmplitude(t)
- getMagnitudeDB uses cached sq amp (10*log10, no sqrt)
- detectPeaks uses squaredAmp from cache instead of recomputing FFT
- extractPartials: use cache frames, return {partials, frames}
- Press 'p' to toggle raw peak overlay in viewer
- threshold input: step=any, change event triggers re-extraction
- runExtraction() shared by button and threshold change
handoff(Claude): mq_partial peaks/cache refactor complete
Diffstat (limited to 'tools/mq_editor/index.html')
| -rw-r--r-- | tools/mq_editor/index.html | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/tools/mq_editor/index.html b/tools/mq_editor/index.html index 84abd1c..27eba2a 100644 --- a/tools/mq_editor/index.html +++ b/tools/mq_editor/index.html @@ -82,7 +82,7 @@ <input type="number" id="hopSize" value="256" min="64" max="1024" step="64"> <label>Threshold (dB):</label> - <input type="number" id="threshold" value="-60" min="-80" max="-20" step="5"> + <input type="number" id="threshold" value="-60" step="any"> </div> </div> @@ -173,9 +173,8 @@ } }); - // Extract partials - extractBtn.addEventListener('click', () => { - if (!audioBuffer) return; + function runExtraction() { + if (!stftCache) return; setStatus('Extracting partials...', 'info'); extractBtn.disabled = true; @@ -189,13 +188,12 @@ sampleRate: audioBuffer.sampleRate }; - const partials = extractPartials(audioBuffer, params); + const result = extractPartials(params, stftCache); - extractedPartials = partials; - setStatus(`Extracted ${partials.length} partials`, 'info'); - - // Update viewer - viewer.setPartials(partials); + extractedPartials = result.partials; + viewer.setFrames(result.frames); + setStatus(`Extracted ${result.partials.length} partials`, 'info'); + viewer.setPartials(result.partials); } catch (err) { setStatus('Extraction error: ' + err.message, 'error'); @@ -203,6 +201,16 @@ } extractBtn.disabled = false; }, 50); + } + + // Extract partials + extractBtn.addEventListener('click', () => { + if (!audioBuffer) return; + runExtraction(); + }); + + threshold.addEventListener('change', () => { + if (stftCache) runExtraction(); }); // Play audio @@ -325,6 +333,9 @@ if (!playBtn.disabled) { playBtn.click(); } + } else if (e.code === 'KeyP') { + e.preventDefault(); + if (viewer) viewer.togglePeaks(); } }); </script> |
