fix: activeNotes key dùng MIDI channel gốc, không phải FluidSynth channel

Key _activeNotes[ch:midiPitch] dùng ch đã remap (FluidSynth channel),
stopNote lookup bằng MIDI channel (0) → không tìm thấy.
Fix: key = (channel ?? 0) + ':' + midiPitch (MIDI channel gốc).
This commit is contained in:
2026-07-27 15:50:28 +07:00
parent 7a2ac3a851
commit 987ecffc6c
+3 -2
View File
@@ -394,12 +394,13 @@
try {
console.log("[SonicSF] noteOn ch:", ch, "pitch:", midiPitch, "vel:", midiVel);
_fluidModule._fluid_synth_noteon(_synthPtr, ch, midiPitch, midiVel);
_activeNotes[ch + ':' + midiPitch] = ch;
_activeNotes[(channel !== undefined ? channel : 0) + ':' + midiPitch] = ch;
var noteMapKey = (channel !== undefined ? channel : 0) + ':' + midiPitch;
if (durationMs > 0 && durationMs < 60000) {
scheduledNote.off = setTimeout(function () {
try {
_fluidModule._fluid_synth_noteoff(_synthPtr, ch, midiPitch);
delete _activeNotes[ch + ':' + midiPitch];
delete _activeNotes[noteMapKey];
} catch (e) {}
}, durSec * 1000);
}