From 1790f743d65c6ea5e731e249d61e4d2a28a5a56d Mon Sep 17 00:00:00 2001 From: 3dtours Date: Fri, 31 Jul 2026 08:26:06 +0700 Subject: [PATCH] fix: add 400ms decay to MIDI noteoff for natural release --- app/static/js/services/soundfontPlayer.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/static/js/services/soundfontPlayer.js b/app/static/js/services/soundfontPlayer.js index c904a54..015b750 100644 --- a/app/static/js/services/soundfontPlayer.js +++ b/app/static/js/services/soundfontPlayer.js @@ -436,6 +436,9 @@ if (!_activeNotes[noteMapKey]) _activeNotes[noteMapKey] = []; if (_activeNotes[noteMapKey].indexOf(ch) === -1) _activeNotes[noteMapKey].push(ch); if (durationMs > 0 && durationMs < 60000) { + var releaseMs = 400; + var totalDurMs = durationMs + releaseMs; + if (totalDurMs > 60000) totalDurMs = 60000; scheduledNote.off = setTimeout(function () { try { _fluidModule._fluid_synth_noteoff(_synthPtr, ch, midiPitch); @@ -446,7 +449,7 @@ if (arr.length === 0) delete _activeNotes[noteMapKey]; } } catch (e) {} - }, durSec * 1000); + }, totalDurMs); } } catch (e) { console.warn("[SonicSF] FluidSynth noteOn error:", e);