diff --git a/app/static/js/services/soundfontPlayer.js b/app/static/js/services/soundfontPlayer.js index d6e8f6d..f3b1f41 100644 --- a/app/static/js/services/soundfontPlayer.js +++ b/app/static/js/services/soundfontPlayer.js @@ -163,12 +163,13 @@ stopNote: function (channel, pitch) { if (channel < 0 || channel > 15) return; - if (_initialized && _synthInstance) { + if (!_initialized || !_synthInstance) return; + // Delay noteOff by 100ms for natural release + const timer = setTimeout(() => { 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) {} - } + }, 100); + _scheduledNotes.push({ on: null, off: timer }); }, playNote: function (note, velocity, durationMs, startTime, program, destinationNode, channel, synthEngine) {