fix: _origChannel tránh channel bị ghi đè bởi mappedCh
Line 378: 'if (channel===undefined) channel=ch' gán channel = FluidSynth channel (2), sau đó _activeNotes key dùng channel (2) thay vì MIDI channel (0). stopNote lookup bằng 0 → key mismatch. Fix: _origChannel = channel ngay đầu hàm, dùng _origChannel cho key.
This commit is contained in:
@@ -356,6 +356,7 @@
|
||||
var midiVel = Math.min(127, Math.max(1, Math.floor(
|
||||
typeof velocity === 'number' ? (velocity > 1 ? velocity : velocity * 127) : 100
|
||||
)));
|
||||
var _origChannel = channel;
|
||||
var ch = channel;
|
||||
var usedBank = 0, usedProg = 0;
|
||||
if (synthEngine) {
|
||||
@@ -375,7 +376,6 @@
|
||||
try {
|
||||
_fluidModule._fluid_synth_program_change(_synthPtr, ch, usedProg);
|
||||
} catch (e) {}
|
||||
if (channel === undefined) channel = ch;
|
||||
} else if (program !== undefined) {
|
||||
usedProg = program;
|
||||
if (ch === undefined) ch = 0;
|
||||
@@ -394,13 +394,13 @@
|
||||
try {
|
||||
console.log("[SonicSF] noteOn ch:", ch, "pitch:", midiPitch, "vel:", midiVel);
|
||||
_fluidModule._fluid_synth_noteon(_synthPtr, ch, midiPitch, midiVel);
|
||||
_activeNotes[(channel !== undefined ? channel : 0) + ':' + midiPitch] = ch;
|
||||
var noteMapKey = (channel !== undefined ? channel : 0) + ':' + midiPitch;
|
||||
_activeNotes[(_origChannel !== undefined ? _origChannel : 0) + ':' + midiPitch] = ch;
|
||||
var noteMapKey = (_origChannel !== undefined ? _origChannel : 0) + ':' + midiPitch;
|
||||
if (durationMs > 0 && durationMs < 60000) {
|
||||
scheduledNote.off = setTimeout(function () {
|
||||
try {
|
||||
_fluidModule._fluid_synth_noteoff(_synthPtr, ch, midiPitch);
|
||||
delete _activeNotes[noteMapKey];
|
||||
delete _activeNotes[(_origChannel !== undefined ? _origChannel : 0) + ':' + midiPitch];
|
||||
} catch (e) {}
|
||||
}, durSec * 1000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user