From 3d7bae94f29767d406ea8b409c586cd98dd0cc7b Mon Sep 17 00:00:00 2001 From: 3dtours Date: Mon, 27 Jul 2026 15:36:03 +0700 Subject: [PATCH] fix: schedule noteOff even cho immediate notes (durationMs < 60000) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Trước đây chỉ schedule noteOff khi delay > 0 (notes scheduled). Virtual piano keyboard play note immediate (delay===0) với duration=500ms nhưng không có noteOff → âm thanh play mãi không tắt. Fix: schedule noteOff khi 0 < durationMs < 60000, không phụ thuộc delay. --- app/static/js/services/soundfontPlayer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/static/js/services/soundfontPlayer.js b/app/static/js/services/soundfontPlayer.js index efd8e50..20ec72e 100644 --- a/app/static/js/services/soundfontPlayer.js +++ b/app/static/js/services/soundfontPlayer.js @@ -371,7 +371,7 @@ try { console.log("[SonicSF] noteOn ch:", ch, "pitch:", midiPitch, "vel:", midiVel); _fluidModule._fluid_synth_noteon(_synthPtr, ch, midiPitch, midiVel); - if (delay > 0) { + if (durationMs > 0 && durationMs < 60000) { scheduledNote.off = setTimeout(function () { try { _fluidModule._fluid_synth_noteoff(_synthPtr, ch, midiPitch);