summaryrefslogtreecommitdiff
path: root/tools/mq_editor
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-18 18:03:32 +0100
committerskal <pascal.massimino@gmail.com>2026-02-18 18:03:32 +0100
commitd73414c6d42fbec2666cb24b65b1f597b335c1e9 (patch)
tree3d782c80d82abf5065ceaeda9d389c372ad55fc5 /tools/mq_editor
parent49e4e374bc51517d8119e4c82d46e3a94ea0b75b (diff)
fix(mq_editor): enable explore mode immediately on WAV load
Pre-compute peak frames after STFT cache is built, so trackFromSeed works without requiring Extract Partials first. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'tools/mq_editor')
-rw-r--r--tools/mq_editor/app.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/tools/mq_editor/app.js b/tools/mq_editor/app.js
index 41df49a..62c1bb7 100644
--- a/tools/mq_editor/app.js
+++ b/tools/mq_editor/app.js
@@ -155,7 +155,22 @@ function loadAudioBuffer(buffer, label) {
const signal = audioBuffer.getChannelData(0);
stftCache = new STFTCache(signal, audioBuffer.sampleRate, fftSize, Math.max(64, parseInt(hopSize.value) || 64));
setStatus(`${label} — ${audioBuffer.duration.toFixed(2)}s, ${audioBuffer.sampleRate}Hz, ${audioBuffer.numberOfChannels}ch (${stftCache.getNumFrames()} frames cached)`, 'info');
+
+ // Pre-compute peak frames so explore mode works immediately (before Extract)
+ const peakFrames = [];
+ for (let i = 0; i < stftCache.getNumFrames(); ++i) {
+ const f = stftCache.getFrameAtIndex(i);
+ peakFrames.push({
+ time: f.time,
+ peaks: detectPeaks(f.squaredAmplitude, f.phase, fftSize, audioBuffer.sampleRate,
+ parseFloat(threshold.value), freqWeightCb.checked,
+ parseFloat(prominence.value)),
+ });
+ }
+
viewer = new SpectrogramViewer(canvas, audioBuffer, stftCache);
+ viewer.setFrames(peakFrames);
+ document.getElementById('exploreBtn').disabled = false;
editor.setViewer(viewer);
viewer.onPartialSelect = (i) => editor.onPartialSelect(i);
viewer.onRender = () => editor.onRender();
@@ -284,7 +299,6 @@ function runExtraction() {
autoSpreadAllBtn.disabled = false;
document.getElementById('newPartialBtn').disabled = false;
document.getElementById('clearAllBtn').disabled = false;
- document.getElementById('exploreBtn').disabled = false;
undoStack.length = 0; redoStack.length = 0; _updateUndoRedoBtns();
}, 50);
}