From e866ad1c0de572152a1279588ff671c0814ec165 Mon Sep 17 00:00:00 2001 From: 3dtours Date: Mon, 27 Jul 2026 11:17:36 +0700 Subject: [PATCH] fix: stopNote sends noteOff(ch,pitch,0) + controllerChange(CC64=0) for safety --- app/static/js/services/soundfontPlayer.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/app/static/js/services/soundfontPlayer.js b/app/static/js/services/soundfontPlayer.js index b44d2ad..d6e8f6d 100644 --- a/app/static/js/services/soundfontPlayer.js +++ b/app/static/js/services/soundfontPlayer.js @@ -163,14 +163,11 @@ stopNote: function (channel, pitch) { if (channel < 0 || channel > 15) return; - console.log("[SonicSF] stopNote ch=" + channel + " pitch=" + pitch + " init=" + _initialized); if (_initialized && _synthInstance) { - try { _synthInstance.noteOff(channel, pitch); } catch (e) { - console.warn("[SonicSF] noteOff threw:", e); - } - } else { - // Oscillator fallback: stop is handled by the 60000ms timeout - // Nothing to do — oscillator auto-stops after durationMs + try { _synthInstance.noteOff(channel, pitch); } catch (e) {} + try { _synthInstance.controllerChange(channel, 64, 0); } catch (e) {} + // Also send noteOff with velocity=0 for safety + try { _synthInstance.noteOff(channel, pitch, 0); } catch (e) {} } },