fix: add 400ms decay to MIDI noteoff for natural release

This commit is contained in:
2026-07-31 08:26:06 +07:00
parent ef6370f92e
commit 1790f743d6
+4 -1
View File
@@ -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);