From 8443a233cc7fcefdf8134cebe81395648c364f3b Mon Sep 17 00:00:00 2001 From: jouae Date: Thu, 4 Dec 2025 20:29:33 +0800 Subject: [PATCH] Add zero-duration note handling in web app Handle cases where note off evnents occur at the same time as note on evnents, preventing negative duration notes from being proocessed. --- web/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/app.js b/web/app.js index 2d58e2f..a2396b1 100644 --- a/web/app.js +++ b/web/app.js @@ -312,13 +312,13 @@ function parseMidiFile(buffer) { active.set(evt.note, evt.time); } else { const start = active.get(evt.note); - if (start !== undefined) { + if (start !== undefined && evt.time >= start) { const duration = evt.time - start; const beatVal = Math.max(1, Math.round(duration * 4 / ticksPerBeat)); notes.push(evt.note); beats.push(beatVal); - active.delete(evt.note); } + active.delete(evt.note); } }