summaryrefslogtreecommitdiff
path: root/tools/mq_editor
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-19 07:47:17 +0100
committerskal <pascal.massimino@gmail.com>2026-02-19 07:47:17 +0100
commit7554f59a328acc706119d0952b50ab9fdee8c623 (patch)
tree697512edd40d440c39b1680ea9fb6b23b325c356 /tools/mq_editor
parent07538091b1fac417104c273bd9dc117af8afdb9e (diff)
fix(mq_editor): offset playhead to partial t_start when playing single partial (key 3)HEADmain
handoff(Claude): playhead offset fix for single partial playback
Diffstat (limited to 'tools/mq_editor')
-rw-r--r--tools/mq_editor/app.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/mq_editor/app.js b/tools/mq_editor/app.js
index 1c6d548..55b8d25 100644
--- a/tools/mq_editor/app.js
+++ b/tools/mq_editor/app.js
@@ -388,7 +388,7 @@ for (const el of [birthPersistenceEl, deathAgeEl, phaseErrorWeightEl, minLengthE
el.addEventListener('change', () => { if (stftCache) runExtraction(); });
}
-function playAudioBuffer(buffer, statusMsg) {
+function playAudioBuffer(buffer, statusMsg, timeOffset = 0) {
const startTime = audioContext.currentTime;
currentSource = audioContext.createBufferSource();
currentSource.buffer = buffer;
@@ -406,7 +406,7 @@ function playAudioBuffer(buffer, statusMsg) {
setStatus(statusMsg, 'info');
function tick() {
if (!currentSource) return;
- viewer.setPlayheadTime(audioContext.currentTime - startTime);
+ viewer.setPlayheadTime(timeOffset + audioContext.currentTime - startTime);
requestAnimationFrame(tick);
}
tick();
@@ -530,7 +530,9 @@ document.addEventListener('keydown', (e) => {
const partial = extractedPartials[sel];
if (!partial) return;
stopAudio();
- playAudioBuffer(getAudioBuffer([partial], 0.05), `Playing partial #${sel}...`);
+ const tStart = Math.min(...partial.times);
+ const offset = Math.max(0, tStart - 0.05);
+ playAudioBuffer(getAudioBuffer([partial], 0.05), `Playing partial #${sel}...`, offset);
} else if (e.code === 'KeyP') {
e.preventDefault();
if (viewer) viewer.togglePeaks();