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(
|
var midiVel = Math.min(127, Math.max(1, Math.floor(
|
||||||
typeof velocity === 'number' ? (velocity > 1 ? velocity : velocity * 127) : 100
|
typeof velocity === 'number' ? (velocity > 1 ? velocity : velocity * 127) : 100
|
||||||
)));
|
)));
|
||||||
|
var _origChannel = channel;
|
||||||
var ch = channel;
|
var ch = channel;
|
||||||
var usedBank = 0, usedProg = 0;
|
var usedBank = 0, usedProg = 0;
|
||||||
if (synthEngine) {
|
if (synthEngine) {
|
||||||
@@ -375,7 +376,6 @@
|
|||||||
try {
|
try {
|
||||||
_fluidModule._fluid_synth_program_change(_synthPtr, ch, usedProg);
|
_fluidModule._fluid_synth_program_change(_synthPtr, ch, usedProg);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
if (channel === undefined) channel = ch;
|
|
||||||
} else if (program !== undefined) {
|
} else if (program !== undefined) {
|
||||||
usedProg = program;
|
usedProg = program;
|
||||||
if (ch === undefined) ch = 0;
|
if (ch === undefined) ch = 0;
|
||||||
@@ -394,13 +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[(channel !== undefined ? channel : 0) + ':' + midiPitch] = ch;
|
_activeNotes[(_origChannel !== undefined ? _origChannel : 0) + ':' + midiPitch] = ch;
|
||||||
var noteMapKey = (channel !== undefined ? channel : 0) + ':' + midiPitch;
|
var noteMapKey = (_origChannel !== undefined ? _origChannel : 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[noteMapKey];
|
delete _activeNotes[(_origChannel !== undefined ? _origChannel : 0) + ':' + midiPitch];
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}, durSec * 1000);
|
}, durSec * 1000);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user