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:
@@ -394,12 +394,13 @@
|
|||||||
try {
|
try {
|
||||||
console.log("[SonicSF] noteOn ch:", ch, "pitch:", midiPitch, "vel:", midiVel);
|
console.log("[SonicSF] noteOn ch:", ch, "pitch:", midiPitch, "vel:", midiVel);
|
||||||
_fluidModule._fluid_synth_noteon(_synthPtr, ch, midiPitch, 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) {
|
if (durationMs > 0 && durationMs < 60000) {
|
||||||
scheduledNote.off = setTimeout(function () {
|
scheduledNote.off = setTimeout(function () {
|
||||||
try {
|
try {
|
||||||
_fluidModule._fluid_synth_noteoff(_synthPtr, ch, midiPitch);
|
_fluidModule._fluid_synth_noteoff(_synthPtr, ch, midiPitch);
|
||||||
delete _activeNotes[ch + ':' + midiPitch];
|
delete _activeNotes[noteMapKey];
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}, durSec * 1000);
|
}, durSec * 1000);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user